1
0
Fork 0

Merge pull request 'Add Target' (#2033) from AFCMS/MineClone2:target into master

Reviewed-on: MineClone2/MineClone2#2033
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-02-27 17:25:16 +00:00
commit a3e01e6dbe
16 changed files with 206 additions and 90 deletions

View File

@ -5,6 +5,8 @@
local S = minetest.get_translator("mobs_mc")
local mod_target = minetest.get_modpath("mcl_target")
--###################
--################### BLAZE
--###################
@ -178,11 +180,13 @@ mobs:register_arrow("mobs_mc:blaze_fireball", {
-- Node hit, make fire
hit_node = function(self, pos, node)
if node.name == "air" then
minetest.set_node(pos_above, {name=mobs_mc.items.fire})
if node == "air" then
minetest.set_node(pos, {name = mobs_mc.items.fire})
else
local v = self.object:get_velocity()
v = vector.normalize(v)
if self._shot_from_dispenser and mod_target and node == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
local v = vector.normalize(self.object:get_velocity())
local crashpos = vector.subtract(pos, v)
local crashnode = minetest.get_node(crashpos)
-- Set fire if node is air, or a replacable flammable node (e.g. a plant)

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname())
local mod_target = minetest.get_modpath("mcl_target")
minetest.register_entity("mcl_experience:bottle",{
textures = {"mcl_experience_bottle.png"},
hp_max = 1,
@ -30,6 +32,9 @@ minetest.register_entity("mcl_experience:bottle",{
vertical = false,
texture = "mcl_particles_effect.png^[colorize:blue:127",
})
if mod_target and n == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
self.object:remove()
end
end,

View File

@ -0,0 +1,70 @@
local S = minetest.get_translator("mcl_target")
local mod_farming = minetest.get_modpath("mcl_farming")
mcl_target = {}
function mcl_target.hit(pos, time)
minetest.set_node(pos, {name="mcl_target:target_on"})
mesecon.receptor_on(pos, mesecon.rules.alldirs)
local timer = minetest.get_node_timer(pos)
timer:start(time)
end
minetest.register_node("mcl_target:target_off", {
description = S("Target"),
_doc_items_longdesc = S("A target is a block that provides a temporary redstone charge when hit by a projectile."),
_doc_items_usagehelp = S("Throw a projectile on the target to activate it."),
tiles = {"mcl_target_target_top.png", "mcl_target_target_top.png", "mcl_target_target_side.png"},
groups = {hoey = 1},
sounds = mcl_sounds.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.1},
}),
mesecons = {
receptor = {
state = mesecon.state.off,
rules = mesecon.rules.alldirs,
},
},
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
})
minetest.register_node("mcl_target:target_on", {
description = S("Target"),
_doc_items_create_entry = false,
tiles = {"mcl_target_target_top.png", "mcl_target_target_top.png", "mcl_target_target_side.png"},
groups = {hoey = 1, not_in_creative_inventory = 1},
drop = "mcl_target:target_off",
sounds = mcl_sounds.node_sound_dirt_defaults({
footstep = {name="default_grass_footstep", gain=0.1},
}),
on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
if node.name == "mcl_target:target_on" then --has not been dug
minetest.set_node(pos, {name="mcl_target:target_off"})
mesecon.receptor_off(pos, mesecon.rules.alldirs)
end
end,
mesecons = {
receptor = {
state = mesecon.state.on,
rules = mesecon.rules.alldirs,
},
},
_mcl_blast_resistance = 0.5,
_mcl_hardness = 0.5,
})
if mod_farming then
minetest.register_craft({
output = "mcl_target:target_off",
recipe = {
{"", "mesecons:redstone", ""},
{"mesecons:redstone", "mcl_farming:hay_block", "mesecons:redstone"},
{"", "mesecons:redstone", ""},
},
})
end

View File

@ -0,0 +1,4 @@
# textdomain: mcl_target
Target=Cible
A target is a block that provides a temporary redstone charge when hit by a projectile.=La cible est un bloc qui se comporte comme une source d'énergie temporaire quand elle est frappée par un projectile.
Throw a projectile on the target to activate it.=Lancer un projectile sur la cible pour l'activer.

View File

@ -0,0 +1,4 @@
# textdomain: mcl_target
Target=
A target is a block that provides a temporary redstone charge when hit by a projectile.=
Throw a projectile on the target to activate it.=

View File

@ -0,0 +1,3 @@
name = mcl_target
author = AFCMS
depends = mesecons, mcl_sounds

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

View File

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

View File

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

View File

@ -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,8 +35,8 @@ end
local function particle_explosion(self)
local particle_pattern = math.random(1, 3)
local fpitch = 0
local true_type = ""
local fpitch
--local true_type
local type = math.random(1, 2)
local size = math.random(1, 3)
local colors = {"red", "yellow", "blue", "green", "white"}
@ -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)

View File

@ -1,5 +1,7 @@
local S = minetest.get_translator(minetest.get_current_modname())
local mod_target = minetest.get_modpath("mcl_target")
local function lingering_image(colorstring, opacity)
if not opacity then
opacity = 127
@ -141,6 +143,9 @@ minetest.register_entity(id.."_flying",{
local n = node.name
local g = minetest.get_item_group(n, "liquid")
local d = 4
if mod_target and n == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
add_lingering_effect(pos, color, def, name == "water")

View File

@ -1,6 +1,8 @@
local S = minetest.get_translator(minetest.get_current_modname())
local GRAVITY = tonumber(minetest.settings:get("movement_gravity"))
local mod_target = minetest.get_modpath("mcl_target")
local function splash_image(colorstring, opacity)
if not opacity then
opacity = 127
@ -66,6 +68,9 @@ function mcl_potions.register_splash(name, descr, color, def)
local g = minetest.get_item_group(n, "liquid")
local d = 0.1
local redux_map = {7/8,0.5,0.25}
if mod_target and n == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" and g == 0 or mcl_potions.is_obj_hit(self, pos) then
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
local texture, acc

View File

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

View File

@ -1,3 +1,3 @@
name = mcl_throwing
depends = mcl_colors
optional_depends = mcl_core, mcl_mobitems, doc
optional_depends = mcl_core, mcl_mobitems, doc, mcl_target

View File

@ -3,6 +3,8 @@ local S = minetest.get_translator(minetest.get_current_modname())
local math = math
local vector = vector
local mod_target = minetest.get_modpath("mcl_target")
-- The snowball entity
local snowball_ENTITY={
physical = false,
@ -111,6 +113,9 @@ local function snowball_on_step(self, dtime)
minetest.sound_play("mcl_throwing_snowball_impact_hard", { pos = pos, max_hear_distance=16, gain=0.7 }, true)
snowball_particles(self._lastpos, vel)
self.object:remove()
if mod_target and node.name == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
return
end
end
@ -172,6 +177,9 @@ local function egg_on_step(self, dtime)
end
minetest.sound_play("mcl_throwing_egg_impact", { pos = self.object:get_pos(), max_hear_distance=10, gain=0.5 }, true)
self.object:remove()
if mod_target and node.name == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
return
end
end
@ -276,6 +284,9 @@ local function pearl_on_step(self, dtime)
end
self.object:remove()
if mod_target and node.name == "mcl_target:target_off" then
mcl_target.hit(vector.round(pos), 0.4) --4 redstone ticks
end
return
end
end