Jump to content

Guns (Skript)


CraftE_C

Recommended Posts

I made a script with a few guns.

Here are the stats I put in the beginning of the script:

#Pistol: 1   (10 ammo capacity, 4 DMG) [Leather Horse Armor named "&7Pistol"]
#Burst Rile: 2 (15 ammo capacity, 3 DMG) [Iron Horse Armor named "&aBurst Rifle"]
#AK-47: 3 (25 ammo capacity, 2 DMG) [Iron Horse Armor named "&aAK-47"]
#Shotgun: 4 (2 ammo capacity, 6 projectiles, 4 DMG) [Golden Horse Armor named "&9Shotgun"]
#Desert Eagle: 5 (1 ammo capacity, 16 DMG, 2.5x reload time) [Golden Horse Armor named "&9Desert Eagle"]
#Railgun: 6 (1 ammo capacity, 40 damage, 5x reload time) [Diamond Horse Armor named "&5Railgun"]

Feel free to tamper with the damage, shot cooldown, and reload time as much as you like. I indicated what gun is below in the script.

Use /itemname from EssentialsX to get the horse armor the name it needs.

craftsguns.sk.txt (DO NOT DOWNLOAD, SCROLL DOWN AND OPEN THE SPOILER FOR THE SCRIPT!)

Oh also be prepared to sacrifice the spawning of any chickens, as I use eggs as the bullets...

Edited by CraftE_C
File didnt show any text upon download.
Link to comment
Share on other sites

Oh... I didn't expect that to happen..

3 hours ago, Agentgamer100YT said:

You can't download the skript, as there is nothing in it

Heres the script:

Spoiler

#Bullet IDs (Indicated by the bulletegg player-specification variable)
#Pistol: 1   (10 ammo capacity, 4 DMG) [Leather Horse Armor named "&7Pistol"]
#Burst Rile: 2 (15 ammo capacity, 3 DMG) [Iron Horse Armor named "&aBurst Rifle"]
#AK-47: 3 (25 ammo capacity, 2 DMG) [Iron Horse Armor named "&aAK-47"]
#Shotgun: 4 (2 ammo capacity, 6 projectiles, 4 DMG [Golden Horse Armor named "&9Shotgun"]
#Desert Eagle: 5 (1 ammo capacity, 16 DMG, 2.5x reload time) [Golden Horse Armor named "&9Desert Eagle"]
#Railgun: 6 (1 ammo capacity, 40 damage, 5x reload time) [Diamond Horse Armor named "&5Railgun"

#TO PREVENT RELOAD LOCK BUG
on join:
    set {reloading.%player%} to false


on spawning of chicken:
    cancel event

