Frictional Games Forum (read-only)

Full Version: Urgently need help, loop monster path.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I read the wiki on pathnodes but I really don't understand it. I'm still pretty new to scripting.

I have 4 pathnodes that a monster follows, then I want it to follow; 5,6,7,8 in a continuous loop but I really can't get my head around it.

void MonsterFunction(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1",
for (int i = 1; i <11; i++)
{
int x = i;
if (i == 1)
{
x = 2;
}
if (i = 10)
{
x = 4;
}
if (i != 1 || i != 10)
{
x = 0;
}
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, x, "");
}
}
That's what the wiki says about pathnodes but I don't understand what values stand for and how to manipulate them to suit me. Would really appreciate some help here, it's been bugging me for 2 hours Sad
When you add a path node to a monster it will be placed in the monster's "memory," and it will head to each path node in its "memory" in the order they were added. You don't need to make such a complicated loop like that for the monster to patrol.
Code:
    for(int i=0;i<5;i++) {
        if(i == 5) {
            i = 0;
            }
        
        AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_"+i, 0.0f, "");
        }

This works if you want him to go in a continuous loop. Just change add 1 to i< for however nodes you want him to loop. i.e, you wanted 4 nodes, so I put i<5. That's just the way I do it though, since I usually start i at 0. However, this way he will still eventually dissapear if the player hides from him, i'm not too sure how to stop that myself.