mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 18:41:09 +01:00
Add additional gamerules for damage types
This commit is contained in:
parent
45bdc892f2
commit
95cb4b7bb5
1 changed files with 16 additions and 1 deletions
|
@ -37,6 +37,15 @@ mcl_damage = {
|
||||||
local damage_enabled = vl_tuning.setting("damage_enabled", "bool",{
|
local damage_enabled = vl_tuning.setting("damage_enabled", "bool",{
|
||||||
default = minetest.settings:get_bool("enabled_damage",true)
|
default = minetest.settings:get_bool("enabled_damage",true)
|
||||||
})
|
})
|
||||||
|
local fall_damage_enabled = vl_tuning.setting("gamerule:fallDamage", "bool", {
|
||||||
|
default = true
|
||||||
|
})
|
||||||
|
local drowning_damage_enabled = vl_tuning.setting("gamerule:drowningDamage", "bool", {
|
||||||
|
default = true
|
||||||
|
})
|
||||||
|
local fire_damage_enabled = vl_tuning.setting("gamerule:fireDamage", "bool", {
|
||||||
|
default = true
|
||||||
|
})
|
||||||
|
|
||||||
function mcl_damage.register_modifier(func, priority)
|
function mcl_damage.register_modifier(func, priority)
|
||||||
table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0})
|
table.insert(mcl_damage.modifiers, {func = func, priority = priority or 0})
|
||||||
|
@ -155,10 +164,16 @@ minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
||||||
end, true)
|
end, true)
|
||||||
|
|
||||||
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
minetest.register_on_player_hpchange(function(player, hp_change, mt_reason)
|
||||||
|
-- Check if damage is enabled
|
||||||
if not damage_enabled[1] then return 0 end
|
if not damage_enabled[1] then return 0 end
|
||||||
|
local mcl_reason = mcl_damage.from_mt(mt_reason)
|
||||||
|
if not fire_damage_enabled[1] and mcl_reason.type == "fire" then return 0 end
|
||||||
|
if not drowning_damage_enabled[1] and mcl_reason.type == "drown" then return 0 end
|
||||||
|
if not fall_damage_enabled[1] and mcl_reason.type == "fall" then return 0 end
|
||||||
|
|
||||||
if player:get_hp() > 0 then
|
if player:get_hp() > 0 then
|
||||||
if hp_change < 0 then
|
if hp_change < 0 then
|
||||||
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_damage.from_mt(mt_reason))
|
mcl_damage.run_damage_callbacks(player, -hp_change, mcl_reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end, false)
|
end, false)
|
||||||
|
|
Loading…
Reference in a new issue