Find a place near the player to spawn a mob

  • 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.

Hosom

Member
Jul 10, 2017
22
0
1
27
Code:
command /test:
    trigger:
        loop blocks in radius whatever around player:
            if loop-block is air:
                if block above loop-block is air:
                    add loop-block's location to {_locs::*}
        set {_loc} to random element of {_locs::*}
        spawn a zombie at {_loc}

I found this in the forums, but it is not efficient.

If you set "whatever" to something more than 4, it crashes the server badly.

I just want to find a free spot near the player to spawn a player-like npc with skript-npc :emoji_slight_smile:
 
Unfortunately no.. I am trying to spawn an NPC behind the player, 10 or 20 blocks away. I don't need it to be in a random position, I could do also on a fixed position, but still dynamic and relative to player position. Behind him, some blocks away..
 
About 16 hours (morning for me) i will make a skript for that
[doublepost=1567835220,1567797418][/doublepost]
Code:
command /test:
    trigger:
        spawn a zombie at player's location
        hide last spawned entity from all players
        set {_e} to last spawned entity
        set {_loc} to {_e}'s location
        teleport {_e} 3 meters behind {_e}
        set {_blockat} to block at {_e}
        set {_e}'s name to "&6Spawned Zombie"
        teleport {_e} to location 29999999, 100, 29999999
        if {_blockat} is air:
            if the block above {_blockat} is air:
                if block under {_blockat} is ladder or air or vines:
                    while block under {_blockat} is ladder or air or vines:
                        teleport {_e} 1 meter under location of {_e}
                        set {_blockat} to location of {_e}
                spawn a zombie at ({_blockat})
        wait 3 ticks
        kill {_e}

on death:
    if victim is a zombie:
        if name of victim is "&6Spawned Zombie":
            clear drops

It kinda works.. Try it for your self
 
About 16 hours (morning for me) i will make a skript for that
[doublepost=1567835220,1567797418][/doublepost]
Code:
command /test:
    trigger:
        spawn a zombie at player's location
        hide last spawned entity from all players
        set {_e} to last spawned entity
        set {_loc} to {_e}'s location
        teleport {_e} 3 meters behind {_e}
        set {_blockat} to block at {_e}
        set {_e}'s name to "&6Spawned Zombie"
        teleport {_e} to location 29999999, 100, 29999999
        if {_blockat} is air:
            if the block above {_blockat} is air:
                if block under {_blockat} is ladder or air or vines:
                    while block under {_blockat} is ladder or air or vines:
                        teleport {_e} 1 meter under location of {_e}
                        set {_blockat} to location of {_e}
                spawn a zombie at ({_blockat})
        wait 3 ticks
        kill {_e}

on death:
    if victim is a zombie:
        if name of victim is "&6Spawned Zombie":
            clear drops

It kinda works.. Try it for your self


A bit hacky but it works! Thanks
 
Sry for only setting it to 3 blocks.. I was testing on small platform..
And do you want it to spawn in the air too?

Since I will spawn a citizen npc I just discovered that the y axis is not that important.. it should pathfind to the right y level. But a location on ground would be nice :emoji_slight_smile:
 
Status
Not open for further replies.