Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making spikes have perks for the placer #1135

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
29 changes: 26 additions & 3 deletions mods/ctf/ctf_map/ctf_traps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ minetest.register_node("ctf_map:spike", {
paramtype2 = "meshoptions",
sunlight_propagates = true,
walkable = false,
damage_per_second = 7,
damage_per_second = 5,
LoneWolfHT marked this conversation as resolved.
Show resolved Hide resolved
groups = {cracky=1, level=2},
selection_box = {
type = "fixed",
Expand Down Expand Up @@ -80,15 +80,21 @@ for _, team in ipairs(ctf_teams.teamlist) do
paramtype2 = "meshoptions",
sunlight_propagates = true,
walkable = false,
damage_per_second = 7,
damage_per_second = 5,
groups = {cracky=1, level=2},
drop = "ctf_map:spike",
selection_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5},
},
on_place = function(itemstack, placer, pointed_thing)
return minetest.item_place(itemstack, placer, pointed_thing, 34)
local item, pos = minetest.item_place(itemstack, placer, pointed_thing, 34)
local meta = minetest.get_meta(pos)
local pname = placer:get_player_name()
if pname ~= "" then
meta:set_string("placer", pname)
end
return item, pos
end
})
end
Expand All @@ -100,6 +106,23 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason)
if team and reason.node == string.format("ctf_map:spike_%s", team) then
return 0, true
end
local damaged = false
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
minetest.chat_send_all(minetest.serialize(reason))
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
if reason.node_pos then
local meta = minetest.get_meta(reason.node_pos)
local pname = meta:get_string("placer")
minetest.chat_send_all(pname)
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
if pname ~= "" then
local placer = minetest.get_player_by_name(pname)
if placer then
player:punch(placer, 10, { fleshy = 5, spike = 1})
damaged = true
farooqkz marked this conversation as resolved.
Show resolved Hide resolved
end
end
end
if not damaged then
hp_change = hp_change - 5
end
LoneWolfHT marked this conversation as resolved.
Show resolved Hide resolved
end

return hp_change
Expand Down
1 change: 1 addition & 0 deletions mods/ctf/ctf_modebase/features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local damage_group_textures = {
knockback_grenade = "ctf_mode_nade_fight_knockback_grenade.png",
black_hole_grenade = "ctf_mode_nade_fight_black_hole_grenade.png",
damage_cobble = "ctf_map_damage_cobble.png",
spike = "ctf_map_spike.png",
}

local function get_weapon_image(hitter, tool_capabilities)
Expand Down