From 9cd807d5c5ba6309b1ef1736eae48a343645b131 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Mon, 30 Dec 2024 19:28:16 +0100 Subject: [PATCH 1/3] Basic 3rd person spear aim anim --- mods/PLAYER/mcl_playerplus/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index f14557dcf..e5434d861 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -314,6 +314,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.57, 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)) From bd7524d71241c2dc36b92483e29b8dabbd266e74 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 31 Dec 2024 02:18:54 +0100 Subject: [PATCH 2/3] Actually working spear aiming animation --- mods/PLAYER/mcl_player/init.lua | 4 +++- mods/PLAYER/mcl_playerplus/init.lua | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 83182fcc8..391fe1081 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -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 diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index e5434d861..1707108f8 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -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)) @@ -316,7 +318,7 @@ minetest.register_globalstep(function(dtime) 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.57, 0, pitch * -1 * .35) + 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 From 7ed6e7b7803a18e0721129942b48cb6aaa988382 Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Tue, 31 Dec 2024 02:20:59 +0100 Subject: [PATCH 3/3] Improve spear mobile experience --- mods/ITEMS/vl_weaponry/init.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/vl_weaponry/init.lua b/mods/ITEMS/vl_weaponry/init.lua index ad52195e1..168396a99 100644 --- a/mods/ITEMS/vl_weaponry/init.lua +++ b/mods/ITEMS/vl_weaponry/init.lua @@ -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, })