Frictional Games Forum (read-only)
Enemy spawning at an area - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Enemy spawning at an area (/thread-8256.html)



Enemy spawning at an area - SLAMnesia - 05-26-2011

Im sure there have been threads similar to this one before, but I've searched with no avail. so heres my problem, its simple and do able i just dont know how:

How do I make an enemy (water lurker) spawn/activate when I enter an area? I also want the player to look at the enemy but not lock the screen on the lurker cuz you'll need to turn and run.
i made the area and lurker heres the names
Area:lurkerspawn
lurker:rawr

any help is 200% appreciated thanks, as you can probably tell im relatively new to this stuff
<3


RE: Enemy spawning at an area - palistov - 05-26-2011

To activate the entity, add a collide callback involving the player and a designated trigger area. Add this function to your OnStart:
AddEntityCollideCallback("Player", "area_trigger_entity", "TriggerFunction", true, 1);

//-------------------------
To make the player look at it, place this function under TriggerFunction:
StartPlayerLookAt("water_lurker", 3.0, 3.0, "LurkerSeen");

//------------------------

Lastly, add a third function, LurkerSeen, and place this function under it:
StopPlayerLookAt();

//------------------------

If you have trouble piecing together your script post another reply, I'll lay out an entire script for you.


RE: Enemy spawning at an area - xtron - 05-26-2011

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player" , "lurkerspawn" , "spawn_water_lurker" , true , 1);
}

void spawn_water_lurker(string &in asEntity)
{
SetEntityActive("rawr", true);
StartPlayerLookAt("rawr", 10, 50, "");
AddTimer("", 0.5f, "TimerSlamDoor");
}

void TimerSlamDoor(string &in asTimer)
{
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
AddTimer("", 1.0f, "TimerStopLook");
}

void TimerStopLook(string &in asTimer)
{
StopPlayerLookAt();
}


Now. When you enter the "lurkerspawn" area the function "spawn_water_lurker" will get activated and a breathing sound will be played and the lurker named "rawr" will spawn and then your screen will automaticly move and look at "rawr" for 1sec then return to normal.