diff --git a/mods/CORE/mcl_damage/init.lua b/mods/CORE/mcl_damage/init.lua index 18cb6cb13..2018ffc19 100644 --- a/mods/CORE/mcl_damage/init.lua +++ b/mods/CORE/mcl_damage/init.lua @@ -102,6 +102,9 @@ old_register_hpchange(function(player, hp_change, mt_reason) for _, modf in ipairs(mcl_damage.modifiers) do hp_change = modf.func(player, hp_change, mt_reason, mcl_reason) or hp_change + if hp_change == 0 then + return 0 + end end return hp_change diff --git a/mods/PLAYER/mcl_criticals/init.lua b/mods/PLAYER/mcl_criticals/init.lua new file mode 100644 index 000000000..6b420e0b8 --- /dev/null +++ b/mods/PLAYER/mcl_criticals/init.lua @@ -0,0 +1,38 @@ +mcl_criticals = {} + +function mcl_criticals.modifier(obj, hp_change, reason) + local damage = -hp_change + if damage > 0 and reason.type == "player" then + local hitter = reason.direct + if mcl_sprint.is_sprinting(hitter) then + obj:add_velocity(hitter:get_velocity()) + elseif (hitter:get_velocity() or hitter:get_player_velocity()).y < 0 then + local pos = mcl_util.get_object_center(obj) + minetest.add_particlespawner({ + amount = 15, + time = 0.1, + minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, + maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5}, + minvel = {x=-0.1, y=-0.1, z=-0.1}, + maxvel = {x=0.1, y=0.1, z=0.1}, + minacc = {x=0, y=0, z=0}, + maxacc = {x=0, y=0, z=0}, + minexptime = 1, + maxexptime = 2, + minsize = 1.5, + maxsize = 1.5, + collisiondetection = false, + vertical = false, + texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", + }) + minetest.sound_play("mcl_criticals_hit", {object = obj}) + -- the minecraft wiki is actually wrong about a crit dealing 150% damage, see minecraft source code + damage = damage + math.random(0, math.floor(damage * 1.5 + 2)) + end + end + return -damage +end + +mcl_damage.register_modifier(function(player, hp_change, _, mcl_reason) + return mcl_criticals.modifier(player, hp_change, mcl_reason) +end, -100) diff --git a/mods/PLAYER/mcl_criticals/mod.conf b/mods/PLAYER/mcl_criticals/mod.conf new file mode 100644 index 000000000..5b0b91330 --- /dev/null +++ b/mods/PLAYER/mcl_criticals/mod.conf @@ -0,0 +1,2 @@ +name = mcl_criticals +depends = mcl_damage diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg new file mode 100644 index 000000000..8184d1076 Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.0.ogg differ diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg new file mode 100644 index 000000000..aed998162 Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.1.ogg differ diff --git a/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg new file mode 100644 index 000000000..6d573b9f2 Binary files /dev/null and b/mods/PLAYER/mcl_criticals/sounds/mcl_criticals_hit.2.ogg differ diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 5d74903fb..5cf0253ab 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -113,37 +113,6 @@ end local node_stand, node_stand_below, node_head, node_feet - -minetest.register_on_punchplayer(function(player, hitter, damage) - if hitter:is_player() then - if hitter:get_player_control().aux1 then - player:add_velocity(hitter:get_velocity()) - end - if hitter:get_velocity().y < -6 then - player:set_hp(player:get_hp() - (damage * math.random(0.50 , 0.75))) - local pos = player:get_pos() - minetest.add_particlespawner({ - amount = 15, - time = 0.1, - minpos = {x=pos.x-0.5, y=pos.y-0.5, z=pos.z-0.5}, - maxpos = {x=pos.x+0.5, y=pos.y+0.5, z=pos.z+0.5}, - minvel = {x=-0.1, y=-0.1, z=-0.1}, - maxvel = {x=0.1, y=0.1, z=0.1}, - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, - minexptime = 1, - maxexptime = 2, - minsize = 1.5, - maxsize = 1.5, - collisiondetection = false, - vertical = false, - texture = "mcl_particles_crit.png^[colorize:#bc7a57:127", - }) - end - end -end) - - minetest.register_globalstep(function(dtime) time = time + dtime