Downloads containing Condemned.mut

Downloads
Name Author Game Mode Rating
JJ2+ Only: Condemned Violet CLM Mutator N/A Download file

File preview

  1. #pragma description "Variant on LRS. One or more players are placed randomly on the red team, meaning they are Condemned, and timers count down next to their names. If a player's timer runs out, they are removed from the game. A condemned (red) player may roast a normal (blue) player to swap both their teams. Best played with a low max health, so people die a lot."
  2.  
  3. bool AtLeastOneRoast = false;
  4.  
  5. void onRoast(jjPLAYER@ victim, jjPLAYER@ killer) {
  6.         if (jjIsServer) {
  7.                 AtLeastOneRoast = true;
  8.                 if (victim.team == TEAM::BLUE && killer !is victim) {
  9.                         jjChat("/swap " + (victim.playerID + 1) + " red");
  10.                         jjChat("/swap " + (killer.playerID + 1) + " blue");
  11.                 }
  12.         }
  13. }
  14.  
  15. jjTEXTAPPEARANCE Monospaced(STRING::NORMAL);
  16. void onLevelLoad() {
  17.         Monospaced.monospace = true;
  18.         Monospaced.spacing = 8;
  19. }
  20.  
  21. array<int> Timers(32, 200);
  22.  
  23. bool onDrawGameModeHUD(jjPLAYER@, jjCANVAS@ canvas) {
  24.         const int x = 4;
  25.         int y = 11;
  26.         for (int i = 0; i < 32; ++i) {
  27.                 const jjPLAYER@ other = jjPlayers[i];
  28.                 if (other.isInGame) {
  29.                         canvas.drawString(x, y, (other.teamRed ? "||" : "|||") + formatInt(i + 1, "0", 2) + " " + other.name.substr(0,3), STRING::SMALL, Monospaced);
  30.                         canvas.drawRectangle(x + 58, y - 8, Timers[i] / 2, 10, !other.teamRed ? 34 : 25);
  31.                         if (other.isLocal) //draw an orange > to mark localness, so you can find your timer easily
  32.                                 canvas.drawSprite(x - 8, y - 10, ANIM::FONT, 1, '>'[0] - 32, 1, SPRITE::SINGLEHUE, 40);
  33.                         y += 16;
  34.                 }
  35.         }
  36.         return true;
  37. }
  38.  
  39. void onLevelBegin() {
  40.         if (jjIsServer) {
  41.                 if (jjGameCustom != GAME::FR)
  42.                         jjChat("/fr");
  43.                 jjChat("/joinersspectate on");
  44.                 jjChat("/spectating off");
  45.                 if (!jjPlayers[0].isIdle) {
  46.                         if (jjPlayers[0].isSpectating)
  47.                                 jjChat("/forcespectate 1 off");
  48.                         if (jjPlayers[0].team != TEAM::BLUE)
  49.                                 jjChat("/swap 1 blue");
  50.                 }
  51.                 jjPrint("****     " + jjLevelName + " (" + jjLevelFileName + ") Condemned.mut");
  52.         } else {       
  53.                 jjSTREAM packet;
  54.                 for (int i = 0; i < jjLocalPlayerCount; ++i)
  55.                         packet.push(uint8(jjLocalPlayers[i].playerID));
  56.                 jjSendPacket(packet);
  57.         }
  58. }
  59. void onReceive(jjSTREAM &in packet, int fromClientID) {
  60.         if (jjIsServer) {
  61.                 if (!AtLeastOneRoast)
  62.                         while (!packet.isEmpty()) {
  63.                                 uint8 playerID;
  64.                                 packet.pop(playerID);
  65.                                 const jjPLAYER@ player = jjPlayers[playerID];
  66.                                 if (player.clientID == fromClientID) {
  67.                                         if (player.isSpectating)
  68.                                                 jjChat("/forcespectate " + (playerID + 1) + " off");
  69.                                         if (player.team != TEAM::BLUE)
  70.                                                 jjChat("/swap " + (playerID + 1) + " blue");
  71.                                 } else
  72.                                         return;
  73.                         }
  74.         } else {
  75.                 while (!packet.isEmpty()) {
  76.                         uint8 playerID;
  77.                         packet.pop(playerID);
  78.                         uint8 time;
  79.                         packet.pop(time);
  80.                         Timers[playerID] = time;
  81.                 }
  82.         }
  83. }
  84.  
  85. array<const jjPLAYER@> GetTeamPlayers(TEAM::Color team) {
  86.         array<const jjPLAYER@> result;
  87.         for (uint i = 0; i < 32; ++i) {
  88.                 jjPLAYER@ possible = jjPlayers[i];
  89.                 if (possible.isInGame && possible.team == team)
  90.                         result.insertLast(possible);
  91.         }
  92.         return result;
  93. }
  94.  
  95. void onMain() {
  96.         if (jjIsServer) {
  97.                 if ((jjGameState == GAME::STARTED || jjGameState == GAME::OVERTIME) && jjGameTicks % 21 == 20) {
  98.                         array<const jjPLAYER@>@ red = GetTeamPlayers(TEAM::RED);
  99.                         for (uint i = 0; i < red.length; ++i) { //should be at most 1...
  100.                                 const jjPLAYER@ player = red[i];
  101.                                 if ((Timers[player.playerID] -= (jjGameState == GAME::STARTED ? 1 : 2)) <= 0) {
  102.                                         jjChat("/forcespectate " + (player.playerID + 1) + " on");
  103.                                         jjPrint("**** " + player.name + " eliminated.");
  104.                                         jjAlert(player.name + " is out!", true, STRING::MEDIUM);
  105.                                 }
  106.                         }
  107.                        
  108.                         jjSTREAM packet;
  109.                         for (uint8 i = 0; i < 32; ++i) {
  110.                                 if (jjPlayers[i].isInGame) {
  111.                                         packet.push(i);
  112.                                         if (Timers[i] < 0)
  113.                                                 packet.push(uint8(0));
  114.                                         else
  115.                                                 packet.push(uint8(Timers[i]));
  116.                                 }
  117.                         }
  118.                         if (packet.getSize() <= 2) { //at most one player alive
  119.                                 if (packet.getSize() == 2) { //exactly one player alive
  120.                                         uint8 playerID;
  121.                                         packet.pop(playerID);
  122.                                         jjPrint("**** " + jjPlayers[playerID].name + " wins.");
  123.                                         jjAlert(jjPlayers[playerID].name + " wins!", true, STRING::MEDIUM);
  124.                                 }
  125.                                 jjChat("/stop");
  126.                                 for (uint i = 0; i < 32; ++i)
  127.                                         Timers[i] = 200;
  128.                                 AtLeastOneRoast = false;
  129.                                 return;
  130.                         }
  131.                         jjSendPacket(packet);
  132.                        
  133.                         if (int(GetTeamPlayers(TEAM::RED).length) <= (int(GetTeamPlayers(TEAM::BLUE).length) - 1) / 4) {
  134.                                 int minimumRoasts = 9999;
  135.                                 array<const jjPLAYER@> contenders;
  136.                                 for (uint i = 0; i < 32; ++i) {
  137.                                         const jjPLAYER@ possible = jjPlayers[i];
  138.                                         if (possible.isInGame && possible.team == TEAM::BLUE) {
  139.                                                 if (possible.roasts < minimumRoasts) {
  140.                                                         minimumRoasts = possible.roasts;
  141.                                                         contenders.resize(0);
  142.                                                 }
  143.                                                 if (possible.roasts == minimumRoasts) { //including the above case
  144.                                                         contenders.insertLast(possible);
  145.                                                 }
  146.                                         }
  147.                                 }
  148.                                 if (contenders.length != 0) {
  149.                                         const jjPLAYER@ loser = contenders[jjRandom() % contenders.length];
  150.                                         if (AtLeastOneRoast)
  151.                                                 jjAlert(loser.name + " had the fewest roasts...", true, STRING::MEDIUM);
  152.                                         jjChat("/swap " + (loser.playerID + 1) + " red");
  153.                                 }
  154.                         }
  155.                 }
  156.         }
  157. }
  158.  
  159. uint TimeTopLeft = 0;
  160. void onPlayer(jjPLAYER@ player) {
  161.         if (player.health > 0 && int(player.xPos) / 32 <= 0 && int(player.yPos) / 32 <= 0 && player.warpID == 0) {
  162.                 if (++TimeTopLeft % 280 == 250) {
  163.                         for (int x = jjLayerWidth[4]; --x >= 0;)
  164.                         for (int y = jjLayerHeight[4]; --y >= 0;) {
  165.                                 const uint8 event = jjEventGet(x,y);
  166.                                 if (event == AREA::JAZZSTART || event == AREA::MPSTART) {
  167.                                         player.warpToTile(x,y);
  168.                                         return;
  169.                                 }
  170.                         }
  171.                 }
  172.         } else TimeTopLeft = 0;
  173. }