diff --git a/mods/ENTITIES/mcl_falling_nodes/init.lua b/mods/ENTITIES/mcl_falling_nodes/init.lua index 92cca7031..5f54f58d3 100644 --- a/mods/ENTITIES/mcl_falling_nodes/init.lua +++ b/mods/ENTITIES/mcl_falling_nodes/init.lua @@ -1,5 +1,4 @@ local dmes = minetest.get_modpath("mcl_death_messages") ~= nil -local hung = minetest.get_modpath("mcl_hunger") ~= nil local get_falling_depth = function(self) if not self._startpos then @@ -56,9 +55,6 @@ local deal_falling_damage = function(self, dtime) if dmes then mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name())) end - if hung then - mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) - end end v:set_hp(hp) end diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 30b8a582f..337deeb07 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -96,6 +96,7 @@ mobs.fallback_node = minetest.registered_aliases["mapgen_dirt"] or "mcl_core:dir local mod_weather = minetest.get_modpath("mcl_weather") ~= nil local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil +local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil -- play sound local mob_sound = function(self, sound, is_opinion) @@ -2342,10 +2343,15 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) end - -- weapon wear + -- punch interval local weapon = hitter:get_wielded_item() local punch_interval = 1.4 + -- exhaust attacker + if mod_hunger and hitter:is_player() then + mcl_hunger.exhaust(hitter:get_player_name(), mcl_hunger.EXHAUST_ATTACK) + end + -- calculate mob damage local damage = 0 local armor = self.object:get_armor_groups() or {} diff --git a/mods/ENTITIES/mcl_mobs/depends.txt b/mods/ENTITIES/mcl_mobs/depends.txt index a1d9c9aa2..eb3eb2aa0 100644 --- a/mods/ENTITIES/mcl_mobs/depends.txt +++ b/mods/ENTITIES/mcl_mobs/depends.txt @@ -1,6 +1,7 @@ mcl_core mcl_weather? mcl_tnt? +mcl_hunger? invisibility? intllib? lucky_block? diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index 52a857a0e..a3c8fb4a1 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -7,7 +7,6 @@ local GRAVITY = 9.81 local YAW_OFFSET = -math.pi/2 -local mod_mcl_hunger = minetest.get_modpath("mcl_hunger") local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_button = minetest.get_modpath("mesecons_button") @@ -193,9 +192,6 @@ ARROW_ENTITY.on_step = function(self, dtime) -- “Ding” sound for hitting another player minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter}) end - if mod_mcl_hunger then - mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) - end end if lua then diff --git a/mods/ITEMS/mcl_bows/depends.txt b/mods/ITEMS/mcl_bows/depends.txt index 736cd117a..08132ddbf 100644 --- a/mods/ITEMS/mcl_bows/depends.txt +++ b/mods/ITEMS/mcl_bows/depends.txt @@ -1,7 +1,6 @@ controls awards? mcl_achievements? -mcl_hunger? mcl_core? mcl_mobitems? playerphysics? diff --git a/mods/ITEMS/mcl_tnt/depends.txt b/mods/ITEMS/mcl_tnt/depends.txt index 0f49dddde..f02d2b054 100644 --- a/mods/ITEMS/mcl_tnt/depends.txt +++ b/mods/ITEMS/mcl_tnt/depends.txt @@ -1,5 +1,4 @@ mcl_sounds? mcl_mobitems? -mcl_hunger? mcl_death_messages? doc_identifier? diff --git a/mods/ITEMS/mcl_tnt/init.lua b/mods/ITEMS/mcl_tnt/init.lua index dd6ebc66a..fbe82c1c1 100644 --- a/mods/ITEMS/mcl_tnt/init.lua +++ b/mods/ITEMS/mcl_tnt/init.lua @@ -1,5 +1,4 @@ local mod_death_messages = minetest.get_modpath("mcl_death_messages") -local mod_hunger = minetest.get_modpath("mcl_hunger") local function spawn_tnt(pos, entname) minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,}) @@ -33,9 +32,6 @@ local function do_tnt_physics(tnt_np,tntr) if mod_death_messages then mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name())) end - if mod_hunger then - mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) - end end obj:set_hp(obj:get_hp() - damage) end diff --git a/mods/PLAYER/mcl_hunger/init.lua b/mods/PLAYER/mcl_hunger/init.lua index f71dc1216..5df787e7d 100644 --- a/mods/PLAYER/mcl_hunger/init.lua +++ b/mods/PLAYER/mcl_hunger/init.lua @@ -29,7 +29,7 @@ mcl_hunger.EXHAUST_SPRINT_JUMP = 200 -- jump while sprinting mcl_hunger.EXHAUST_ATTACK = 100 -- hit an enemy mcl_hunger.EXHAUST_SWIM = 10 -- player movement in water mcl_hunger.EXHAUST_SPRINT = 100 -- sprint (per node) -mcl_hunger.EXHAUST_DAMAGE = 100 -- TODO (mostly done): taking damage (protected by armor) +mcl_hunger.EXHAUST_DAMAGE = 100 -- taking damage (protected by armor) mcl_hunger.EXHAUST_REGEN = 6000 -- Regenerate 1 HP mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lowered @@ -134,12 +134,19 @@ end) -- PvP combat exhaustion minetest.register_on_punchplayer(function(victim, puncher, time_from_last_punch, tool_capabilities, dir, damage) - if victim:is_player() and puncher:is_player() then - mcl_hunger.exhaust(victim:get_player_name(), mcl_hunger.EXHAUST_DAMAGE) + if puncher:is_player() then mcl_hunger.exhaust(puncher:get_player_name(), mcl_hunger.EXHAUST_ATTACK) end end) +-- Exhaust on taking damage +minetest.register_on_player_hpchange(function(player, hp_change) + if hp_change < 0 then + local name = player:get_player_name() + mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_DAMAGE) + end +end) + local main_timer = 0 local timer = 0 -- Half second timer local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index f9022a3b7..17074ea98 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -135,7 +135,6 @@ minetest.register_globalstep(function(dtime) if dist < 1.1 or dist_feet < 1.1 then if player:get_hp() > 0 then mcl_death_messages.player_damage(player, string.format("%s was prickled by a cactus.", name)) - mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_DAMAGE) player:set_hp(player:get_hp() - 1) end end