Working on the special weapons
This commit is contained in:
parent
a15938c9cd
commit
8f29da4bb4
@ -779,18 +779,35 @@ minetest.register_tool("nssm:axe_of_pride", {
|
|||||||
on_drop = function(itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
local objects = minetest.env:get_objects_inside_radius(pos, 10)
|
local objects = minetest.env:get_objects_inside_radius(pos, 10)
|
||||||
local flag = 0
|
local flag = 0
|
||||||
|
local meta = minetest.get_meta({x=0,y=0,z=0})
|
||||||
|
|
||||||
for _,obj in ipairs(objects) do
|
for _,obj in ipairs(objects) do
|
||||||
--scrivi qui
|
local timer = meta:get_string("axe_of_pride_"..obj:get_player_name())
|
||||||
if flag == 0 then
|
minetest.chat_send_all(timer)
|
||||||
flag=1
|
if timer then
|
||||||
if (obj:is_player()) then
|
|
||||||
obj:set_hp(obj:get_hp()-10)
|
--timer = tonumber(timer)
|
||||||
dropper:set_hp(dropper:get_hp()+10)
|
|
||||||
elseif (obj:get_luaentity()) then
|
local tim = os.time() - timer
|
||||||
obj:set_hp(obj:get_hp()-10)
|
if tim < 30 then
|
||||||
dropper:set_hp(dropper:get_hp()+10)
|
minetest.chat_send_player(dropper:get_player_name(),"Too soon. Wait for "..30-tim.." seconds")
|
||||||
end
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
meta:set_string("axe_of_pride_"..dropper:get_player_name(), tostring(os.time()))
|
||||||
|
if (obj:is_player()) then
|
||||||
|
--minetest.chat_send_all("Giocatore")
|
||||||
|
if (obj:get_player_name()~=dropper:get_player_name()) then
|
||||||
|
obj:set_hp(obj:get_hp()-10)
|
||||||
|
dropper:set_hp(dropper:get_hp()+10)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if (obj:get_luaentity().health) then
|
||||||
|
--minetest.chat_send_all("Entity")
|
||||||
|
obj:get_luaentity().health = obj:get_luaentity().health -10
|
||||||
|
dropper:set_hp(dropper:get_hp()+10)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -220,17 +220,19 @@ local function default_on_step(
|
|||||||
end
|
end
|
||||||
|
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
|
--minetest.chat_send_all("Timer: "..self.timer)
|
||||||
|
|
||||||
--while going around it damages entities
|
--while going around it damages entities
|
||||||
local objects = minetest.env:get_objects_inside_radius(pos, 2)
|
local objects = minetest.env:get_objects_inside_radius(pos, 2)
|
||||||
if self.timer > 0.3 then
|
if self.timer > 0.1 then
|
||||||
|
self.timer = 0
|
||||||
for _,obj in ipairs(objects) do
|
for _,obj in ipairs(objects) do
|
||||||
if obj:get_entity_name() ~= self.object:get_luaentity().name then
|
if (obj:get_entity_name() ~= self.object:get_luaentity().name) and (obj:get_luaentity().name ~= "__builtin:item") then
|
||||||
if obj:is_player() then
|
if obj:is_player() then
|
||||||
obj:set_hp(obj:get_hp()-damage)
|
obj:set_hp(obj:get_hp()-damage)
|
||||||
elseif obj:get_luaentity().health then
|
elseif obj:get_luaentity().health then
|
||||||
obj:get_luaentity().health = obj:get_luaentity().health - damage
|
obj:get_luaentity().health = obj:get_luaentity().health - damage
|
||||||
minetest.chat_send_all("Vita health: "..obj:get_luaentity().health)
|
--minetest.chat_send_all("Danneggiato: "..obj:get_entity_name().." Vita: "..obj:get_luaentity().health)
|
||||||
check_for_death(obj:get_luaentity())
|
check_for_death(obj:get_luaentity())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user