Update 1.1

This commit is contained in:
echoes91
2020-04-18 15:31:17 +02:00
parent 00d86908d8
commit 3c174db494
2 changed files with 17 additions and 24 deletions

View File

@ -14,19 +14,19 @@ function spears_shot (itemstack, player)
return true
end
function spears_set_entity(kind, eq, toughness)
function spears_set_entity(spear_type, base_damage, toughness)
local SPEAR_ENTITY={
physical = false,
timer=0,
visual = "wielditem",
visual_size = {x=0.15, y=0.1},
textures = {"spears:spear_" .. kind},
textures = {"spears:spear_" .. spear_type},
lastpos={},
collisionbox = {0,0,0,0,0,0},
on_punch = function(self, puncher)
if puncher then
if puncher:is_player() then
local stack = {name='spears:spear_' .. kind, wear=self.wear+65535/toughness}
local stack = {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness}
local inv = puncher:get_inventory()
if inv:room_for_item("main", stack) then
inv:add_item("main", stack)
@ -49,22 +49,22 @@ function spears_set_entity(kind, eq, toughness)
if node.name ~= "air" and not (string.find(node.name, 'grass') and not string.find(node.name, 'dirt')) and not string.find(node.name, 'flowers:') and not string.find(node.name, 'farming:') then
self.object:remove()
if self.wear+65535/toughness < 65535 then
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
minetest.add_item(self.lastpos, {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness})
end
elseif self.timer>0.2 then
local objs = minetest.get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1)
for k, obj in pairs(objs) do
if obj:get_luaentity() ~= nil then
if obj:get_luaentity().name ~= "spears:spear_" .. kind .. "_entity" and obj:get_luaentity().name ~= "__builtin:item" then
if obj:get_luaentity().name ~= "spears:spear_" .. spear_type .. "_entity" and obj:get_luaentity().name ~= "_builtin:item" then
local speed = vector.length(self.object:getvelocity())
local damage = (speed + eq)^1.12-20
local damage = (speed + base_damage)^1.12-20
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
}, nil)
self.object:remove()
if self.wear+65535/toughness < 65535 then
minetest.add_item(self.lastpos, {name='spears:spear_' .. kind, wear=self.wear+65535/toughness})
minetest.add_item(self.lastpos, {name='spears:spear_' .. spear_type, wear=self.wear+65535/toughness})
end
end
end