The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetEntityExists looping timer with monster
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#1
GetEntityExists looping timer with monster

Spoiler below!
OnStart()
{
AddEntityCollideCallback("servant_grunt_1", "ScriptArea_7", "OnMonsterCollide_1", true, 1);


AddEntityCollideCallback("servant_grunt_2", "ScriptArea_8", "OnMonsterCollide_2", true, 1);
}


void OnMonsterCollide_1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", false);
AddDebugMessage("Monster_1 Inactive", false);

SetEntityActive("servant_grunt_2", true);
AddDebugMessage("Monster_2 Active", false);
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_2", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_3", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_5", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_6", 0, "");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_9", 0, "");
}


void OnMonsterCollide_2(string &in asParent, string &in asChild, int alState)
{
ClearEnemyPatrolNodes("servant_grunt_2");
AddEnemyPatrolNode("servant_grunt_2", "PathNodeArea_44", 0, "");
AddTimer("", 0.1, "IfMonsterActive");
}


void IfMonsterActive(string &in asTimer)
{
if(GetEntityExists("servant_grunt_2") == false)
{
AddDebugMessage("Level door is unlocked", false);
PlaySoundAtEntity("", "door_level_cellar_open", "Player", 0, false);
SetLevelDoorLocked("level_celler_1", false);
RemoveTimer("CheckIfMonsterActive");
RemoveTimer("IfMonsterActive");
}
else
{
AddDebugMessage("Timer 2", false);
AddTimer("CheckIfMonsterActive", 0.1, "CheckIfMonsterActive");
}
}

void CheckIfMonsterActive(string &in asTimer)
{
AddDebugMessage("Timer 1", false);
AddTimer("IfMonsterActive", 0.1, "IfMonsterActive");
}


The problem is that the monster disappears, but the script doesn't get that it doesn't exist anymore... so the leveldoor doesnt unlock, the sound doesnt play, but the monster is gone...

Trying is the first step to success.
06-07-2012, 10:40 AM
Find


Messages In This Thread
GetEntityExists looping timer with monster - by FlawlessHappiness - 06-07-2012, 10:40 AM



Users browsing this thread: 1 Guest(s)