Merge pull request 'Basic 3rd person spear aim animation' (#4773) from animation_fixes into master

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4773
This commit is contained in:
the-real-herowl 2024-12-31 03:49:01 +01:00
commit 7324c6b39e
3 changed files with 22 additions and 8 deletions

View file

@ -371,7 +371,7 @@ core.register_tool("vl_weaponry:spear_wood", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=15 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=15 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -386,6 +386,7 @@ core.register_tool("vl_weaponry:spear_wood", {
swordy = { speed = 2, level = 1, uses = uses.wood },
swordy_cobweb = { speed = 2, level = 1, uses = uses.wood }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 5,
})
core.register_tool("vl_weaponry:spear_stone", {
@ -397,7 +398,7 @@ core.register_tool("vl_weaponry:spear_stone", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=5 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=5 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -412,6 +413,7 @@ core.register_tool("vl_weaponry:spear_stone", {
swordy = { speed = 2, level = 1, uses = uses.stone },
swordy_cobweb = { speed = 2, level = 1, uses = uses.stone }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 6,
})
core.register_tool("vl_weaponry:spear_iron", {
@ -423,7 +425,7 @@ core.register_tool("vl_weaponry:spear_iron", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=14 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=14 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -438,6 +440,7 @@ core.register_tool("vl_weaponry:spear_iron", {
swordy = { speed = 2, level = 1, uses = uses.iron },
swordy_cobweb = { speed = 2, level = 1, uses = uses.iron }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 7,
})
core.register_tool("vl_weaponry:spear_gold", {
@ -449,7 +452,7 @@ core.register_tool("vl_weaponry:spear_gold", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=22 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=22 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -464,6 +467,7 @@ core.register_tool("vl_weaponry:spear_gold", {
swordy = { speed = 2, level = 1, uses = uses.gold },
swordy_cobweb = { speed = 2, level = 1, uses = uses.gold }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 5,
})
core.register_tool("vl_weaponry:spear_diamond", {
@ -475,7 +479,7 @@ core.register_tool("vl_weaponry:spear_diamond", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=10 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=10 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -490,6 +494,7 @@ core.register_tool("vl_weaponry:spear_diamond", {
swordy = { speed = 2, level = 1, uses = uses.diamond },
swordy_cobweb = { speed = 2, level = 1, uses = uses.diamond }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 8,
_mcl_upgradable = true,
_mcl_upgrade_item = "vl_weaponry:spear_netherite"
@ -503,7 +508,7 @@ core.register_tool("vl_weaponry:spear_netherite", {
wield_scale = wield_scale,
on_place = spear_on_place,
on_secondary_use = spear_on_place,
groups = { weapon=1, spear=1, dig_speed_class=2, enchantability=10, fire_immune=1 },
groups = { weapon=1, weapon_ranged=1, spear=1, dig_speed_class=2, enchantability=10, fire_immune=1 },
range = SPEAR_RANGE,
tool_capabilities = {
full_punch_interval = 0.75,
@ -518,6 +523,7 @@ core.register_tool("vl_weaponry:spear_netherite", {
swordy = { speed = 2, level = 1, uses = uses.netherite },
swordy_cobweb = { speed = 2, level = 1, uses = uses.netherite }
},
touch_interaction = "short_dig_long_place",
_mcl_spear_thrown_damage = 12,
})

View file

@ -14,6 +14,7 @@ local function get_mouse_button(player)
local get_wielded_item_name = player:get_wielded_item():get_name()
if controls.RMB and not string.find(get_wielded_item_name, "mcl_bows:bow") and
not string.find(get_wielded_item_name, "mcl_bows:crossbow") and
core.get_item_group(get_wielded_item_name, "spear") == 0 and
not mcl_shields.wielding_shield(player, 1) and not mcl_shields.wielding_shield(player, 2) or controls.LMB then
return true
else
@ -263,7 +264,8 @@ minetest.register_globalstep(function(dtime)
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)
mcl_shields.wielding_shield(player, 2) or
core.get_item_group(wielded_itemname, "spear") > 0
if player_sneak[name] ~= controls.sneak then
player_anim[name] = nil
player_sneak[name] = controls.sneak

View file

@ -284,7 +284,9 @@ minetest.register_globalstep(function(dtime)
playerphysics.remove_physics_factor(player, "gravity", "mcl_playerplus:elytra")
end
if wielded_def and wielded_def._mcl_toollike_wield then
if control.RMB and core.get_item_group(wielded:get_name(), "spear") > 0 then
set_bone_pos(player, "Wield_Item", vector.new(0, 5.2, 1.2), vector.new(-1.57, 5.7, 1.57))
elseif wielded_def and wielded_def._mcl_toollike_wield then
set_bone_pos(player, "Wield_Item", vector.new(0, 4.7, 3.1), vector.new(-1.57, 3.93, 1.57))
elseif string.find(wielded:get_name(), "mcl_bows:bow") then
set_bone_pos(player, "Wield_Item", vector.new(1, 4, 0), vector.new(1.57, 2.27, 2.01))
@ -314,6 +316,10 @@ minetest.register_globalstep(function(dtime)
local left_arm_rot = vector.new(pitch + 1.57, 0.75, pitch * .35)
set_bone_pos(player, "Arm_Right_Pitch_Control", nil, right_arm_rot)
set_bone_pos(player, "Arm_Left_Pitch_Control", nil, left_arm_rot)
-- controls arm for spear throwing
elseif core.get_item_group(wielded:get_name(), "spear") > 0 and control.RMB then
local right_arm_rot = vector.new(pitch + 1.8, 0, pitch * -1 * .35)
set_bone_pos(player, "Arm_Right_Pitch_Control", nil, right_arm_rot)
-- controls right and left arms pitch when loading a crossbow
elseif string.find(wielded:get_name(), "mcl_bows:crossbow_") then
set_bone_pos(player, "Arm_Right_Pitch_Control", nil, vector.new(0.786, -0.35, 0.47))