Frictional Games Forum (read-only)
Noob in trouble! - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Noob in trouble! (/thread-14757.html)

Pages: 1 2 3 4


Noob in trouble! - Macetrow - 04-13-2012

Hi, i created a thread the other day with a problem that my monster did not spawn from a key being picked up. Good news thou i fixed that so the monster spawns, but my key doesn't work for any door. I've gone through the tutorial on the wiki and several videos, but nothing seems to work. I didn't want to bother any of the more experienced developers on the forums with this, but it seems i've run out of options.

TL;DR: What did i do wrong with my script so my door doesn't work?

////////////////////////
//Run when starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "mansion_3", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in item, string &in entity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster", true);
ShowEnemyPlayerPosition("monster");
}
void DoorLockedPlayer(string &in entity)
{
if(GetSwingDoorLocked("mansion_3") == true)
{

SetMessage("Messages", "msgname1", 0);

}
}
////////////////////////
//Run when entering map
void OnEnter()
{

}
////////////////////////
//Run when leaving map
void OnLeave()
{

}



RE: Noob in trouble! - Putmalk - 04-13-2012

Do you have a map_cache? If so, delete it.

Is the key called "key_1" in the editor?

Is the door called called "mansion_3" in the editor?

Try replacing the "UsedKeyOnDoor" arguments to "(string &in asItem, string &in asEntity)"



RE: Noob in trouble! - Macetrow - 04-13-2012

Alright, i'll take a look.
Nope, the names are correct, i deleted the cache and fixed the argument, but still doesn't work.


RE: Noob in trouble! - Putmalk - 04-13-2012

I triple-checked your code, and I just cross-checked this with my own code, and I don't see any errors. Here, I'll post what I have:

Code:
void OnStart()
{

    //Callbacks
    AddEntityCollideCallback("Player", "Area_Wind", "HallwayWindEvent", true, 1);
    AddEntityCollideCallback("Player", "Area_FallTree", "FallTreeEvent", true, 1);
    
    AddUseItemCallback("keyondoor", "key_study_1", "level_wood_3", "UnlockLevelDoor", true);
    
    SetEntityPlayerInteractCallback("Area_InteractBed", "BedEvent", true);
    
    //Enemy pathnodes, this guy is harmless though
    AddEnemyPatrolNode("enemy_suitor_1", "PathNodeArea_4", 0, "");

}

void InteractLevelDoor(string &in asEntity)
{

    AddLocalVarInt("DoorTouched", 1);

    if(HasItem("key_study_1") == true)
    {
        SetMessage("Interact", "Ch01_01_KeyOnDoor", 0);
    }

    if(GetLocalVarInt("DoorTouched") == 1)
    {
        AddQuest("01UnlockEntranceHall", "01UnlockEntranceHall");
    }

}

void UnlockLevelDoor(string &in asItem, string &in asEntity)
{

    PlaySoundAtEntity("unlock", "unlock_door.snt", "level_wood_3", 0.4f, false);
    SetLevelDoorLocked("level_wood_3", false);
    
    RemoveItem("key_study_1");
    CompleteQuest("01UnlockEntranceHall", "01UnlockEntranceHall");

}

I guess you can use that as a reference since that works??? The only problem I can see is that your names or your cache would be wrong/still there. You're getting a "Cannot use item this way!" message?



RE: Noob in trouble! - Macetrow - 04-13-2012

Yes, that's the message i'm getting. I've checked a ton of times and started over multiple times, but i still get the same message.


RE: Noob in trouble! - Putmalk - 04-13-2012

Try commenting out "SetEntityCallbackFunc("key_1", "OnPickup");" and try again, as I said, the rest of your code is fine.



RE: Noob in trouble! - Macetrow - 04-13-2012

I removed that, and the monster keeps spawning anyways (i deleted the cache) and the key stil doesn't work


RE: Noob in trouble! - Putmalk - 04-13-2012

I don't think your map is picking up changes to your script, because removing that callback func should have disabled the monster (which is what I was aiming to do for test purposes). But then again, as I've said, that only happens if the CACHE is gone, but you said you deleted it, which is making me scratch my head.

Sometimes what I'll do is open up the script and accidentally save it to a different location, and edit it from there, which is what may be happening. Otherwise, since I can't see your screen, it's impossible for me to tell what's the problem since I can't see what's actually happening.

Try making a syntax error to crash the script/game. If that doesn't work, you're not changing your script in any way.

Just a quick checklist:

- deleted cache
- proper arguments
- names are the same
- script changes when you change something in it
- saving to the correct location, script name is identical to map name with extension .hps



RE: Noob in trouble! - Macetrow - 04-13-2012

I did make some changes so it sort of looked like yours and i accidently made a syntax error so it's not being saved to a different location. My cache has been deleted everytime i changed something, my arguments should be correct, the names on the door and key are correct, and it's saved where i want it to be saved.


RE: Noob in trouble! - zombiehacker595 - 04-14-2012

try changing

void UsedKeyOnDoor(string &in item, string &in entity)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}


to

void UsedKeyOnDoor(string &in item, string &in door)
{
SetSwingDoorLocked("mansion_3", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "mansion_3", 0, false);
RemoveItem("key_1");
}

thats how i always put it and it works