Page 1 of 1
Is there a way to make Monsters explore?
Posted: Thu Jan 14, 2021 1:50 pm
by Duvo
Specifically, is there a way to make monsters rotate around all the sectors they can access?
I'm creating a mod where monsters duke it out deathmatch style and I need them to rotate
around the map when they're not fighting, looking for new targets.
Re: Is there a way to make Monsters explore?
Posted: Thu Jan 14, 2021 5:11 pm
by Matt
Trying to work out which ones they can access, without spending a lot of time having them go through all their surroundings by trial and error, seems to be the biggest issue.
Re: Is there a way to make Monsters explore?
Posted: Fri Jan 15, 2021 1:04 pm
by Caligari87
I made a "searching" AI procedure that mostly works with existing
A_Chase code.
- If the monster doesn't have a target pointer, create a path node somewhere nearby.
- Set the monster's goal pointer to the path node.
- When the monster reaches the path node, remove it.
- If the monster doesn't reach the node in some reasonable time, remove the node and start over.
- Cast rays in a 180° fan from the monster's facing angle (I like to limit these to 512 units or so).
- Pick the longest ray and set a new path node at the end of it.
- Repeat.
While simple, I find this routine does well at making monsters that seem to "explore" spaces in a more ordered fashion than just calling
A_Wander. Namely, they tend to avoid walls better (especially if the goal nodes are placed close together). It's also great at helping monsters "search" for the player if you set the first goal node to the player's position when they break line-of-sight. Obviously you can enhance this routine by checking for height differences, setting different criteria for the raycasts, etc.
Look at Josh771's
universal Enhanced AI for a more complex implementation of this idea, using nested goal nodes to search each area the monster reaches before moving on.

Re: Is there a way to make Monsters explore?
Posted: Thu Jan 21, 2021 9:46 am
by Duvo
Thanks @Caligari87, I'm excited to try this out