Opened 9 years ago

Last modified 3 years ago

#3444 new defect

[PATCH] Lions / Lionesses don't run when attacked

Reported by: Koufalex Owned by: erraunt
Priority: Should Have Milestone: Work In Progress
Component: Simulation Keywords: patch rfc
Cc: knight.erraunt@… Patch:

Description (last modified by Freagarach)

Lions / lionesses when attacked cruise slowly towards the attacker. It would be expected when lions are attacked to run towards the attacker as other animals run away, instead they just walk slowly while dying by javelins.

I believe animals, or maybe every unit, has walking and running speed, it seems like lions' running speed is either very low or they don't run.

Also this is my first bug report, so feel free to correct me or leave any feedback.

Attachments (6)

my_patch.diff (932 bytes ) - added by erraunt 8 years ago.
A simple dirty fix which seems to do what is asked in this issue.
UnitAI_my_changes.js (175.5 KB ) - added by erraunt 8 years ago.
the whole file for simpler comparison.
UnitAI_animal_behavior.diff (1.5 KB ) - added by erraunt 8 years ago.
Changed the diff format to the one suggested in the wiki.
UnitAI_animal_behavior_with_Itms_suggestion.diff (1.5 KB ) - added by erraunt 8 years ago.
UnitAI_animal_behavior_with_elexis_suggestion.diff (1.2 KB ) - added by erraunt 8 years ago.
UnitAI.diff (1.5 KB ) - added by erraunt 8 years ago.

Download all attachments as: .zip

Change History (26)

comment:1 by Itms, 9 years ago

Component: AICore engine
Keywords: pathfinding added; lions running speed removed

Hi and thanks for the report! Are you playing with the development version or with Alpha 18? :)

comment:2 by Koufalex, 9 years ago

Hello, I'm playing with the Alpha 18. Specifically it says "Build: Mar 3, 2015 (16404)". I see you changed Component from AI to Core Engine would you mind to explain, because it's fuzzy to me? Thank you for answering! :D

in reply to:  2 comment:3 by elexis, 9 years ago

Replying to Koufalex:

I see you changed Component from AI to Core Engine would you mind to explain, because it's fuzzy to me?

Only things that relate to the Petra Bot should be listed under AI. It seems to be caused by the pathfinder, otherwise he wouldn't have added that keyword and those bugs are part of the core-engine.


You can find lions on the skirmish map Gold Oasis (2). In the templates you will see that their walk speed is quite slow, so everything works the way it should.

We could easily increase it to 30 walk and 40 run, since they should be able to walk/run faster than horses, right?

But I think this would not be an ideal change, since then they would always use this very fast walk speed, even when roaming. The animation used for walking also is not adequate for running. Also lions only run for short distances I think.

So ideally we would not increase their walk speed but make them run for some seconds when attacked and force some walking after that (before potentially running again) (in my opinion).

comment:4 by Koufalex, 9 years ago

Lions can also be found on the map Savvana River (2). After a search I did on the internet I found that indeed lions sprint for sort distances when hunting and with speed larger than an average horse along with a rider. According to wikipedia an average galloping horse runs at speed of 40 - 48 km/h. And the max speed of a lion is around 80 km/h.

elexis idea: "So ideally we would not increase their walk speed but make them run for some seconds when attacked and force some walking after that" Sounds great.

by erraunt, 8 years ago

Attachment: my_patch.diff added

A simple dirty fix which seems to do what is asked in this issue.

by erraunt, 8 years ago

Attachment: UnitAI_my_changes.js added

the whole file for simpler comparison.

comment:5 by erraunt, 8 years ago

