Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 0e12e60

Browse files
committed
First check for possible divide-by-zero errors.
1 parent 70f5e57 commit 0e12e60

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Base.rte/AI/HumanFunctions.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function HumanFunctions.DoAlternativeGib(actor)
2121
end
2222
if actor.detachImpulseLimit and actor.TravelImpulse.Magnitude > actor.detachImpulseLimit then
2323
local parts = {actor.BGLeg, actor.BGArm, actor.FGLeg, actor.FGArm, actor.Head}; --Priority order
24-
local impulsePoint = actor.Pos - actor.TravelImpulse/actor.Mass;
24+
local impulsePoint = actor.Pos - actor.TravelImpulse/(actor.Mass == 0 and 0.0001 or actor.Mass);
2525
local closestDist, detachLimb;
2626
--Pick the limb closest to the direction of impulse
2727
for _, limb in pairs(parts) do
@@ -35,7 +35,7 @@ function HumanFunctions.DoAlternativeGib(actor)
3535
end
3636
end
3737
if detachLimb then
38-
local limbImpulse = actor.TravelImpulse.Magnitude/detachLimb.Mass;
38+
local limbImpulse = actor.TravelImpulse.Magnitude/(detachLimb.Mass == 0 and 0.0001 or detachLimb.Mass);
3939
if limbImpulse > detachLimb.JointStrength then
4040
detachLimb.JointStrength = -1;
4141
if math.random() * limbImpulse > detachLimb.GibImpulseLimit then

0 commit comments

Comments
 (0)