Attempt to fix SplashDamage error w.r.t. line 604

Guard against event.target:getPosition() potentially being nil
This commit is contained in:
Raffson 2025-04-12 17:24:23 +02:00
parent 1db84307fe
commit de1f8a7abc
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99

View File

@ -601,7 +601,6 @@ function onWpnEvent(event)
local player = event.initiator
local targetName = event.target:getTypeName()
local impactPoint = event.target:getPosition().p
if weapon and targetName then
env.info(weapon.." hit "..targetName)
debugMsg(weapon.." hit "..targetName)
@ -610,7 +609,8 @@ function onWpnEvent(event)
if clusterWeaps[weapon] then
local ordnance = event.weapon
tracked_weapons[event.weapon.id_] = { wpn = ordnance, init = event.initiator:getName(), pos = ordnance:getPoint(), dir = ordnance:getPosition().x, name = ordnance:getTypeName(), speed = ordnance:getVelocity(), cat = ordnance:getCategory(), player=event.initiator }
else
elseif event.target:getPosition() ~= nil then
local impactPoint = event.target:getPosition().p
blastWave(impactPoint, splash_damage_options.blast_search_radius, event.weapon, getWeaponExplosive(weapon), player)
end
end