Frictional Games Forum (read-only)
Weird monster behaviour - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Weird monster behaviour (/thread-9194.html)



Weird monster behaviour - MrCookieh - 07-17-2011

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.


RE: Weird monster behaviour - Kyle - 07-17-2011

Code please? It may help at the very least.


RE: Weird monster behaviour - MrCookieh - 07-17-2011

Spoiler below!
Code:
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.


RE: Weird monster behaviour - hkkomiltinn - 07-17-2011

you can blame the pathfinding


RE: Weird monster behaviour - MrCookieh - 07-17-2011

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.



RE: Weird monster behaviour - palistov - 07-17-2011

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");


RE: Weird monster behaviour - MrCookieh - 07-17-2011

Ah, should work with AddEntityCollideCallback, haven't thought of using this with pathnodes.
Haven't tested it yet, but it should work! Thanks! Smile