Function to Mob Spawn depending on Room teleport

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

Jerooski

Member
Apr 19, 2020
16
0
0
25
So I wanna make it so custom mobs spawn in set locations depending on the room the players enter.

For example if player Steve gets teleported to room 1, mobs spawn at locations A & B of the room 1.
then Steve moves to room 2, mobs spawn at locations A & B of room 2.

The thing is room teleport is random and have over 30 rooms, how could I make it into a function so it detects what room player is teleporting to and just spawns the mobs in the set locations of that same room.

(I have already set the rooms locations and have no problem with that)
I'm quite lost and just have this, what would be the best way to store those mobs locations and spawn them on point A and B depending on the room.

Code:
set {_roomtp} to a random integer between 1 and 30
teleport player to {spawn.room%{_roomtp}%}
run function mobSpawn("moblocation", "room%{_roomtp}%")


function mobSpawn(m: text, r: text):
    if {_r} is "room1":
        spawn 1 adult zombie at location {_m1}
        set name of last spawned entity to "&2Death Miner &7&o%player%"
        set health of last spawned entity to 10
        set {_chest} to leather chestplate
        dye {_chest} (205, 89, 255)
        equip last spawned entity with {_chest}
        equip last spawned entity with chain leggings
        equip last spawned entity with leather boots
        set tool of last spawned entity to stone pickaxe
        spawn 1 adult zombie at location {_m2}
        set name of last spawned entity to "&2Death Miner &7&o%player%"
        set health of last spawned entity to 10
        set {_chest} to leather chestplate
        dye {_chest} (205, 89, 255)
        equip last spawned entity with {_chest}
        equip last spawned entity with chain leggings
        equip last spawned entity with leather boots
        set tool of last spawned entity to stone pickaxe
 
Try setting a variable after the player has been teleported to the room to then have the zombies spawn at a location according to that variable.
 
Status
Not open for further replies.