Hbm's Nuclear Tech Mod

Hbm's Nuclear Tech Mod

1M Downloads

Rounding issue in negative chunks with ExplosionNukeRayBatched

Vaern opened this issue ยท 3 comments

commented

Describe the bug

In the latest version, Mk5 explosions result in a lopsided/incorrect application of block damage when detonated in negative chunks.

The distance travelled by each ray is tracked by a for loop, wherein the control variable i is used to calculate a factor. This factor is used to modify the blast resistance of the block at those coordinates - specifically, resistance grows exponentially with a higher distance, meaning that anything near the epicenter is annihilated, with a significant falloff.

However, the actual block coordinates are simply truncated and casted from the vector coordinates. For the actual position of any given block, the coordinates are rounded down to the nearest integer to negative infinity; however, truncating the decimal of a given coordinate rounds down to the integer closest to 0.

As a result, when one of the coordinates of a ray is negative, the converted block position can actually be further away or nearer to the epicenter. Since the distance remains the same, the modification to resistance can result in a) blocks being destroyed when they shouldn't be or b) blocks left undestroyed when they should be.

Properly rounding the coordinates should fix this.

commented

You know; if this was made from the mk4 design or have some familiar parts to it, it could explain why some things were not destroyed before like missed chunks. This is only a speculation.

commented

:3

commented

Fixed in X4501.