Getting maximum health.

Getting maximum health.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
code_man
Posts: 260
Joined: 19 Jan 2014, 13:10

Getting maximum health.

Post by code_man »

I need the maximum health of a unit including veterancy bonus.

I tried the Spring.GetUnitHealth function but that didnt work and i dont know even if thats the right function for that since i couldnt make much sense out of the discription.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Getting maximum health.

Post by CarRepairer »

Spring.GetUnitHealth
( number unitID ) -> nil | number health, number maxHealth, number paralyzeDamage,
number captureProgress, number buildProgress
http://springrts.com/wiki/Lua_SyncedRead

The function returns multiple return values. You might be looking just at the first one. Try

Code: Select all

health, maxHealth = Spring.GetUnitHealth(...)
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Getting maximum health.

Post by Jools »

But does that return nominal maximum health or the current (veteran bonus corrected) one? I think it returns the current maxhealth. If so, how does one get the nominal one?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Re: Getting maximum health.

Post by FLOZi »

Jools wrote:But does that return nominal maximum health or the current (veteran bonus corrected) one? I think it returns the current maxhealth. If so, how does one get the nominal one?
UnitDefs[unitDefID].health
Post Reply

Return to “Lua Scripts”