Page 1 of 1

wild animals disappear

Posted: Thu Dec 20, 2018 5:14 am
by Dino the Dinosore
I'm playing with the new wild animal feature and found they all disappear pretty quickly after the game starts. Not what I want, and I expect most folks would agree they should stick around until they're killed, since, unlike human pirates and barbarians, animals can survive and reproduce in their native tiles. I'm dubious that this behavior was intended when the wild animal feature was introduced. It's possible new animals get generated once barbarians start appearing, if so, that's OK.
Figured out they are subject to the same "retirement" that happens to other barbarian units. Tech details - ".../share/freeciv/nation/animals.ruleset" has the line -
groups="Core", "Barbarian"
just like ".../share/freeciv/nation/barbarian.ruleset" and ".../share/freeciv/nation/pirate.ruleset". This behavior must be hard-coded, I can't find any way for ruleset files to configure it. Maybe there should be some way added to allow a ruleset to control barbarian behavior.
Meanwhile I have a work-around, adding code in the "script.lua" file to catch when an animal gets retired, and re-spawn a replacement

Code: Select all

function unit_lost_callback(unit, loser, reason)
  nation = loser.nation:name_translation()
  if nation == "Animal Kingdom" and reason == "retired" then
    edit.create_unit(loser, unit.tile, unit.utype, 0, unit.homecity, -1)
  end

  -- continue processing
  return false
end

signal.connect("unit_lost", "unit_lost_callback")

Only problem: have to set the "veteran_level" param to 0 (= "green") because there's no way to get a unit's veteran_level value. I would prefer to use, e.g. "edit.create_unit(loser, unit.tile, unit.utype, unit.veteran_level, unit.homecity, -1)" if I could. In addition to the missing "unit.veteran_level", there's also no corresponding "edit.unit_veteran_level".

Re: wild animals disappear

Posted: Thu Dec 20, 2018 3:14 pm
by Ignatus
This is likely because of Retire_Pct effect (effect_barb_disappear in effects.ruleset), try just put there a requirement like

Code: Select all

"Nation", "Animal Kingdom", "Local", FALSE

Re: wild animals disappear

Posted: Fri Dec 21, 2018 1:15 am
by Dino the Dinosore
Thanx - I missed that Retire_Pct effect.

Re: wild animals disappear

Posted: Fri Dec 21, 2018 2:24 am
by Dino the Dinosore
It doesn't like range "Local". Have now verified what works is

Code: Select all

 "Nation", "Animal Kingdom", "World", FALSE

Re: wild animals disappear

Posted: Fri Dec 21, 2018 2:26 am
by cazfi
Dino the Dinosore wrote:It doesn't like range "Local". Have now verified what works is

Code: Select all

 "Nation", "Animal Kingdom", "World", FALSE

That prevents retirement of also normal barbarians when Animal Kingdom exist. What you want is "Player" range.

Re: wild animals disappear

Posted: Fri Dec 21, 2018 3:50 am
by Dino the Dinosore
Not sure I fully understand how ranges work, but I believe you. Tested

Code: Select all

"Nation", "Animal Kingdom", "Player", FALSE
and it appears to work OK. Thanks.