Frictional Games Forum (read-only)
Spawning an enemy - 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)
+--- Thread: Spawning an enemy (/thread-53596.html)



Spawning an enemy - XeOnTricks - 02-25-2017

i was trying to create a script so i could spawn a brute for a long hallway chase but idk the script, i did try on my own but i think i did it wrong. maybe an example script could help me? thx for anyone who helps me Smile And sorry for posting so much, just really new to this and im in the middle of creating my first CS. Thx for the help guys! Smile


RE: Spawning an enemy - Romulator - 02-25-2017

It's pretty straightforward if it is a Collide Callback with a ScriptArea. I've named the ScriptArea SpawnCorridorMonster for this example.

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""SpawnCorridorMonster""MonsterSpawn"true1);
}

void MonsterSpawn(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("servant_brute_1"true);


You can also call ShowEnemyPlayerPosition after you set it active to make the enemy immediately chase after the player.

A list of all the basic functions Amnesia can recognize are here: https://wiki.frictionalgames.com/hpl2/amnesia/script_functions

You can also check Frictional Games' levels to see how they did it. There are countless examples where they use CollideCallbacks to spawn enemies, especially in the Sewer level.


RE: Spawning an enemy - FlawlessHappiness - 02-25-2017

Remember to actually place an enemy in your level.
You're not really "spawning" it. The enemy is supposed to be inactive in your level, and in your script you use "SetEntityActive" like Romulator did, and the enemy will be set active.