# -------------------------------------------------- # SkWand v. 1.0 # Skrypt na różdżkę strzelającą pociskami # # Autor: Kormic # -------------------------------------------------- options: wand: blaze rod named "&bMagic Wand" # przedmiot reprezentujący różdżkę wandCooldown: 2 seconds # najkrótszy czas między wystrzeleniem kolejnych pocisków wandMaxDist: 100 # maksymalny dystans, który pocisk może pokonać wandDamage: 3 # obrażenia zadawane przez pocisk różdżki wandProjectileParticle: mobspawner flames # wizualny efekt reprezentujący pocisk wandProjectileSpeed: 1 # współczynnik szybkości pocisku wandProjectileExplosionHitboxRange: 3.5 # zasięg odrzucenia przy wybuchu pocisku różdżki wandProjectileHitboxRange: 1.8 # promień pocisku wandPermission: skwand.command.magicwand # permisja wymagana do otrzymania i używania różdżki wandNoPermissionMessage: &cNie możesz korzystać z różdżki! # wiadomość wyświetlana graczowi w przypadku braku powyższej permisji function skWand_squaredDistance(l1: location, l2: location) :: number: return ((x-loc of {_l1} - x-loc of {_l2})^2 + (y-loc of {_l1} - y-loc of {_l2})^2 + (z-loc of {_l1} - z-loc of {_l2})^2) function skWand_scalarToVector(n: number) :: vector: return vector {_n}, {_n}, {_n} function skWand_shootProjectile(p: player): set {_hitRange} to {@wandProjectileHitboxRange} set {_speed} to {@wandProjectileSpeed} set {_sqMaxDist} to {@wandMaxDist}^2 set {_explRange} to {@wandProjectileExplosionHitboxRange} set {_vDir} to vector from yaw ({_p}'s yaw) and pitch ({_p}'s pitch) set {_vStartOffset} to skWand_scalarToVector({_hitRange}) set {_vSpeed} to vector {_speed}, {_speed}, {_speed} set {_startLoc} to (location of {_p}'s head) ~ ({_vStartOffset} ** {_vDir}) set {_currLoc} to {_startLoc} while skWand_squaredDistance({_startLoc}, {_currLoc}) < {_sqMaxDist}: play {@wandProjectileParticle} at {_currLoc} set {_e::*} to living entities in radius {_hitRange} around {_currLoc} remove {_p} from {_e::*} if size of {_e::*} > 0: damage {_e::*} by {@wandDamage} exit loop if block at {_currLoc} is not air: play huge explosion at {_currLoc} play sound "ENTITY_GENERIC_EXPLODE" at {_currLoc} loop living entities in radius {_explRange} around {_currLoc}: set {_vExpl} to vector from {_currLoc} to loop-entity set {_vMax} to (normalized {_vExpl}) ** skWand_scalarToVector({_explRange}) push loop-entity ({_vMax} -- {_vExpl}) exit loop set {_currLoc} to {_currLoc} ~ ({_vSpeed} ** {_vDir}) wait 1 tick on right click: player's tool is {@wand} player doesn't have permission "{@wandPermission}": send "{@wandNoPermissionMessage}" to player stop if {magicWand::cooldown::%uuid of player%} is set: (difference between {magicWand::cooldown::%uuid of player%} and now) < {@wandCooldown} stop set {magicWand::cooldown::%uuid of player%} to now skWand_shootProjectile(player) command /magicwand: executable by: players permission: {@wandPermission} permission message: {@wandNoPermissionMessage} trigger: give player {@wand}