1
0
Fork 0

Merge pull request 'Multishot angular spread is constant, no matter the player's orientation' (#3833) from seventeenthShulker/MineClone2:relative_multishot into master

Reviewed-on: MineClone2/MineClone2#3833
Reviewed-by: ancientmarinerdev <ancientmariner_dev@proton.me>
This commit is contained in:
ancientmarinerdev 2023-07-22 20:01:31 +00:00
commit 13fc47751d
1 changed files with 14 additions and 2 deletions

View File

@ -105,8 +105,20 @@ local function player_shoot_arrow(wielditem, player, power, damage, is_critical)
local yaw = player:get_look_horizontal() local yaw = player:get_look_horizontal()
if has_multishot_enchantment then if has_multishot_enchantment then
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir.x, y=dir.y, z=dir.z + .2}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false) -- calculate rotation by 10 degrees 'left' and 'right' of facing direction
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir.x, y=dir.y, z=dir.z - .2}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false) local pitch = player:get_look_vertical()
local pitch_c = math.cos(pitch)
local pitch_s = math.sin(pitch)
local yaw_c = math.cos(yaw + math.pi / 2)
local yaw_s = math.sin(yaw + math.pi / 2)
local rot_left = {x = yaw_c * pitch_s * math.pi / 18, y = pitch_c * math.pi / 18, z = yaw_s * pitch_s * math.pi / 18}
local rot_right = {x = - yaw_c * pitch_s * math.pi / 18, y = - pitch_c * math.pi / 18, z = - yaw_s * pitch_s * math.pi / 18}
local dir_left = vector.rotate(dir, rot_left)
local dir_right = vector.rotate(dir, rot_right)
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir_left.x, y=dir_left.y, z=dir_left.z}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false)
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, {x=dir_right.x, y=dir_right.y, z=dir_right.z}, yaw, player, power, damage, is_critical, player:get_wielded_item(), false)
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true) mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true)
else else
mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true) mcl_bows_s.shoot_arrow_crossbow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player, power, damage, is_critical, player:get_wielded_item(), true)