PHP Code:
/*Map: Monster Carnival Room 4 Lobby: mapt* Credits go to Thane Krios (alias: lfatelhighdef)*/
var status;
var coin = 4001129; // currency for summoning mobs
var startspiece = 4001254; // this is the item piece the NPC shall check to decide whether or not the PQ has started
// IMPORTANT
// Change it to some undroppable item so they cannot abuse respawning. And make sure to change Spiegelmann's removal of the item so that players do not keep the PQ starting item when they leave
// IMPORTANT
var map = 980000400; // map 2
var mapt = 980000300; // map 1
var starts = 0; // depending on what # starts is equal to will allow players to summon mobs, or have to continue waiting.
var finish; // depending on what value finish is, 0 = defeat and 1 = victory, will decide where the parties will go upon loss/defeat.
var leave; // this is set to 1 if there is only one party on either map. As a result, in the next status the NPC will know to warp the party out if they do not want to wait.
var players; // depending on what value this is will tell the NPC that both maps have a sufficient amount of people.
var mobs = [[9300128, 9300129, 9300130, 9300131, 9300132, 9300133, 9300134, 9300135, 9300136],[2,2,3,4,4,5,6,10,20,30],
["Brown Teddy", "Bloctopus", "Ratz", "Chronos", "Toy Trojan", "Tick-Tock", "Robo", "King Block", "Master Chronos", "Rombot"]]; // mobs, cost, name
// brown teddy, bloctopus, ratz, chronos, toy trojan, tick-tock, robo, king block, master chronos, rombot
function start() {
status = -1;
action(1,0,0);
}
function action(mode, type, selection) {
if (mode == -1) {
return;
cm.dispose();
} else if (mode == 0) {
status--;
} else {
status++;
}
if (status == 0) {
var party = cm.partyMembersInMap(); // # of party members in the player's map
var count = cm.getPlayerCount(map); // # of party members in variable map
var countt = cm.getPlayerCount(mapt); // # of party members in variable mapt
var mob = cm.getMonsterCount(map); // same thing as above, except checks the # of monsters in the map
var mobt = cm.getMonsterCount(mapt); // same thing as above sentence, but for different map
var yours = cm.getMapId(); // retrieves the player's map id... not sure why I still have it here. Didn't use it the entire script.
var your = cm.getMonsterCount(yours); // didn't use this the entire time.
(count == 0 || countt == 0 ? players = 0 : players = 1);
/* if the # of players in count (variable for # of players in "map") is = 0, or if the # of players in countt = 0, then set players = 0
Otherwise, in all other cases set players = 1. In shorter terms, when players = 0, there conditions for the PQ in terms of players have not been met. When
players = 1, then yes, this condition is met.*/
(!cm.haveItem(startspiece,1) ? starts = 0 : starts = 1);
/* if the player does not have the starting piece (the one that deems whether or not the PQ has begun), then set variable starts = 0. In all other cases set "starts" = 1
Basically, when starts = 0, the PQ has not begun. When starts = 1, then it has begun.*/
(cm.haveItem(startspiece,1) && cm.getMapId()==map && countt < 1 ? finish = 0 : cm.haveItem(startspiece,1) && cm.getMapId()==map && mob == 0 ? finish = 1 :
cm.haveItem(startspiece,1) && cm.getMapId()==mapt && count < 1 ? finish = 0 : cm.haveItem(startspiece,1) && cm.getMapId()==mapt && mobt == 0 ? finish = 1 : finish = -1);
/* THIS is what determines which party will win or lose.
1) (cm.haveItem(startspiece,1) && cm.getMapId()==map && countt < 1 ? finish = 0) -- this is the first bit you see. Basically, if the PQ has begun and the player is in
"map" and the number of players in the opposing map is = 0, then set finish = 0. (In other terms, if there are no players in the opposing map and the PQ has begun, that means
the player's party themselves have lost the PQ, and that the opposing party has won and therefore been warped out first.
2) (cm.haveItem(startspiece,1) && cm.getMapId()==map && mob == 0 ? finish = 1) -- This is the victory condition for the player's party. If the PQ has begun and they are in
the map "map", and the mob count in their map is = 0, then set their finish condition to VICTORY (AKA 1)
3) ( cm.haveItem(startspiece,1) && cm.getMapId()==mapt && count < 1 ? finish = 0) -- This is the defeat condition, however, on the OTHER map. If the PQ has begun and
their map is "mapt", and the player count in the opposing map is = 0, then set the player's party finish condition to DEFEAT (AKA 0)
4) (cm.haveItem(startspiece,1) && cm.getMapId()==mapt && mobt == 0 ? finish = 1) -- This is the victory condition. Again, it is applicable to the other map. If the PQ has
begun and their map is "mapt", and the mob count on "mapt" is = 0, then the player's party has finished their conditions to win and the party's finish condition is VICTORY
(AKA --> 1)
*/
if (cm.getParty() == null) { // if one does not have a party then they are kicked out from the PQ.
cm.warp(980000504);
cm.sendOk("You have been warped out due to not being in a party.");
cm.dispose();
} else if (!cm.haveItem(startspiece,1) && (mob > 0 || mobt > 0)) { // if the party does not have the startspiece, but the PQ has already begun
cm.givePartyItems(startspiece, 1, cm.getPartyMembers());
cm.mapMessage(5, "Your party has been updated to active. You will now be able to summon monsters.");
cm.dispose();
} else if (finish == 0) { // This is where the victory conditions settle in. If their victory condition is 0, (AKA Defeat), then warp them to the defeated map and send the defeat message
cm.warpParty(980000404);
cm.mapMessage(5, "Sorry! The enemy team has won the match. Please talk to Spiegelmann to gain your rewards!");
cm.dispose();
} else if (finish == 1) { // if they are the winners, then send them to the victory map and send the victory declaration
cm.warpParty(980000403);
cm.mapMessage(5, "Congratulations! You have won the carnival game! Please talk to Spiegelmann for a handsome reward for your participation!");
cm.dispose();
} else if (players == 0) { // When players == 0, it is parallel to stating that one of the maps do not meet the requirements for # of people.
leave = 1; // sets their leave status to 1
cm.sendYesNo("You must wait for an opposing party to enter before you can starts the PQ. Would you like to leave?\r\n\r\n#eChoosing to leave will exit your entire party.#n");
} else if (starts == 0) { // starts = 0, or in other wards, the PQ has not started. Basically starts only = 0 when players do not have the starting item the NPC gives when the PQ begins.
if (!cm.isLeader()) { // if you aren't the leader
cm.sendOk("Please wait for the leaders to begin the PQ. Both teams are ready and able-bodied to begin the game.");
cm.dispose();
} else if (!cm.haveItem(startspiece,1)) {
/* By elimination, the player who reaches this condition IS the leader.
If the leader does not have the start piece, then the PQ has not begun. Since we have fulfilled all the checks up to this point,
this means there are a sufficient amount of players to begin the PQ, the NPC will initiate the PQ by giving
everyone in the party the "startspiece" so that it can keep track of their progress*/
// the two following if statements below just summon mobs in both maps to begin the PQ. It also gives the party that initiated the PQ the startspiece.
if (cm.getMapId()==map) {
cm.givePartyItems(startspiece, 1, cm.getPartyMembers());
cm.mapMessage(5, "You have been given a Shiny Maple Coin. Do not drop this item. If you do, then you will be unable to spawn any more monsters.");
cm.summonMobAtPosition(9300133,3,-111,162);
cm.summonMobAtPosition(9300136,3,231,162);
cm.summonMobAtPosition(9300136,3,36,162);
cm.summonMobAtPosition(9300133,3,185,162);
cm.summonMobAtPosition(9300136,3,295,-138);
cm.summonMobAtPosition(9300133,3,115,-138);
cm.spawnMobOnDiffMap(mapt,9300133,3,-111,162);
cm.spawnMobOnDiffMap(mapt, 9300136,3,231,162);
cm.spawnMobOnDiffMap(mapt, 9300136,3,36,162);
cm.spawnMobOnDiffMap(mapt, 9300133,3,185,162);
cm.spawnMobOnDiffMap(mapt, 9300136,3,295,-138);
cm.spawnMobOnDiffMap(mapt, 9300133,3,115,-138);
cm.dispose();
} else {
cm.summonMobAtPosition(9300133,3,-111,162);
cm.summonMobAtPosition(9300136,3,231,162);
cm.summonMobAtPosition(9300136,3,36,162);
cm.summonMobAtPosition(9300133,3,185,162);
cm.summonMobAtPosition(9300136,3,295,-138);
cm.summonMobAtPosition(9300133,3,115,-138);
cm.spawnMobOnDiffMap(map,9300133,3,-111,162);
cm.spawnMobOnDiffMap(map, 9300136,3,231,162);
cm.spawnMobOnDiffMap(map, 9300136,3,36,162);
cm.spawnMobOnDiffMap(map, 9300133,3,185,162);
cm.spawnMobOnDiffMap(map, 9300136,3,295,-138);
cm.spawnMobOnDiffMap(map, 9300133,3,115,-138);
}
}
} else {
// THE classic infinite loop array. It increases variable "i" each time "i" is less than the length of the array and its sub arrays. Very useful for listing large amounts of items, mobs, or maps
txt = "These are the monsters that you can summon on the opposing map. You will spawn a total of #e21#n mobs on the other side each time you select a mob to spawn.";
for (var i = 0; i < mobs[0].length; i++)
txt += "\r\n#L"+i+"##o"+mobs[0][i]+"# - #b"+mobs[1][i]+"#k #i"+coin+"#";
cm.sendSimple(txt);
}
} else if (status == 1) {
if (leave == 1) { // If the party had wanted to leave earlier, this is where they get warped.
cm.warpParty(980000000);
cm.dispose();
} else if (!cm.haveItem(coin, mobs[1][selection])) { // if the # of coins the player has is insufficient to summon hte mob.
cm.sendOk("You cannot summon this monster, #b#o"+mobs[0][selection]+"##k. You are lacking #b"+(mobs[1][selection] - cm.haveItem(coin))+"#k #i"+coin+"#.");
cm.dispose();
} else {
// the checks below will determine where the monsters are summoned. If the player is in "map", then mobs will be spawned on "mapt". Same with vice versa. There is also a notice to their party that their teammate has just summoned more monsters.
if (cm.getMapId()==map) {
cm.mapMessage(5, ""+cm.getPlayer().getName+" has summoned 21 "+mobs[2][selection]+" on the enemy's side!");
cm.gainItem(coin, -mobs[1][selection]);
cm.spawnMobOnDiffMap(mapt, mobs[0][selection], 7, -207, 162);
cm.spawnMobOnDiffMap(mapt,mobs[0][selection], 7, 221, -138);
cm.spawnMobOnDiffMap(mapt, mobs[0][selection], 7, 232, 162);
cm.dispose();
} else {
cm.mapMessage(5, ""+cm.getPlayer().getName+" has summoned 21 "+mobs[2][selection]+" on the enemy's side!");
cm.gainItem(coin, -mobs[1][selection]);
cm.spawnMobOnDiffMap(map, mobs[0][selection], 7, -207, 162);
cm.spawnMobOnDiffMap(map,mobs[0][selection], 7, 221, -138);
cm.spawnMobOnDiffMap(map, mobs[0][selection], 7, 232, 162);
cm.dispose();
}
}
}
}