Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

[Logged] Lua SetUnitDamage dp cast to int vs float

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [Logged] Lua SetUnitDamage dp cast to int vs float Page: [1]
Login
Message << Older Topic   Newer Topic >>
[Logged] Lua SetUnitDamage dp cast to int vs float - 6/13/2021 11:16:42 AM   
KnightHawk75

 

Posts: 1211
Joined: 11/15/2018
Status: online
So ScenEdit_SetUnitDamage() allows setting the unit's .damage.dp amount via the {...DP=X} parameter pos or negative change.

The problem: When the DP value is parsed in, it's converted to an integer before later being converted to float when it's used to do the work, this removes (at times) critically needed precision from the user input.

Request: Please change this to parse it as a float initially, or single or double or decimal, anything but int please.

When does this come up:
This is a problem when trying to repair something accurately, or when trying to do damage in small increments in many cases, where it can be kind of worked around involves way more code than it should.

For example in the special cases where startdp < 2 indicating special handling and one is trying to say negate a current dp of 0.3012456789 (indicating 70% current damage), one can not do it accurately (one can work around it with lots of if-then-elses and some math to ensure it ends up above 1.0 and < 2, but it's a pita even though it seems to work, and you can never get it to 0.0 or 1.0 etc. BUT even the workarounds only works for restoring a unit fully. If one was trying to simulate a slow, very incremental repair one can not at the fidelity one may want.

Take the non-special case of a hanger with 600dp.. it gets damaged, dp shows 501.12456 left. I want to decrease it by 1.1% (6.6dp) an hour till I hit the 600 max. Can't really do it 'nicely', I can creatively hack around the problem and get it to 601.x in full integer increments only though, and yes thankfully the underlying system allows it to work but in the cases of one where it's 'special' and non sensor based ie do tracked from 1.0 down to 0.0, I simply can't do incremental even in-artfully.



< Message edited by KnightHawk75 -- 6/20/2021 2:22:41 AM >
Post #: 1
RE: Lua SetUnitDamage dp cast to int vs float - 6/14/2021 6:45:29 AM   
Geoffropi

 

Posts: 81
Joined: 10/27/2020
Status: offline
Logged[14602]

(in reply to KnightHawk75)
Post #: 2
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> [Logged] Lua SetUnitDamage dp cast to int vs float Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.246