According to the spec for the CHK UNIS/UNIX sections, each unit hitpoint is turned into its human readable value by dividing by 256. I've verified this with my own tools.
However I've come across something weird where SCMDraft will give units like Goliath Turrets/Tank Turrets/Sweeper Scanners (units that can never be placed) with 1 hitpoint in UNIS/UNIX section. This would translate to 1/256 HP in the game.
Is this a mistake? Should I treat any non-multiple of 256 or less than 256 as an error? Any hitpoint less than 256 can be safely rounded/fixed to 0 HP?
None.
Sorry no one has responded to this. Personally, I'm not sure what you're trying to accomplish here. In my experience, goliath turrets and tank turrets and scanner's hp doesn't matter because they are all not targetable units. From my understanding of the way unit HP works, I believe that values less than 256 will
display as 0, but the true value is still stored in SC's memory. The fractional portion of HP is used for things like zerg HP regeneration. In any case, it shouldn't matter too much either way with the units you described since they are invincible.
Thanks for clarifying!
I noticed that SCMDraft would save units with 0 hitpoint to 1 hitpoint, but my code that turns hitpoints into readable values would render this a fraction, then it would be saved as 0 once written back to the UNIS/UNIX CHK section.
What's the problem? Well if you have a program that reads a SCX/CHK file into memory and make no changes, you should get the same exact SCX/CHK file back. In this case I wasn't, because of the weird 1 hitpoint being stored on units like Scanner Sweeper, etc.
How have I dealt with this...in the human readable portion, I decided to store it as a float and not integer. That way the original CHK data is preserved, even if a 1 HP value is ultimately to a 0 HP value.
None.