forked from VoxeLibre/VoxeLibre
Remove _thrower from vl_projectile (uses self._vl_projectile.owner instead), reorder some code
This commit is contained in:
parent
ff5aab5d7c
commit
1f7a810497
|
@ -34,6 +34,7 @@ minetest.register_entity("mcl_throwing:ender_pearl_entity",{
|
||||||
get_staticdata = mcl_throwing.get_staticdata,
|
get_staticdata = mcl_throwing.get_staticdata,
|
||||||
on_activate = mcl_throwing.on_activate,
|
on_activate = mcl_throwing.on_activate,
|
||||||
|
|
||||||
|
on_step = vl_projectile.update_projectile,
|
||||||
_lastpos={},
|
_lastpos={},
|
||||||
_thrower = nil, -- Player ObjectRef of the player who threw the ender pearl
|
_thrower = nil, -- Player ObjectRef of the player who threw the ender pearl
|
||||||
_vl_projectile = {
|
_vl_projectile = {
|
||||||
|
@ -127,6 +128,4 @@ minetest.register_entity("mcl_throwing:ender_pearl_entity",{
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
},
|
},
|
||||||
|
|
||||||
on_step = vl_projectile.update_projectile,
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -50,9 +50,10 @@ minetest.register_entity("mcl_throwing:snowball_entity", {
|
||||||
|
|
||||||
get_staticdata = mcl_throwing.get_staticdata,
|
get_staticdata = mcl_throwing.get_staticdata,
|
||||||
on_activate = mcl_throwing.on_activate,
|
on_activate = mcl_throwing.on_activate,
|
||||||
|
|
||||||
|
on_step = vl_projectile.update_projectile,
|
||||||
_thrower = nil,
|
_thrower = nil,
|
||||||
_lastpos = nil,
|
_lastpos = nil,
|
||||||
|
|
||||||
_vl_projectile = {
|
_vl_projectile = {
|
||||||
behaviors = {
|
behaviors = {
|
||||||
vl_projectile.collides_with_solids,
|
vl_projectile.collides_with_solids,
|
||||||
|
@ -74,6 +75,5 @@ minetest.register_entity("mcl_throwing:snowball_entity", {
|
||||||
},
|
},
|
||||||
damage_groups = { snowball_vulnerable = 3 },
|
damage_groups = { snowball_vulnerable = 3 },
|
||||||
},
|
},
|
||||||
on_step = vl_projectile.update_projectile,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ function mod.collides_with_entities(self, dtime, entity_def, projectile_def)
|
||||||
local dmg = projectile_def.damage_groups or 0
|
local dmg = projectile_def.damage_groups or 0
|
||||||
|
|
||||||
local hit = nil
|
local hit = nil
|
||||||
|
local owner = self._vl_projectile.owner
|
||||||
|
|
||||||
local objects = minetest.get_objects_inside_radius(pos, 1.5)
|
local objects = minetest.get_objects_inside_radius(pos, 1.5)
|
||||||
for i = 1,#objects do
|
for i = 1,#objects do
|
||||||
|
@ -116,9 +117,9 @@ function mod.collides_with_entities(self, dtime, entity_def, projectile_def)
|
||||||
local entity = object:get_luaentity()
|
local entity = object:get_luaentity()
|
||||||
|
|
||||||
if entity and entity.name ~= self.object:get_luaentity().name then
|
if entity and entity.name ~= self.object:get_luaentity().name then
|
||||||
if object:is_player() and self._thrower ~= object:get_player_name() then
|
if object:is_player() and owner ~= object:get_player_name() then
|
||||||
return handle_entity_collision(self, entity_def, projectile_def, object)
|
return handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
elseif (entity.is_mob == true or entity._hittable_by_projectile) and (self._thrower ~= object) then
|
elseif (entity.is_mob == true or entity._hittable_by_projectile) and (owner ~= object) then
|
||||||
return handle_entity_collision(self, entity_def, projectile_def, object)
|
return handle_entity_collision(self, entity_def, projectile_def, object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue