Help needed with SetEntityActive in custom story
Hello. I decided to make a custom story. I am green at scripting, however i can make some simple things like key that unlocks specific doors n stuff. Today i tried to make a script where a monster spawns when player collides with ScriptArea, walks abit and then despawns at certain pathnode. The monster spawns, walks, however it doesnt despawn i tried multiple times watched multiple videos but it doesnt work. I will appreciate any help. My script:
void OnStart()
{
AddEntityCollideCallback("Player", "area", "monster", true,1);
AddEntityCollideCallback("grunt", "PathNodeArea_12", "CollideStop", true, 1);
}
void monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt",true);
AddEnemyPatrolNode("grunt", "PathNodeArea_1", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_2", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_3", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_4", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_5", 4, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_6", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_7", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_8", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_9", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_10", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_11", 0.001, "");
AddEnemyPatrolNode("grunt", "PathNodeArea_12", 0.001, "");
}
void CollideStop(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("grunt", false);
}
THANK YOU !!!
|