Skip to content

Commit

Permalink
Make indestructible blocks only deal damage near enemy flags (#1290)
Browse files Browse the repository at this point in the history
* initial update

* commit to make it actually work

* remove whitespaces

* fixed more luacheck stuff

* Update nodes.lua

---------

Co-authored-by: LoneWolfHT <[email protected]>
  • Loading branch information
pl608 and LoneWolfHT authored Jun 4, 2024
1 parent de78d48 commit 7abc3d2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mods/ctf/ctf_map/nodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ local function make_immortal(def)
def.description = def.description and ("Indestructible " .. def.description)
end

minetest.register_on_player_hpchange(function(player, hp_change, reason)
local pos = player:get_pos()
if reason.type == 'node_damage' and minetest.registered_nodes[reason.node].groups.immortal then
for _, flagteam in ipairs(ctf_teams.current_team_list) do
if flagteam ~= ctf_teams.get(player) then
local fdist = vector.distance(pos, ctf_map.current_map.teams[flagteam].flag_pos)
if fdist <= 6 then
return hp_change
end
end
end
end

return 0
end, true)

local queue = {}
for name, def in pairs(minetest.registered_nodes) do
local mod, nodename = name:match"(..-):(.+)"
Expand Down

0 comments on commit 7abc3d2

Please sign in to comment.