Fixed possible division by zero in CritterMoth
This commit is contained in:
parent
c806c1a482
commit
1a9175d4b7
Binary file not shown.
@ -362,13 +362,20 @@ ObjectReference Function PickNextPlant()
|
||||
|
||||
float distanceTraveled = Math.sqrt(Math.pow(distanceTraveledX, 2) + Math.pow(distanceTraveledY, 2))
|
||||
|
||||
wanderRangeX = RandomFloat(fMinWander, fMaxWander) * Math.cos(distanceTraveledX / distanceTraveled)
|
||||
if (distanceTraveledX < 0) ; more efficient than calling math.abs
|
||||
wanderRangeX *= -1
|
||||
if distanceTraveled > 0
|
||||
wanderRangeX = RandomFloat(fMinWander, fMaxWander) * Math.cos(distanceTraveledX / distanceTraveled)
|
||||
if (distanceTraveledX < 0) ; more efficient than calling math.abs
|
||||
wanderRangeX *= -1
|
||||
endif
|
||||
wanderRangeY = RandomFloat(fMinWander, fMaxWander) * Math.sin(distanceTraveledY / distanceTraveled)
|
||||
endif
|
||||
wanderRangeY = RandomFloat(fMinWander, fMaxWander) * Math.sin(distanceTraveledY / distanceTraveled)
|
||||
else
|
||||
endif
|
||||
|
||||
if wanderRangeX == 0
|
||||
wanderRangeX = RandomFloat(fMinWander, fMaxWander) * RandomInt(-1, 1)
|
||||
endif
|
||||
|
||||
if wanderRangeY == 0
|
||||
wanderRangeY = RandomFloat(fMinWander, fMaxWander) * RandomInt(-1, 1)
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user