forked from VoxeLibre/VoxeLibre
add better pvp knockback
This commit is contained in:
parent
efcd0c8dcc
commit
b7eda10054
|
@ -130,6 +130,20 @@ mcl_enchanting.enchantments.fire_aspect = {
|
|||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
if hitter and hitter:is_player() then
|
||||
local wielditem = hitter:get_wielded_item()
|
||||
local p = player:get_pos()
|
||||
if time_from_last_punch > 0.5 then
|
||||
local yy=0
|
||||
if math.abs(player:get_velocity().y) < 0.1 then
|
||||
yy=4
|
||||
end
|
||||
player:get_meta():set_string("punched", tostring(minetest.get_gametime()))
|
||||
minetest.after(0.4, function()
|
||||
player:get_meta():set_string("punched", "0")
|
||||
end)
|
||||
|
||||
local d = hitter:get_look_dir()
|
||||
player:add_velocity({x=d.x*4,y=yy,z=d.z*4})
|
||||
end
|
||||
if wielditem then
|
||||
local fire_aspect_level = mcl_enchanting.get_enchantment(wielditem, "fire_aspect")
|
||||
if fire_aspect_level > 0 then
|
||||
|
|
|
@ -231,13 +231,21 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
local velocity = player:get_velocity() or player:get_player_velocity()
|
||||
|
||||
local mod_speed = 5
|
||||
if player:get_meta():get("punched") and tonumber(player:get_meta():get("punched")) > 0 then
|
||||
mod_speed = 10
|
||||
end
|
||||
-- Apply animations based on what the player is doing
|
||||
if player:get_hp() == 0 then
|
||||
player_set_animation(player, "die")
|
||||
elseif player:get_meta():get("punched") and tonumber(player:get_meta():get("punched")) > 0 then
|
||||
player_set_animation(player, "run_walk", animation_speed_mod)
|
||||
player:set_animation_frame_speed((math.abs(velocity.x)+math.abs(velocity.z))*mod_speed)
|
||||
elseif walking and velocity.x > 0.35
|
||||
or walking and velocity.x < -0.35
|
||||
or walking and velocity.z > 0.35
|
||||
or walking and velocity.z < -0.35 then
|
||||
player:set_animation_frame_speed((math.abs(velocity.x)+math.abs(velocity.z))*mod_speed)
|
||||
local wielded_itemname = player:get_wielded_item():get_name()
|
||||
local no_arm_moving = string.find(wielded_itemname, "mcl_bows:bow") or mcl_shields.wielding_shield(player, 1) or mcl_shields.wielding_shield(player, 2)
|
||||
if player_sneak[name] ~= controls.sneak then
|
||||
|
|
Loading…
Reference in New Issue