Reduce Hitpoints in Lua script

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
BadPractice
Posts: 4
Joined: Mon Oct 20, 2014 11:59 am

Reduce Hitpoints in Lua script

Post by BadPractice »

Hi,

I still did not find an way to reduce the hp (or any attribute) of an specific unit via Lua script. Is there any?
btharper
Posts: 2
Joined: Thu Mar 12, 2015 2:29 am

Re: Reduce Hitpoints in Lua script

Post by btharper »

I don't see anything in the wikia entry, you might be able to hack something together by killing and creating a new unit in it's place edit.create_unit_full(). I'm not sure if this would have any unintended effects (dropping new units into locations, adding units to cities, transports, increment counters, just changing the unit's ID), but you could also capture some events by catching the unit_built signal and returning true to stop the bubbling to other event handlers to avoid some of these things.

Something built into the API would obviously be simpler, but that requires a change in the source. It is at least completely backwards compatible.
Post Reply