Fix exhauston for attacking and taking dmg
parent
6497916ade
commit
7851cee45e
|
@ -1,5 +1,4 @@
|
||||||
local dmes = minetest.get_modpath("mcl_death_messages") ~= nil
|
local dmes = minetest.get_modpath("mcl_death_messages") ~= nil
|
||||||
local hung = minetest.get_modpath("mcl_hunger") ~= nil
|
|
||||||
|
|
||||||
local get_falling_depth = function(self)
|
local get_falling_depth = function(self)
|
||||||
if not self._startpos then
|
if not self._startpos then
|
||||||
|
@ -56,9 +55,6 @@ local deal_falling_damage = function(self, dtime)
|
||||||
if dmes then
|
if dmes then
|
||||||
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
mcl_death_messages.player_damage(v, string.format(msg, v:get_player_name()))
|
||||||
end
|
end
|
||||||
if hung then
|
|
||||||
mcl_hunger.exhaust(v:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
v:set_hp(hp)
|
v:set_hp(hp)
|
||||||
end
|
end
|
||||||
|
|
|
@ -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_weather = minetest.get_modpath("mcl_weather") ~= nil
|
||||||
local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil
|
local mod_tnt = minetest.get_modpath("mcl_tnt") ~= nil
|
||||||
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
local mod_mobspawners = minetest.get_modpath("mcl_mobspawners") ~= nil
|
||||||
|
local mod_hunger = minetest.get_modpath("mcl_hunger") ~= nil
|
||||||
|
|
||||||
-- play sound
|
-- play sound
|
||||||
local mob_sound = function(self, sound, is_opinion)
|
local mob_sound = function(self, sound, is_opinion)
|
||||||
|
@ -2342,10 +2343,15 @@ local mob_punch = function(self, hitter, tflp, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- weapon wear
|
-- punch interval
|
||||||
local weapon = hitter:get_wielded_item()
|
local weapon = hitter:get_wielded_item()
|
||||||
local punch_interval = 1.4
|
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
|
-- calculate mob damage
|
||||||
local damage = 0
|
local damage = 0
|
||||||
local armor = self.object:get_armor_groups() or {}
|
local armor = self.object:get_armor_groups() or {}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
mcl_core
|
mcl_core
|
||||||
mcl_weather?
|
mcl_weather?
|
||||||
mcl_tnt?
|
mcl_tnt?
|
||||||
|
mcl_hunger?
|
||||||
invisibility?
|
invisibility?
|
||||||
intllib?
|
intllib?
|
||||||
lucky_block?
|
lucky_block?
|
||||||
|
|
|
@ -7,7 +7,6 @@ local GRAVITY = 9.81
|
||||||
|
|
||||||
local YAW_OFFSET = -math.pi/2
|
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_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements")
|
||||||
local mod_button = minetest.get_modpath("mesecons_button")
|
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
|
-- “Ding” sound for hitting another player
|
||||||
minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter})
|
minetest.sound_play({name="mcl_bows_hit_player", gain=0.1}, {to_player=self._shooter})
|
||||||
end
|
end
|
||||||
if mod_mcl_hunger then
|
|
||||||
mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if lua then
|
if lua then
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
controls
|
controls
|
||||||
awards?
|
awards?
|
||||||
mcl_achievements?
|
mcl_achievements?
|
||||||
mcl_hunger?
|
|
||||||
mcl_core?
|
mcl_core?
|
||||||
mcl_mobitems?
|
mcl_mobitems?
|
||||||
playerphysics?
|
playerphysics?
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
mcl_sounds?
|
mcl_sounds?
|
||||||
mcl_mobitems?
|
mcl_mobitems?
|
||||||
mcl_hunger?
|
|
||||||
mcl_death_messages?
|
mcl_death_messages?
|
||||||
doc_identifier?
|
doc_identifier?
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
|
local mod_death_messages = minetest.get_modpath("mcl_death_messages")
|
||||||
local mod_hunger = minetest.get_modpath("mcl_hunger")
|
|
||||||
|
|
||||||
local function spawn_tnt(pos, entname)
|
local function spawn_tnt(pos, entname)
|
||||||
minetest.sound_play("tnt_ignite", {pos = pos,gain = 1.0,max_hear_distance = 15,})
|
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
|
if mod_death_messages then
|
||||||
mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name()))
|
mcl_death_messages.player_damage(obj, string.format("%s was caught in an explosion.", obj:get_player_name()))
|
||||||
end
|
end
|
||||||
if mod_hunger then
|
|
||||||
mcl_hunger.exhaust(obj:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
obj:set_hp(obj:get_hp() - damage)
|
obj:set_hp(obj:get_hp() - damage)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ mcl_hunger.EXHAUST_SPRINT_JUMP = 200 -- jump while sprinting
|
||||||
mcl_hunger.EXHAUST_ATTACK = 100 -- hit an enemy
|
mcl_hunger.EXHAUST_ATTACK = 100 -- hit an enemy
|
||||||
mcl_hunger.EXHAUST_SWIM = 10 -- player movement in water
|
mcl_hunger.EXHAUST_SWIM = 10 -- player movement in water
|
||||||
mcl_hunger.EXHAUST_SPRINT = 100 -- sprint (per node)
|
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_REGEN = 6000 -- Regenerate 1 HP
|
||||||
mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lowered
|
mcl_hunger.EXHAUST_LVL = 4000 -- at what exhaustion player saturation gets lowered
|
||||||
|
|
||||||
|
@ -134,12 +134,19 @@ end)
|
||||||
|
|
||||||
-- PvP combat exhaustion
|
-- PvP combat exhaustion
|
||||||
minetest.register_on_punchplayer(function(victim, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
minetest.register_on_punchplayer(function(victim, puncher, time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
if victim:is_player() and puncher:is_player() then
|
if puncher:is_player() then
|
||||||
mcl_hunger.exhaust(victim:get_player_name(), mcl_hunger.EXHAUST_DAMAGE)
|
|
||||||
mcl_hunger.exhaust(puncher:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
mcl_hunger.exhaust(puncher:get_player_name(), mcl_hunger.EXHAUST_ATTACK)
|
||||||
end
|
end
|
||||||
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 main_timer = 0
|
||||||
local timer = 0 -- Half second timer
|
local timer = 0 -- Half second timer
|
||||||
local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second
|
local timerMult = 1 -- Cycles from 0 to 7, each time when timer hits half a second
|
||||||
|
|
|
@ -135,7 +135,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
if dist < 1.1 or dist_feet < 1.1 then
|
if dist < 1.1 or dist_feet < 1.1 then
|
||||||
if player:get_hp() > 0 then
|
if player:get_hp() > 0 then
|
||||||
mcl_death_messages.player_damage(player, string.format("%s was prickled by a cactus.", name))
|
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)
|
player:set_hp(player:get_hp() - 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue