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
19 changes: 18 additions & 1 deletion mods/ctf/ctf_map/ctf_traps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ for _, team in ipairs(ctf_teams.teamlist) do
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,17 @@ 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
if reason.node_pos then
local meta = minetest.get_meta(reason.node_pos)
local pname = meta:get_string("placer")
if pname ~= "" then
local placer = minetest.get_player_by_name(pname)
if placer then
player:punch(placer, 1, { fleshy = 7, spike = 1})
return 0
end
end
end
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