void OnStart()
{
AddEntityCollideCallback("Player" , "Origin" , "scareactive" , true , 1);
}
////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "key_1", "door_1", "KeyOnDoor", true);
AddUseItemCallback("", "key_2", "door_2", "KeyOnDoor2", true);
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
////////////////////////////
// Actual functions
void KeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, false);
RemoveItem("key_1");
AddDebugMessage("KeyOnDoor", false);
}
void KeyOnDoor2(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("door_2", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "door_1", 0.0f, true);
}
void scareactive(string &in asParent , string &in asChild , int alState)
{
SetEntityActive("monster_1" , true);
AddEnemyPatrolNode("enemyname", "nodename", waiting time (for example: 0.0f), "animation to play");
}
You have to add path nodes when spawning a monster, or it will despawn right away.
This is because after a monster has walked it's last path, it will disappear, hence, having no path, it will disappear right away.
Again, make sure everything is organized.
Put your functions that don't belong in any of the "On...." functions, at the end of your script.