Files
magic_arrow.sk
Code
1 151
magic_arrow.sk
# Magic Arrow: right-click with a sword to unleash a particle-rich block-display burst.
# Requires Skript 2.10+ on Paper 1.20.4+.
# Place in plugins/Skript/scripts/ and run /sk reload magic_arrow.
options:
cooldown: 15 ticks
blocks: 18
spin-ticks: 48
burst-ticks: 32
on right click:
"%type of player's tool%" contains "sword"
if {-magicarrow::%uuid of player%} is set:
stop
set {-magicarrow::%uuid of player%} to true
set {_eye} to location of player's head
spawn an arrow at {_eye}
set {_a} to last spawned entity
set shooter of {_a} to player
add "magic_arrow" to scoreboard tags of {_a}
set gravity of {_a} to false
set velocity of {_a} to (vector from yaw (yaw of player) and pitch (pitch of player)) * 3
play sound "entity.blaze.shoot" with volume 1 with pitch 1.6 at player
play sound "block.amethyst_block.chime" with volume 0.6 with pitch 1.8 at player
set {_uuid} to uuid of player
wait {@cooldown}
delete {-magicarrow::%{_uuid}%}
loop 100 times:
if {_a} is not valid:
stop
set {_trailAngle} to loop-number * 24
set {_trailLoc} to location of {_a}
draw 2 of end rod at {_trailLoc}
draw 3 of electric spark at {_trailLoc}
draw 1 of witch at {_trailLoc}
draw 1 of soul fire flame at {_trailLoc} ~ vector(cos({_trailAngle}) * 0.2, sin({_trailAngle} * 2) * 0.15, sin({_trailAngle}) * 0.2)
wait 1 tick
if {_a} is valid:
delete {_a}
on projectile hit:
scoreboard tags of projectile contains "magic_arrow"
set {_loc} to location of projectile
delete projectile
magicBlast({_loc})
function magicBlast(loc: location):
set {_c} to {_loc} ~ vector(0, 1, 0)
# Impact flash and expanding ground rings
draw 50 of firework at {_c}
draw 1 of explosion emitter at {_c}
draw 20 of end rod at {_c}
play sound "entity.generic.explode" with volume 1 with pitch 1.3 at {_c}
play sound "block.beacon.activate" with volume 1 with pitch 2 at {_c}
loop 8 times:
set {_wave} to loop-number
set {_radius} to {_wave} * 0.45
loop 24 times:
set {_ringAngle} to loop-number * 15
set {_ringPos} to {_c} ~ vector(cos({_ringAngle}) * {_radius}, 0, sin({_ringAngle}) * {_radius})
draw 1 of electric spark at {_ringPos}
draw 1 of flame at {_ringPos}
wait 1 tick
# Summon the orbiting block displays
set {_mats::*} to magma block, crying obsidian, amethyst block, glowstone, purple concrete, sea lantern, shroomlight, diamond block, emerald block, lapis block
loop {@blocks} times:
set {_i} to loop-number
spawn a block display at {_c}
set {_d::%{_i}%} to last spawned entity
set display block data of {_d::%{_i}%} to random element of {_mats::*}
set transformation scale of {_d::%{_i}%} to vector(0.4, 0.4, 0.4)
set {_off::%{_i}%} to (360 / {@blocks}) * {_i}
# Tightening, accelerating vortex
set {_angle} to 0
loop {@spin-ticks} times:
set {_tick} to loop-number
set {_p} to {_tick} / {@spin-ticks}
set {_r} to 4 - (3.4 * {_p})
set {_angle} to {_angle} + 6 + (50 * {_p} * {_p})
loop {@blocks} times:
set {_i} to loop-number
set {_a} to {_angle} + {_off::%{_i}%}
set {_y} to sin({_angle} * 0.7 + ({_i} * 40)) * 0.8
set {_pos} to {_c} ~ vector(cos({_a}) * {_r}, {_y}, sin({_a}) * {_r})
teleport {_d::%{_i}%} to {_pos} ~ vector(-0.2, -0.2, -0.2)
draw 1 of end rod at {_pos}
draw 1 of soul fire flame at {_pos}
draw 1 of electric spark at {_pos}
if mod({_tick}, 6) = 0:
loop 24 times:
set {_ringAngle} to loop-number * 15 + {_angle}
set {_ringPos} to {_c} ~ vector(cos({_ringAngle}) * (1.5 - ({_p} * 0.5)), sin({_ringAngle} * 2) * 0.15, sin({_ringAngle}) * (1.5 - ({_p} * 0.5)))
draw 1 of witch at {_ringPos}
play sound "block.amethyst_block.chime" with volume 0.7 with pitch (0.5 + {_p} * 1.5) at {_c}
wait 1 tick
# Implosion pulse before the outward burst
play sound "block.beacon.power_select" with volume 1 with pitch 0.7 at {_c}
draw 30 of end rod at {_c}
draw 20 of witch at {_c}
loop {@blocks} times:
set {_i} to loop-number
set {_a} to {_angle} + {_off::%{_i}%}
set {_pp::%{_i}%} to {_c} ~ vector(cos({_a}) * 0.35, 0, sin({_a}) * 0.35)
teleport {_d::%{_i}%} to {_pp::%{_i}%} ~ vector(-0.2, -0.2, -0.2)
# Burst the blocks out in random directions
play sound "entity.firework_rocket.blast" with volume 1.5 with pitch 0.8 at {_c}
play sound "entity.warden.sonic_boom" with volume 0.7 with pitch 1.6 at {_c}
draw 60 of flame at {_c}
draw 35 of electric spark at {_c}
loop {@blocks} times:
set {_i} to loop-number
set {_yaw} to random number between 0 and 360
set {_pitch} to random number between -50 and 80
set {_spd} to random number between 0.5 and 1.4
set {_v::%{_i}%} to vector(cos({_yaw}) * cos({_pitch}), sin({_pitch}), sin({_yaw}) * cos({_pitch})) * {_spd}
loop {@burst-ticks} times:
set {_tick} to loop-number
loop {@blocks} times:
set {_i} to loop-number
subtract 0.03 from y component of {_v::%{_i}%}
set {_pp::%{_i}%} to {_pp::%{_i}%} ~ {_v::%{_i}%}
teleport {_d::%{_i}%} to {_pp::%{_i}%} ~ vector(-0.2, -0.2, -0.2)
draw 1 of flame at {_pp::%{_i}%}
draw 1 of smoke at {_pp::%{_i}%}
draw 1 of electric spark at {_pp::%{_i}%}
if mod({_tick}, 8) = 0:
set {_radius} to 1 + ({_tick} * 0.12)
loop 24 times:
set {_ringAngle} to loop-number * 15
set {_ringPos} to {_c} ~ vector(cos({_ringAngle}) * {_radius}, sin({_ringAngle} * 2) * 0.2, sin({_ringAngle}) * {_radius})
draw 1 of end rod at {_ringPos}
wait 1 tick
# Final aftershock and cleanup
play sound "block.respawn_anchor.deplete" with volume 0.8 with pitch 1.4 at {_c}
loop {@blocks} times:
set {_i} to loop-number
draw 8 of poof at {_pp::%{_i}%}
draw 4 of firework at {_pp::%{_i}%}
delete {_d::%{_i}%}
draw 24 of electric spark at {_c}