Ticket #1192 (new enhancement)

Opened 15 months ago

Last modified 12 months ago

[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

public.diff (10.0 KB) - added by Zaggy1024 15 months ago.

Change History

Changed 15 months ago by Zaggy1024

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.

Last edited 15 months ago by Zaggy1024 (previous) (diff)

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:5 Changed 15 months ago by historic_bruno

  • Milestone changed from Alpha 9 to Alpha 10

comment:6 Changed 14 months ago by k776

  • Keywords patch, added

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.

comment:8 Changed 13 months ago by k776

  • Keywords patch added; patch, removed
  • Milestone changed from Alpha 10 to Alpha 11

comment:9 Changed 12 months ago by historic_bruno

  • Keywords review removed
  • Milestone changed from Alpha 11 to Backlog
Note: See TracTickets for help on using tickets.