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
Weird monster behaviour
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#1
Weird monster behaviour

Hi guys!

I added a monster in my custom story, and it should patrol (not disappearing, or hallucination). I've placed the monster and its pathnodes.
Everything works fine, but then, the monster walks like an idiot. He runs towards his next pathnode, suddenly stops walking, turn around, runs in the other direction for a half second, turns around again, and follows his pathnodes. What can cause this? My script isn't that advanced, just adding pathnodes to it.

Now a second question: How can I make my monster patrol, so it doesn't disappear when it reached its last pathnode? It should go all pathnodes back to his starting point, and then starts over. This all the time.
(This post was last modified: 07-17-2011, 11:05 PM by MrCookieh.)
07-17-2011, 03:42 PM
Find
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: Weird monster behaviour

Code please? It may help at the very least.

07-17-2011, 03:46 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#3
RE: Weird monster behaviour

Spoiler below!
void OnStart(){
    AddUseItemCallback("", "storageroomkey", "storageroom", "StorageRoomKey", true);
}

void StorageRoomKey(string &in asItem, string &in asEntity){
    SetSwingDoorLocked("storageroom", false, true);
    RemoveItem("storageroomkey");
    SetEntityActive("grunt2", true);
    AddEnemyPatrolNode("grunt2", "patrol1", 0.01, "");
    AddEnemyPatrolNode("grunt2", "patrol2", 3, "");
    AddEnemyPatrolNode("grunt2", "patrol3", 3, "");
    AddEnemyPatrolNode("grunt2", "patrol4", 0.01, "");
    AddEnemyPatrolNode("grunt2", "patrol5", 3, "");
    PlayMusic("29_amb02", true, 100, 0, 0, true);
}


this is the small code part of my script. Like I've said, nothing big, just the normal monster settings.
07-17-2011, 04:01 PM
Find
hkkomiltinn Away
Member

Posts: 120
Threads: 7
Joined: Jun 2011
Reputation: 0
#4
RE: Weird monster behaviour

you can blame the pathfinding
07-17-2011, 04:06 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#5
RE: Weird monster behaviour

so it's normal that the monster behaves like an idiot?
(I once made a monster, with only one pathnode, at the other side of a wall. The monster walked the whole time against a wall, although there was a door some metres next to him... so I think I have to live with that AI...)

Anyways, that's not that bad, but how about the patroling thing?
Quote:Now a second question: How can I make my monster patrol, so it doesn't disappear when it reached its last pathnode? It should go all pathnodes back to his starting point, and then starts over. This all the time.
07-17-2011, 04:10 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#6
RE: Weird monster behaviour

In your debug menu, enable the entity info option. This will display active monsters' state (path, investigate, hunt, alert, wait, etc) as well as its current node. It will basically give you a lot of information which can help you determine what is causing your monster to freak out. It could be that the edge nodes (path nodes between your script-assigned nodes) are poorly placed. It could be that your scripted path nodes are in the wrong order, too.

Anyways, just study the monster with the entity info and see if you can figure out exactly what causes it.

Now as for your quote, to prevent a monster from disappearing, just assign it new path nodes once it reaches or nears the end of its path, using a collide callback that doesn't auto-remove.

AddEntityCollideCallback("grunt", "grunt_newnodes", "GruntNewNodes", false, 1);

Put that in your OnStart, match the parent and child names to the props in your map, and make sure your function contains ClearEnemyPatrolNodes("grunt");

07-17-2011, 05:13 PM
Find
MrCookieh Offline
Member

Posts: 157
Threads: 8
Joined: Jul 2011
Reputation: 0
#7
RE: Weird monster behaviour

Ah, should work with AddEntityCollideCallback, haven't thought of using this with pathnodes.
Haven't tested it yet, but it should work! Thanks! Smile
07-17-2011, 11:04 PM
Find




Users browsing this thread: 1 Guest(s)