From 3d7e38ab45f02d52b010668a13ca678f8862b037 Mon Sep 17 00:00:00 2001 From: Juraj Vajda Date: Sun, 21 Mar 2021 14:39:02 -0400 Subject: [PATCH] add settingtypes and disable attached arrows to entitties by default --- README.md | 1 + arrow.lua | 44 +++++++++++++++++++++++++------------------- init.lua | 5 ++++- settingtypes.txt | 2 ++ 4 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 settingtypes.txt diff --git a/README.md b/README.md index 04a15eb..5125aad 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Video: https://youtu.be/pItpltmUoa8 * arrows can be picked up again after stuck in solid nodes * registers only one entity reused for all arrows * (experimental) poison arrow - dealing damage for 5s but will not kill the target +* target block reduces fall damage by -30 ## Dependencies diff --git a/arrow.lua b/arrow.lua index e0c87da..5e61361 100644 --- a/arrow.lua +++ b/arrow.lua @@ -310,7 +310,7 @@ minetest.register_entity('x_bows:arrow_entity', { return end - -- attach arrow + -- attach arrow prepare local rotation = {x = 0, y = 0, z = 0} local position = {x = 0, y = 0, z = 0} @@ -382,24 +382,6 @@ minetest.register_entity('x_bows:arrow_entity', { position.z = zmin / 10 end - self.object:set_attach( - pointed_thing.ref, - '', - position, - rotation, - true - ) - self._attached = true - self._attached_to.type = pointed_thing.type - self._attached_to.pos = position - - local children = pointed_thing.ref:get_children() - - -- remove last arrow when too many already attached - if #children >= 5 then - children[1]:remove() - end - -- poison arrow if self._poison_arrow then local old_damage_texture_modifier = pointed_thing.ref:get_properties().damage_texture_modifier @@ -428,6 +410,30 @@ minetest.register_entity('x_bows:arrow_entity', { end end + if not x_bows.settings.x_bows_attach_arrows_to_entities and not pointed_thing.ref:is_player() then + self.object:remove() + return + end + + -- attach arrow + self.object:set_attach( + pointed_thing.ref, + '', + position, + rotation, + true + ) + self._attached = true + self._attached_to.type = pointed_thing.type + self._attached_to.pos = position + + local children = pointed_thing.ref:get_children() + + -- remove last arrow when too many already attached + if #children >= 5 then + children[1]:remove() + end + return elseif pointed_thing.type == 'node' and not self._attached then diff --git a/init.lua b/init.lua index cda8962..991574c 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,10 @@ x_bows = { hbhunger = minetest.get_modpath('hbhunger'), registered_arrows = {}, registered_bows = {}, - player_bow_sneak = {} + player_bow_sneak = {}, + settings = { + x_bows_attach_arrows_to_entities = minetest.settings:get_bool("x_bows_attach_arrows_to_entities", false) + } } function x_bows.is_creative(name) diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..f4842e4 --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# Disabled per default due to inconsistent mob models scaling (visual_size). This will scale the arrows unproportionally and looks bad. If you have mobs with no scaling you can enable this setting. +x_bows_attach_arrows_to_entities (Attach arrows to entities) bool false