Add status effect icons
@ -1,22 +1,30 @@
|
||||
local is_invisible = {}
|
||||
local is_poisoned = {}
|
||||
local is_regenerating = {}
|
||||
local is_strong = {}
|
||||
local is_weak = {}
|
||||
local is_water_breathing = {}
|
||||
local is_leaping = {}
|
||||
local is_swift = {}
|
||||
local is_cat = {}
|
||||
local is_fire_proof = {}
|
||||
local EF = {}
|
||||
EF.invisible = {}
|
||||
EF.poisoned = {}
|
||||
EF.regenerating = {}
|
||||
EF.strong = {}
|
||||
EF.weak = {}
|
||||
EF.water_breathing = {}
|
||||
EF.leaping = {}
|
||||
EF.swift = {} -- for swiftness AND slowness
|
||||
EF.night_vision = {}
|
||||
EF.fire_proof = {}
|
||||
|
||||
local EFFECT_TYPES = 0
|
||||
for _,_ in pairs(EF) do
|
||||
EFFECT_TYPES = EFFECT_TYPES + 1
|
||||
end
|
||||
|
||||
local icon_ids = {}
|
||||
local icon_types = {}
|
||||
|
||||
local function potions_set_hudbar(player)
|
||||
|
||||
if is_poisoned[player] and is_regenerating[player] then
|
||||
if EF.poisoned[player] and EF.regenerating[player] then
|
||||
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png")
|
||||
elseif is_poisoned[player] then
|
||||
elseif EF.poisoned[player] then
|
||||
hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png")
|
||||
elseif is_regenerating[player] then
|
||||
elseif EF.regenerating[player] then
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png")
|
||||
else
|
||||
hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png")
|
||||
@ -24,6 +32,61 @@ local function potions_set_hudbar(player)
|
||||
|
||||
end
|
||||
|
||||
local function potions_init_icons(player)
|
||||
local name = player:get_player_name()
|
||||
icon_ids[name] = {}
|
||||
icon_types[name] = {}
|
||||
for e=1, EFFECT_TYPES do
|
||||
local x = -48 * e
|
||||
local id = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
text = "blank.png",
|
||||
position = { x = 1, y = 0 },
|
||||
offset = { x = x, y = 256+32 },
|
||||
scale = { x = 2, y = 2 },
|
||||
alignment = { x = 1, y = 1 },
|
||||
z_index = 100,
|
||||
})
|
||||
table.insert(icon_ids[name], id)
|
||||
end
|
||||
end
|
||||
|
||||
local function potions_set_icons(player)
|
||||
local name = player:get_player_name()
|
||||
if not icon_ids[name] then
|
||||
return
|
||||
end
|
||||
local active_effects = {}
|
||||
for effect_name, effect in pairs(EF) do
|
||||
if effect[player] then
|
||||
table.insert(active_effects, effect_name)
|
||||
end
|
||||
end
|
||||
|
||||
for i=1, EFFECT_TYPES do
|
||||
local icon = icon_ids[name][i]
|
||||
local itype = icon_types[name][i]
|
||||
local effect_name = active_effects[i]
|
||||
if effect_name == "swift" and EF.swift[player].is_slow then
|
||||
effect_name = "slow"
|
||||
end
|
||||
if effect_name == nil then
|
||||
icon_types[name][i] = nil
|
||||
player:hud_change(icon, "text", "blank.png")
|
||||
elseif effect_name ~= itype then
|
||||
icon_types[name][i] = effect_name
|
||||
player:hud_change(icon, "text", "mcl_potions_effect_"..effect_name..".png")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function potions_set_hud(player)
|
||||
|
||||
potions_set_hudbar(player)
|
||||
potions_set_icons(player)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- ███╗░░░███╗░█████╗░██╗███╗░░██╗ ███████╗███████╗███████╗███████╗░█████╗░████████╗
|
||||
@ -45,101 +108,101 @@ local is_player, entity, meta
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
-- Check for invisible players
|
||||
for player, vals in pairs(is_invisible) do
|
||||
for player, vals in pairs(EF.invisible) do
|
||||
|
||||
is_invisible[player].timer = is_invisible[player].timer + dtime
|
||||
EF.invisible[player].timer = EF.invisible[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#B0B0B0") end
|
||||
|
||||
if is_invisible[player].timer >= is_invisible[player].dur then
|
||||
if EF.invisible[player].timer >= EF.invisible[player].dur then
|
||||
mcl_potions.make_invisible(player, false)
|
||||
is_invisible[player] = nil
|
||||
EF.invisible[player] = nil
|
||||
if player:is_player() then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_invisible", minetest.serialize(is_invisible[player]))
|
||||
meta:set_string("_is_invisible", minetest.serialize(EF.invisible[player]))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for poisoned players
|
||||
for player, vals in pairs(is_poisoned) do
|
||||
for player, vals in pairs(EF.poisoned) do
|
||||
|
||||
is_player = player:is_player()
|
||||
entity = player:get_luaentity()
|
||||
|
||||
is_poisoned[player].timer = is_poisoned[player].timer + dtime
|
||||
is_poisoned[player].hit_timer = (is_poisoned[player].hit_timer or 0) + dtime
|
||||
EF.poisoned[player].timer = EF.poisoned[player].timer + dtime
|
||||
EF.poisoned[player].hit_timer = (EF.poisoned[player].hit_timer or 0) + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#225533") end
|
||||
|
||||
if is_poisoned[player].hit_timer >= is_poisoned[player].step then
|
||||
if EF.poisoned[player].hit_timer >= EF.poisoned[player].step then
|
||||
|
||||
if entity and entity._cmi_is_mob then
|
||||
entity.health = math.max(entity.health - 1, 1)
|
||||
is_poisoned[player].hit_timer = 0
|
||||
EF.poisoned[player].hit_timer = 0
|
||||
elseif is_player then
|
||||
player:set_hp( math.max(player:get_hp() - 1, 1), { type = "punch", other = "poison"})
|
||||
is_poisoned[player].hit_timer = 0
|
||||
EF.poisoned[player].hit_timer = 0
|
||||
else -- if not player or mob then remove
|
||||
is_poisoned[player] = nil
|
||||
EF.poisoned[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if is_poisoned[player] and is_poisoned[player].timer >= is_poisoned[player].dur then
|
||||
is_poisoned[player] = nil
|
||||
if EF.poisoned[player] and EF.poisoned[player].timer >= EF.poisoned[player].dur then
|
||||
EF.poisoned[player] = nil
|
||||
if is_player then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_poisoned", minetest.serialize(is_poisoned[player]))
|
||||
potions_set_hudbar(player)
|
||||
meta:set_string("_is_poisoned", minetest.serialize(EF.poisoned[player]))
|
||||
potions_set_hud(player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for regnerating players
|
||||
for player, vals in pairs(is_regenerating) do
|
||||
for player, vals in pairs(EF.regenerating) do
|
||||
|
||||
is_player = player:is_player()
|
||||
entity = player:get_luaentity()
|
||||
|
||||
is_regenerating[player].timer = is_regenerating[player].timer + dtime
|
||||
is_regenerating[player].heal_timer = (is_regenerating[player].heal_timer or 0) + dtime
|
||||
EF.regenerating[player].timer = EF.regenerating[player].timer + dtime
|
||||
EF.regenerating[player].heal_timer = (EF.regenerating[player].heal_timer or 0) + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#A52BB2") end
|
||||
|
||||
if is_regenerating[player].heal_timer >= is_regenerating[player].step then
|
||||
if EF.regenerating[player].heal_timer >= EF.regenerating[player].step then
|
||||
|
||||
if is_player then
|
||||
player:set_hp(math.min(player:get_properties().hp_max or 20, player:get_hp() + 1), { type = "set_hp", other = "regeneration" })
|
||||
is_regenerating[player].heal_timer = 0
|
||||
EF.regenerating[player].heal_timer = 0
|
||||
elseif entity and entity._cmi_is_mob then
|
||||
entity.health = math.min(entity.hp_max, entity.health + 1)
|
||||
is_regenerating[player].heal_timer = 0
|
||||
EF.regenerating[player].heal_timer = 0
|
||||
else -- stop regenerating if not a player or mob
|
||||
is_regenerating[player] = nil
|
||||
EF.regenerating[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if is_regenerating[player] and is_regenerating[player].timer >= is_regenerating[player].dur then
|
||||
is_regenerating[player] = nil
|
||||
if EF.regenerating[player] and EF.regenerating[player].timer >= EF.regenerating[player].dur then
|
||||
EF.regenerating[player] = nil
|
||||
if is_player then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_regenerating", minetest.serialize(is_regenerating[player]))
|
||||
potions_set_hudbar(player)
|
||||
meta:set_string("_is_regenerating", minetest.serialize(EF.regenerating[player]))
|
||||
potions_set_hud(player)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for water breathing players
|
||||
for player, vals in pairs(is_water_breathing) do
|
||||
for player, vals in pairs(EF.water_breathing) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_water_breathing[player].timer = is_water_breathing[player].timer + dtime
|
||||
EF.water_breathing[player].timer = EF.water_breathing[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#0000AA") end
|
||||
|
||||
@ -147,146 +210,146 @@ minetest.register_globalstep(function(dtime)
|
||||
if player:get_breath() < 10 then player:set_breath(10) end
|
||||
end
|
||||
|
||||
if is_water_breathing[player].timer >= is_water_breathing[player].dur then
|
||||
if EF.water_breathing[player].timer >= EF.water_breathing[player].dur then
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_water_breathing", minetest.serialize(is_water_breathing[player]))
|
||||
is_water_breathing[player] = nil
|
||||
meta:set_string("_is_water_breathing", minetest.serialize(EF.water_breathing[player]))
|
||||
EF.water_breathing[player] = nil
|
||||
end
|
||||
|
||||
else
|
||||
is_water_breathing[player] = nil
|
||||
EF.water_breathing[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for leaping players
|
||||
for player, vals in pairs(is_leaping) do
|
||||
for player, vals in pairs(EF.leaping) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_leaping[player].timer = is_leaping[player].timer + dtime
|
||||
EF.leaping[player].timer = EF.leaping[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#00CC33") end
|
||||
|
||||
if is_leaping[player].timer >= is_leaping[player].dur then
|
||||
if EF.leaping[player].timer >= EF.leaping[player].dur then
|
||||
playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
|
||||
is_leaping[player] = nil
|
||||
EF.leaping[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_leaping", minetest.serialize(is_leaping[player]))
|
||||
meta:set_string("_is_leaping", minetest.serialize(EF.leaping[player]))
|
||||
end
|
||||
|
||||
else
|
||||
is_leaping[player] = nil
|
||||
EF.leaping[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for swift players
|
||||
for player, vals in pairs(is_swift) do
|
||||
for player, vals in pairs(EF.swift) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_swift[player].timer = is_swift[player].timer + dtime
|
||||
EF.swift[player].timer = EF.swift[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#009999") end
|
||||
|
||||
if is_swift[player].timer >= is_swift[player].dur then
|
||||
if EF.swift[player].timer >= EF.swift[player].dur then
|
||||
playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
|
||||
is_swift[player] = nil
|
||||
EF.swift[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_swift", minetest.serialize(is_swift[player]))
|
||||
meta:set_string("_is_swift", minetest.serialize(EF.swift[player]))
|
||||
end
|
||||
|
||||
else
|
||||
is_swift[player] = nil
|
||||
EF.swift[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for Night Vision equipped players
|
||||
for player, vals in pairs(is_cat) do
|
||||
for player, vals in pairs(EF.night_vision) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_cat[player].timer = is_cat[player].timer + dtime
|
||||
EF.night_vision[player].timer = EF.night_vision[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#1010AA") end
|
||||
|
||||
if is_cat[player].timer >= is_cat[player].dur then
|
||||
is_cat[player] = nil
|
||||
if EF.night_vision[player].timer >= EF.night_vision[player].dur then
|
||||
EF.night_vision[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_cat", minetest.serialize(is_cat[player]))
|
||||
meta:set_string("_is_cat", minetest.serialize(EF.night_vision[player]))
|
||||
meta:set_int("night_vision", 0)
|
||||
end
|
||||
mcl_weather.skycolor.update_sky_color({player})
|
||||
|
||||
else
|
||||
is_cat[player] = nil
|
||||
EF.night_vision[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for Fire Proof players
|
||||
for player, vals in pairs(is_fire_proof) do
|
||||
for player, vals in pairs(EF.fire_proof) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
player = player or player:get_luaentity()
|
||||
|
||||
is_fire_proof[player].timer = is_fire_proof[player].timer + dtime
|
||||
EF.fire_proof[player].timer = EF.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
|
||||
if EF.fire_proof[player].timer >= EF.fire_proof[player].dur then
|
||||
EF.fire_proof[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_fire_proof", minetest.serialize(is_fire_proof[player]))
|
||||
meta:set_string("_is_fire_proof", minetest.serialize(EF.fire_proof[player]))
|
||||
end
|
||||
|
||||
else
|
||||
is_fire_proof[player] = nil
|
||||
EF.fire_proof[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for Weak players
|
||||
for player, vals in pairs(is_weak) do
|
||||
for player, vals in pairs(EF.weak) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_weak[player].timer = is_weak[player].timer + dtime
|
||||
EF.weak[player].timer = EF.weak[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#7700BB") end
|
||||
|
||||
if is_weak[player].timer >= is_weak[player].dur then
|
||||
is_weak[player] = nil
|
||||
if EF.weak[player].timer >= EF.weak[player].dur then
|
||||
EF.weak[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_weak", minetest.serialize(is_weak[player]))
|
||||
meta:set_string("_is_weak", minetest.serialize(EF.weak[player]))
|
||||
end
|
||||
|
||||
else
|
||||
is_weak[player] = nil
|
||||
EF.weak[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Check for Strong players
|
||||
for player, vals in pairs(is_strong) do
|
||||
for player, vals in pairs(EF.strong) do
|
||||
|
||||
if player:is_player() then
|
||||
|
||||
is_strong[player].timer = is_strong[player].timer + dtime
|
||||
EF.strong[player].timer = EF.strong[player].timer + dtime
|
||||
|
||||
if player:get_pos() then mcl_potions._add_spawner(player, "#7700BB") end
|
||||
|
||||
if is_strong[player].timer >= is_strong[player].dur then
|
||||
is_strong[player] = nil
|
||||
if EF.strong[player].timer >= EF.strong[player].dur then
|
||||
EF.strong[player] = nil
|
||||
meta = player:get_meta()
|
||||
meta:set_string("_is_strong", minetest.serialize(is_strong[player]))
|
||||
meta:set_string("_is_strong", minetest.serialize(EF.strong[player]))
|
||||
end
|
||||
|
||||
else
|
||||
is_strong[player] = nil
|
||||
EF.strong[player] = nil
|
||||
end
|
||||
|
||||
end
|
||||
@ -307,7 +370,7 @@ local is_fire_node = { ["mcl_core:lava_flowing"]=true,
|
||||
-- Prevent damage to player with Fire Resistance enabled
|
||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||
|
||||
if is_fire_proof[player] and hp_change < 0 then
|
||||
if EF.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
|
||||
-- it's worth noting that you don't take damage from players in this case...
|
||||
@ -350,26 +413,26 @@ function mcl_potions._reset_player_effects(player)
|
||||
meta = player:get_meta()
|
||||
|
||||
mcl_potions.make_invisible(player, false)
|
||||
is_invisible[player] = nil
|
||||
is_poisoned[player] = nil
|
||||
is_regenerating[player] = nil
|
||||
is_strong[player] = nil
|
||||
is_weak[player] = nil
|
||||
is_water_breathing[player] = nil
|
||||
EF.invisible[player] = nil
|
||||
EF.poisoned[player] = nil
|
||||
EF.regenerating[player] = nil
|
||||
EF.strong[player] = nil
|
||||
EF.weak[player] = nil
|
||||
EF.water_breathing[player] = nil
|
||||
|
||||
is_leaping[player] = nil
|
||||
EF.leaping[player] = nil
|
||||
playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
|
||||
|
||||
is_swift[player] = nil
|
||||
EF.swift[player] = nil
|
||||
playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
|
||||
|
||||
is_cat[player] = nil
|
||||
EF.night_vision[player] = nil
|
||||
meta:set_int("night_vision", 0)
|
||||
mcl_weather.skycolor.update_sky_color({player})
|
||||
|
||||
is_fire_proof[player] = nil
|
||||
EF.fire_proof[player] = nil
|
||||
|
||||
potions_set_hudbar(player)
|
||||
potions_set_hud(player)
|
||||
|
||||
end
|
||||
|
||||
@ -380,16 +443,16 @@ function mcl_potions._save_player_effects(player)
|
||||
end
|
||||
meta = player:get_meta()
|
||||
|
||||
meta:set_string("_is_invisible", minetest.serialize(is_invisible[player]))
|
||||
meta:set_string("_is_poisoned", minetest.serialize(is_poisoned[player]))
|
||||
meta:set_string("_is_regenerating", minetest.serialize(is_regenerating[player]))
|
||||
meta:set_string("_is_strong", minetest.serialize(is_strong[player]))
|
||||
meta:set_string("_is_weak", minetest.serialize(is_weak[player]))
|
||||
meta:set_string("_is_water_breathing", minetest.serialize(is_water_breathing[player]))
|
||||
meta:set_string("_is_leaping", minetest.serialize(is_leaping[player]))
|
||||
meta:set_string("_is_swift", minetest.serialize(is_swift[player]))
|
||||
meta:set_string("_is_cat", minetest.serialize(is_cat[player]))
|
||||
meta:set_string("_is_fire_proof", minetest.serialize(is_fire_proof[player]))
|
||||
meta:set_string("_is_invisible", minetest.serialize(EF.invisible[player]))
|
||||
meta:set_string("_is_poisoned", minetest.serialize(EF.poisoned[player]))
|
||||
meta:set_string("_is_regenerating", minetest.serialize(EF.regenerating[player]))
|
||||
meta:set_string("_is_strong", minetest.serialize(EF.strong[player]))
|
||||
meta:set_string("_is_weak", minetest.serialize(EF.weak[player]))
|
||||
meta:set_string("_is_water_breathing", minetest.serialize(EF.water_breathing[player]))
|
||||
meta:set_string("_is_leaping", minetest.serialize(EF.leaping[player]))
|
||||
meta:set_string("_is_swift", minetest.serialize(EF.swift[player]))
|
||||
meta:set_string("_is_cat", minetest.serialize(EF.night_vision[player]))
|
||||
meta:set_string("_is_fire_proof", minetest.serialize(EF.fire_proof[player]))
|
||||
|
||||
end
|
||||
|
||||
@ -401,53 +464,58 @@ function mcl_potions._load_player_effects(player)
|
||||
meta = player:get_meta()
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_invisible")) then
|
||||
is_invisible[player] = minetest.deserialize(meta:get_string("_is_invisible"))
|
||||
EF.invisible[player] = minetest.deserialize(meta:get_string("_is_invisible"))
|
||||
mcl_potions.make_invisible(player, true)
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_poisoned")) then
|
||||
is_poisoned[player] = minetest.deserialize(meta:get_string("_is_poisoned"))
|
||||
EF.poisoned[player] = minetest.deserialize(meta:get_string("_is_poisoned"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_regenerating")) then
|
||||
is_regenerating[player] = minetest.deserialize(meta:get_string("_is_regenerating"))
|
||||
EF.regenerating[player] = minetest.deserialize(meta:get_string("_is_regenerating"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_strong")) then
|
||||
is_strong[player] = minetest.deserialize(meta:get_string("_is_strong"))
|
||||
EF.strong[player] = minetest.deserialize(meta:get_string("_is_strong"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_weak")) then
|
||||
is_weak[player] = minetest.deserialize(meta:get_string("_is_weak"))
|
||||
EF.weak[player] = minetest.deserialize(meta:get_string("_is_weak"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_water_breathing")) then
|
||||
is_water_breathing[player] = minetest.deserialize(meta:get_string("_is_water_breathing"))
|
||||
EF.water_breathing[player] = minetest.deserialize(meta:get_string("_is_water_breathing"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_leaping")) then
|
||||
is_leaping[player] = minetest.deserialize(meta:get_string("_is_leaping"))
|
||||
EF.leaping[player] = minetest.deserialize(meta:get_string("_is_leaping"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_swift")) then
|
||||
is_swift[player] = minetest.deserialize(meta:get_string("_is_swift"))
|
||||
EF.swift[player] = minetest.deserialize(meta:get_string("_is_swift"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_cat")) then
|
||||
is_cat[player] = minetest.deserialize(meta:get_string("_is_cat"))
|
||||
EF.night_vision[player] = minetest.deserialize(meta:get_string("_is_cat"))
|
||||
end
|
||||
|
||||
if minetest.deserialize(meta:get_string("_is_fire_proof")) then
|
||||
is_fire_proof[player] = minetest.deserialize(meta:get_string("_is_fire_proof"))
|
||||
EF.fire_proof[player] = minetest.deserialize(meta:get_string("_is_fire_proof"))
|
||||
end
|
||||
|
||||
potions_set_hudbar(player)
|
||||
minetest.after(1, function(player_ref)
|
||||
if player_ref and player_ref:is_player() then
|
||||
potions_set_hud(player_ref)
|
||||
end
|
||||
end, player)
|
||||
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer( function(player)
|
||||
mcl_potions._save_player_effects(player)
|
||||
mcl_potions._reset_player_effects(player) -- clearout the buffer to prevent looking for a player not there
|
||||
icon_ids[player:get_player_name()] = nil
|
||||
icon_types[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
minetest.register_on_dieplayer( function(player)
|
||||
@ -455,6 +523,7 @@ minetest.register_on_dieplayer( function(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer( function(player)
|
||||
potions_init_icons(player)
|
||||
mcl_potions._reset_player_effects(player) -- make sure there are no wierd holdover effects
|
||||
mcl_potions._load_player_effects(player)
|
||||
end)
|
||||
@ -516,9 +585,9 @@ function mcl_potions.make_invisible(player, toggle)
|
||||
if toggle then -- hide player
|
||||
|
||||
if player:is_player() then
|
||||
is_invisible[player].old_size = player:get_properties().visual_size
|
||||
EF.invisible[player].old_size = player:get_properties().visual_size
|
||||
elseif entity then
|
||||
is_invisible[player].old_size = entity.visual_size
|
||||
EF.invisible[player].old_size = entity.visual_size
|
||||
else -- if not a player or entity, do nothing
|
||||
return
|
||||
end
|
||||
@ -526,9 +595,9 @@ function mcl_potions.make_invisible(player, toggle)
|
||||
player:set_properties({visual_size = {x = 0, y = 0}})
|
||||
player:set_nametag_attributes({color = {a = 0}})
|
||||
|
||||
elseif is_invisible[player] then -- show player
|
||||
elseif EF.invisible[player] then -- show player
|
||||
|
||||
player:set_properties({visual_size = is_invisible[player].old_size})
|
||||
player:set_properties({visual_size = EF.invisible[player].old_size})
|
||||
player:set_nametag_attributes({color = {r = 255, g = 255, b = 255, a = 255}})
|
||||
|
||||
end
|
||||
@ -645,21 +714,26 @@ function mcl_potions.swiftness_func(player, factor, duration)
|
||||
return false
|
||||
end
|
||||
|
||||
if not is_swift[player] then
|
||||
if not EF.swift[player] then
|
||||
|
||||
is_swift[player] = {dur = duration, timer = 0}
|
||||
EF.swift[player] = {dur = duration, timer = 0, is_slow = factor < 1}
|
||||
playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
|
||||
|
||||
else
|
||||
|
||||
local victim = is_swift[player]
|
||||
local victim = EF.swift[player]
|
||||
|
||||
playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
victim.is_slow = factor < 1
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function mcl_potions.leaping_func(player, factor, duration)
|
||||
@ -668,14 +742,14 @@ function mcl_potions.leaping_func(player, factor, duration)
|
||||
return false
|
||||
end
|
||||
|
||||
if not is_leaping[player] then
|
||||
if not EF.leaping[player] then
|
||||
|
||||
is_leaping[player] = {dur = duration, timer = 0}
|
||||
EF.leaping[player] = {dur = duration, timer = 0}
|
||||
playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
|
||||
|
||||
else
|
||||
|
||||
local victim = is_leaping[player]
|
||||
local victim = EF.leaping[player]
|
||||
|
||||
playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
@ -683,18 +757,22 @@ function mcl_potions.leaping_func(player, factor, duration)
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.weakness_func(player, factor, duration)
|
||||
|
||||
if not is_weak[player] then
|
||||
if not EF.weak[player] then
|
||||
|
||||
is_weak[player] = {dur = duration, timer = 0, factor = factor}
|
||||
EF.weak[player] = {dur = duration, timer = 0, factor = factor}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_weak[player]
|
||||
local victim = EF.weak[player]
|
||||
|
||||
victim.factor = factor
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
@ -702,18 +780,22 @@ function mcl_potions.weakness_func(player, factor, duration)
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.strength_func(player, factor, duration)
|
||||
|
||||
if not is_strong[player] then
|
||||
if not EF.strong[player] then
|
||||
|
||||
is_strong[player] = {dur = duration, timer = 0, factor = factor}
|
||||
EF.strong[player] = {dur = duration, timer = 0, factor = factor}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_strong[player]
|
||||
local victim = EF.strong[player]
|
||||
|
||||
victim.factor = factor
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
@ -721,18 +803,22 @@ function mcl_potions.strength_func(player, factor, duration)
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.poison_func(player, factor, duration)
|
||||
|
||||
if not is_poisoned[player] then
|
||||
if not EF.poisoned[player] then
|
||||
|
||||
is_poisoned[player] = {step = factor, dur = duration, timer = 0}
|
||||
EF.poisoned[player] = {step = factor, dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_poisoned[player]
|
||||
local victim = EF.poisoned[player]
|
||||
|
||||
victim.step = math.min(victim.step, factor)
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
@ -741,7 +827,7 @@ function mcl_potions.poison_func(player, factor, duration)
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_hudbar(player)
|
||||
potions_set_hud(player)
|
||||
end
|
||||
|
||||
end
|
||||
@ -749,13 +835,13 @@ end
|
||||
|
||||
function mcl_potions.regeneration_func(player, factor, duration)
|
||||
|
||||
if not is_regenerating[player] then
|
||||
if not EF.regenerating[player] then
|
||||
|
||||
is_regenerating[player] = {step = factor, dur = duration, timer = 0}
|
||||
EF.regenerating[player] = {step = factor, dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_regenerating[player]
|
||||
local victim = EF.regenerating[player]
|
||||
|
||||
victim.step = math.min(victim.step, factor)
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
@ -764,7 +850,7 @@ function mcl_potions.regeneration_func(player, factor, duration)
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_hudbar(player)
|
||||
potions_set_hud(player)
|
||||
end
|
||||
|
||||
end
|
||||
@ -772,67 +858,79 @@ end
|
||||
|
||||
function mcl_potions.invisiblility_func(player, null, duration)
|
||||
|
||||
if not is_invisible[player] then
|
||||
if not EF.invisible[player] then
|
||||
|
||||
is_invisible[player] = {dur = duration, timer = 0}
|
||||
EF.invisible[player] = {dur = duration, timer = 0}
|
||||
mcl_potions.make_invisible(player, true)
|
||||
|
||||
else
|
||||
|
||||
local victim = is_invisible[player]
|
||||
local victim = EF.invisible[player]
|
||||
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function mcl_potions.water_breathing_func(player, null, duration)
|
||||
|
||||
if not is_water_breathing[player] then
|
||||
if not EF.water_breathing[player] then
|
||||
|
||||
is_water_breathing[player] = {dur = duration, timer = 0}
|
||||
EF.water_breathing[player] = {dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_water_breathing[player]
|
||||
local victim = EF.water_breathing[player]
|
||||
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.fire_resistance_func(player, null, duration)
|
||||
|
||||
if not is_fire_proof[player] then
|
||||
if not EF.fire_proof[player] then
|
||||
|
||||
is_fire_proof[player] = {dur = duration, timer = 0}
|
||||
EF.fire_proof[player] = {dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_fire_proof[player]
|
||||
local victim = EF.fire_proof[player]
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
|
||||
end
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function mcl_potions.night_vision_func(player, null, duration)
|
||||
|
||||
meta = player:get_meta()
|
||||
if not is_cat[player] then
|
||||
if not EF.night_vision[player] then
|
||||
|
||||
is_cat[player] = {dur = duration, timer = 0}
|
||||
EF.night_vision[player] = {dur = duration, timer = 0}
|
||||
|
||||
else
|
||||
|
||||
local victim = is_cat[player]
|
||||
local victim = EF.night_vision[player]
|
||||
|
||||
victim.dur = math.max(duration, victim.dur - victim.timer)
|
||||
victim.timer = 0
|
||||
@ -847,6 +945,10 @@ function mcl_potions.night_vision_func(player, null, duration)
|
||||
end
|
||||
mcl_weather.skycolor.update_sky_color({player})
|
||||
|
||||
if player:is_player() then
|
||||
potions_set_icons(player)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function mcl_potions._extinguish_nearby_fire(pos, radius)
|
||||
|
After Width: | Height: | Size: 215 B |
After Width: | Height: | Size: 239 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_invisible.png
Normal file
After Width: | Height: | Size: 233 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_leaping.png
Normal file
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 221 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_poisoned.png
Normal file
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 230 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_slow.png
Normal file
After Width: | Height: | Size: 226 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_strong.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_swift.png
Normal file
After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 239 B |
BIN
mods/ITEMS/mcl_potions/textures/mcl_potions_effect_weak.png
Normal file
After Width: | Height: | Size: 235 B |