Let players shoot themselves with potion arrows

This commit is contained in:
cora 2021-07-11 19:37:01 +02:00 committed by Nils Dagsson Moskopp
parent 6951ecdfc9
commit 8ed5fd4740
No known key found for this signature in database
GPG key ID: A3BC671C35191080

View file

@ -130,6 +130,8 @@ function mcl_potions.register_arrow(name, desc, color, def)
end
ARROW_ENTITY.on_step = function(self, dtime)
self._time_in_air = self._time_in_air + .001
local pos = self.object:get_pos()
local dpos = table.copy(pos) -- digital pos
dpos = vector.round(dpos)
@ -193,10 +195,10 @@ function mcl_potions.register_arrow(name, desc, color, def)
for k, obj in pairs(objs) do
local ok = false
-- Arrows can only damage players and mobs
if obj ~= self._shooter and obj:is_player() then
if obj:is_player() then
ok = true
elseif obj:get_luaentity() ~= nil then
if obj ~= self._shooter and obj:get_luaentity()._cmi_is_mob then
if obj:get_luaentity()._cmi_is_mob then
ok = true
end
end
@ -218,7 +220,7 @@ function mcl_potions.register_arrow(name, desc, color, def)
local obj = closest_object
local is_player = obj:is_player()
local lua = obj:get_luaentity()
if obj ~= self._shooter and (is_player or (lua and lua._cmi_is_mob)) then
if obj == self._shooter and self._time_in_air > 1.02 or obj ~= self._shooter and (is_player or (lua and (lua._cmi_is_mob or lua._hittable_by_projectile))) then
if obj:get_hp() > 0 then
-- Check if there is no solid node between arrow and object
@ -395,6 +397,7 @@ function mcl_potions.register_arrow(name, desc, color, def)
ARROW_ENTITY.on_activate = function(self, staticdata, dtime_s)
local data = minetest.deserialize(staticdata)
self._time_in_air = 1.0
if data then
self._stuck = data.stuck
if data.stuck then