From 754fb124428dc1f05a58c6284ae9bba894a96ddb Mon Sep 17 00:00:00 2001 From: Elkien3 Date: Thu, 14 Mar 2019 16:05:46 -0500 Subject: [PATCH] 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. --- api.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api.lua b/api.lua index 0c2a531..3df7341 100644 --- a/api.lua +++ b/api.lua @@ -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"