/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <[email protected]>
Matthias Butz <[email protected]>
Jan Christian Meyer <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Boss Quest(Player NPC)
Located in FreeMarket (910000000)
*/
//Chairs
var mil35 = new Array(3010007,3010008,3010011,3010013,3010014,3010018,3010040,3010041,3010045,3010057,3010063,3010046,3010047,3010043,3010071,3010085,3010098,3010073,3010099); // Clean Items 2k Leaf + 50mBPQ
//Mounts
var mil50 = new Array(1912000,1902000,1902001,1902002,1912005,1902005,1902006,1902007,1912011,1902015,1902016,1902017,1902018);
var status = 0;
var prize;
var chosen;
function numberFormat(nStr,prefix){
var prefix = prefix || '';
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) x1 = x1.replace(rgx, '$1' + ',' + '$2');
return prefix + x1 + x2;
}
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1)
cm.dispose();
else {
if (mode == 0) {
cm.sendOk("Come back when you next want to participate in the Boss Quest!");
cm.dispose();
return;
}
if (mode == 1)
status++;
else
status--;
if (status == 0) {
var sendStr = "#fUI/UIWindow.img/BetaEdition/BetaEdition#\r\nHello! I can offer you access to the Boss Quest!";
cm.sendNext(sendStr);
}
else if (status == 1) {
chosen = 0;
cm.sendSimple("What would you like to do? #b\r\n#L0#Start the Boss Quest#l\r\n#L1#Trade your Boss Quest Points#l");
}
else if (status == 2) {
if (selection == 0) {
if (cm.getParty() == null) {
cm.sendOk("To begin the Boss Quest you must be in a party, either create one or join your friend's.");
cm.dispose();
return;
}
else if (!cm.isLeader()) {
cm.sendOk("You aren't the leader of your party! If you want to begin the Boss Quest, please tell the leader to talk to me.");
cm.dispose();
return;
}
else {
var em = cm.getEventManager("BossQuest");
if (em == null)
cm.sendOk("The Boss Quest is currently unavailable.");
else {
var party = cm.getParty().getMembers();
var mapId = cm.getPlayer().getMapId();
var minimum = 50;
var inMap = true;
var canRepeat = true;
var canEnter = true;
var badRepeat;
var badEnter;
var it = party.iterator();
while (it.hasNext()) {
var cPlayer = it.next();
if (cPlayer.getMapid() != mapId) {
inMap = false;
}
}
if (inMap == false) {
cm.sendOk("Please make sure all the members of your party are in the map!");
cm.dispose();
}
else {
var iterator = party.iterator();
while (iterator.hasNext()) {
var member = iterator.next();
if (member.getPlayer().getLevel() <= 50) {
canEnter = false;
}
}
if (canEnter == true) {
em.startInstance(cm.getParty(), cm.getPlayer().getMap(), true);
} else {
cm.sendOk("Please make sure all the members of your party are level 120 and above!");
cm.dispose();
}
}
}
cm.dispose();
return;
}
} else if (selection == 1) {
cm.sendSimple("You currently have #b" + numberFormat(cm.getPlayer().getBossPoints()) + "#k Boss Quest Points! \r\nI can trade some of my items for your Boss Quest Points and Maple Leafs."+
"Which section would you like to visit?"+
"#b\r\n#L0#Chairs!#l" +
"\r\n#L1#Belts!#l" +
"\r\n#L2#Mounts!#l");
}
} else if (status == 3) {
if (selection == 0) {
cm.sendSimple("#rPlease check your inventory before using it as there will be NO refund given if your inventory is full and you didn't get that item.\r\n#k#L0#Click Me to proceed!#l");
chosen = 0;
} else if (selection == 1) {
cm.sendSimple("#rPlease check your inventory before using it as there will be NO refund given if your inventory is full and you didn't get that item.\r\n#k#L0#Click Me to proceed!#l");
chosen = 1;
} else if (selection == 2) {
cm.sendSimple("#rPlease check your inventory before using it as there will be NO refund given if your inventory is full and you didn't get that item.\r\n#k#L0#Click Me to proceed!#l");
chosen = 2;
}
} else if (status == 4) {
var quantity;
var selStr;
if (chosen == 0) {
if (selection == 0) {
prize = 0;
selStr = "Okay, all of these costs 35,000,000 BossQuest Points\r\nWhich prize would you like to trade your Boss Quest Points for?\r\n#b";
for (var i = 0; i < mil35.length; i++)
selStr += "#L" + i + "##v" + mil35[i] + "##l #z" + mil35[i] + "##l\r\n";
cm.sendSimple(selStr);
}
} else if (chosen == 1) {
if (selection == 0) {
prize = 1;
cm.sendSimple ("Okay, all of these have different prices" +
"\r\n#rPlease note that you will NOT get an upgraded one if you already have one in your inventory! #k" +
"#k\r\n#L11#Make All Stats 2500 #i1132000#, (250,000,000 BossQuest Points)" +
"#k\r\n#L12#Make All Stats 5000 #i1132001#, (500,000,000 BossQuest Points)" +
"#k\r\n#L13#Make All Stats 7500 #i1132002#, (750,000,000 BossQuest Points)" +
"#k\r\n#L14#Make All Stats 13337 #i1132003#, (900,000,000 BossQuest Points)" +
"#k\r\n#L15#Make All Stats 32767#i1132004#, (2,000,000,000 BossQuest Points)");
}
} else if (chosen == 2) {
if (selection == 0) {
prize = 2;
selStr = "Okay, all of these cost 50,000,000 BossQuest Points\r\n"+
"#rPlease note that you will disconnect if you equip a higher level mount that you!#k\r\n";
for (var i = 0; i < mil50.length; i++) {
selStr += "#L" + i + "##v" + mil50[i] + "##l #z" + mil50[i] + "# \r\n";
}
cm.sendSimple(selStr);
}
}
} else if (status == 5) {
var quantity = 1;
var win;
if (prize == 0) {
if (cm.getPlayer().getBossPoints() < 35000000) {
cm.sendOk("You do not have #b35,000,000#k Boss Quest Points to trade with. Sorry!");
cm.dispose();
return;
}
var win = mil35[selection];
cm.getPlayer().setBossPoints(cm.getPlayer().getBossPoints() - 35000000);
cm.gainItem(win, quantity);
} else if (prize == 1) {
if (selection == 11) {
if (cm.getPlayer().getBossPoints() > 250000000) {
cm.getPlayer().gainBossPoints(-250000000);
if (cm.canHold(1132000)) {
var equip = Packages.server.MapleItemInformationProvider.getInstance().getEquipById(1132000);
equip.setStr(2500);
equip.setDex(2500);
equip.setInt(2500);
equip.setLuk(2500);
equip.setWatk(25);
equip.setMatk(25);
cm.getPlayer().getInventory(Packages.client.MapleInventoryType.EQUIP).addItem(equip);
cm.reloadChar();
cm.dispose();
} else {
cm.sendOk("Your inventory is full.");
}
cm.dispose();
}
} else if (selection == 12) {
if (cm.getPlayer().getBossPoints() > 500000000) {
cm.getPlayer().gainBossPoints(-500000000);
if (cm.canHold(1132001)) {
var equip = Packages.server.MapleItemInformationProvider.getInstance().getEquipById(1132001);
equip.setStr(5000);
equip.setDex(5000);
equip.setInt(5000);
equip.setLuk(5000);
equip.setWatk(50);
equip.setMatk(50);
cm.getPlayer().getInventory(Packages.client.MapleInventoryType.EQUIP).addItem(equip);
cm.reloadChar();
cm.dispose();
} else {
cm.sendOk("Your inventory must be full or you do not have enough BossPoints.");
}
cm.dispose();
}
} else if (selection == 13) {
if (cm.getPlayer().getBossPoints() > 750000000) {
cm.getPlayer().gainBossPoints(-750000000);
if (cm.canHold(1132002)) {
var equip = Packages.server.MapleItemInformationProvider.getInstance().getEquipById(1132002);
equip.setStr(7500);
equip.setDex(7500);
equip.setInt(7500);
equip.setLuk(7500);
equip.setWatk(75);
equip.setMatk(75);
cm.getPlayer().getInventory(Packages.client.MapleInventoryType.EQUIP).addItem(equip);
cm.reloadChar();
cm.dispose();
} else {
cm.sendOk("Your inventory is full.");
}
cm.dispose();
}
} else if (selection == 14) {
if (cm.getPlayer().getBossPoints() > 900000000) {
cm.getPlayer().gainBossPoints(-900000000);
if (cm.canHold(1132003)) {
var equip = Packages.server.MapleItemInformationProvider.getInstance().getEquipById(1132003);
equip.setStr(13337);
equip.setDex(13337);
equip.setInt(13337);
equip.setLuk(13337);
equip.setWatk(80);
equip.setMatk(80);
cm.getPlayer().getInventory(Packages.client.MapleInventoryType.EQUIP).addItem(equip);
cm.reloadChar();
cm.dispose();
} else {
cm.sendOk("Your inventory is full.");
}
cm.dispose();
}
} else if (selection == 15) {
if (cm.getPlayer().getBossPoints() < 2000000000) {
cm.sendOk("You do not have enough BossPoints to purchase this item.");
cm.dispose();
return;
cm.getPlayer().gainBossPoints(-2000000000);
if (cm.canHold(1132004)) {
var equip = Packages.server.MapleItemInformationProvider.getInstance().getEquipById(1132004);
equip.setStr(32767);
equip.setDex(32767);
equip.setInt(32767);
equip.setLuk(32767);
equip.setWatk(100);
equip.setMatk(100);
cm.getPlayer().getInventory(Packages.client.MapleInventoryType.EQUIP).addItem(equip);
cm.reloadChar();
cm.sendOk("You have been awarded with your prize. I hope you are pleased! Good luck with your future ventures into The Boss Quest.");
} else {
cm.sendOk("Your inventory is full.");
}
cm.dispose();
}
} else if (prize == 2) {
if (cm.getPlayer().getBossPoints() < 50000000) {
cm.sendOk("You do not have #b50,000,000#k Boss Quest Points to trade with. Sorry!");
cm.dispose();
return;
var win = mil50[selection];
cm.gainItem(4001126, -3000);
cm.getPlayer().setBossPoints(cm.getPlayer().getBossPoints() - 50000000);
cm.gainItem(win, quantity);
}
cm.sendOk("You have been awarded with your prize. I hope you are pleased! Good luck with your future ventures into The Boss Quest.");
cm.dispose();
return;
}
}
}
}
}