make all arrow types activate target (+ depends and code fixes)

This commit is contained in:
AFCMS 2022-02-26 23:52:03 +01:00
parent 210a0d8ee1
commit 5a7b1cc382
Signed by untrusted user: AFCMS
GPG Key ID: 8720389A25B652E3
4 changed files with 28 additions and 23 deletions

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local mod_target = minetest.get_modpath("mcl_target")
local math = math local math = math
local vector = vector local vector = vector
@ -117,8 +119,7 @@ function ARROW_ENTITY.on_step(self, dtime)
self._time_in_air = self._time_in_air + .001 self._time_in_air = self._time_in_air + .001
local pos = self.object:get_pos() local pos = self.object:get_pos()
local dpos = table.copy(pos) -- digital pos local dpos = vector.round(vector.new(pos)) -- digital pos
dpos = vector.round(dpos)
local node = minetest.get_node(dpos) local node = minetest.get_node(dpos)
if self._stuck then if self._stuck then
@ -383,6 +384,11 @@ function ARROW_ENTITY.on_step(self, dtime)
tnt.ignite(self._stuckin) tnt.ignite(self._stuckin)
end 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! -- 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 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) local bdir = minetest.wallmounted_to_dir(node.param2)

View File

@ -1,6 +1,6 @@
name = mcl_bows name = mcl_bows
author = Arcelmi author = Arcelmi
description = This mod adds bows and arrows for MineClone 2. 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 optional_depends = awards, mcl_achievements, mcl_core, mcl_mobitems, playerphysics, doc, doc_identifier, mesecons_button

View File

@ -18,20 +18,6 @@ local function dir_to_pitch(dir)
return -math.atan2(-dir.y, xz) return -math.atan2(-dir.y, xz)
end 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) local function damage_explosion(self, damagemulitplier)
mcl_explosions.explode(self.object:get_pos(), 3, {}) mcl_explosions.explode(self.object:get_pos(), 3, {})
local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8) local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8)
@ -49,8 +35,8 @@ end
local function particle_explosion(self) local function particle_explosion(self)
local particle_pattern = math.random(1, 3) local particle_pattern = math.random(1, 3)
local fpitch = 0 local fpitch
local true_type = "" --local true_type
local type = math.random(1, 2) local type = math.random(1, 2)
local size = math.random(1, 3) local size = math.random(1, 3)
local colors = {"red", "yellow", "blue", "green", "white"} local colors = {"red", "yellow", "blue", "green", "white"}
@ -64,11 +50,11 @@ local function particle_explosion(self)
fpitch = math.random(60, 70) fpitch = math.random(60, 70)
end end
if type == 1 then --[[if type == 1 then
true_type = "Popper" true_type = "Popper"
else else
true_type = "Floof" true_type = "Floof"
end end]]
if type == 1 then if type == 1 then
minetest.sound_play("mcl_bows_firework", { 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_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
local mod_button = minetest.get_modpath("mesecons_button") local mod_button = minetest.get_modpath("mesecons_button")
local mod_target = minetest.get_modpath("mcl_target")
minetest.register_craftitem("mcl_bows:rocket", { minetest.register_craftitem("mcl_bows:rocket", {
description = S("Arrow"), description = S("Arrow"),
@ -578,6 +565,11 @@ function ARROW_ENTITY.on_step(self, dtime)
tnt.ignite(self._stuckin) tnt.ignite(self._stuckin)
end 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! -- 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 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) local bdir = minetest.wallmounted_to_dir(node.param2)

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local mod_target = minetest.get_modpath("mcl_target")
local math = math local math = math
-- Time in seconds after which a stuck arrow is deleted -- 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_velocity({x=0, y=0, z=0})
self.object:set_acceleration({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! -- 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 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) local bdir = minetest.wallmounted_to_dir(node.param2)