fix crash when shooting player

base_dmg by istelf is nil, and if def.dmg_mult is nil it also crashes, so I gave it a default value of 1 if it's not already specified in the gun definiton.
This commit is contained in:
Elkien3 2019-03-14 16:05:46 -05:00
parent 2c8fbc70cc
commit 754fb12442

View File

@ -115,7 +115,7 @@ local function fire(stack, player)
if pointed and pointed.type == "object" then
local target = pointed.ref
local point = pointed.intersection_point
local dmg = base_dmg * def.dmg_mult
local dmg = def.base_dmg * def.dmg_mult
-- Add 50% damage if headshot
if point.y > target:get_pos().y + 1.5 then
@ -308,7 +308,9 @@ function gunslinger.register_gun(name, def)
return entity:on_rightclick(player) or on_rclick(stack, player)
end
end
if not def.dmg_mult then
def.dmg_mult = 1
end
if not def.fire_sound then
def.fire_sound = (def.mode ~= "splash")
and "gunslinger_fire1" or "gunslinger_fire2"