forked from VoxeLibre/VoxeLibre
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:
commit
a3e01e6dbe
|
@ -5,6 +5,8 @@
|
|||
|
||||
local S = minetest.get_translator("mobs_mc")
|
||||
|
||||
local mod_target = minetest.get_modpath("mcl_target")
|
||||
|
||||
--###################
|
||||
--################### BLAZE
|
||||
--###################
|
||||
|
@ -178,17 +180,19 @@ 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)
|
||||
if crashnode.name == "air" or
|
||||
(minetest.registered_nodes[crashnode.name].buildable_to and minetest.get_item_group(crashnode.name, "flammable") >= 1) then
|
||||
minetest.set_node(crashpos, {name=mobs_mc.items.fire})
|
||||
minetest.set_node(crashpos, {name = mobs_mc.items.fire})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
|
@ -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.
|
|
@ -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.=
|
|
@ -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 |
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -95,71 +97,74 @@ function mcl_potions.register_lingering(name, descr, color, def)
|
|||
end
|
||||
end
|
||||
minetest.register_craftitem(id, {
|
||||
description = descr,
|
||||
_tt_help = def.tt,
|
||||
_doc_items_longdesc = longdesc,
|
||||
_doc_items_usagehelp = S("Use the “Punch” key to throw it."),
|
||||
inventory_image = lingering_image(color),
|
||||
groups = {brewitem=1, not_in_creative_inventory=0},
|
||||
on_use = function(item, placer, pointed_thing)
|
||||
local velocity = 10
|
||||
local dir = placer:get_look_dir();
|
||||
local pos = placer:getpos();
|
||||
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
|
||||
local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
|
||||
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3})
|
||||
obj:get_luaentity()._thrower = placer:get_player_name()
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
item:take_item()
|
||||
description = descr,
|
||||
_tt_help = def.tt,
|
||||
_doc_items_longdesc = longdesc,
|
||||
_doc_items_usagehelp = S("Use the “Punch” key to throw it."),
|
||||
inventory_image = lingering_image(color),
|
||||
groups = {brewitem=1, not_in_creative_inventory=0},
|
||||
on_use = function(item, placer, pointed_thing)
|
||||
local velocity = 10
|
||||
local dir = placer:get_look_dir();
|
||||
local pos = placer:getpos();
|
||||
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
|
||||
local obj = minetest.add_entity({x=pos.x+dir.x,y=pos.y+2+dir.y,z=pos.z+dir.z}, id.."_flying")
|
||||
obj:setvelocity({x=dir.x*velocity,y=dir.y*velocity,z=dir.z*velocity})
|
||||
obj:setacceleration({x=dir.x*-3, y=-9.8, z=dir.z*-3})
|
||||
obj:get_luaentity()._thrower = placer:get_player_name()
|
||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||
item:take_item()
|
||||
end
|
||||
return item
|
||||
end,
|
||||
stack_max = 1,
|
||||
_on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir)
|
||||
local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51))
|
||||
local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}
|
||||
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
|
||||
local obj = minetest.add_entity(pos, id.."_flying")
|
||||
local velocity = 22
|
||||
obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity})
|
||||
obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3})
|
||||
end
|
||||
return item
|
||||
end,
|
||||
stack_max = 1,
|
||||
_on_dispense = function(stack, dispenserpos, droppos, dropnode, dropdir)
|
||||
local s_pos = vector.add(dispenserpos, vector.multiply(dropdir, 0.51))
|
||||
local pos = {x=s_pos.x+dropdir.x,y=s_pos.y+dropdir.y,z=s_pos.z+dropdir.z}
|
||||
minetest.sound_play("mcl_throwing_throw", {pos = pos, gain = 0.4, max_hear_distance = 16}, true)
|
||||
local obj = minetest.add_entity(pos, id.."_flying")
|
||||
local velocity = 22
|
||||
obj:set_velocity({x=dropdir.x*velocity,y=dropdir.y*velocity,z=dropdir.z*velocity})
|
||||
obj:set_acceleration({x=dropdir.x*-3, y=-9.8, z=dropdir.z*-3})
|
||||
end
|
||||
})
|
||||
})
|
||||
|
||||
local w = 0.7
|
||||
local w = 0.7
|
||||
|
||||
minetest.register_entity(id.."_flying",{
|
||||
textures = {lingering_image(color)},
|
||||
hp_max = 1,
|
||||
visual_size = {x=w/2,y=w/2},
|
||||
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
||||
pointable = false,
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:get_pos()
|
||||
local node = minetest.get_node(pos)
|
||||
local n = node.name
|
||||
local g = minetest.get_item_group(n, "liquid")
|
||||
local d = 4
|
||||
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")
|
||||
local texture
|
||||
if name == "water" then
|
||||
texture = "mcl_particles_droplet_bottle.png"
|
||||
else
|
||||
if def.instant then
|
||||
texture = "mcl_particles_instant_effect.png"
|
||||
minetest.register_entity(id.."_flying",{
|
||||
textures = {lingering_image(color)},
|
||||
hp_max = 1,
|
||||
visual_size = {x=w/2,y=w/2},
|
||||
collisionbox = {-0.1,-0.1,-0.1,0.1,0.1,0.1},
|
||||
pointable = false,
|
||||
on_step = function(self, dtime)
|
||||
local pos = self.object:get_pos()
|
||||
local node = minetest.get_node(pos)
|
||||
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")
|
||||
local texture
|
||||
if name == "water" then
|
||||
texture = "mcl_particles_droplet_bottle.png"
|
||||
else
|
||||
texture = "mcl_particles_effect.png"
|
||||
if def.instant then
|
||||
texture = "mcl_particles_instant_effect.png"
|
||||
else
|
||||
texture = "mcl_particles_effect.png"
|
||||
end
|
||||
end
|
||||
linger_particles(pos, d, texture, color)
|
||||
if name == "water" then
|
||||
mcl_potions._extinguish_nearby_fire(pos, d)
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
linger_particles(pos, d, texture, color)
|
||||
if name == "water" then
|
||||
mcl_potions._extinguish_nearby_fire(pos, d)
|
||||
end
|
||||
self.object:remove()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue