I've made some progress on the plugin; it currently walks the entire list of units, and looks for eligible ones. I've had to write a set of criteria; I want a sanity check to make sure this sounds good:



It first excludes all invaders, HFS, FB, titans, and dead units (as hilarious as it would be to treat fallen enemies), then it runs through the following checks:



/**

* So, for a unit to be elligable for the hospital, all the following must be true

*

* 1. It must be a member of our civilization

* 2. It must have a health struct (which is generated by combat)

* 3. health->requires_diagonsis must be set to true

* 4. If health->requires_recovery is set, the creature can't move under its own power

* and a Recover Wounded or Pen/Pasture job MUST be created - TODO

* 4.1 If CAN_LEARN, and can move, go to the hospital under own power

* 4.2 If it can't move, make a hauling job happen

* 4.3 If in a cage/chain, Pen/Pasture it to the hospital

* 5. It must be tame (semi-wild counts for this(?))

* 6. An open spot in the "Animal Hospital" (activity zone with hospital+animal training set)

* must be available

*/



2 and 3 seem to work reliably. I need to science 4 to see if that actually works; I think it does, but my method of animal injuring isn't precise enough to know for sure. If anyone knows how to maim any animal reliably to the point they can't walk, let me know. Otherwise, I'm building a kittypault.



With dwarves, they'll automatically path to the hospital, and sit in a bed. I think the correct thing to do is check the critter for the CAN_LEARN tag, and if its there, do that (out of the box, I think gremlins are the only tamable CAN_LEARN boost). Otherwise we're going to need a recover task; I haven't gotten these working reliably, but abusing pen/pasture could do the trick.



4.1 (Caged/Chained) is annoying. I had issues with recovered wounded and animals, and I doubt it would work for a critter in a cage/pen (else we'd never have caged dwarves). Not sure how to get a critter out of a cage. Plus the headache of putting them BACK in a cage; we may end up in a "hilarious" situation where the Animal Caretaker, and the Pen/Pasture get in a tug-of-war (though given its an injured animal, for all I know, they might both win). I'm hoping zone.cpp has most of this logic figured out for sheer sanity reasons.



5 is semi-problematic; I don't do a lot of animal training in my forts, so I'm probably going to have to build a fort entirely for this purpose and watch how animals go wild. I'm guessing the tame status goes to 9 (WildUntamed), but the civ flag isn't cleared, which is why they're TRAPAVOID; I might as well fix this case as well while I'm here.



6. This was the closest I could think equals animal hospital. We don't want to send them to a regular hospital because if they go into a bed, they seem to get stuck and never leave until its deconstruction. Animal health jobs never seem to cause traction or crutch requests, so it shouldn't be a BIG deal, but I'm thinking I'm going to be dropping every animal in vanilla a couple of Z levels and mopping up the bits.



