AJPlayz7

bossrush code

Nov 26th, 2021
1,130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //I'll just post how here in steps
  2. //1. go to your config file and add this:
  3.  
  4.   "BOSSRUSH": ["crasher", 3, "crasher", "crasher", "crasher"],
  5.  
  6. //2. go to your server file and if you have bots make sure to add this
  7.  
  8. case "bossrush":
  9. body.team = -1;
  10. body.color = 10
  11. break;
  12.  
  13. //3. under the make npcs function add this code
  14. //that should be it let me know if you have issues
  15.  
  16.         if (room.gameMode == "bossrush" || "rbossrush") {
  17.             let rounds = -1
  18.  
  19.             function spawnNextBoss() { //this function runs when a boss dies and signals to spawn the next one
  20.                 rounds++
  21.                 if (room.gameMode == "rbossrush") {
  22.                     room.maxFood /= 2
  23.                     room.nestFoodAmount /= 2
  24.                     if (rounds > 3) {
  25.                         room.enableFood = false
  26.                     }
  27.                 }
  28.                 if (rounds < c.BOSSRUSH.length) { //check if the game is over
  29.                     if (isNaN(c.BOSSRUSH[rounds])) { //check if the value is a entity to spawn or a multispawn #
  30.                         let o = new Entity(room.randomType('norm'))
  31.                         o.define(Class[c.BOSSRUSH[rounds]])
  32.                         o.team = -100
  33.                         sockets.broadcast("A " + o.label + " has been spawned!");
  34.                         o.ondeath = () => { //after this entity dies wait and spawn another
  35.                             sockets.broadcast("The next wave will start in 5 seconds.");
  36.                             setTimeout(() => {
  37.                                 spawnNextBoss()
  38.                             }, 5000)
  39.                         }
  40.                     } else { //if the input is a multispawn #, run # times and update the round value accordingly so we don't repeat bosses
  41.                         let bossesDefeated = 0
  42.                         for (let j = 1; j < 1 + c.BOSSRUSH[rounds]; j++) {
  43.                             let o = new Entity(room.randomType('norm'))
  44.                             o.define(Class[c.BOSSRUSH[j + rounds]])
  45.                             o.team = -100
  46.                             sockets.broadcast("A " + o.label + " has been spawned!");
  47.                             o.ondeath = () => { //after this entity dies wait and spawn another
  48.                                 bossesDefeated += 1
  49.                                 sockets.broadcast("A boss has been defeated, " + (c.BOSSRUSH[rounds] - bossesDefeated) + " to go!");
  50.                                 if (c.BOSSRUSH[rounds] == bossesDefeated) {
  51.                                     sockets.broadcast("The next wave will start in 5 seconds.");
  52.                                     setTimeout(() => {
  53.                                         rounds += c.BOSSRUSH[rounds]
  54.                                         spawnNextBoss()
  55.                                     }, 5000)
  56.                                 }
  57.                             }
  58.                         }
  59.                     };
  60.                 } else {
  61.                     sockets.broadcast("All bosses have been defeated!")
  62.                     setTimeout(() => {
  63.                         closeArena()
  64.                     }, 5000)
  65.                 }
  66.             }
  67.  
  68.             function waitForStart() {
  69.                 if (joinableServer == 2) {
  70.                     spawnNextBoss()
  71.                     sockets.broadcast("The game has started!")
  72.                 } else {
  73.                     setTimeout(() => {
  74.                         waitForStart()
  75.                     }, 1000)
  76.                 }
  77.             }
  78.             if (room.gameMode == "bossrush") {
  79.                 spawnNextBoss()
  80.             } else {
  81.                 waitForStart()
  82.             }
  83.  
  84.         }
  85.  
  86. //oh yeah also it works by putting in the name of the entity for the round in config list, or a number spawns the next x //items, x being number, for the round
  87. //so the list there has two rounds, one ends after a crasher is killed the second ends after 3 crashers
RAW Paste Data