Well, the only thing is, there are a lot of variables when it comes to scripting. But I'll give you an example to work off of.
Code:
OnStart()
{
//Key_01, the name of the key entity.
SetEntityPlayerInteractCallback("key_01", "spawn_monster", true);
//Add an Area Script with the name Area_1, just in front of the door the player enters.
AddEntityCollideCallback("Player", "Area_1", "close_door", true, 1);
}
void spawn_monster(string &in asEntity)
{
//monster_1, name of the monster entity.
SetEntityActive("monster_1", true);
//Add a path node inside the room, name it node_1
AddEnemyPatrolNode("monster_1", "node_1", 30.0f, "");
//Add a path node outside the room, name it node_2
AddEnemyPatrolNode("monster_1", "node_2", 0.0f, "");
//Add a area script outside the room, with node_2 inside of it
AddEntityCollideCallback("monster_1", "Area_2", "despawn_monster", true, 1);
}
void close_door(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorLocked("door_1", true, true);
}
void despawn_monster(string &in asEntity)
{
SetEntityActive("monster_1", false);
}
If you like, I can go into detail of the script. You'll have to go back and change the names of the entities in your map for this to work. As I said,
Also, check this out.