Hard Light Productions Forums
Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: General Battuta on November 28, 2020, 10:29:00 pm

(This only applies to certain percentagebased values)
Set a ship's weapon ETS to 0 (lock it so the AI can't put power back in weapons). Set its weapon energy to 0.
Add 1 to the ship's weapon energy percent every second.
You'll never hit 100!

Did you know that the 100th argument in a SEXP will be marked as "0"? :nervous:

Is this similar to the Y2K problem in its foundation?

Is this similar to the Y2K problem in its foundation?
Not quite. It's a floatingpoint rounding error; certain numbers that are nice, round numbers in decimal (like 0.52, since Battuta ran into this problem at 52%) aren't nice, round numbers in binary. Since the SEXP code turns that floatingpoint number into an integer through truncation, 52% winds up rounding into 51, so when 1 is added it just brings it back up to 52... where it started. Technically, we could fix this (by using a higher precision floatingpoint format and/or rounding instead of truncating), but it's honestly a very lowpriority problem (since you can work around it by just using an increment larger than 1).