Below is the code that I think would be 'ideal', however the damage table in the unit wrapper is 'read only' so the changes made in the code below aren't actually saved. I have tried using the SetUnitDamage function but that appears to only influence component damage, fire and flood--not damage points.
Also, I was wondering if there's a way to return all the sides that are in a scenario? Something like: ScenEdit_ListSides() --returns a table of sides with name and guid
Code: Select all
p_side = ScenEdit_PlayerSide()
side = VP_GetSide({name=p_side})
for i = 1,#side.units do
unit = ScenEdit_GetUnit({guid=side.units[i].guid})
damage = unit.damage
damage_start = tonumber(damage.startdp)
damage_current = tonumber(damage.dp)
if damage_current < damage_start then
ScenEdit_SetUnit({guid=unit.guid,damage={dp=damage_start}})
end
endAny suggestions?

