[ZScript] [Enemy AI] Path-finding

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.

[ZScript] [Enemy AI] Path-finding

Postby phantombeta » Tue Sep 05, 2017 8:49 pm

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. :\
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013

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

Postby Caligari87 » Wed Sep 06, 2017 8:58 am

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.

8-)
User avatar
Caligari87
User Accounts Assistant
 
Joined: 26 Feb 2004
Discord: Caligari87#3089
Github ID: caligari87

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

Postby phantombeta » Wed Sep 06, 2017 11:41 am

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.
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013


Return to Editing (Archive)

Who is online

Users browsing this forum: No registered users and 2 guests