From f993202fa2dcff59465797ffce1acd989749a107 Mon Sep 17 00:00:00 2001 From: Sterling Parker Date: Sat, 23 Mar 2019 21:06:28 -0600 Subject: [PATCH] Account for possible div-by-zero in stealth module --- modules/ai/stealth.zsc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ai/stealth.zsc b/modules/ai/stealth.zsc index 726c74a6..f20e0c75 100644 --- a/modules/ai/stealth.zsc +++ b/modules/ai/stealth.zsc @@ -44,7 +44,8 @@ class UaS_StealthHandler : Inventory { vector3 posdiff = levellocals.Vec3Diff((owner.pos.x, owner.pos.y, owner.pos.z + (owner.height / 2)), currentlight.pos); double currentDistance = posdiff.length(); //owner.Distance3D(currentLight); - double distanceFactor = currentDistance / (double(currentLight.args[DynamicLight.LIGHT_INTENSITY]+1) * 2); + double lightIntensity = max(currentLight.args[DynamicLight.LIGHT_INTENSITY], 1); + double distanceFactor = currentDistance / (lightIntensity * 2); double avgIntensity = (currentLight.args[DynamicLight.LIGHT_RED] + currentLight.args[DynamicLight.LIGHT_GREEN] +