From 229fdc067f7d62a808a95359c66b8b9ba46f459e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 21 May 2017 05:27:33 +0200 Subject: [PATCH] Exhaust for attacking/getting attacked by mobs --- mods/ENTITIES/mobs/api.lua | 11 +++++++++++ mods/ENTITIES/mobs/depends.txt | 1 + 2 files changed, 12 insertions(+) diff --git a/mods/ENTITIES/mobs/api.lua b/mods/ENTITIES/mobs/api.lua index bf8d4559..a9c290e7 100644 --- a/mods/ENTITIES/mobs/api.lua +++ b/mods/ENTITIES/mobs/api.lua @@ -577,6 +577,7 @@ local function entity_physics(pos, radius) if objs[n]:is_player() then objs[n]:set_hp(objs[n]:get_hp() - damage) + mcl_hunger.exhaust(objs[n]:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) else --if ent.health then @@ -1693,6 +1694,7 @@ local do_states = function(self, dtime) full_punch_interval = 1.0, damage_groups = {fleshy = self.damage} }, nil) + mcl_hunger.exhaust(self.attack:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) end end else -- call custom attack every second @@ -1874,6 +1876,11 @@ end * tmp * ((armor[group] or 0) / 100.0) end + -- Exhaust attacker + if hitter:is_player() then + mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK) + end + -- check for tool immunity or special damage for n = 1, #self.immune_to do @@ -1902,6 +1909,7 @@ end and weapon:get_definition().tool_capabilities then weapon:add_wear(floor((punch_interval / 75) * 9000)) hitter:set_wielded_item(weapon) + end -- only play hit sound and show blood effects if damage is 1 or over @@ -2248,6 +2256,9 @@ local do_tnt = function(obj, damage) full_punch_interval = 1.0, damage_groups = {fleshy = damage}, }, nil) + if obj.object:is_player() then + mcl_hunger.exhaust(obj.object:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) + end return false, true, {} end diff --git a/mods/ENTITIES/mobs/depends.txt b/mods/ENTITIES/mobs/depends.txt index 6077b78d..614b3fac 100644 --- a/mods/ENTITIES/mobs/depends.txt +++ b/mods/ENTITIES/mobs/depends.txt @@ -1,5 +1,6 @@ mcl_core mcl_sounds +mcl_hunger invisibility? intllib? lucky_block?