2020-06-20 20:30:35 +03:00
|
|
|
local is_invisible = {}
|
|
|
|
local is_poisoned = {}
|
|
|
|
local is_regenerating = {}
|
|
|
|
local is_strong = {}
|
|
|
|
local is_weak = {}
|
2020-06-20 22:50:58 +03:00
|
|
|
local is_water_breathing = {}
|
|
|
|
local is_leaping = {}
|
|
|
|
local is_swift = {}
|
2020-06-21 04:30:26 +03:00
|
|
|
local is_cat = {}
|
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
|
|
|
|
minetest.register_globalstep(function(dtime)
|
|
|
|
|
|
|
|
-- Check for invisible players
|
2020-06-20 22:50:58 +03:00
|
|
|
for player, vals in pairs(is_invisible) do
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_invisible[player] and player:get_properties() then
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
is_invisible[player].timer = is_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
|
|
|
|
mcl_potions.make_invisible(player, false)
|
|
|
|
is_invisible[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_invisible[player] = nil
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for poisoned players
|
2020-06-20 22:50:58 +03:00
|
|
|
for player, vals in pairs(is_poisoned) do
|
2020-06-20 20:30:35 +03:00
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_poisoned[player] and player:get_properties() then
|
2020-06-20 20:30:35 +03:00
|
|
|
|
|
|
|
player = player or 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
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if player:get_pos() then mcl_potions._add_spawner(player, "#225533") end
|
2020-06-20 20:30:35 +03:00
|
|
|
|
|
|
|
if is_poisoned[player].hit_timer >= is_poisoned[player].step then
|
2020-06-26 02:21:16 +03:00
|
|
|
|
|
|
|
if player._cmi_is_mob then
|
|
|
|
player.health = math.max(player.health - 1, 1)
|
|
|
|
else
|
|
|
|
player:set_hp( math.max(player:get_hp() - 1, 1) )
|
|
|
|
end
|
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
is_poisoned[player].hit_timer = 0
|
2020-06-26 02:21:16 +03:00
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
2020-06-13 02:54:45 +03:00
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
if is_poisoned[player].timer >= is_poisoned[player].dur then
|
|
|
|
is_poisoned[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_poisoned[player] = nil
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for regnerating players
|
|
|
|
for player, vals in pairs(is_regenerating) do
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_regenerating[player] and player:get_properties() then
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
player = player or 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
|
|
|
|
|
|
|
|
if player:get_pos() then mcl_potions._add_spawner(player, "#A52BB2") end
|
|
|
|
|
|
|
|
if is_regenerating[player].heal_timer >= is_regenerating[player].step then
|
|
|
|
player:set_hp(math.min(player:get_properties().hp_max or 20, player:get_hp() + 1))
|
|
|
|
is_regenerating[player].heal_timer = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
if is_regenerating[player].timer >= is_regenerating[player].dur then
|
|
|
|
is_regenerating[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_regenerating[player] = nil
|
2020-06-20 22:50:58 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for water breathing players
|
|
|
|
for player, vals in pairs(is_water_breathing) do
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_water_breathing[player] and player:get_properties() then
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
is_water_breathing[player].timer = is_water_breathing[player].timer + dtime
|
|
|
|
|
|
|
|
if player:get_pos() then mcl_potions._add_spawner(player, "#0000AA") end
|
|
|
|
|
|
|
|
if player:get_breath() then
|
|
|
|
if player:get_breath() < 10 then player:set_breath(10) end
|
|
|
|
end
|
|
|
|
|
|
|
|
if is_water_breathing[player].timer >= is_water_breathing[player].dur then
|
|
|
|
is_water_breathing[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_water_breathing[player] = nil
|
2020-06-20 22:50:58 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for leaping players
|
|
|
|
for player, vals in pairs(is_leaping) do
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_leaping[player] and player:get_properties() then
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
is_leaping[player].timer = is_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
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
|
2020-06-20 22:50:58 +03:00
|
|
|
is_leaping[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_leaping[player] = nil
|
2020-06-20 22:50:58 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Check for swift players
|
|
|
|
for player, vals in pairs(is_swift) do
|
|
|
|
|
2020-06-21 01:11:35 +03:00
|
|
|
if is_swift[player] and player:get_properties() then
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
is_swift[player].timer = is_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
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
|
2020-06-20 22:50:58 +03:00
|
|
|
is_swift[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-21 04:00:57 +03:00
|
|
|
elseif not player:get_properties() then
|
2020-06-21 01:11:35 +03:00
|
|
|
is_swift[player] = nil
|
2020-06-20 22:50:58 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
|
|
|
|
2020-06-21 04:30:26 +03:00
|
|
|
-- Check for Night Vision equipped players
|
|
|
|
for player, vals in pairs(is_cat) do
|
|
|
|
|
|
|
|
if is_cat[player] and player:get_properties() then
|
|
|
|
|
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
is_cat[player].timer = is_cat[player].timer + dtime
|
|
|
|
|
|
|
|
if player:get_pos() then mcl_potions._add_spawner(player, "#1010AA") end
|
|
|
|
player:override_day_night_ratio(0.45)
|
|
|
|
|
|
|
|
if is_cat[player].timer >= is_cat[player].dur then
|
|
|
|
is_cat[player] = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif not player:get_properties() then
|
|
|
|
is_cat[player] = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-24 04:36:55 +03:00
|
|
|
end)
|
2020-06-20 20:30:35 +03:00
|
|
|
|
2020-06-24 04:36:55 +03:00
|
|
|
local function _reset_player_effects(player)
|
2020-06-13 02:54:45 +03:00
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
player = player or player:get_luaentity()
|
|
|
|
|
|
|
|
if is_invisible[player] then
|
|
|
|
is_invisible[player] = nil
|
|
|
|
end
|
2020-06-20 03:22:32 +03:00
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if is_poisoned[player] then
|
|
|
|
is_poisoned[player] = nil
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if is_regenerating[player] then
|
|
|
|
is_regenerating[player] = nil
|
2020-06-20 03:22:32 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if is_strong[player] then
|
|
|
|
is_strong[player] = nil
|
2020-06-20 17:16:00 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if is_weak[player] then
|
|
|
|
is_weak[player] = nil
|
2020-06-20 17:16:00 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
if is_water_breathing[player] then
|
|
|
|
is_water_breathing[player] = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
if is_leaping[player] then
|
|
|
|
is_leaping[player] = nil
|
2020-06-26 02:21:16 +03:00
|
|
|
playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
|
2020-06-20 22:50:58 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if is_swift[player] then
|
|
|
|
is_swift[player] = nil
|
2020-06-26 02:21:16 +03:00
|
|
|
playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
|
2020-06-20 20:30:35 +03:00
|
|
|
end
|
2020-06-20 17:16:00 +03:00
|
|
|
|
2020-06-21 04:30:26 +03:00
|
|
|
if is_cat[player] then
|
|
|
|
is_cat[player] = nil
|
|
|
|
end
|
|
|
|
|
2020-06-24 04:36:55 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_on_leaveplayer( function(player) _reset_player_effects(player) end)
|
|
|
|
|
|
|
|
minetest.register_on_dieplayer( function(player) _reset_player_effects(player) end)
|
2020-06-13 02:54:45 +03:00
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
function mcl_potions.make_invisible(player, toggle)
|
2020-06-13 02:54:45 +03:00
|
|
|
|
|
|
|
if not player then return false end
|
|
|
|
|
|
|
|
if toggle then -- hide player
|
2020-06-20 22:50:58 +03:00
|
|
|
is_invisible[player].old_size = player:get_properties().visual_size
|
2020-06-13 02:54:45 +03:00
|
|
|
player:set_properties({visual_size = {x = 0, y = 0}})
|
|
|
|
player:set_nametag_attributes({color = {a = 0}})
|
|
|
|
else -- show player
|
2020-06-20 22:50:58 +03:00
|
|
|
player:set_properties({visual_size = is_invisible[player].old_size})
|
2020-06-13 02:54:45 +03:00
|
|
|
player:set_nametag_attributes({color = {a = 255}})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-20 03:22:32 +03:00
|
|
|
function mcl_potions.poison(player, toggle)
|
|
|
|
|
|
|
|
if not player then return false end
|
2020-06-20 20:30:35 +03:00
|
|
|
is_poisoned[player:get_player_name()] = toggle
|
2020-06-20 03:22:32 +03:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-20 17:16:00 +03:00
|
|
|
function mcl_potions.regenerate(player, toggle)
|
|
|
|
|
|
|
|
if not player then return false end
|
2020-06-20 20:30:35 +03:00
|
|
|
is_regenerating[player:get_player_name()] = toggle
|
2020-06-20 17:16:00 +03:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-20 16:00:53 +03:00
|
|
|
function mcl_potions._use_potion(item, obj, color)
|
2020-06-19 04:04:31 +03:00
|
|
|
local d = 0.1
|
2020-06-20 16:00:53 +03:00
|
|
|
local pos = obj:get_pos()
|
2020-06-21 15:39:08 +03:00
|
|
|
minetest.sound_play("mcl_potions_drinking", {pos = pos, max_hear_distance = 6, gain = 1})
|
2020-06-19 04:04:31 +03:00
|
|
|
minetest.add_particlespawner({
|
2020-06-20 16:00:53 +03:00
|
|
|
amount = 25,
|
|
|
|
time = 1,
|
|
|
|
minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d},
|
|
|
|
maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d},
|
|
|
|
minvel = {x=-0.1, y=0, z=-0.1},
|
|
|
|
maxvel = {x=0.1, y=0.1, z=0.1},
|
|
|
|
minacc = {x=-0.1, y=0, z=-0.1},
|
|
|
|
maxacc = {x=0.1, y=.1, z=0.1},
|
|
|
|
minexptime = 1,
|
|
|
|
maxexptime = 5,
|
|
|
|
minsize = 0.5,
|
|
|
|
maxsize = 1,
|
|
|
|
collisiondetection = true,
|
|
|
|
vertical = false,
|
|
|
|
texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
|
|
|
|
})
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 16:00:53 +03:00
|
|
|
|
|
|
|
function mcl_potions._add_spawner(obj, color)
|
|
|
|
local d = 0.2
|
|
|
|
local pos = obj:get_pos()
|
|
|
|
minetest.add_particlespawner({
|
2020-06-20 20:30:35 +03:00
|
|
|
amount = 2,
|
2020-06-20 16:00:53 +03:00
|
|
|
time = 1,
|
|
|
|
minpos = {x=pos.x-d, y=pos.y+1, z=pos.z-d},
|
|
|
|
maxpos = {x=pos.x+d, y=pos.y+2, z=pos.z+d},
|
|
|
|
minvel = {x=-0.1, y=0, z=-0.1},
|
|
|
|
maxvel = {x=0.1, y=0.1, z=0.1},
|
|
|
|
minacc = {x=-0.1, y=0, z=-0.1},
|
|
|
|
maxacc = {x=0.1, y=.1, z=0.1},
|
|
|
|
minexptime = 0.5,
|
|
|
|
maxexptime = 1,
|
|
|
|
minsize = 0.5,
|
|
|
|
maxsize = 1,
|
|
|
|
collisiondetection = false,
|
|
|
|
vertical = false,
|
|
|
|
texture = "mcl_potions_sprite.png^[colorize:"..color..":127",
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-06-18 23:56:19 +03:00
|
|
|
local is_zombie = {}
|
|
|
|
|
|
|
|
for i, zombie in ipairs({"husk","zombie","pigman"}) do
|
|
|
|
is_zombie["mobs_mc:"..zombie] = true
|
|
|
|
is_zombie["mobs_mc:baby_"..zombie] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function mcl_potions.healing_func(player, hp)
|
2020-06-19 00:17:56 +03:00
|
|
|
|
2020-06-26 02:21:16 +03:00
|
|
|
obj = player:get_luaentity()
|
|
|
|
|
2020-06-18 23:56:19 +03:00
|
|
|
if is_zombie[player:get_entity_name()] then hp = -hp end
|
2020-06-20 03:22:32 +03:00
|
|
|
|
2020-06-19 00:17:56 +03:00
|
|
|
if hp > 0 then
|
2020-06-26 02:21:16 +03:00
|
|
|
|
|
|
|
if obj and obj._cmi_is_mob then
|
|
|
|
obj.health = math.max(obj.health + hp, obj.hp_max)
|
|
|
|
else
|
|
|
|
player:set_hp(math.min(player:get_hp() + hp, player:get_properties().hp_max))
|
|
|
|
end
|
|
|
|
|
2020-06-19 00:17:56 +03:00
|
|
|
else
|
2020-06-26 02:21:16 +03:00
|
|
|
|
|
|
|
if obj and obj._cmi_is_mob then
|
|
|
|
obj.health = obj.health + hp
|
|
|
|
else
|
|
|
|
player:set_hp(player:get_hp() + hp)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
-- adjust mob health
|
|
|
|
obj = player:get_luaentity()
|
|
|
|
if obj and obj._cmi_is_mob then
|
|
|
|
print("working "..obj.health)
|
|
|
|
obj.health = obj.health + hp
|
2020-06-19 00:17:56 +03:00
|
|
|
end
|
2020-06-18 23:56:19 +03:00
|
|
|
|
|
|
|
end
|
2020-06-13 02:54:45 +03:00
|
|
|
|
|
|
|
function mcl_potions.swiftness_func(player, factor, duration)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-19 03:22:44 +03:00
|
|
|
if not player:get_meta() then return false end
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
if not is_swift[player] then
|
|
|
|
|
|
|
|
is_swift[player] = {dur = duration, timer = 0}
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_swift[player]
|
|
|
|
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.add_physics_factor(player, "speed", "mcl_potions:swiftness", factor)
|
2020-06-20 22:50:58 +03:00
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
2020-06-20 16:00:53 +03:00
|
|
|
end
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function mcl_potions.leaping_func(player, factor, duration)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
if not player:get_meta() then return false end
|
|
|
|
|
|
|
|
if not is_leaping[player] then
|
|
|
|
|
|
|
|
is_leaping[player] = {dur = duration, timer = 0}
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_leaping[player]
|
|
|
|
|
2020-06-24 04:36:55 +03:00
|
|
|
playerphysics.add_physics_factor(player, "jump", "mcl_potions:leaping", factor)
|
2020-06-20 22:50:58 +03:00
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
2020-06-20 16:00:53 +03:00
|
|
|
end
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
function mcl_potions.weakness_func(player, factor, duration)
|
|
|
|
player:set_attribute("weakness", tostring(factor))
|
2020-06-19 03:22:44 +03:00
|
|
|
-- print(player:get_player_name().." ".."weakness = "..player:get_attribute("weakness"))
|
2020-06-13 02:54:45 +03:00
|
|
|
minetest.after(duration, function() player:set_attribute("weakness", tostring(0)) end )
|
2020-06-20 16:00:53 +03:00
|
|
|
for i=1,math.floor(duration) do
|
|
|
|
minetest.after(i, function() mcl_potions._add_spawner(player, "#6600AA") end)
|
|
|
|
end
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
function mcl_potions.poison_func(player, factor, duration)
|
2020-06-20 03:22:32 +03:00
|
|
|
|
2020-06-20 20:30:35 +03:00
|
|
|
if not is_poisoned[player] then
|
|
|
|
|
|
|
|
is_poisoned[player] = {step = factor, dur = duration, timer = 0}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_poisoned[player]
|
|
|
|
|
|
|
|
victim.step = math.min(victim.step, factor)
|
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
2020-06-19 03:08:00 +03:00
|
|
|
end
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-20 22:50:58 +03:00
|
|
|
|
2020-06-19 03:08:00 +03:00
|
|
|
function mcl_potions.regeneration_func(player, factor, duration)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
if not is_regenerating[player] then
|
|
|
|
|
|
|
|
is_regenerating[player] = {step = factor, dur = duration, timer = 0}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_regenerating[player]
|
|
|
|
|
|
|
|
victim.step = math.min(victim.step, factor)
|
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
2020-06-20 16:00:53 +03:00
|
|
|
end
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
|
|
|
|
2020-06-19 03:08:00 +03:00
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
function mcl_potions.invisiblility_func(player, duration)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
if not is_invisible[player] then
|
|
|
|
|
|
|
|
is_invisible[player] = {dur = duration, timer = 0}
|
|
|
|
mcl_potions.make_invisible(player, true)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_invisible[player]
|
|
|
|
|
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-13 02:54:45 +03:00
|
|
|
end
|
2020-06-19 00:59:36 +03:00
|
|
|
|
|
|
|
function mcl_potions.water_breathing_func(player, duration)
|
2020-06-20 22:50:58 +03:00
|
|
|
|
|
|
|
if not is_water_breathing[player] then
|
|
|
|
|
|
|
|
is_water_breathing[player] = {dur = duration, timer = 0}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_water_breathing[player]
|
|
|
|
|
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
2020-06-20 16:00:53 +03:00
|
|
|
|
2020-06-19 00:59:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2020-06-21 04:00:57 +03:00
|
|
|
|
|
|
|
|
|
|
|
function mcl_potions.fire_resistance_func(player, duration)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
2020-06-21 04:17:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
function mcl_potions.night_vision_func(player, duration)
|
2020-06-21 04:30:26 +03:00
|
|
|
|
|
|
|
if not is_cat[player] then
|
|
|
|
|
|
|
|
is_cat[player] = {dur = duration, timer = 0}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
local victim = is_cat[player]
|
|
|
|
|
|
|
|
victim.dur = math.max(duration, victim.dur - victim.timer)
|
|
|
|
victim.timer = 0
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-06-21 04:17:45 +03:00
|
|
|
end
|