Fix exhauston for attacking and taking dmg

This commit is contained in:
Wuzzy 2019-02-28 16:43:52 +01:00
parent 6497916ade
commit 7851cee45e
9 changed files with 18 additions and 19 deletions

View File

@ -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

View File

@ -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 {}

View File

@ -1,6 +1,7 @@
mcl_core
mcl_weather?
mcl_tnt?
mcl_hunger?
invisibility?
intllib?
lucky_block?

View File

@ -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

View File

@ -1,7 +1,6 @@
controls
awards?
mcl_achievements?
mcl_hunger?
mcl_core?
mcl_mobitems?
playerphysics?

View File

@ -1,5 +1,4 @@
mcl_sounds?
mcl_mobitems?
mcl_hunger?
mcl_death_messages?
doc_identifier?

View File

@ -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

View File

@ -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

View File

@ -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