0
0
Fork 0

Update to reset player_physics on log out or death. Fix mobs die with potions.

This commit is contained in:
Brandon 2020-06-25 19:21:16 -04:00
parent fceffa6f1c
commit 1d5a04acb3
1 changed files with 33 additions and 3 deletions

View File

@ -46,8 +46,15 @@ minetest.register_globalstep(function(dtime)
if player:get_pos() then mcl_potions._add_spawner(player, "#225533") end if player:get_pos() then mcl_potions._add_spawner(player, "#225533") end
if is_poisoned[player].hit_timer >= is_poisoned[player].step then if is_poisoned[player].hit_timer >= is_poisoned[player].step then
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) ) player:set_hp( math.max(player:get_hp() - 1, 1) )
end
is_poisoned[player].hit_timer = 0 is_poisoned[player].hit_timer = 0
end end
if is_poisoned[player].timer >= is_poisoned[player].dur then if is_poisoned[player].timer >= is_poisoned[player].dur then
@ -210,10 +217,12 @@ local function _reset_player_effects(player)
if is_leaping[player] then if is_leaping[player] then
is_leaping[player] = nil is_leaping[player] = nil
playerphysics.remove_physics_factor(player, "jump", "mcl_potions:leaping")
end end
if is_swift[player] then if is_swift[player] then
is_swift[player] = nil is_swift[player] = nil
playerphysics.remove_physics_factor(player, "speed", "mcl_potions:swiftness")
end end
if is_cat[player] then if is_cat[player] then
@ -312,16 +321,37 @@ end
function mcl_potions.healing_func(player, hp) function mcl_potions.healing_func(player, hp)
obj = player:get_luaentity()
if is_zombie[player:get_entity_name()] then hp = -hp end if is_zombie[player:get_entity_name()] then hp = -hp end
if hp > 0 then if hp > 0 then
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)) player:set_hp(math.min(player:get_hp() + hp, player:get_properties().hp_max))
end
else
if obj and obj._cmi_is_mob then
obj.health = obj.health + hp
else else
player:set_hp(player:get_hp() + hp) player:set_hp(player:get_hp() + hp)
end end
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
end
end
function mcl_potions.swiftness_func(player, factor, duration) function mcl_potions.swiftness_func(player, factor, duration)
if not player:get_meta() then return false end if not player:get_meta() then return false end