add settingtypes and disable attached arrows to entitties by default

This commit is contained in:
Juraj Vajda 2021-03-21 14:39:02 -04:00
parent 7090f5cf0b
commit 3d7e38ab45
4 changed files with 32 additions and 20 deletions

View File

@ -23,6 +23,7 @@ Video: https://youtu.be/pItpltmUoa8
* arrows can be picked up again after stuck in solid nodes * arrows can be picked up again after stuck in solid nodes
* registers only one entity reused for all arrows * registers only one entity reused for all arrows
* (experimental) poison arrow - dealing damage for 5s but will not kill the target * (experimental) poison arrow - dealing damage for 5s but will not kill the target
* target block reduces fall damage by -30
## Dependencies ## Dependencies

View File

@ -310,7 +310,7 @@ minetest.register_entity('x_bows:arrow_entity', {
return return
end end
-- attach arrow -- attach arrow prepare
local rotation = {x = 0, y = 0, z = 0} local rotation = {x = 0, y = 0, z = 0}
local position = {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 position.z = zmin / 10
end 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 -- poison arrow
if self._poison_arrow then if self._poison_arrow then
local old_damage_texture_modifier = pointed_thing.ref:get_properties().damage_texture_modifier 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
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 return
elseif pointed_thing.type == 'node' and not self._attached then elseif pointed_thing.type == 'node' and not self._attached then

View File

@ -8,7 +8,10 @@ x_bows = {
hbhunger = minetest.get_modpath('hbhunger'), hbhunger = minetest.get_modpath('hbhunger'),
registered_arrows = {}, registered_arrows = {},
registered_bows = {}, 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) function x_bows.is_creative(name)

2
settingtypes.txt Normal file
View File

@ -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