{ startdp = '0', fires = 'NoFire', flood = 'NoFlooding', dp_percent = '50', dp = 0 }
Issue: Upon a repair no matter if via Lua or the GUI the dp_percent value stays at the value prior to the change.
This is not a problem with the GUI display, that % updates accurately.
Repo: (plot basic hanger and some some other unit that will damage it less that 100% per munition)
1. Have unit fire a shots at the hanger.
1. A unit takes damage let say to 40%.
2. One queries it via Lua
3. One repairs the unit fully (via the GUI or Lua.. does not matter in my testing).u = ScenEdit_GetUnit({guid="TheGuidHere"})
print(u.damage)
-->> { startdp = '0', fires = 'NoFire', flood = 'NoFlooding', dp_percent = '40', dp = 0 }
4. One queries it again via Lua (the GUI shows correct 0% damage value).
5. Have hanger unit take damage again, say of 25%.u = ScenEdit_GetUnit({guid="TheGuidHere"})
print(u.damage)
-->> { startdp = '0', fires = 'NoFire', flood = 'NoFlooding', dp_percent = '40', dp = 0, dp_percent_now=0}
6. One queries it again via Lua (the GUI shows correct 25% left value).
u = ScenEdit_GetUnit({guid="TheGuidHere"})
print(u.damage)
-->> { startdp = '0', fires = 'NoFire', flood = 'NoFlooding', dp_percent = '25', dp = 0}
Is this intentional?
Also when a trigger fires based on damage dp_percent_now will also appear with the % damage taken it would seem either 'that round' or in the amount that caused the trigger to well.. trigger.

I was thinking maybe it's the way it is to so someone could track differences without their own table, but in addition to the above complicating that, the _now variant will not show up on lua or gui invoked new 'damage' so that would not work in a full coverage sort of way. btw I'm not say _now should appear in that case just pointing out it doesn't - it does for lua invoked full repairs.
So I wonder can we get dp_percent to just update upon repairs to 0? Along with keeping the _now flag stuff untouched? Would that break\impact something I'm not thinking about?
If that can't be tweaked without other impact, then if I was to work around this issue I have a question. Is it ALWAYS the case that the something like the following first line will be true only when a repair has happened but no new damage has been taken yet.
Code: Select all
if (u.damage.dp_percent_now ~=nil) and u.damage.dp_percent_now == 0.0 and u.damage.dp_percent > 0.0 then
--I've been repaired recently to 100%|0 damage, use dp_percent_now value as real dmg percentage.
elseif((u.damage.dp_percent_now ~=nil) and u.damage.dp_percent_now >0.0) and u.damage.dp_percent > 0.0 then
--I've just been damaged this cycle\second add both together for real total 'this second'.
--till it's incorporated into percent next cycle where dp_percent_now does not exist anymore.
elseif((u.damage.dp_percent_now ==nil) and u.damage.dp_percent > 0.0 then
--Unit has damage, dp_percent is correct value for damage, including if It's been repaired to less than 100%.
--check my external damage tracking table for last value to detect if new value is pos or neg change.
--and if to do something and update the value.
... yada yada
else
-- go update last value in our external damage tracking table for this unitguid.
...yada yada
end
Just wondering if there are other cases the devs might shed light on.
Thanks.
I'll provide a scenes if needed, this is more a is it really supposed to work this way sort of question when it comes to dp_percent not updating, cause I could see there being a reason, and just trying to find a workaround for it.
edited 6/14: I had 100% where I meant 0% for what the gui displays for damage, but I think anyone reading knew what I meant along with minor edit in verbiage for better clarity.