Make arrows head in a random direction

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
Jan 28, 2017
23
1
0
53
Question: How can I make 100 arrows go to a random location
code_language.skript:
on leftclick with diamond:
    make player shoot a fireball
    set {_proj} to last spawned projectile
    wait 5 ticks
    loop all entities:
        if "%loop-entity-1%" = "fireball":
            send "%loop-entity-1%"
            set {_loc} to location of loop-entity-1
            delete loop-entity-1
            spawn a armor stand at {_loc}
            loop all blocks in radius 15 around {_loc}:
                add location of loop-block to {random.location.loop.blocks.meteor::*}
            loop all players:
                loop 100 times:
                    set {_number} to a random number between -180 and 180
                    set {_loc2} to a random element out of {random.location.loop.blocks.meteor::*}
                    change yaw of {_loc2} to {_number}
                    make last spawned armor stand shoot an arrow at speed 1 direction from {_loc} to {_loc2}
                    set {hit.%last spawned projectile%} to true
                    delete last spawned armor stand
[doublepost=1501935893,1501931658][/doublepost]Anyone? I really need this.
 
Question: How can I make 100 arrows go to a random location
code_language.skript:
on leftclick with diamond:
    make player shoot a fireball
    set {_proj} to last spawned projectile
    wait 5 ticks
    loop all entities:
        if "%loop-entity-1%" = "fireball":
            send "%loop-entity-1%"
            set {_loc} to location of loop-entity-1
            delete loop-entity-1
            spawn a armor stand at {_loc}
            loop all blocks in radius 15 around {_loc}:
                add location of loop-block to {random.location.loop.blocks.meteor::*}
            loop all players:
                loop 100 times:
                    set {_number} to a random number between -180 and 180
                    set {_loc2} to a random element out of {random.location.loop.blocks.meteor::*}
                    change yaw of {_loc2} to {_number}
                    make last spawned armor stand shoot an arrow at speed 1 direction from {_loc} to {_loc2}
                    set {hit.%last spawned projectile%} to true
                    delete last spawned armor stand
[doublepost=1501935893,1501931658][/doublepost]Anyone? I really need this.
wait 24 hours before bumping
 
Oh okay, oops.
[doublepost=1502020062,1501935981][/doublepost]Bump.
You can make a simple chance system, and set some custom variables, then pull a random variable to determine the direction of the arrow(s), and just simply push the last spawned projectile in the randomly pulled direction.
I could attempt to make this, let me know if you need an example!
 
I'd appreciate it if you could send me an example.
I never really mess with these kinds of things, so this is in a way, way out of my skript knowledge area, but in theory, in my head at least, this could work with tweaks here and there. Enjoy? xD
code_language.skript:
on leftclick with diamond:
    make player shoot a fireball
    set {_proj} to last spawned projectile
    wait 5 ticks
    loop all entities:
        if "%loop-entity-1%" = "fireball":
            send "%loop-entity-1%"
            set {_loc} to location of loop-entity-1
            delete loop-entity-1
        set {chance} to a random integer between 1 and 6:
            if {chance} is 1:
                set {dir} to "up"
            if {chance} is 2:
                set {dir} to "down"
            if {chance} is 3:
                set {dir} to "north"
            if {chance} is 4:
                set {dir} to "south"
            if {chance} is 5:
                set {dir} to "east"
            if {chance} is 6:
                set {dir} to "west"
        spawn an arrow at {_loc}:
            push last spawned projectile {dir} with force 5.0
Not saying this will work but this is my idea on a roughdraft of code. (the simple variable system and using it to determine which direction the arrow will be pushed)
 
I never really mess with these kinds of things, so this is in a way, way out of my skript knowledge area, but in theory, in my head at least, this could work with tweaks here and there. Enjoy? xD
code_language.skript:
on leftclick with diamond:
    make player shoot a fireball
    set {_proj} to last spawned projectile
    wait 5 ticks
    loop all entities:
        if "%loop-entity-1%" = "fireball":
            send "%loop-entity-1%"
            set {_loc} to location of loop-entity-1
            delete loop-entity-1
        set {chance} to a random integer between 1 and 6:
            if {chance} is 1:
                set {dir} to "up"
            if {chance} is 2:
                set {dir} to "down"
            if {chance} is 3:
                set {dir} to "north"
            if {chance} is 4:
                set {dir} to "south"
            if {chance} is 5:
                set {dir} to "east"
            if {chance} is 6:
                set {dir} to "west"
        spawn an arrow at {_loc}:
            push last spawned projectile {dir} with force 5.0
Not saying this will work but this is my idea on a roughdraft of code. (the simple variable system and using it to determine which direction the arrow will be pushed)
1. Don't use global variables because what's the point of saving them.
2. There's a much shorter way of doing this. Your code is just too unnecessarily long.

The code I provided below is an example of how you can push an arrow at a random location.
code_language.skript:
add north, south, east, west, northwest, northeast, southwest and southeast to {_directions::*}
spawn an arrow above {_loc} # you have to define the {_loc} variable
set {_push} to a random element out of {_directions::*}
push last spawned arrow {_push} at speed 1
 
1. Don't use global variables because what's the point of saving them.
2. There's a much shorter way of doing this. Your code is just too unnecessarily long.

The code I provided below is an example of how you can push an arrow at a random location.
code_language.skript:
add north, south, east, west, northwest, northeast, southwest and southeast to {_directions::*}
spawn an arrow above {_loc} # you have to define the {_loc} variable
set {_push} to a random element out of {_directions::*}
push last spawned arrow {_push} at speed 1
Thanks for the uh code refining but as I said, it wasn't something I'm good at xP
 
Status
Not open for further replies.