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
Monster disappears after loop
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#1
Monster disappears after loop

Now, let me say that I'm sure this is really simple and I have just done something silly in my code :3

Quite simply, there is a long corridor with a few rooms on each side allowing you to hide if you are quick enough to get inbetween each one. In this corridor, I have 12 pathnodes for 1 monster, which I want to continuously walk up and down the corridor.

I can get him to the 12th, then back to the 1st, but when he gets back to the 12th, he disappears.

This is my code:
void OnStart()
    {
        AddEntityCollideCallback("Player", "ScriptArea_1", "monsterspawn", true, 1);
    }
void monsterspawn(string &in asParent, string &in asChild, int alState)
    {
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 2, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_6", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_7", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_8", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_9", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_10", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_11", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_12", 4, "");
    for (int i = 1; i < 13; i++)
            {
                AddEnemyPatrolNode("servant_grunt_1","PathNodeArea_"+i, 0, "");
            }
    }

Of course, I'm nowhere near finished on my CS, this is the first level xP but its not my first, and I'm always looking for improvement.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 03-02-2013, 11:24 AM by Romulator.)
03-01-2013, 03:46 PM
Find
ghostelom Offline
Junior Member

Posts: 15
Threads: 7
Joined: Mar 2013
Reputation: 0
#2
RE: Monster disappears after loop

the monster should disappear
03-01-2013, 03:49 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#3
RE: Monster disappears after loop

(03-01-2013, 03:49 PM)ghostelom Wrote: the monster should disappear

Yes, it does.
But I want it to loop continuously... forever... and ever... and ever... (until the player exits the map actually, because he wont be able to return Smile )

Discord: Romulator#0001
[Image: 3f6f01a904.png]
03-01-2013, 03:51 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#4
RE: Monster disappears after loop

In that function, you are setting up path 1 - 12 then 1 - 12 again, which is why he goes twice before dissapearing. If you want to set those 12 up again, you need it to collide with a script area that will call that function again - if he is going to collide with the first area again, then you need to set the area to not delete after the collide (you have 'true', should be 'false')

Also, you only need the for... loop in there, as that will set up the same path nodes as all the previous individual ones you typed

03-01-2013, 08:02 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#5
RE: Monster disappears after loop

Continually adding patrol nodes to the monster is excessive and unnecessary to meet the desired result. All you have to do is modify the monster entity variables. Since you're using the grunt, you're going to have to make a copy of the grunt so that it doesn't overwrite the original grunt. You do this by making a copy of the ENT file that represents the grunt, give it a different file name so that the original does not take its place, then edit the ENT in a plain-text editor.

Under user defined variables, you add
<Var Name="AutoRemoveAtPathEnd" Value="false" />

You may also want to increase the activation distance of the monster to prevent premature deactivation of the monster. Then in the level editor replace the grunt with the modified grunt. This also requires that the custom_stories folder is listed in the resources.cfg file.

Note that if you choose to edit the modified grunt in the model editor, it'll undo the manual changes to the ENT file if you save. Meaning, you'll have to add the code again.

Tutorials: From Noob to Pro
(This post was last modified: 03-02-2013, 01:36 AM by Your Computer.)
03-02-2013, 01:34 AM
Website Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: Monster disappears after loop

(03-01-2013, 08:02 PM)Adrianis Wrote: In that function, you are setting up path 1 - 12 then 1 - 12 again, which is why he goes twice before dissapearing. If you want to set those 12 up again, you need it to collide with a script area that will call that function again - if he is going to collide with the first area again, then you need to set the area to not delete after the collide (you have 'true', should be 'false')

Also, you only need the for... loop in there, as that will set up the same path nodes as all the previous individual ones you typed
Thanks for that Big Grin Works like a charm!
(03-02-2013, 01:34 AM)Your Computer Wrote: Continually adding patrol nodes to the monster is excessive and unnecessary to meet the desired result. All you have to do is modify the monster entity variables. Since you're using the grunt, you're going to have to make a copy of the grunt so that it doesn't overwrite the original grunt. You do this by making a copy of the ENT file that represents the grunt, give it a different file name so that the original does not take its place, then edit the ENT in a plain-text editor.

Under user defined variables, you add

You may also want to increase the activation distance of the monster to prevent premature deactivation of the monster. Then in the level editor replace the grunt with the modified grunt. This also requires that the custom_stories folder is listed in the resources.cfg file.

Note that if you choose to edit the modified grunt in the model editor, it'll undo the manual changes to the ENT file if you save. Meaning, you'll have to add the code again.
I was just coming back to say that it worked, so I no longer require assistance, but thanks for this input. It may help later if I choose to add another Grunt to the room, dumping the old one so it uses some more sexy path nodes into the rooms itself Big Grin I'll give reputation for you both Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
03-02-2013, 03:30 AM
Find




Users browsing this thread: 1 Guest(s)