Modding, Mission Design, and Coding > The FRED Workshop

Did you know that FRED can't count to 100?

(1/1)

**General Battuta**:

(This only applies to certain percentage-based 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!

**Mobius**:

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

**TopAce**:

Is this similar to the Y2K problem in its foundation?

**AdmiralRalwood**:

--- Quote from: TopAce on November 29, 2020, 05:54:42 am ---Is this similar to the Y2K problem in its foundation?

--- End quote ---

Not quite. It's a floating-point 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 floating-point 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 floating-point format and/or rounding instead of truncating), but it's honestly a very low-priority problem (since you can work around it by just using an increment larger than 1).

Navigation

[0] Message Index

Go to full version