Opened 12 years ago

Last modified 4 years ago

#1192 new enhancement

[PATCH] Improve animal UnitAI behavior

Reported by: Zaggy1024 Owned by:
Priority: Nice to Have Milestone: Backlog
Component: Core engine Keywords: patch
Cc: Patch:

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 (1)

public.diff (10.0 KB ) - added by Zaggy1024 12 years ago.

Download all attachments as: .zip

Change History (12)

by Zaggy1024, 12 years ago

Attachment: public.diff added

comment:1 by Zaggy1024, 12 years ago

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 12 years ago by Zaggy1024 (previous) (diff)

comment:2 by Zaggy1024, 12 years ago

Keywords: review added
Summary: Improve animal UnitAI behavior[PATCH] Improve animal UnitAI behavior

comment:3 by B. Guns, 12 years ago

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 by Zaggy1024, 12 years ago

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 by historic_bruno, 12 years ago

Milestone: Alpha 9Alpha 10

comment:6 by Kieran P, 12 years ago

Keywords: patch added

comment:7 by historic_bruno, 12 years ago

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 by Kieran P, 12 years ago

Keywords: patch, review → patch review
Milestone: Alpha 10Alpha 11

comment:9 by historic_bruno, 12 years ago

Keywords: review removed
Milestone: Alpha 11Backlog

comment:10 by historic_bruno, 10 years ago

Owner: Zaggy1024 removed

comment:11 by Freagarach, 4 years ago

Refs. #3919.

Note: See TracTickets for help on using tickets.