From dc7592528cf948556e4e925310e830648b52dff1 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 17:23:00 -0400 Subject: [PATCH 1/2] Add red tint hurt effect --- mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 09877ac2a..36ba4d755 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -695,7 +695,14 @@ mobs.mob_step = function(self, dtime) self.object:remove() return false end - + + + --color mod which coincides with the pause_timer + if self.old_health and self.health < self.old_health then + self.object:set_texture_mod("^[colorize:red:120") + end + self.old_health = self.health + --do death logic (animation, poof, explosion, etc) if self.health <= 0 then @@ -724,8 +731,9 @@ mobs.mob_step = function(self, dtime) if self.pause_timer > 0 then self.pause_timer = self.pause_timer - dtime --perfectly reset pause_timer - if self.pause_timer < 0 then + if self.pause_timer <= 0 then self.pause_timer = 0 + self.object:set_texture_mod("") end end --this overrides internal lua collision detection @@ -783,8 +791,9 @@ mobs.mob_step = function(self, dtime) end --perfectly reset pause_timer - if self.pause_timer < 0 then + if self.pause_timer <= 0 then self.pause_timer = 0 + self.object:set_texture_mod("") end --stop projectile mobs from being completely disabled while stunned From 9720986c4d30bf8fcd2cf1117d80eea06da5332a Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Fri, 23 Apr 2021 17:27:08 -0400 Subject: [PATCH 2/2] Fix punching a mob breaking it's velocity --- .../mcl_mobs/api/mob_functions/ai.lua | 2 +- .../api/mob_functions/interaction.lua | 41 +++---------------- 2 files changed, 7 insertions(+), 36 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua index 36ba4d755..99dca9911 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/ai.lua @@ -697,7 +697,7 @@ mobs.mob_step = function(self, dtime) end - --color mod which coincides with the pause_timer + --color modifier which coincides with the pause_timer if self.old_health and self.health < self.old_health then self.object:set_texture_mod("^[colorize:red:120") end diff --git a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua index 6cbc48b0b..00ad066f0 100644 --- a/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua +++ b/mods/ENTITIES/mcl_mobs/api/mob_functions/interaction.lua @@ -187,35 +187,14 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) -- only play hit sound and show blood effects if damage is 1 or over; lower to 0.1 to ensure armor works appropriately. if damage >= 0.1 then - -- weapon sounds - --this doesn't work right for nodes - --[[ - if weapon:get_definition().sounds ~= nil then - - local s = math_random(1, #weapon:get_definition().sounds) - - minetest_sound_play(weapon:get_definition().sounds[s], { - object = self.object, --hitter, - max_hear_distance = 16 - }, true) - else - ]]-- minetest_sound_play("default_punch", { object = self.object, max_hear_distance = 16 }, true) - --end - - --damage_effect(self, damage) -- do damage self.health = self.health - damage - -- skip future functions if dead, except alerting others - --if check_for_death(self, "hit", {type = "punch", puncher = hitter}) then - -- die = true - --end - -- knock back effect local velocity = self.object:get_velocity() @@ -244,27 +223,19 @@ mobs.mob_punch = function(self, hitter, tflp, tool_capabilities, dir) multiplier = knockback_enchant + 1 --(starts from 1, 1 would be no change) end + if self.hostile then + multiplier = multiplier + 2 + end + local luaentity - --[[ --why does this multiply it again??? - if hitter then - luaentity = hitter:get_luaentity() - end - if hitter and is_player then - local wielditem = hitter:get_wielded_item() - kb = kb + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback") - elseif luaentity and luaentity._knockback then - kb = kb + luaentity._knockback - end - ]]-- - dir = vector_multiply(dir,multiplier) dir.y = up - --add velocity breaks momentum - use set velocity - self.object:set_velocity(dir) + --add the velocity + self.object:add_velocity(dir) --0.4 seconds until you can hurt the mob again self.pause_timer = 0.4