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
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#2
RE: GetEntityExists looping timer with monster

I think the monster being active and the monster existing are two different things.

Perhaps, instead of deactivating him, make him fade to smoke, as this removes him from the map, whereas deactivating him just keeps him in the map, just not activated.

Dark Seclusion Here
06-07-2012, 11:02 AM
Find
FlawlessHappiness Offline
Posting Freak

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

Ignore servant_grunt_1. It is servant_grunt_2 i need help with.

Yes but the problem is that im not deactivating him.
He deactivates when i'm in a long enough distance from him, and when im not looking at him.
It would look unrealistic if he just faded away in front of the player. That makes the player wonder if those monsters even are dangerous..

Trying is the first step to success.
06-07-2012, 11:43 AM
Find
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#4
RE: GetEntityExists looping timer with monster

Maybe you could contain the location in a ScriptBox, and check to see if he is colliding with it. If he is, he's still alive and well, if he isn't, he has despawned. When he disappears, it may or may not say that he is no longer colliding with the ScriptBox.

Dark Seclusion Here
06-07-2012, 01:21 PM
Find
FlawlessHappiness Offline
Posting Freak

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

Good idea! Smile

EDIT: I can't get it to work...

Here is my script.

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("servant_grunt_2", "ScriptArea_10", "OnMonsterCollide_3", true, 1);
}

void OnMonsterCollide_3(string &in asParent, string &in asChild, int alState)
{
AddTimer("IfMonsterCollide", 0.1, "IfMonsterCollide");
}

void IfMonsterCollide(string &in asTimer)
{
if(GetEntitiesCollide("ScriptArea_11", "servant_grunt_2") == false)
{
AddDebugMessage("Level door is unlocked", false);
PlaySoundAtEntity("", "door_level_cellar_open", "Player", 0, false);
SetLevelDoorLocked("level_celler_1", false);
RemoveTimer("ReenableMonsterCollide");
RemoveTimer("IfMonsterCollide");
}
else
AddDebugMessage("Timer_1_active", false);
AddTimer("ReenableMonsterCollide", 0.1, "ReenableMonsterCollide");
}

void ReenableMonsterCollide(string &in asTimer)
{
AddDebugMessage("Timer_2_active", false);
AddTimer("IfMonsterCollide", 0.1, "IfMonsterCollide");
}


The monster disappears, but the timer doesn't get anything...

Trying is the first step to success.
(This post was last modified: 06-08-2012, 08:29 AM by FlawlessHappiness.)
06-07-2012, 01:38 PM
Find




Users browsing this thread: 1 Guest(s)