Frictional Games Forum (read-only)
[SCRIPT] Activating a monster if the player stands in area for certain time problem [SOLVED] - 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: [SCRIPT] Activating a monster if the player stands in area for certain time problem [SOLVED] (/thread-30277.html)



Activating a monster if the player stands in area for certain time problem [SOLVED] - Slanderous - 07-18-2015

Hey. I've been making a script on a separated map just to test it out, basically what I'm aiming to do is activating a monster if the player stands in a specific area for 5 seconds. The problem is, no matter whether I stand there for 1, 2 or 4 seconds, the monster still spawns.

Here is what my .hps file contains.

Thanks in advance

PS. Sorry for damn long thread name, but I didn't know how to describe it shorter.


RE: Activating a monster if the player stands in area for certain time problem - Mudbill - 07-18-2015

Make it simple. The simpler the better.

After entering the area, add a timer. Upon leaving the area, remove the timer. Have the monster enable in the timer callback.

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""SpidersHatch"false0);
}

void SpidersHatch(string &in asParentstring &in asChildint alState)
{
    if(
alState == 1AddTimer("hatch_time"5.0f"Hatching_Timer");
    if(
alState == -1RemoveTimer("hatch_time");
}

void Hatching_Timer(string &in asTimer)
{
    
SetEntityActive("Spiders?"true);




RE: Activating a monster if the player stands in area for certain time problem - Slanderous - 07-18-2015

(07-18-2015, 06:31 PM)Mudbill Wrote: Make it simple. The simpler the better.

After entering the area, add a timer. Upon leaving the area, remove the timer. Have the monster enable in the timer callback.

PHP Code:
void OnStart()
{
    
AddEntityCollideCallback("Player""ScriptArea_1""SpidersHatch"false0);
}

void SpidersHatch(string &in asParentstring &in asChildint alState)
{
    if(
alState == 1AddTimer("hatch_time"5.0f"Hatching_Timer");
    if(
alState == -1RemoveTimer("hatch_time");
}

void Hatching_Timer(string &in asTimer)
{
    
SetEntityActive("Spiders?"true);


Worked as intended, I didn't realise you can do it in such way XD Anyways, thanks a lot man!