wild animal killing bonus

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

wild animal killing bonus

Postby Dino the Dinosore » Fri Jun 01, 2018 3:43 am

I'm playing with the new wild animal feature in my 2.6 ruleset ( see this thread - http://forum.freeciv.org/f/viewtopic.php?f=12&t=705 )
To balance the bad effects with something good, I'd like to have killing an animal give a bonus, like when you kill a barbarian leader. But I can't figure out a way to do that. The script event "unit_lost()" doesn't tell who killed the unit, and I don't see any way for a xxx.ruleset file to do it. Is this not possible?

Caedo
Elite
Posts: 421
Joined: Sun Feb 10, 2013 10:21 pm
Location: Germany

Re: wild animal killing bonus

Postby Caedo » Fri Jun 01, 2018 6:37 am

Did you try giving the animal units the Barbarian Leader flag? I mean, it would make an animal worth the same amount as a barbarian leader, but it would be a reward.

Alternatively, you could just put something on the tile where the animal died that somehow gives a bonus. There might be some voodoo-coding approaches to do this, but I can't think of a good one right now.

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

Re: wild animal killing bonus

Postby Dino the Dinosore » Mon Jun 04, 2018 9:35 pm

Tried the Barbarian Leader flag - it sort of works, but there are problems in addition to the amount being the same as a barbarian leader. The message shown says "Barbarian leader killed" and i don't think that can be changed. And it doesn't work for animals on ocean tiles (like my Kraken), ruleset fails to load. I'd also like to reward a culture point in addition to 10 gold.
I have another elaborate idea to try - use the "action_started_unit_unit" event to see if an animal is involved, if so, store it and its foe in a "database" (a lua table), then when get a "unit_lost" event, look up the unit in the "database" to find the foe. Also have to use the "action_started_unit_units" event because there might be a stack of animals, or an animal attacking a stack. A lot of coding - maybe it will work.

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

Re: wild animal killing bonus

Postby Dino the Dinosore » Tue Jul 10, 2018 3:35 am

The "action_started_unit_unit" event doesn't work - it's only for diplomat actions and doesn't get triggered when units attack. I have another idea to try next.

Caedo
Elite
Posts: 421
Joined: Sun Feb 10, 2013 10:21 pm
Location: Germany

Re: wild animal killing bonus

Postby Caedo » Tue Jul 10, 2018 6:32 am

Dino the Dinosore wrote:The "action_started_unit_unit" event doesn't work - it's only for diplomat actions and doesn't get triggered when units attack.

I believe this is different (and should work) in current developmental versions, since attacks have been unified with diplomat and caravan actions (along with a bunch of other stuff).

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

Re: wild animal killing bonus

Postby Dino the Dinosore » Fri Jul 13, 2018 5:38 pm

I was using freeciv 2.6.0b2, I'll try the 2.6.0-final which is scheduled to come out soon. (this weekend?)