Spawn 5 zombies at a time

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

Mattllama987

Active Member
Aug 5, 2018
225
7
18
24
Hi, im adding custom mobs to my server, and im adding Easy, Medium and hard mobs. Im trying to makit so it only spawn like 5 mobs at a time. How can i make it so it will spawn 5 zombies at a time, and not anymore. Ive already started on it, and its not working the best. Sometimes it wont even spawn the zombies, and sometimes it spawns more than 5. Its like a 50/50 chance it will work. If anyone knows how to fix this, please let me know ASAP.

Thanks!
~Matt

CODE:

Code:
every 5 seconds:
    loop 5 times:
        set {var} to random element out of {easymobs::*}
        if {maxspawn} is less than or equal to 5:
            spawn adult zombie at {var}
            add 1 to {maxspawn}
            set name of last spawned zombie to "&cBrute Zombie"
            set tool of last spawned zombie to iron sword of sharpness 1 named "&cBrute sword"
            equip last spawned zombie with iron helmet of protection 1
            equip last spawned zombie with iron chestplate of protection 1
            equip last spawned zombie with iron leggings of protection 1
            equip last spawned zombie with iron boots of protection 1
on death of adult zombie:
    if attacker is a player:
        if "%region at attacker%" contains "night":
            remove 1 from {maxspawn}
 
Maybe this would work?

Code:
every 5 seconds:
    loop 5 times:
        if {maxspawn} is less than 5:
            add 1 to {maxspawn}
            set {_var} to random element out of {easymobs::*}
            spawn adult zombie at {_var}
            set name of last spawned zombie to "&cBrute Zombie"
            set tool of last spawned zombie to iron sword of sharpness 1 named "&cBrute sword"
            equip last spawned zombie with iron helmet of protection 1
            equip last spawned zombie with iron chestplate of protection 1
            equip last spawned zombie with iron leggings of protection 1
            equip last spawned zombie with iron boots of protection 1
        else:
            stop
on death of adult zombie:
    if attacker is a player:
        if "%region at attacker%" contains "night":
            remove 1 from {maxspawn}
 
Thank you for responding to me! But thats kinda doing the same thing. It only spawned 4, and then i killed one, and now there are like 8 zombies when there should be 5
 
Try this and look if it only removes 1 from {maxspawn}, when a zombie dies.

Code:
on load:
    set {maxspawn} to 0

every 5 seconds:
    loop 5 times:
        if {maxspawn} is less than 5:
            add 1 to {maxspawn}
            set {_var} to random element out of {easymobs::*}
            spawn adult zombie at {_var}
            set name of last spawned zombie to "&cBrute Zombie"
            set tool of last spawned zombie to iron sword of sharpness 1 named "&cBrute sword"
            equip last spawned zombie with iron helmet of protection 1
            equip last spawned zombie with iron chestplate of protection 1
            equip last spawned zombie with iron leggings of protection 1
            equip last spawned zombie with iron boots of protection 1
        else:
            stop
on death of adult zombie:
    if attacker is a player:
        if "%region at attacker%" contains "night":
            remove 1 from {maxspawn}
            send "You killed a zombie. Removed 1 from {maxspawn} which is now %{maxspawn}%" to attacker
 
It does remove 1 from the {maxspawn} yeah. But its also removing 1 if i kill a baby zombie. Im making it if you smack a zombie, it will spawn like 4 baby zombies around it. I the baby zombies are what might be messing it up
[doublepost=1590524074,1590523998][/doublepost]Also, its like a chance to spawn them. It doesnt 100% spawn them everytime.
 
Try and output {_var} and see if the zombies spawn somewhere far away or some other weird location
 
<none> means that the location of the zombie is set to <none>. That would result in it not spawning.
 
Yeah. Im just redoing my spawn set, and spawning, and now they arnt even spawning. It send the message that they should be spawning, but they arnt.

UPDATED CODE:

Code:
command /mobspawn [<text>] [<text>]:
    usage: &aUse /mobdspawn <zombie> <number>%nl%&aUse /mobspawn <list>
    trigger:
        if player has permission "mob.spawn":
            if arg-1 isn't set:
                send "&aUse /mobdspawn <zombie> <number>%nl%&aUse /mobspawn <list>"
            if arg-1 is "zombie":
                if {zombiespawn::*} contains arg-2:
                    send "&cThat spawn point exists!"
                    send "&aUse /mobspawn list, to see the spawns!"
                else:
                    set {zombiespawn1::%arg-2%} to location of player
                    add arg-2 to {zombiespawn::*}
                    send "&cYou set a spawn for zombies named &a%arg-2%"
            if arg-1 is "list":
                send "&a%{zombiespawn::*}%"
            if arg-1 is "delete":
                remove arg-2 from {zombiespawn::*}
                send "&aYou removed &c%arg-2%&a from the spawn list of zombie!"
command /test2:
    trigger:
        set {_var} to random element out of {zombiespawn::*}
        spawn adult zombie at {_var}
        send "&7Spawned zombie at &a%{_var}%"
[doublepost=1590595788,1590595618][/doublepost]Ok, i think i might have fixed it. Will let you know how its going :emoji_slight_smile:
 
in the command /test2 you used {zombiespawn::*} as the list of locations, while in /mobspawn you put the location into {zombiespawn1::%arg-2%}
 
Yeah, i got it figured out :emoji_slight_smile: Im having a little problem with attacking baby zombies. When i hit a adult zombie, it would spawn the bay zombies around that zombie. But if i hit a baby zombie, it can spawn more baby zombies. Is there a way to fix it?

Code:
on damage of adult zombie:
    if victim is adult zombie:
        if "%region at attacker%" contains "night":
            set {zombie::%attacker%} to random integer between 1 and 3
            if {zombie::%attacker%} = 1:
                if victim is adult zombie:
                    send "&c&lBrute Zombie: &7Do no challenge me to a fight, for you might lose!" to attacker
                    set {var::%attacker%} to random integer between 1 and 5
                else:
                    stop
            if {var::%attacker%} = 1:
                if victim is adult zombie:
                    spawn 1 baby zombie at block north victim
                    set name of last spawned baby zombie to "&cBrute Minion"
                    equip last spawned baby zombie with iron helmet of protection 1
                    set tool of last spawned baby zombie to iron sword of sharpness 1 named "&cMinion sword"
                    spawn 1 baby zombie at block east victim
                    set name of last spawned baby zombie to "&cBrute Minion"
                    equip last spawned baby zombie with iron helmet of protection 1
                    set tool of last spawned baby zombie to iron sword of sharpness 1 named "&cMinion sword"
                    spawn 1 baby zombie at block south of victim
                    set name of last spawned baby zombie to "&cBrute Minion"
                    equip last spawned baby zombie with iron helmet of protection 1
                    set tool of last spawned baby zombie to iron sword of sharpness 1 named "&cMinion sword"
                    spawn 1 baby zombie at block west victim
                    set name of last spawned baby zombie to "&cBrute Minion"
                    equip last spawned baby zombie with iron helmet of protection 1
                    set tool of last spawned baby zombie to iron sword of sharpness 1 named "&cMinion sword"
                    send "&c&lBrute Zombie: &7Arise, my minions!" to attacker
                    set {var::%attacker%} to 0
                else:
                    stop
    else:
        stop
 
Status
Not open for further replies.