Frictional Games Forum (read-only)
[CHAOS] How to use key to unlock level door? - 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: [CHAOS] How to use key to unlock level door? (/thread-11017.html)



How to use key to unlock level door? - MissMarilynn - 10-28-2011

How do I script a key to unlock a level door?

How do I script it so when I pick up a key a monster will spawn?



RE: How to use key to unlock level door? - Obliviator27 - 10-28-2011

You'll want to use AddUseItemCallback for the level door, as well as SetLevelDoorLocked.

For your second question, you'll want
SetEntityPlayerInteractCallback as well as SetEntityActive.



RE: How to use key to unlock level door? - MissMarilynn - 10-28-2011

(10-28-2011, 12:07 AM)Obliviator27 Wrote: You'll want to use AddUseItemCallback for the level door, as well as SetLevelDoorLocked.

For your second question, you'll want
SetEntityPlayerInteractCallback as well as SetEntityActive.
Can you give me examples? I have no idea how to set up the door one...I've tried. My door is "girlsdormfirstfloor" and the key is "masterkey".

Is this correct?



SetEntityPlayerInteractCallback("masterkey", "ScaryMonster", true);


void ScaryMonster(string &in entity)
{
What should go here???
}



RE: How to use key to unlock level door? - Your Computer - 10-28-2011

http://www.youtube.com/watch?v=mEpIqXo7MAc


RE: How to use key to unlock level door? - Tanshaydar - 10-28-2011

http://wiki.frictionalgames.com/hpl2/start?idx=hpl2%3Atutorials

Wiki will help you a lot.



RE: How to use key to unlock level door? - Obliviator27 - 10-28-2011

Code:
void OnStart()
{
         AddUseItemCallback("", "masterkey", "girlsdormfirstfloor", "UnlockDoor", true);
         SetEntityPlayerInteractCallback("masterkey", "SpawnMonster", true);
}
void UnlockDoor(string &in asItem, string &in asEntity)
{
        SetLevelDoorLocked("girlsdormfirstfloor", false);
        PlaySoundAtEntity("", "unlock_door.snt", "girlsdormfirstfloor", 0, false);
        RemoveItem("masterkey");
}
void SpawnMonster(string &in asEntity)
{
       SetEntityActive("servant_grunt_1", true);
       (Add Various Pathnodes here, if you like)
}
Is an example.



RE: How to use key to unlock level door? - MissMarilynn - 10-28-2011

(10-28-2011, 12:19 AM)Obliviator27 Wrote:
Code:
void OnStart()
{
         AddUseItemCallback("", "masterkey", "girlsdormfirstfloor", "UnlockDoor", true);
         SetEntityPlayerInteractCallback("masterkey", "SpawnMonster", true);
}
void UnlockDoor(string &in asItem, string &in asEntity)
{
        SetLevelDoorLocked("girlsdormfirstfloor", false);
        PlaySoundAtEntity("", "unlock_door.snt", "girlsdormfirstfloor", 0, false);
        RemoveItem("masterkey");
}
void SpawnMonster(string &in asEntity)
{
       SetEntityActive("servant_grunt_1", true);
       (Add Various Pathnodes here, if you like)
}
Is an example.
Ooh yay! I was close haha! How do I set it so that he notices you right away? ShowPlayerPosition?


RE: How to use key to unlock level door? - Obliviator27 - 10-28-2011

(10-28-2011, 12:34 AM)MissMarilynn Wrote: Ooh yay! I was close haha! How do I set it so that he notices you right away? ShowPlayerPosition?
Yep.