fix damage
This commit is contained in:
parent
6e3c930fb7
commit
99d1c64e9b
18
api.lua
18
api.lua
@ -53,28 +53,32 @@ guns.fire_bullet = function(self, itemstack, player)
|
||||
}
|
||||
local bullet_drop = 0
|
||||
local bullet_velocity = 0
|
||||
local bullet_damage = {}
|
||||
local damage = def._gun_damage or {}
|
||||
local accuracy = def._gun_accuracy or 0
|
||||
local velocity = def._gun_velocity or 0
|
||||
|
||||
local meta = itemstack:get_meta()
|
||||
local ammo = minetest.registered_items[meta:get("bullets_name")]
|
||||
|
||||
local damage = {}
|
||||
local add_damage = function(arr)
|
||||
for k, v in pairs(arr) do
|
||||
local i = damage[k] or 0
|
||||
damage[k] = i + v
|
||||
end
|
||||
end
|
||||
add_damage(def._gun_damage or {})
|
||||
|
||||
if ammo then
|
||||
bullet_drop = ammo._bullet_drop or bullet_drop
|
||||
bullet_velocity = ammo._bullet_velocity or bullet_velocity
|
||||
bullet_damage = ammo._bullet_damage or bullet_damage
|
||||
if ammo._bullet_properties then
|
||||
bullet_properties = ammo._bullet_properties
|
||||
else
|
||||
table.insert(bullet_properties["textures"], ammo.name)
|
||||
end
|
||||
add_damage(ammo._bullet_damage or {})
|
||||
end
|
||||
|
||||
for k, v in pairs(bullet_damage) do
|
||||
local i = damage[k] or 0
|
||||
damage[k] = i + v
|
||||
end
|
||||
velocity = velocity + bullet_velocity
|
||||
accuracy = math.max(0, (100 - accuracy) / 10)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user