I have created a simple patch which makes animals APPROACH in runSpeed and CHASE in runSpeed even when the enemy is not FLEEING (it was stupid when the lion did not chase you solidiers when you ordered them to go away). Tested on lions/lionness, crocodiles and elephants, seems to work resonably, the lions are the only ones seriously affected the crocodiles/elephants probably have similar walk and run speed. Concerning speeds - not sure whether you strive for playability or real world feeling, but I think it is strange that I can escape a lion on foot, and the lions don't even bother to chase cavalry, I mean, they do but leave it very fast after realizing they will not catch them. In my mind it should be scaled so that it is possible to escape with cavalry, to get a similar feeling like now with the infantry - what do you guys think? About the speeds and the patch.

Speeds (walk/run) FYI: Roman Cavalry spearman speed is 22/40 lion speed is 3/15 Infantry spearman speed is 8.5/15

Last edited 8 years ago by erraunt (previous) (diff)

by erraunt, 8 years ago

Attachment: UnitAI_animal_behavior.diff added

Changed the diff format to the one suggested in the wiki.

comment:6 by Itms, 8 years ago

Please read the page wiki:SubmittingPatches, and also wiki:Coding_Conventions :)

On top of that I suggest you add the this.IsAnimal check in the leave branch so the code stays consistent.

Thanks for working on the issue!

comment:7 by erraunt, 8 years ago

Cc: knight.erraunt@… added
Keywords: rfc patch added
Summary: Lions / Lionesses don't run when attacked[PATCH] Lions / Lionesses don't run when attacked

comment:8 by Stan, 8 years ago

When possible (Except really rare edgecases) use let instezd of var.

comment:9 by erraunt, 8 years ago

Removed the creation of temporary variable for speed, previously was inspired how it was done in CHASE.enter, don't know which is better, changed it everywhere though - so it is consistent.

comment:10 by erraunt, 8 years ago

Milestone: BacklogAlpha 21

comment:11 by bb, 8 years ago

Useless braces in L1999

comment:12 by erraunt, 8 years ago

@bb: you are right, fixed.

comment:13 by Itms, 8 years ago

Component: Core engineUI & Simulation
Keywords: review added; pathfinding rfc removed

The patch looks good and works well! Do you want your name added to the game credits? If so, please update the file ps/trunk/binaries/data/mods/public/gui/credits/texts/programming.json.

comment:14 by Itms, 8 years ago

Keywords: review removed

Sorry, I missed something big: if the animal manages to kill the attacker, it should go back to its normal speed, so your line 1718 is wrong, it should be the regular speed.

Your new line 1999 will also add this kind of problem, since I assume the call for going back to the regular speed works for valid targets. I'm not sure your change to the conditional is actually needed, but I agree with removing the temporary variable.

comment:15 by elexis, 8 years ago

Milestone: Alpha 21Alpha 22

It were nice to have for next release, but if noone is going to patch it until then (deadline tomorrow night)...

comment:16 by erraunt, 8 years ago

Of course 1718 was wrong.

Removed the temporary variable and added a conditional in 2009 - we don't want non-animal units to change speed in case of health change. But don't know what more can be wrong with 1999.

Will be back at Monday so I guess it will have to wait for Alpha 22 (if anyone else want to take care of it feel free).

EDIT: the conditional in 1718 was unnecessary I reckon - was that the one you wanted to change? Hopefully.

Last edited 8 years ago by Itms (previous) (diff)

by erraunt, 8 years ago

Attachment: UnitAI.diff added

comment:17 by elexis, 7 years ago

Keywords: rfc added
Milestone: Alpha 22Work In Progress

Don't forget to add a name entry for programming.json and add a review or rfc keyword if you want your old patch to receive attention (or even better moving it to code.wildfiregames.com as explained at wiki:SubmittingPatches)

comment:18 by Imarok, 5 years ago

Component: UI & SimulationSimulation

Move tickets to Simulation as UI & Simulation got some sub components.

comment:19 by Freagarach, 4 years ago

Description: modified (diff)

See also #3919.

comment:20 by Silier, 3 years ago

Owner: set to erraunt
Note: See TracTickets for help on using tickets.