From 5a7b1cc382f2a5ca5769a4544dd8ed7308f7b86e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 26 Feb 2022 23:52:03 +0100 Subject: [PATCH] make all arrow types activate target (+ depends and code fixes) --- mods/ITEMS/mcl_bows/arrow.lua | 10 ++++++-- mods/ITEMS/mcl_bows/mod.conf | 2 +- mods/ITEMS/mcl_bows/rocket.lua | 32 ++++++++++--------------- mods/ITEMS/mcl_potions/tipped_arrow.lua | 7 ++++++ 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 7529da167f..b82d65ff2d 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + local math = math local vector = vector @@ -117,8 +119,7 @@ function ARROW_ENTITY.on_step(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) + local dpos = vector.round(vector.new(pos)) -- digital pos local node = minetest.get_node(dpos) if self._stuck then @@ -383,6 +384,11 @@ function ARROW_ENTITY.on_step(self, dtime) tnt.ignite(self._stuckin) end + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2) diff --git a/mods/ITEMS/mcl_bows/mod.conf b/mods/ITEMS/mcl_bows/mod.conf index 79ae42436d..e9f025a94d 100644 --- a/mods/ITEMS/mcl_bows/mod.conf +++ b/mods/ITEMS/mcl_bows/mod.conf @@ -1,6 +1,6 @@ name = mcl_bows author = Arcelmi description = This mod adds bows and arrows for MineClone 2. -depends = controls, mcl_particles, mcl_enchanting, mcl_init +depends = controls, mcl_particles, mcl_enchanting, mcl_init, mcl_util optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 678aba4d42..2c1d30dcd4 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -18,20 +18,6 @@ local function dir_to_pitch(dir) return -math.atan2(-dir.y, xz) end -local function random_arrow_positions(positions, placement) - if positions == "x" then - return math.random(-4, 4) - elseif positions == "y" then - return math.random(0, 10) - end - if placement == "front" and positions == "z" then - return 3 - elseif placement == "back" and positions == "z" then - return -3 - end - return 0 -end - local function damage_explosion(self, damagemulitplier) mcl_explosions.explode(self.object:get_pos(), 3, {}) local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8) @@ -49,10 +35,10 @@ end local function particle_explosion(self) local particle_pattern = math.random(1, 3) - local fpitch = 0 - local true_type = "" - local type = math.random(1,2) - local size = math.random(1,3) + local fpitch + --local true_type + local type = math.random(1, 2) + local size = math.random(1, 3) local colors = {"red", "yellow", "blue", "green", "white"} local this_colors = {colors[math.random(#colors)], colors[math.random(#colors)], colors[math.random(#colors)]} @@ -64,11 +50,11 @@ local function particle_explosion(self) fpitch = math.random(60, 70) end - if type == 1 then + --[[if type == 1 then true_type = "Popper" else true_type = "Floof" - end + end]] if type == 1 then minetest.sound_play("mcl_bows_firework", { @@ -243,6 +229,7 @@ end local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_button = minetest.get_modpath("mesecons_button") +local mod_target = minetest.get_modpath("mcl_target") minetest.register_craftitem("mcl_bows:rocket", { description = S("Arrow"), @@ -578,6 +565,11 @@ function ARROW_ENTITY.on_step(self, dtime) tnt.ignite(self._stuckin) end + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 1717533a8f..880dff9562 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -1,5 +1,7 @@ local S = minetest.get_translator(minetest.get_current_modname()) +local mod_target = minetest.get_modpath("mcl_target") + local math = math -- Time in seconds after which a stuck arrow is deleted @@ -342,6 +344,11 @@ function mcl_potions.register_arrow(name, desc, color, def) self.object:set_velocity({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0}) + -- Activate target + if mod_target and snode.name == "mcl_target:target_off" then + mcl_target.hit(self._stuckin, 1) --10 redstone ticks + end + -- Push the button! Push, push, push the button! if mod_button and minetest.get_item_group(node.name, "button") > 0 and minetest.get_item_group(node.name, "button_push_by_arrow") == 1 then local bdir = minetest.wallmounted_to_dir(node.param2)