Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dwarf-By-Dwarf Pathing/AI Options  (Read 633 times)

Stungun

  • Bay Watcher
    • View Profile
Dwarf-By-Dwarf Pathing/AI Options
« on: March 23, 2011, 05:05:40 pm »

So, as we've known for a while, DF doesn't exactly handle dwarves that are amphibious or fliers too well, especially when player characters. Also, they tend to commit themselves to the hospital for the tiniest of wounds like a compound-fractured fingernail. A modded race without infections has nothing to fear from a compound fractured fingernail. What I propose is that we make it so that dwarves have AI flags (or any kind of variable) that can be set on their status screen that will determine how they behave in regards to pathing and certain behaviours. Possibly even a tool to set all your dwarves' AI flags at once, if you want the entire race to behave a certain way. The options would be organized as follows:

[Swimming Options]: Determines how dwarves behave with respect to water and magma. This may require a raw tag that tells dwarves that magma is perfectly safe for them, because it occurs to me that making the game check every aspect of the creature to determine whether or not it's 'magma-safe' would take a long time. (I suppose you could check every tissue layer used in the creature, though.)
 - Don't Swim: How DF behaves by default, dwarves will avoid going through water at all costs and if they're in water, they attempt to get out (canceling their task to do so).
 - Allow Swim: Dwarves with this will path through water, but only along the surface -- and if the dwarf is untrained or novice in swimming, they will only path through shallow water. (The latter part will be ignored for dwarves that are unable to drown, e.g. NOBREATHE) If the dwarf's magma-safe (either it could check all the dwarf's tissues to see if they're 'magma-safe', or you could put a raw tag in the creature that would tell the game it is magmasafe), it will path through magma as well.
 - Prefer Swim: As above, but pathing costs through water are lower than across land.
 - Allow Dive: This flag will allow dwarves to path underwater. I don't know how drown mechanics work, but this will ideally limit underwater pathing so that the dwarf won't run out of breath before it reaches its destination. Naturally creatures that can't drown ignore this check entirely.
 - No Magma: Only applicable for magma-safe dwarves. This will override the dwarf's magma-safe status and discourage it from entering magma, useful to prevent our fireproof dwarf from getting a new pair of !!giant cave spider silk shoes!!.

[Flying Options]: Determines how dwarves behave with respect to Z-level travel. Anything that require the dwarf be able to fly isn't used unless the dwarf can fly, and also isn't used if the dwarf has lost their ability to fly. "Allow Flying" isn't even shown for dwarves that can't fly.
 - Landbound: How Dwarf Fortress behaves by default when you have normal dwarves. A dwarf cannot path up or down except through stairs or ramps, and will ignore any flight capabilities they may have.
 - Jump and Climb: A dwarf will path up or down over ledges but can only do so if they are tall enough to climb up the full elevation (or can fly). If they cannot fly, they will be willing to jump down. Pathing up and down is restricted to one Z-level at a time (to prevent injury and getting stuck -- the dwarf will not path up over a two-Z-level wall if they can fly).
 - Allow Vertical: A dwarf can path up or down indefinitely if they can (only flying dwarves can path up in this fashion). However, vertical motion through the Z-levels has a high pathing cost so moving on the ground is preferred.
 - Allow Flying: A dwarf will path through the skies freely, at the same movement costs as moving across land. They will not get stuck.

[Monster Options]: Determine how dwarves will behave in the proximity of monsters. These settings do not affect military dwarves.
 - Avoid Monsters: Standard DF behaviour. A nonmilitary dwarf will keep away from monsters, and if they see them, stop working and get out of there.
 - Ignore Monsters: A nonmilitary dwarf will completely ignore a monster unless the monster decides to actually attack them, at which point the dwarf will get away. You will still be warned whenever a monster is seen by a dwarf ignoring monsters, however.
 - Fight Back: As above, but when the dwarf is attacked, it will fight back with whatever weapons it has on hand (for mining, woodcutting, and hunting dwarves, this will be their tool/ranged weapon; otherwise, their fists/other natural attacks). If the monster runs away or is killed, the dwarf will attempt to get back to work.

[Injury Options]: Changing these options will cause resting dwarves to re-evaluate their status and possibly cancel resting to get back to work. Dwarves ignoring injury can drink booze instead of water -- they behave as if they're just fine in all regards.
 - Observe Wounds: Standard DF behaviour. Dwarves will go to the hospital for any wound.
 - Ignore Non-Critical Wounds: Unless the dwarf is Pale, lightly bleeding wounds and injury of non-critical tissue (e.g. fingernails) will be ignored.
 - Ignore All Wounds: The dwarf will ignore all wounds even if their torso is spraying blood, they have 12 infections, brain necrosis, and a hangnail.
 - Finish Work: With this flag on, a dwarf will finish their current job (if in the middle of something) before they go off to the hospital to get checked out.
 - Ignore Permanent Injury: With this flag on, a 'permanent invalid' will still try, to the best of their ability, to work -- be it from nervous system damage or lost limbs. They will crawl if need be.
 - Allow Crawling To Bed: With this flag on, a wounded, immobile dwarf that is supposed to be resting but isn't in a bed will not wait for rescue, but will instead drag themselves off to bed (via crawling).
 - Serve Self While Resting: With this flag on, a resting dwarf will -- if they are starving/dehydrated -- get themselves out of bed and head off to get something to eat or drink instead of letting themselves die. They will only drink water, however.

I already hear you saying, "All that pathing stuff is going to slow down our game so much! Imagine how long it'd take for a computer to run through all that for each creature!" Well, it's not as bad as you think for the following reasons:
1. It only applies to creatures you control.
2. You can turn them on or off -- if you don't need it, just switch it off and the game behaves as normal, as fast as it was before.
3. You can turn them on or off on a dwarf-by-dwarf basis. It won't be as much of a burden if only 5 of your 100 dwarves are assigned as your fliers (ya know, to build the really high walls of that megaproject?)
But this could seriously help out, especially when using modded races. I've got a race of swimming fliers with armor under their skin, but it's no good when they won't swim, won't fly, and still go to the hospital for a broken nail despite the fact the crundle can't possibly hope to tear through their tissue layer of solid iron...
Logged

EmperorJon

  • Bay Watcher
  • Still waiting...
    • View Profile
Re: Dwarf-By-Dwarf Pathing/AI Options
« Reply #1 on: March 23, 2011, 05:48:09 pm »

Some nice options. As for the wounded crawling one, I believe Toady has now made it so that even dwarves which are too injured to use crutches (also fixed) will crawl if they must. The idea of telling dwarves to ignore enemies is nice, but feels too... I dunno, it's just they run for a reason, you know? It's not like you can just tell them to ignore it and carry on, the whole point is, if they're scared they leg it.
Logged
I think it's the way towns develop now. In the beginning, people move into a town. Then they start producing tables, which results in more and more tables. Soon tables represent a significant portion of the population, they start lobbying for new laws and regulations, putting people to greater and greater disadvantage...
Link for full quote. 'tis mighty funny.

Urist McCheeseMaker

  • Bay Watcher
    • View Profile
Re: Dwarf-By-Dwarf Pathing/AI Options
« Reply #2 on: March 23, 2011, 06:26:42 pm »

So.. ignoring enemies is affected by personality and distance to the monster, perhaps?
Logged