pvp refactor

master
Juraj Vajda 2018-10-16 22:01:41 -04:00
parent 347c963516
commit 58cb3adc78
1 changed files with 8 additions and 30 deletions

View File

@ -167,20 +167,10 @@ minetest.register_entity("basic_machines:ball",{
local hp = obj:get_hp()
local newhp = hp-self.hurt;
local player_pos = obj:get_pos()
-- jail time
if minetest.global_exists("city_block") then
city_block.register_on_punchplayer(
obj, -- player
minetest.get_player_by_name(self.owner), --hitter
nil, -- time_from_last_punch
nil, -- tool_capabilities
nil, -- dir
self.hurt -- damage
)
end
-- pvp block
if minetest.global_exists("pvp_block") then
if pvp_block:in_area(player_pos) then
pvp_block.register_on_punchplayer(
obj, -- player
minetest.get_player_by_name(self.owner), --hitter
@ -191,23 +181,10 @@ minetest.register_entity("basic_machines:ball",{
)
end
-- spawnnokill
if minetest.global_exists("defaultx") then
local do_damage = defaultx.register_on_punchplayer(
obj, -- player
minetest.get_player_by_name(self.owner), --hitter
nil, -- time_from_last_punch
nil, -- tool_capabilities
nil, -- dir
self.hurt -- damage i.e. {fleshy = 8}
)
if do_damage then
return
end
end
obj:set_hp(newhp)
obj:punch(self.object, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=self.hurt},
}, nil)
else -- non player
local lua_entity = obj:get_luaentity();
if lua_entity and lua_entity.itemstring then
@ -682,7 +659,8 @@ minetest.register_tool("basic_machines:ball_spell", {
obj:set_properties({textures={meta["texture"]}})
itemstack:take_item()
return itemstack
end,