Skip to content

Commit

Permalink
Account for possible div-by-zero in stealth module
Browse files Browse the repository at this point in the history
  • Loading branch information
caligari87 committed Mar 24, 2019
1 parent 8ab11fc commit f993202
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/ai/stealth.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -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] +
Expand Down

0 comments on commit f993202

Please sign in to comment.