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
25 changes: 23 additions & 2 deletions mods/ctf/ctf_map/ctf_traps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ minetest.register_node("ctf_map:spike", {
local pteam = ctf_teams.get(placer)

if pteam then
local pname = placer:get_player_name()

if not ctf_core.pos_inside(pointed_thing.above, ctf_teams.get_team_territory(pteam)) then
minetest.chat_send_player(placer:get_player_name(), "You can only place spikes in your own territory!")
minetest.chat_send_player(pname, "You can only place spikes in your own territory!")
return itemstack
end

Expand All @@ -57,6 +59,8 @@ minetest.register_node("ctf_map:spike", {
local result = minetest.item_place(newitemstack, placer, pointed_thing, 34)

if result then
minetest.get_meta(pointed_thing.above):set_string("placer", pname)

itemstack:set_count(result:get_count())
end

Expand Down Expand Up @@ -88,7 +92,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)

if item then
minetest.get_meta(pointed_thing.above):set_string("placer", placer:get_player_name())
end

return item, pos
end
})
end
Expand All @@ -100,6 +110,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, {damage_groups = {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