0
0
Fork 0

Get fire resistance working.

This commit is contained in:
Brandon 2020-06-28 16:45:49 -04:00
parent 46dca32ce9
commit 34631dd32e
2 changed files with 60 additions and 1 deletions

View File

@ -7,7 +7,12 @@ local is_water_breathing = {}
local is_leaping = {}
local is_swift = {}
local is_cat = {}
local is_fire_proof = {}
local fire_nodes = {["mcl_core:lava_flowing"]=true,
["mcl_core:lava_source"]=true,
["mcl_fire:eternal_fire"]=true,
["mcl_fire:fire"]=true}
minetest.register_globalstep(function(dtime)
@ -185,8 +190,48 @@ minetest.register_globalstep(function(dtime)
end
-- Check for Fire Proof players
for player, vals in pairs(is_fire_proof) do
if is_fire_proof[player] and player:get_properties() then
player = player or player:get_luaentity()
is_fire_proof[player].timer = is_fire_proof[player].timer + dtime
if player:get_pos() then mcl_potions._add_spawner(player, "#E0B050") end
if is_fire_proof[player].timer >= is_fire_proof[player].dur then
is_fire_proof[player] = nil
end
elseif not player:get_properties() then
is_fire_proof[player] = nil
end
end
end)
minetest.register_on_player_hpchange(function(player, hp_change)
if is_fire_proof[player] and hp_change < 0 then
-- This is a bit forced, but it assumes damage is taken by fire and avoids it
-- also assumes any change in hp happens between calls to this function
local player_info = mcl_playerinfo[player:get_player_name()]
if fire_nodes[player_info.node_head] or fire_nodes[player_info.node_feet] then
return 0
else
return hp_change
end
else
return hp_change
end
end, true)
function mcl_potions._reset_player_effects(player)
player = player or player:get_luaentity()
@ -229,6 +274,10 @@ function mcl_potions._reset_player_effects(player)
is_cat[player] = nil
end
if is_fire_proof[player] then
is_fire_proof[player] = nil
end
end
minetest.register_on_leaveplayer( function(player) mcl_potions._reset_player_effects(player) end)
@ -492,7 +541,17 @@ end
function mcl_potions.fire_resistance_func(player, duration)
if not is_fire_proof[player] then
is_fire_proof[player] = {dur = duration, timer = 0}
else
local victim = is_fire_proof[player]
victim.dur = math.max(duration, victim.dur - victim.timer)
victim.timer = 0
end
end

View File

@ -306,7 +306,7 @@ local awkward_table = {
["mcl_potions:speckled_melon"] = "mcl_potions:healing",
["mcl_farming:carrot_item_gold"] = "mcl_potions:night_vision",
["mcl_core:sugar"] = "mcl_potions:swiftness",
["mcl_mobitems:magma_cream"] = "mcl_potions:fire_resistance", --add craft
["mcl_mobitems:magma_cream"] = "mcl_potions:fire_resistance",
["mcl_mobitems:blaze_powder"] = "mcl_potions:strength", --add craft
["mcl_fishing:pufferfish_raw"] = "mcl_potions:water_breathing",
["mcl_mobitems:ghast_tear"] = "mcl_potions:regeneration",