Ticket #1192 (new enhancement)
[PATCH] Improve animal UnitAI behavior
| Reported by: | Zaggy1024 | Owned by: | Zaggy1024 |
|---|---|---|---|
| Priority: | Nice to Have | Milestone: | Backlog |
| Component: | Core engine | Keywords: | patch |
| Cc: |
Description
Currently, the feeding code in UnitAI makes the deer (and any other animals set up to use this code), when they're idle, constantly feed, and when they're walking, never feed at all. The way the gazelle is set up, it randomly begins eating while idling or walking with no continuity to the previous animation that was playing.
Attachments
Change History
comment:1 Changed 15 months ago by Zaggy1024
The modified UnitAI.js in the diff makes animals have the following states:
- IDLE state: Plays the normal "idle" animation. After a randomized amount of time (between <FeedTimeMin?> and <FeedTimeMax?>), it will choose whether to switch to the ROAMING state or the FEEDING state.
- ROAMING state: Plays the "walk" animation and moves the unit randomly. After a randomized amount of time (between <RoamingTimeMin?> and <RoamingTimeMax?>), it will choose between switching to the FEEDING state or the IDLE state.
- FEEDING state: Plays the "feeding" animation. After a randomized amount of time (between <FeedTimeMin?> and <FeedTimeMax?>), it will choose whether to switch to the ROAMINGFEEDING state or the IDLE state.
- ROAMINGFEEDING state: Plays the "move_feeding" animation and moves the unit randomly. After a randomized amount of time (between <FeedTimeMin?> and <FeedTimeMax?>), it will choose whether to switch to the ROAMINGFEEDING state or the IDLE state.
Added a <Feeds> boolean element to the <UnitAI> element in entity templates.
comment:2 Changed 15 months ago by Zaggy1024
- Keywords review added
- Summary changed from Improve animal UnitAI behavior to [PATCH] Improve animal UnitAI behavior
comment:3 Changed 15 months ago by plumo
what about a DRINKING state ? Deer, elephants and other fauna very occasionally move to a river or water hole (in group?) for water ( needs new animation).
This is not only realistic, it makes hunting around water holes and rivers much more rewarding. In that way, you could see the water hole or river as an indirect resource 'an sich'. Also: wouldnt mind seeing a deer pulled in the water by a croc :D
comment:4 Changed 15 months ago by Zaggy1024
It might be nice to have some sort of setup where the random movement code makes animals tend towards lower altitude (maybe), but making a new DRINKING state would probably be unnecessary since, when animals walk towards water (and therefore into a position where they could be drinking), they would be pointing towards the water (most likely) and so the FEEDING state would look just as fine as a DRINKING state.
About deer getting pulled in the water by a croc, I think that's detail that would take too long to make to be worth it (if it's even possible the with the set of functions exposed to JS).
comment:7 Changed 13 months ago by historic_bruno
Alternatively: extend or rewrite the animation system to support interpolation between animations, with hand-crafted transition animations as an option. UnitAI isn't really intended for fine control of animations.