#--------------------------------------------------------------------
#                           PISTOL
#--------------------------------------------------------------------
on rightclick:
    player is holding a leather horse armor named "&7Pistol"
    {pistolammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 0.2 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        shoot an egg from player at speed 2.5
        play sound "entity.generic.explode" from master category at volume 0.35 with pitch 2 at player's location
        set {bulletegg.%player%} to 1
        subtract 1 from {pistolammo.%player%}
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 2 seconds
                play sound "block.wooden_door.close" from master category with pitch 2 at player's location
                wait 8 ticks
                play sound "block.wooden_door.close" from master category with pitch 2 at player's location
                set {pistolammo.%player%} to 10
                set {reloading.%player%} to false

on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 1
    damage victim by 2 hearts

#--------------------------------------------------------------------
#                           BURST RIFLE
#--------------------------------------------------------------------
on rightclick:
    player is holding an iron horse armor named "&aBurst Rifle"
    {burstammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 0.8 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        subtract 1 from {burstammo.%player%}
        set {bulletegg.%player%} to 2
        shoot an egg from player at speed 2.5
        play sound "entity.zombie.attack_wooden_door" from master category at volume 0.35 with pitch 1.7 at player's location
        wait 4 ticks
        shoot an egg from player at speed 2.5
        play sound "entity.zombie.attack_wooden_door" from master category at volume 0.35 with pitch 1.7 at player's location
        wait 4 ticks
        shoot an egg from player at speed 2.5
        play sound "entity.zombie.attack_wooden_door" from master category at volume 0.35 with pitch 1.7 at player's location
        wait 4 ticks
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 2 seconds
                play sound "block.piston.contract" from master category with pitch 2 at player's location
                wait 8 ticks
                play sound "block.piston.extend" from master category with pitch 2 at player's location
                set {burstammo.%player%} to 5
                set {reloading.%player%} to false

on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 2
    damage victim by 3

on rightclick:
    player is holding an iron horse armor named "&aAK-47"
    {akammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 0.15 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        subtract 1 from {akammo.%player%}
        set {bulletegg.%player%} to 3
        shoot an egg from player at speed 2.5
        chance of 35%:
            push the last shot projectile left at speed 0.03
        chance of 35%:
            push the last shot projectile right at speed 0.03
        chance of 35%:
            push the last shot projectile upwards at speed 0.03
        chance of 35%:
            push the last shot projectile downwards at speed 0.03
        chance of 35%:
            push the last shot projectile left at speed 0.02
        chance of 35%:
            push the last shot projectile right at speed 0.02
        chance of 35%:
            push the last shot projectile upwards at speed 0.02
        chance of 35%:
            push the last shot projectile downwards at speed 0.02
        play sound "entity.zombie.attack_wooden_door" from master category at volume 0.35 with pitch 2 at player's location
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 2 seconds
                play sound "block.piston.contract" from master category with pitch 2 at player's location
                wait 8 ticks
                play sound "block.piston.extend" from master category with pitch 2 at player's location
                set {akammo.%player%} to 25
                set {reloading.%player%} to false

on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 3
    damage victim by 2

#--------------------------------------------------------------------
#                           SHOTGUN
#--------------------------------------------------------------------
on rightclick:
    player is holding golden horse armor named "&9Shotgun"
    {shotgunammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 1.5 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        play sound "entity.dragon_fireball.explode" from master category at volume 2 with pitch 1.7 at player's location
        set {bulletegg.%player%} to 4
        subtract 1 from {shotgunammo.%player%}
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
        shoot egg from player at speed 3.5
        chance of 45%:
            push last shot egg upwards with speed 0.06
        chance of 45%:
            push last shot egg downwards with speed 0.06
        chance of 45%:
            push last shot egg left with speed 0.06
        chance of 45%:
            push last shot egg right with speed 0.06
        chance of 45%:
            push last shot egg upwards with speed 0.09
        chance of 45%:
            push last shot egg downwards with speed 0.09
        chance of 45%:
            push last shot egg left with speed 0.09
        chance of 45%:
            push last shot egg right with speed 0.09
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 2 seconds
                play sound "block.piston.contract" from master category with pitch 2 at player's location
                wait 8 ticks
                play sound "block.piston.extend" from master category with pitch 2 at player's location
                set {shotgunammo.%player%} to 2
                set {reloading.%player%} to false


on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 4
    damage victim by 4

#--------------------------------------------------------------------
#                           DESERT EAGLE
#--------------------------------------------------------------------
on rightclick:
    player is holding a golden horse armor named "&9Desert Eagle"
    {DEammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 2 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        shoot an egg from player at speed 3.5
        play sound "entity.generic.explode" from master category at volume 0.5 with pitch 1.7 at player's location
        set {bulletegg.%player%} to 5
        subtract 1 from {DEammo.%player%}
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 5 seconds
                play sound "block.wooden_door.close" from master category with pitch 2 at player's location
                wait 7 ticks
                play sound "block.wooden_door.close" from master category with pitch 2 at player's location
                set {DEammo.%player%} to 1
                set {reloading.%player%} to false

on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 5
    damage victim by 8 hearts

#--------------------------------------------------------------------
#                           RAILGUN (SNIPER)
#--------------------------------------------------------------------
on rightclick:
    player is holding a diamond horse armor named "&5Railgun"
    {RGammo.%player%} is greater than 0:
        set {guncd} to difference between {gunclick.%player%} and now
        if {guncd} < 5 seconds:
            cancel event
            stop
        set {gunclick.%player%} to now
        set {reloading.%player%} to false
        shoot an egg from player at speed 50
        play sound "entity.blaze.death" from master category with pitch 0.6 at player's location
        set {bulletegg.%player%} to 6
        subtract 1 from {RGammo.%player%}
    else:
        player has spruce door named "&cAmmo Clip":
            {reloading.%player%} = false:
                remove spruce door named "&cAmmo Clip" from player's inventory
                play sound "block.wooden_door.open" from master category with pitch 2 at player's location
                set {reloading.%player%} to true
                wait 10 seconds
                play sound "block.piston.contract" from master category with pitch 2 at player's location
                wait 8 ticks
                play sound "item.trident.return" from master category with pitch 0.6 at player's location
                set {RGammo.%player%} to 1
                set {reloading.%player%} to false

on damage:
    event-projectile is egg
    {bulletegg.%shooter%} = 6
    damage victim by 20 hearts
 

 

Edited by CraftE_C
Link to comment
Share on other sites

Thanks for this, but a few optimizations you should change:

Make different guns do different damage

Take out some of the randomness, maybe skip every other one or something, It seems unnecessarily long and unneeded.

Use functions to clean up the code and add randomness to more wepons by plugining in an integer (i.e. 

function randomness(i: integer) :: string:
#code here to get a randomness as a up/down and left/right integer. 
#it would use the sent integer to apply a level of randomness (0 for none), 
#then return the 2 integers (this may have to be 2 functions idk) 
#this should help clean up code.

 Using functions should allow you to much easier add more weapons.

also pls use arrows or snowballs as the projectile kthx

Edited by quick007

 

 

image.png

image.png

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...