Spawn monsters - 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: Spawn monsters (/thread-17489.html) |
Spawn monsters - tokugawa1 - 08-04-2012 Well i want to spawn these monsters but not at the same time. they spawn at the same time with this script and also the game crashes so here it is void OnStart() { AddUseItemCallback("", "key_tomb_1", "mansion_1", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_tomb_1", "Spawn_Monster", true); AddUseItemCallback("", "key_torture_chamber_1", "mansion_4", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_torture_chamber_1", "Spawn_Monster", true); SetEntityPlayerInteractCallback("note_generic_3", "Spawn_Monster", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_tomb_1"); SetSwingDoorLocked("mansion_4", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_torture_chamber_1"); } void Spawn_Monster(string &in asEntity) { SetEntityActive("servant_grunt_1", true); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, ""); } { SetEntityActive("servant_brute_1", true); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 1, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 0, ""); } { SetEntityActive("servant_brute_2", true); SetEntityActive("servant_brute_3", true); SetEntityActive("servant_brute_4", true); SetEntityActive("servant_grunt_2", true); SetEntityActive("servant_grunt_3", true); } RE: Spawn monsters - Steve - 08-04-2012 easy one you just need some timers I don't really know how many seconds you want to have between the monster so I just make it 5 seconds. void OnStart() { AddUseItemCallback("", "key_tomb_1", "mansion_1", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_tomb_1", "Spawn_Monster", true); AddUseItemCallback("", "key_torture_chamber_1", "mansion_4", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_torture_chamber_1", "Spawn_Monster", true); SetEntityPlayerInteractCallback("note_generic_3", "Spawn_Monster", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_tomb_1"); SetSwingDoorLocked("mansion_4", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_torture_chamber_1"); } void Spawn_Monster(string &in asEntity) { SetEntityActive("servant_grunt_1", true); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, ""); AddTimer("timer01", 5.0f, "Secondmonster"); } void Secondmonster(string& asTimer) { SetEntityActive("servant_brute_1", true); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 1, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 0, ""); AddTimer("timer02", 5.0f, "Thirdmonster"); } void Thirdmonster(string& asTimer) { SetEntityActive("servant_brute_2", true); SetEntityActive("servant_brute_3", true); SetEntityActive("servant_brute_4", true); SetEntityActive("servant_grunt_2", true); SetEntityActive("servant_grunt_3", true); } EDIT: and it crashed because you had more { } than one in your void. aand also if you want: SetEntityActive("servant_brute_2", true); SetEntityActive("servant_brute_3", true); SetEntityActive("servant_brute_4", true); SetEntityActive("servant_grunt_2", true); SetEntityActive("servant_grunt_3", true); to have time between them make timers for them as well if you have any question ask me RE: Spawn monsters - tokugawa1 - 08-04-2012 (08-04-2012, 08:30 PM)Steve Wrote: easy one you just need some timers I don't really know how many seconds you want to have between the monster so I just make it 5 seconds.ok thx but i actually wanted to spawn the monsters when picking up something. when i pick up the first key the servant grunt_1 spawns, when i pick up the second key the servant_brute_1 spawns, and when i pick up the note_generic_3 the last monsters spawn : SetEntityActive("servant_brute_2", true); SetEntityActive("servant_brute_3", true); SetEntityActive("servant_brute_4", true); SetEntityActive("servant_grunt_2", true); SetEntityActive("servant_grunt_3", true); RE: Spawn monsters - Steve - 08-04-2012 oh like that than just do this. void OnStart() { AddUseItemCallback("", "key_tomb_1", "mansion_1", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_tomb_1", "Spawn_Monster", true); AddUseItemCallback("", "key_torture_chamber_1", "mansion_4", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_torture_chamber_1", "Spawn_Monster_two", true); SetEntityPlayerInteractCallback("note_generic_3", "Spawn_Monster_three", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_tomb_1"); SetSwingDoorLocked("mansion_4", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_torture_chamber_1"); } void Spawn_Monster(string &in asEntity) { SetEntityActive("servant_grunt_1", true); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, ""); } void Spawn_Monster_two(string &in asEntity) { SetEntityActive("servant_brute_1", true); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_1", 2, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_2", 1, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_3", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_4", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_5", 0, ""); AddEnemyPatrolNode("servant_brute_1", "PathNodeArea_6", 0, ""); } void Spawn_Monster_three(string &in asEntity) { SetEntityActive("servant_brute_2", true); SetEntityActive("servant_brute_3", true); SetEntityActive("servant_brute_4", true); SetEntityActive("servant_grunt_2", true); SetEntityActive("servant_grunt_3", true); } this should do the job RE: Spawn monsters - tokugawa1 - 08-04-2012 (08-04-2012, 09:06 PM)Steve Wrote: oh like that than just do this.weird. the first monster didn't spawn because the first key which had no name. randomly got the name of a key from the previous map and i also couldnt unlock the door RE: Spawn monsters - Steve - 08-04-2012 as first check the names and make sure they are the same as in the level editor and as second you have both keys unlock the same doors so when you open one door You open both doors to fix that make it like this: void OnStart() { AddUseItemCallback("", "key_tomb_1", "mansion_1", "UsedKeyOnDoor", true); SetEntityPlayerInteractCallback("key_tomb_1", "Spawn_Monster", true); AddUseItemCallback("", "key_torture_chamber_1", "mansion_4", "KeyOnDoor", true); SetEntityPlayerInteractCallback("key_torture_chamber_1", "Spawn_Monster_two", true); SetEntityPlayerInteractCallback("note_generic_3", "Spawn_Monster_three", true); } void UsedKeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_1", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_tomb_1"); } void KeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("mansion_4", false, true); PlayGuiSound("unlock_door", 0.8f); RemoveItem("key_torture_chamber_1"); } RE: Spawn monsters - tokugawa1 - 08-04-2012 (08-04-2012, 09:06 PM)Steve Wrote: oh like that than just do this.weird. the first monster didn't spawn because the first key which had no name. randomly got the name of a key from the previous map and i also couldnt unlock the door (08-04-2012, 09:34 PM)Steve Wrote: as first check the names and make sure they are the same as in the level editor and as second you have both keys unlock the same doors so when you open one door You open both doors to fix that make it like this:well before i got that script you gave me, the keys worked. its not your fault something weird happened. if i get to fix this error i can release my map.. well and the key still says "picked up prison key". the prison key was on the previous map and not on this one. P.S this script is for the second map (after teleporting through a Level Door) maybe that helps RE: Spawn monsters - Steve - 08-05-2012 I'm a little tired at the moment but try changing the name of the key. RE: Spawn monsters - tokugawa1 - 08-05-2012 (08-05-2012, 05:00 PM)Steve Wrote: I'm a little tired at the moment but try changing the name of the key.Thanks that worked. RE: Spawn monsters - Steve - 08-05-2012 that's good to hear |