forked from VoxeLibre/VoxeLibre
Merge pull request 'Color modifier for punched mobs and fixing breaking velocity when punched' (#1626) from jordan4ibanez/MineClone2:mineclone5 into mineclone5
Reviewed-on: MineClone2/MineClone2#1626
This commit is contained in:
commit
a6dae8e5a8
|
@ -696,6 +696,13 @@ mobs.mob_step = function(self, dtime)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--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
|
||||||
|
self.old_health = self.health
|
||||||
|
|
||||||
--do death logic (animation, poof, explosion, etc)
|
--do death logic (animation, poof, explosion, etc)
|
||||||
if self.health <= 0 then
|
if self.health <= 0 then
|
||||||
|
|
||||||
|
@ -724,8 +731,9 @@ mobs.mob_step = function(self, dtime)
|
||||||
if self.pause_timer > 0 then
|
if self.pause_timer > 0 then
|
||||||
self.pause_timer = self.pause_timer - dtime
|
self.pause_timer = self.pause_timer - dtime
|
||||||
--perfectly reset pause_timer
|
--perfectly reset pause_timer
|
||||||
if self.pause_timer < 0 then
|
if self.pause_timer <= 0 then
|
||||||
self.pause_timer = 0
|
self.pause_timer = 0
|
||||||
|
self.object:set_texture_mod("")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--this overrides internal lua collision detection
|
--this overrides internal lua collision detection
|
||||||
|
@ -783,8 +791,9 @@ mobs.mob_step = function(self, dtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
--perfectly reset pause_timer
|
--perfectly reset pause_timer
|
||||||
if self.pause_timer < 0 then
|
if self.pause_timer <= 0 then
|
||||||
self.pause_timer = 0
|
self.pause_timer = 0
|
||||||
|
self.object:set_texture_mod("")
|
||||||
end
|
end
|
||||||
|
|
||||||
--stop projectile mobs from being completely disabled while stunned
|
--stop projectile mobs from being completely disabled while stunned
|
||||||
|
|
|
@ -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.
|
-- 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
|
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", {
|
minetest_sound_play("default_punch", {
|
||||||
object = self.object,
|
object = self.object,
|
||||||
max_hear_distance = 16
|
max_hear_distance = 16
|
||||||
}, true)
|
}, true)
|
||||||
--end
|
|
||||||
|
|
||||||
--damage_effect(self, damage)
|
|
||||||
|
|
||||||
-- do damage
|
-- do damage
|
||||||
self.health = self.health - 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
|
-- knock back effect
|
||||||
local velocity = self.object:get_velocity()
|
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)
|
multiplier = knockback_enchant + 1 --(starts from 1, 1 would be no change)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.hostile then
|
||||||
|
multiplier = multiplier + 2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local luaentity
|
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 = vector_multiply(dir,multiplier)
|
||||||
|
|
||||||
dir.y = up
|
dir.y = up
|
||||||
|
|
||||||
--add velocity breaks momentum - use set velocity
|
--add the velocity
|
||||||
self.object:set_velocity(dir)
|
self.object:add_velocity(dir)
|
||||||
|
|
||||||
--0.4 seconds until you can hurt the mob again
|
--0.4 seconds until you can hurt the mob again
|
||||||
self.pause_timer = 0.4
|
self.pause_timer = 0.4
|
||||||
|
|
Loading…
Reference in New Issue