Page 1 of 1

[ZScript] [Enemy AI] Path-finding

Posted: Tue Sep 05, 2017 8:49 pm
by phantombeta
Is it possible to do proper path-finding with ZScript? If so, how would I do this?
I don't really know much about coding AIs, but I really want my mod's monsters to not be dumb like Doom's monsters. :\

Re: [ZScript] [Enemy AI] Path-finding

Posted: Wed Sep 06, 2017 8:58 am
by Caligari87
A few ways I've brainstormed to possibly make more "advanced" AI, though I've never actually tried any of them.
  • Treat the level as an arbitrary grid (maybe in 16 or 32 unit increments) and do simple A* pathfinding on it.
  • Manually pre-place nav-node mapspots in the level with args pointing to the next/nearest nodes, then have monsters calculate a backwards path from the map node nearest their goal.
  • Automatically place such nodes on level load with an invisible wandering actor that has some kind of logic to keep it from getting stuck in a room (like only ever turn left or something).
  • Whenever a monster needs to make a decision, have it send out invisible random-wander versions of itself that look for certain criteria (such as breaking/connecting LOS with the player). If the criteria is met, drop a goal node for the real monster. This could be expanded for monsters that seek and use health/ammo pickups.
  • Give monsters hitscan "feelers" (ahead, to the sides, etc) with criteria like "keep equidistant from walls on the left and right unless strafing" or "always follow the right wall if searching/wandering"
  • Logic rules such as "don't walk directly at the player if we can't see the player" (more specific version would be "if the player is ahead and to our left but out of LOS, turn left, walk forward, and keep checking right until we have LOS")
  • Abuse the "Frightened" flag. Make monsters "fear" fresh monster corpses for a while so they don't crowd into player-camped killzones. Make them run away from the player if their pain state is triggered, they're under a certain health threshold, or other criteria are met (like a bullet hitting nearby).
  • Apparently it's possible to set "goal" and "target" separately in ZScript. Use this for monsters that shoot at the player, but move toward something else. Maybe monsters that follow the strongest monster in their immediate area, or monsters that avoid getting too close to members of their same species, or monsters that guard medikits when the player is low on health.
  • Track other monsters and don't shoot if there's another monster between them and the player, basically avoid infighting.
That's less "nuts and bolts" than it is actual techniques, but I'm pretty sure all of the above (and more!) is perfectly do-able with ZScript.


Re: [ZScript] [Enemy AI] Path-finding

Posted: Wed Sep 06, 2017 11:41 am
by phantombeta
I guess my main issue with just doing this is figuring out how to code A* pathfinding. How do I even use it?
Whenever I look at stuff about AI, it seems like people just overcomplicate everything and give no code or pseudocode at all and assume everyone knows everything math-related that's needed to do/use it.