// @Author Groat
// Boss Quest
importPackage(net.sf.odinms.world);
importPackage(net.sf.odinms.client);
var exitMap;
var instanceId;
var monster;
monster = new Array(
3220000, // Stumpy,
9300003, // Slime King
4130103, // Rombot
9300012, // Alishar
8220001, // Yeti on Skis
8220000, // Elliza
9300119, // Lord Pirate
9300152, // Angry Franken Lloyd
9300039, // Papa Pixie
9300032, // Knight Statue B
9300028, // Ergoth
9400549, // Headless Horseman
8180001, // Griffey
8180000, // Manon
8500001, // Papulatus
9400575, // Big Foot
9400014, // Black Crow
8800002, // Zakum Body 3
9400121, // Female Boss
9400300 // The Boss
);
function init() {
}
function monsterValue(eim, mobId) {
return 1;
}
function setup(partyid) {
exitMap = em.getChannelServer().getMapFactory().getMap(200000000);
var instanceName = "BossQuest" + partyid;
var eim = em.newInstance(instanceName);
var mf = eim.getMapFactory();
var map = mf.getMap(240060200, false, true, false);
map.toggleDrops();
eim.setProperty("points", 0);
eim.setProperty("monster_number", 0);
eim.schedule("beginQuest", 5000);
return eim;
}
function playerEntry(eim, player) {
var map = eim.getMapInstance(240060200);
player.changeMap(map, map.getPortal(0));
}
function playerDead(eim, player) {
}
function playerRevive(eim, player) {
player.setHp(player.getMaxHp());
playerExit(eim, player);
return false;
}
function playerDisconnected(eim, player) {
removePlayer(eim, player);
}
function leftParty(eim, player) {
playerExit(eim, player);
}
function disbandParty(eim) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
}
function playerExit(eim, player) {
var party = eim.getPlayers();
var dispose = false;
if (party.size() == 1) {
dispose = true;
}
eim.saveBossQuestPoints(parseInt(eim.getProperty("points")), player);
player.getClient().getSession().write(net.sf.odinms.tools.MaplePacketCreator.serverNotice(6, "[The Boss Quest] Your current points have been awarded, spend them as you wish. Better luck next time!"));
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
if (dispose) {
eim.dispose();
}
}
function removePlayer(eim, player) {
var party = eim.getPlayers();
var dispose = false;
if (party.size() == 1) {
dispose = true;
}
eim.saveBossQuestPoints(parseInt(eim.getProperty("points")), player);
eim.unregisterPlayer(player);
player.getMap().removePlayer(player);
player.setMap(exitMap);
if (dispose) {
eim.dispose();
}
}
function clearPQ(eim) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
}
function allMonstersDead(eim) {
var monster_number = parseInt(eim.getProperty("monster_number"));
var points = parseInt(eim.getProperty("points"));
var monster_end = java.lang.System.currentTimeMillis();
var monster_time = Math.round((monster_end - parseInt(eim.getProperty("monster_start"))) / 1000);
if (1200 - monster_time <= 0) points += monster_number * 10000;
else points += (monster_number * 10000) + ((1200 - monster_time) * (monster_number + 1));
monster_number++;
if (monster_number > 19) {
points += 10000000;
}
eim.setProperty("points", points);
eim.setProperty("monster_number", monster_number);
var map = eim.getMapInstance(240060200);
if (monster_number > 19) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
party.get(i).finishAchievement(2);
}
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.serverNotice(6, "[The Boss Quest] Congratulations! Your team has defeated all the bosses with " + points + " points!"));
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.serverNotice(6, "[The Boss Quest] The points have been awarded, spend them as you wish."));
disbandParty();
}
else {
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.serverNotice(6, "[The Boss Quest] Your team now has " + points + " points! The next boss will spawn in 10 seconds."));
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.getClock(10));
eim.schedule("monsterSpawn", 10000);
}
}
function monsterSpawn(eim) {
var mob = net.sf.odinms.server.life.MapleLifeFactory.getMonster(monster[parseInt(eim.getProperty("monster_number"))]);
var overrideStats = new net.sf.odinms.server.life.MapleMonsterStats();
if (parseInt(eim.getProperty("monster_number")) > 16) overrideStats.setHp(mob.getHp());
else overrideStats.setHp(mob.getHp() * 2);
overrideStats.setExp(mob.getExp() * 2);
overrideStats.setMp(mob.getMaxMp());
mob.setOverrideStats(overrideStats);
if (parseInt(eim.getProperty("monster_number")) > 16) mob.setHp(mob.getHp());
else mob.setHp(mob.getHp() * 2);
eim.registerMonster(mob);
var map = eim.getMapInstance(240060200);
map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(100, 100));
eim.setProperty("monster_start", java.lang.System.currentTimeMillis());
}
function beginQuest(eim) {
var map = eim.getMapInstance(240060200);
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.serverNotice(6, "[The Boss Quest] The creatures of the darkness are coming in 30 seconds. Prepare for the worst!"));
eim.schedule("monsterSpawn", 30000);
map.broadcastMessage(net.sf.odinms.tools.MaplePacketCreator.getClock(30));
}
function cancelSchedule() {
Capture the flag
*/
/*
* @Author Rich
*
* Capture the Flag - fail
*/
importPackage(net.sf.odinms.world);
importPackage(net.sf.odinms.client);
importPackage(net.sf.odinms.server.maps);
var exitMap;
var flagmap;
var instanceId;
var minPlayers = 1;
function init() {
instanceId = 1;
}
function monsterValue(eim, mobId) {
return 1;
}
function setup(eim) {
instanceId = em.getChannelServer().getInstanceId();
exitMap = em.getChannelServer().getMapFactory().getMap(100000000); // Loser's Exit Map
flagmap = em.getChannelServer().getMapFactory().getMap(1010000); // IDK LOL
exitMap2 = em.getChannelServer().getMapFactory().getMap(980000303); // Winner's Exit - why the hell would we need this?
var instanceName = "COF" + instanceId;
var eim = em.newInstance(instanceName);
var mf = eim.getMapFactory();
em.getChannelServer().addInstanceId();
var map = mf.getMap(980000301);//wutt
return eim;
}
function playerEntry(eim, player) {
var map = eim.getMapInstance(1010001); // waiting room before capture the flag
player.changeMap(map, map.getPortal(0));
player.getClient().getSession().write(net.sf.odinms.tools.MaplePacketCreator.getClock(600)); // It's just going to dissapear anyway :\
}
function playerDead(eim, player) {
if (player.getMap().hasTimer() == false) {
player.getClient().getSession().write(net.sf.odinms.tools.MaplePacketCreator.getClock(600));
player.getMap().setTimer(true);
}
}
function playerRevive(eim, player) {
if (eim.isLeader(player)) { //check for party leader
//boot whole party and end
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose2();
}
else { //boot dead player
// If only 5 players are left, uncompletable:
var party = eim.getPlayers();
if (party.size() <= minPlayers) {
for (var i = 0; i < party.size(); i++) {
playerExit(eim,party.get(i));
}
eim.dispose2();
}
else
playerExit(eim, player);
}
}
function playerDisconnected(eim, player) {
if (eim.isLeader(player)) { //check for party leader
//PWN THE PARTY (KICK OUT)
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
if (party.get(i).equals(player)) {
removePlayer(eim, player);
}
else {
playerExit(eim, party.get(i));
}
}
eim.dispose2();
}
else { //KICK THE D/CED CUNT
// If only 5 players are left, uncompletable:
var party = eim.getPlayers();
if (party.size() < minPlayers) {
for (var i = 0; i < party.size(); i++) {
playerExit(eim,party.get(i));
}
eim.dispose2();
}
else
playerExit(eim, player);
}
}
function leftParty(eim, player) {
// If only 5 players are left, uncompletable:
var party = eim.getPlayers();
if (party.size() <= minPlayers) {
for (var i = 0; i < party.size(); i++) {
playerExit(eim,party.get(i));
}
eim.dispose2();
}
else
playerExit(eim, player);
}
function disbandParty(eim) {
//boot whole party and end
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose2();
}
function playerExit(eim, player) {
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
}
function playerEntry2(eim, player) {
var map = eim.getMapInstance(1010000); // yay
player.changeMap(map, map.getPortal(0));
player.getClient().getSession().write(net.sf.odinms.tools.MaplePacketCreator.getClock(600)); // It's just going to dissapear anyway :\
}
//Those offline cuntts
function removePlayer(eim, player) {
eim.unregisterPlayer(player);
player.getMap().removePlayer(player);
player.setMap(exitMap);
}
function clearPQ(eim) {
//HTPQ does nothing special with winners
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose2();
}
function allMonstersDead(eim) {
//Open Portal? o.O
}
function cancelSchedule() {
}
function timeOut() {
var iter = em.getInstances().iterator();
while (iter.hasNext()) {
var eim = iter.next();
if (eim.getPlayerCount() > 0) {
var pIter = eim.getPlayers().iterator();
while (pIter.hasNext()) {
playerExit(eim, pIter.next());
}
}
eim.dispose2();
}
}