From 5baa1b027570977f2bfc91ce0ebf1d609399572a Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 6 Jul 2020 18:57:00 -0400 Subject: [PATCH] Allow damage to armor players with poison --- mods/ITEMS/mcl_armor/armor.lua | 8 ++++++-- mods/ITEMS/mcl_potions/functions.lua | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_armor/armor.lua b/mods/ITEMS/mcl_armor/armor.lua index 7edd77c2f..d0bce25ed 100644 --- a/mods/ITEMS/mcl_armor/armor.lua +++ b/mods/ITEMS/mcl_armor/armor.lua @@ -192,7 +192,7 @@ end armor.update_armor = function(self, player) -- Legacy support: Called when armor levels are changed - -- Other mods can hook on to this function, see hud mod for example + -- Other mods can hook on to this function, see hud mod for example end armor.get_armor_points = function(self, player) @@ -429,7 +429,7 @@ minetest.register_on_joinplayer(function(player) for i=1, 6 do local stack = player_inv:get_stack("armor", i) armor_inv:set_stack("armor", i, stack) - end + end armor.def[name] = { count = 0, level = 0, @@ -499,6 +499,10 @@ minetest.register_on_player_hpchange(function(player, hp_change, reason) return hp_change end + if reason.other == "poison" then + return hp_change + end + local heal_max = 0 local items = 0 local armor_damage = math.max(1, math.floor(math.abs(hp_change)/4)) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index aae3975de..820da1e72 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -51,7 +51,7 @@ minetest.register_globalstep(function(dtime) 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), { type = "punch", from = "potion" }) + player:set_hp( math.max(player:get_hp() - 1, 1), { type = "punch", other = "poison"}) end is_poisoned[player].hit_timer = 0 @@ -81,7 +81,7 @@ minetest.register_globalstep(function(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)) + 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 end @@ -467,7 +467,7 @@ function mcl_potions.healing_func(player, hp) 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), { type = "set_hp", other = "healing" }) end else @@ -475,7 +475,7 @@ function mcl_potions.healing_func(player, hp) if obj and obj._cmi_is_mob then obj.health = obj.health + hp else - player:set_hp(player:get_hp() + hp, { type = "punch", from = "potion" }) + player:set_hp(player:get_hp() + hp, { type = "punch", other = "harming" }) end end