Files
minigun_crossbow.sk
Code
1 88
minigun_crossbow.sk
# ================================
# Minigun Crossbow
# ================================
# Place in: plugins/Skript/scripts/
# Reload with: /sk reload minigun_crossbow
# ================================
options:
# Name the crossbow must have (case-insensitive check)
gun-name: &fMinigun
# How many extra arrows to fire per burst
burst-count: 8
# Delay between each burst arrow (in ticks, 2 ticks = 0.1s)
burst-delay: 2
# Spread of the bullets (higher = more spread)
spread: 0.25
# Bullet speed
speed: 3.0
# Cooldown between bursts (in seconds)
cooldown: 1.5
# ================================
# When a player shoots a crossbow
# ================================
on shoot:
shooter is a player
projectile is an arrow
set {_item} to player's tool
if type of {_item} is crossbow:
if display name of {_item} contains "minigun":
# Cancel the original single arrow shot
cancel event
# Prevent firing if on cooldown
if {minigun.cooldown::%player's uuid%} is set:
send action bar "&cMinigun cooling down!" to player
stop
# Set cooldown immediately so burst can't be re-triggered mid-fire
set {minigun.cooldown::%player's uuid%} to true
# Burst fire loop
set {_player} to player
loop {@burst-count} times:
set {_count} to loop-number
wait {_count} * {@burst-delay} ticks
if {_player} is online:
# Spawn arrow from player's eyes
set {_loc} to eye location of {_player}
set {_arrow} to shoot arrow from {_loc} at speed {@speed}
set shooter of {_arrow} to {_player}
# Apply random spread to velocity
set {_spreadX} to (random number between -{@spread} and {@spread})
set {_spreadY} to (random number between -{@spread} and {@spread})
set {_vx} to x-velocity of {_arrow} + {_spreadX}
set {_vy} to y-velocity of {_arrow} + {_spreadY}
set {_vz} to z-velocity of {_arrow}
set velocity of {_arrow} to vector({_vx}, {_vy}, {_vz})
# Muzzle smoke
play smoke particle at eye location of {_player} offset by 0, 0, 0 with speed 0.05 count 3
# Rapid-fire gunshot sounds
if loop-number mod 2 is 0:
play sound "entity.arrow.shoot" at {_player} with volume 0.6 and pitch 1.8
else:
play sound "entity.arrow.shoot" at {_player} with volume 0.6 and pitch 1.6
# Clear cooldown after delay
wait {@cooldown} seconds
delete {minigun.cooldown::%player's uuid%}
# ================================
# Give command
# ================================
command /minigun:
permission: minigun.give
permission message: &cYou don't have permission to use this!
trigger:
give player 1 crossbow named "{@gun-name}"
send "&aYou received a &fMinigun&a! Load it by right-clicking, then fire!"
on script load:
send "[Minigun] Minigun Crossbow loaded!" to console