wild animals disappear

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
User avatar
Dino the Dinosore
Posts: 44
Joined: Sun Dec 31, 2017 3:41 am

wild animals disappear

Postby Dino the Dinosore » Thu Dec 20, 2018 5:14 am

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".

Ignatus
Veteran
Posts: 126
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: wild animals disappear

Postby Ignatus » Thu Dec 20, 2018 3:14 pm

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

User avatar
Dino the Dinosore
Posts: 44
Joined: Sun Dec 31, 2017 3:41 am

Re: wild animals disappear

Postby Dino the Dinosore » Fri Dec 21, 2018 1:15 am

Thanx - I missed that Retire_Pct effect.

User avatar
Dino the Dinosore
Posts: 44
Joined: Sun Dec 31, 2017 3:41 am

Re: wild animals disappear

Postby Dino the Dinosore » Fri Dec 21, 2018 2:24 am

It doesn't like range "Local". Have now verified what works is

Code: Select all

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

cazfi
Elite
Posts: 1588
Joined: Tue Jan 29, 2013 6:54 pm

Re: wild animals disappear

Postby cazfi » Fri Dec 21, 2018 2:26 am

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.

User avatar
Dino the Dinosore
Posts: 44
Joined: Sun Dec 31, 2017 3:41 am

Re: wild animals disappear

Postby Dino the Dinosore » Fri Dec 21, 2018 3:50 am

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.