From aac9d6a105b93c83fc90b54a93ade0a4936a0eb9 Mon Sep 17 00:00:00 2001 From: epCode Date: Sun, 25 Apr 2021 15:49:15 -0700 Subject: [PATCH] impliment crash damage for elytra --- mods/PLAYER/mcl_playerplus/init.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 13d136ecf8..ee24267135 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -4,6 +4,7 @@ mcl_playerplus = { elytra = {}, } +local player_velocity_old = {x=0, y=0, z=0} local get_connected_players = minetest.get_connected_players local dir_to_yaw = minetest.dir_to_yaw local get_item_group = minetest.get_item_group @@ -195,6 +196,12 @@ minetest.register_globalstep(function(dtime) and (fly_node == "air" or fly_node == "ignore") if elytra.active then + if player_velocity.x < (player_velocity_old.x - 10) or player_velocity.x > (player_velocity_old.x + 10) then + player:set_hp(player:get_hp() - (math.abs(player_velocity_old.x) * 0.2)) + end + if player_velocity.z < (player_velocity_old.z - 10) or player_velocity.z > (player_velocity_old.z + 10) then + player:set_hp(player:get_hp() - (math.abs(player_velocity_old.z) * 0.2)) + end mcl_player.player_set_animation(player, "fly") if player_velocity.y < -1.5 then player:add_velocity({x=0, y=0.17, z=0}) @@ -240,6 +247,7 @@ minetest.register_globalstep(function(dtime) playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra") end + player_velocity_old = player:get_velocity() or player:get_player_velocity() -- controls right and left arms pitch when shooting a bow if string.find(wielded:get_name(), "mcl_bows:bow") and control.RMB and not control.LMB and not control.up and not control.down and not control.left and not control.right then player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35))