From 6951ecdfc9fc5310f7fb3a11ce0058cc9a828baf Mon Sep 17 00:00:00 2001 From: epCode Date: Wed, 17 Mar 2021 13:47:02 -0700 Subject: [PATCH] Let players shoot themselves with regular arrows --- mods/ITEMS/mcl_bows/arrow.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 035dd122..6952f594 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -136,6 +136,8 @@ end ARROW_ENTITY.on_step = function(self, dtime) mcl_burning.tick(self.object, 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) @@ -201,10 +203,10 @@ ARROW_ENTITY.on_step = function(self, dtime) 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 or obj:get_luaentity()._hittable_by_projectile) then + if obj:get_luaentity()._cmi_is_mob or obj:get_luaentity()._hittable_by_projectile then ok = true end end @@ -226,7 +228,7 @@ ARROW_ENTITY.on_step = function(self, dtime) 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 or lua._hittable_by_projectile))) 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 local ray = minetest.raycast(self.object:get_pos(), obj:get_pos(), true) @@ -411,6 +413,7 @@ end 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