on right click:
player's tool's name contains "Terminator"
#run the function
function termbeam(p: player, length: number, dmg: number):
set {_x} to 0
set {_l} to 0
loop {_length} times: #loops as many times as long as the length from the function input
add 1 to {_x}
add 0.25 to {_l}
set {_rg%{_x}%} to location {_l} meters infront of {_p}
set {_rg%{_x}%} to location 1.18 meters above {_rg%{_x}%} #aligns with where player is looking better
# all of the locations are saved as soon as the function is called, effects such as particles can be applied afterwards.
set {_x} to 0
loop {_length} times:
add 1 to {_x}
draw 1 dripping_lava at {_rg%{_x}%} #change color or particle type
loop entities in radius 1 around {_rg%{_x}%}:
loop-entity is not {_p}
damage loop-entity by {_dmg}
loop blocks in radius 0.5 around {_rg%{_x}%}:
if loop-block is not tall grass, short grass, snow layer, air or water:
stop #projectile does not go through blocks, but passes through expected blocks
on damage:
attacker is player
attacker's tool's name contains "Terminator"
set {hits::%victim's uuid%::%attacker's uuid%} to {hits::%victim's uuid%::%attacker's uuid%} + 1
{hits::%victim's uuid%::%attacker's uuid%} = 3
clear {hits::%victim's uuid%::%attacker's uuid%}
{termbeam.%attacker's uuid%} isn't set
set {termbeam.%attacker's uuid%} to 1
termbeam(attacker, 50, 70)
wait 0.5 second
clear {termbeam.%attacker's uuid%}