Skip to content

Fix for floating point error accumulation (Invisibility, Stealth, Confusion)

A few properties are manipulated as floats but have important binary behaviors based on their status as zero or not. For example, invisible is the "invisibility power" and is used as a floating point number for seeing through it, but any creature with invisible != 0 will cause the (annoying) shader and be completely invisible to any creature without see_invisible, even if they only have 0.00001 invisibility power. This low value is usually not reached in normal gameplay, but for characters that repeatedly toggle invisibility or stealth (like Shalore with Secrets of the Eternals), accumulating floating point errors can sometimes cause them to be stuck in a state of permanent invisibility.

We introduce a new parameter for entities, attr_eps that sets a threshold for certain properties. Attributes that end up with an absolute value less than attr_eps get forced to zero (the assigned nil for the engine). This should prevent the floating point error. This is set per class and per property, and is currently set at 0.01 for invisible, stealth, and confused (which can similarly be applied often and prevents leaving areas).

Merge request reports