Implemented Kites, PlayerNPCs and C. Shop Surprise & Tweaked login

Added code support for Kites.
Reviewed concurrent access issues with pet autopot.
Addressed PlayerStorage issue where characters would not be properly deregistered from channel PlayerStorage in certain situations.
Implemented harp quest (questid 3314) because of reasons.
Added SFX to signalize KC/NLC subway departing/approaching.
Changed traveling time values to work similarly to GMS.
Properly developed the PlayerNPC feature in the source.
Added autodeployable PlayerNPC system and Hall of Fame.
Solved a glitch with NLC mayor's quiz questline that would allow a player to restart the quiz as many times one would see fit.
Added a custom server flag that allows overwriting the ToT 999 mobs to a new value (technically it doesn't overwrite, rather sets the player at quest start with 999 - n credited mobs).
Fixed permanent pets expiring after a while.
Added code support for Cash Shop Surprise item.
Reviewed login handler system as a whole, protecting many exposed flaws.
Solved a bug with ULTRA_THREE_SNAILS sometimes taking wrong etc shell from inventory.
This commit is contained in:
ronancpl
2018-05-19 14:28:06 -03:00
parent 80b1776ad3
commit fca7b2adaa
5747 changed files with 225411 additions and 12868 deletions

View File

@@ -1,33 +0,0 @@
// @Author: Resinate
var towns = new Array(800020120, 251010102, 260010201, 107000300, 200010300, 100040105, 100040106, 261030000, 110040000, 250010504, 240040401, 104000400, 222010310, 230040420, 230040420, 230020100, 105090310, 101030404, 250010304, 220050100, 220050000, 220050200, 221040301);
var spawns = new Array(6090002, 5220004, 3220001, 6220000, 8220000, 5220002, 5220002, 8220002, 5220001, 7220002, 8220003, 2220000, 7220001, 8510000, 8520000, 4220001, 8220008, 3220000, 7220000, 5220003, 5220003, 5220003, 6220001);
var x = new Array(560, 560, 645, 90, 208, 456, 474, -300, 200, 400, 0, 400, 0, 527, 138, 0, -626, 800, -300, -300, 0, 0, -4224);
var y = new Array(50, 50, 275, 119, 83, 278, 278, 180, 140, 540, 1125, 455, 33, -437, 138, 520, -604, 1280, 390, 1030, 1030, 1030, 776);
var mapObj;
var mobObj;
function init() {
scheduleNew();
}
function scheduleNew() {
setupTask = em.schedule("start", 0);
}
function cancelSchedule() {
if (setupTask != null)
setupTask.cancel(true);
}
function start() {
var time = (Math.floor(Math.random() * 10) + 10) * (60 * 1000);
for(var i = 0; i < towns.length; i++) {
mapObj = em.getChannelServer().getMapFactory().getMap(towns[i]);
mobObj = Packages.server.life.MapleLifeFactory.getMonster(spawns[i]);
if(mapObj.getMonsterById(spawns[i]) == null) {
mapObj.spawnMonsterOnGroundBelow(mobObj, new Packages.java.awt.Point(x[i],y[i]));
}
}
em.schedule("start", time);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 KiB

View File

@@ -1,3 +0,0 @@
Change reason: New NPC files uploaded in with misleading header.
Committed 2017-09-01 (Reworked Autoassigner & Hero's Will & Trade + Visual NX + New commands)

View File

@@ -1,5 +0,0 @@
Change reason: New NPC files uploaded in with misleading/missing header.
9000017.js: Introduced before repository started, around 2015-08-05 (extracted from mychanges_ptbr.txt @ "source" commit)
9000036.js: Introduced before repository started, around 2015-07-25 (extracted from mychanges_ptbr.txt @ "source" commit)
9000041.js: Committed 2016-07-18 (Instant sell NPC + new features)

View File

@@ -1,281 +0,0 @@
/*
* This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License 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/>.
*/
/**
* @author: Ronan
* @event: Sharenian Guild PQ
*/
var isPq = true;
var minPlayers = 1, maxPlayers = 30;
var minLevel = 1, maxLevel = 200;
var entryMap = 990000000;
var exitMap = 990001100;
var recruitMap = 101030104;
var clearMap = 990001101;
var minMapId = 990000000;
var maxMapId = 990001101;
var waitTime = 3;
var eventTime = 90; // 90 minutes
var lobbyRange = [0, 0];
function init() {
setEventRequirements();
}
function setLobbyRange() {
return lobbyRange;
}
function setEventRequirements() {
var reqStr = "";
reqStr += "\r\n Number of players: ";
if(maxPlayers - minPlayers >= 1) reqStr += minPlayers + " ~ " + maxPlayers;
else reqStr += minPlayers;
reqStr += "\r\n Level range: ";
if(maxLevel - minLevel >= 1) reqStr += minLevel + " ~ " + maxLevel;
else reqStr += minLevel;
reqStr += "\r\n Time limit: ";
reqStr += eventTime + " minutes";
em.setProperty("party", reqStr);
}
function setEventExclusives(eim) {
var itemSet = [1032033, 4001024, 4001025, 4001026, 4001027, 4001028, 4001029, 4001030, 4001031, 4001032, 4001033, 4001034, 4001035, 4001037];
eim.setExclusiveItems(itemSet);
}
function setEventRewards(eim) {
var itemSet, itemQty, evLevel, expStages;
evLevel = 1; //Rewards at clear PQ
itemSet = [];
itemQty = [];
eim.setEventRewards(evLevel, itemSet, itemQty);
expStages = []; //bonus exp given on CLEAR stage signal
eim.setEventClearStageExp(expStages);
}
function getEligibleParty(party) { //selects, from the given party, the team that is allowed to attempt this event
var eligible = [];
var hasLeader = false;
var guildId = 0;
if(party.size() > 0) {
var partyList = party.toArray();
for(var i = 0; i < party.size(); i++) {
var ch = partyList[i];
if(ch.isLeader()) {
guildId = ch.getGuildId();
break;
}
}
for(var i = 0; i < party.size(); i++) {
var ch = partyList[i];
if(ch.getMapId() == recruitMap && ch.getLevel() >= minLevel && ch.getLevel() <= maxLevel && ch.getGuildId() == guildId) {
if(ch.isLeader()) hasLeader = true;
eligible.push(ch);
}
}
}
if(!(hasLeader)) eligible = [];
return eligible;
}
function setup(level, lobbyid) {
var eim = em.newInstance("Guild" + lobbyid);
eim.setProperty("level", level);
eim.setProperty("guild", 0);
eim.setProperty("canJoin", 1);
eim.setProperty("statusStg1", -1);
eim.getInstanceMap(990000000).resetPQ(level);
eim.getInstanceMap(990000100).resetPQ(level);
eim.getInstanceMap(990000200).resetPQ(level);
eim.getInstanceMap(990000300).resetPQ(level);
eim.getInstanceMap(990000301).resetPQ(level);
eim.getInstanceMap(990000400).resetPQ(level);
eim.getInstanceMap(990000401).resetPQ(level);
eim.getInstanceMap(990000410).resetPQ(level);
eim.getInstanceMap(990000420).resetPQ(level);
eim.getInstanceMap(990000430).resetPQ(level);
eim.getInstanceMap(990000431).resetPQ(level);
eim.getInstanceMap(990000440).resetPQ(level);
eim.getInstanceMap(990000500).resetPQ(level);
eim.getInstanceMap(990000501).resetPQ(level);
eim.getInstanceMap(990000502).resetPQ(level);
eim.getInstanceMap(990000600).resetPQ(level);
eim.getInstanceMap(990000610).resetPQ(level);
eim.getInstanceMap(990000611).resetPQ(level);
eim.getInstanceMap(990000620).resetPQ(level);
eim.getInstanceMap(990000630).resetPQ(level);
eim.getInstanceMap(990000631).resetPQ(level);
eim.getInstanceMap(990000640).resetPQ(level);
eim.getInstanceMap(990000641).resetPQ(level);
eim.getInstanceMap(990000700).resetPQ(level);
eim.getInstanceMap(990000800).resetPQ(level);
eim.getInstanceMap(990000900).resetPQ(level);
eim.getInstanceMap(990001000).resetPQ(level);
eim.getInstanceMap(990001100).resetPQ(level);
eim.getInstanceMap(990001101).resetPQ(level);
respawnStages(eim);
var ts = Date.now();
ts += (60000 * waitTime);
eim.setProperty("entryTimestamp", "" + ts);
eim.startEventTimer(waitTime * 60000);
setEventRewards(eim);
setEventExclusives(eim);
return eim;
}
/*
function isTeamAllJobs(eim) {
var eventJobs = eim.getEventPlayersJobs();
var rangeJobs = parseInt('111110', 2);
return ((eventJobs & rangeJobs) == rangeJobs);
}
*/
function afterSetup(eim) {
eim.setProperty("guild", "" + eim.getLeader().getGuildId());
}
function respawnStages(eim) {}
function playerEntry(eim, player) {
var map = eim.getMapInstance(entryMap);
player.changeMap(map, map.getPortal(0));
var texttt = "So, here is the brief. You guys should be warned that, once out on the fortress outskirts, anyone that would not be equipping the #b#t1032033##k will die instantly due to the deteriorated state of the air around there. That being said, once your team move out to the next stage, make sure to #bhit the glowing rocks#k in that region and #bequip the dropped item#k before advancing stages. That will protect you thoroughly from the air sickness. Good luck!";
player.getClient().getSession().write(Packages.tools.MaplePacketCreator.getNPCTalk(9040000, /*(byte)*/ 0, texttt, "00 00", /*(byte)*/ 0));
}
function scheduledTimeout(eim) {
if(eim.getIntProperty("canJoin") == 1) {
eim.setProperty("canJoin", 0);
if(eim.checkEventTeamLacking(true, minPlayers)) {
end(eim);
} else {
eim.startEventTimer(eventTime * 60000);
}
} else {
end(eim);
}
}
function playerUnregistered(eim, player) {}
function playerExit(eim, player) {
eim.unregisterPlayer(player);
player.changeMap(exitMap, 0);
}
function changedMap(eim, player, mapid) {
if (mapid < minMapId || mapid > maxMapId) {
if (eim.isEventTeamLackingNow(true, minPlayers, player) && eim.getIntProperty("canJoin") == 0) {
eim.unregisterPlayer(player);
end(eim);
}
else
eim.unregisterPlayer(player);
}
}
function changedLeader(eim, leader) {}
function playerDead(eim, player) {}
function playerRevive(eim, player) { // player presses ok on the death pop up.
if (eim.isEventTeamLackingNow(true, minPlayers, player) && eim.getIntProperty("canJoin") == 0) {
eim.unregisterPlayer(player);
end(eim);
}
else
eim.unregisterPlayer(player);
}
function playerDisconnected(eim, player) {
if (eim.isEventTeamLackingNow(true, minPlayers, player) && eim.getIntProperty("canJoin") == 0) {
eim.unregisterPlayer(player);
end(eim);
}
else
eim.unregisterPlayer(player);
}
function leftParty(eim, player) {}
function disbandParty(eim) {
end(eim);
}
function monsterValue(eim, mobId) {
return 1;
}
function end(eim) {
var party = eim.getPlayers();
for (var i = 0; i < party.size(); i++) {
playerExit(eim, party.get(i));
}
eim.dispose();
}
function giveRandomEventReward(eim, player) {
eim.giveEventReward(player);
}
function clearPQ(eim) {
eim.stopEventTimer();
eim.setEventCleared();
}
function monsterKilled(mob, eim) {}
function allMonstersDead(eim) {}
function cancelSchedule() {}
function dispose(eim) {
em.schedule("reopenGuildQuest", em.getLobbyDelay() * 1.5 * 1000);
}
function reopenGuildQuest() {
em.attemptStartGuildInstance();
}

View File

@@ -1,208 +0,0 @@
/*
* This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License 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/>.
*/
/*
* @Author Lerk
*
* Guild Quest
*/
var exitMap;
var waitingListCurrent = 0;
importPackage(Packages.world);
importPackage(Packages.client);
importPackage(Packages.server.maps);
importPackage(java.lang);
function init() {
em.setProperty("shuffleReactors","false");
em.setProperty("canEnter", "true");
em.setProperty("gpqOpen", "true");
}
function monsterValue(eim, mobId) { //should only trigger on ergoth
if (mobId == 9300028) { //but, just to be safe...
var rubian = new Packages.client.inventory.Item(4001024, 0, 1);
var map = eim.getMapInstance(990000900);
var reactor = map.getReactorByName("boss");
map.spawnItemDrop(reactor, eim.getPlayers().get(0), rubian, reactor.getPosition(), true, false);
}
return -1;
}
function setup(eim) {
exitMap = em.getChannelServer().getMapFactory().getMap(990001100); //returning path
//shuffle reactors in two maps for stage 3
eim.getMapInstance(990000501).shuffleReactors();
eim.getMapInstance(990000502).shuffleReactors();
//force no-respawn on certain map reactors
eim.getMapInstance(990000611).getReactorByName("").setDelay(-1);
eim.getMapInstance(990000620).getReactorByName("").setDelay(-1);
eim.getMapInstance(990000631).getReactorByName("").setDelay(-1);
eim.getMapInstance(990000641).getReactorByName("").setDelay(-1);
//activate three minutes after start
eim.setProperty("entryTimestamp", Packages.java.lang.System.currentTimeMillis());
eim.setProperty("canEnter","true");
eim.schedule("begin", 60000);
eim.startEventTimer(60000);
}
function begin(eim) {
eim.setProperty("canEnter","false");
var party = eim.getPlayers();
//if (party.size() < 6) { //not enough to start
// end(eim,"There are no longer enough players to continue, and those remaining shall be warped out.");
//} else {
var iter = party.iterator();
while (iter.hasNext()) {
iter.next().dropMessage(6,"The quest has begun.");
}
eim.startEventTimer(1000 * 60 * 90);
eim.schedule("timeOut", 1000 * 60 * 90);
//}
}
function timeOut(eim) {
end(eim, "Your allotted time to finish the quest has passed.");
}
function playerEntry(eim, player) {
var map = eim.getMapInstance(990000000);
player.changeMap(map, map.getPortal(0));
}
function playerRevive(eim, player) {
var returnMap = 990000200;
if (eim.getProperty("canEnter").equals("true")) {
returnMap = 990000000;
}
player.setHp(50);
player.setStance(0);
player.changeMap(eim.getMapInstance(returnMap), eim.getMapInstance(returnMap).getPortal(0));
return false;
}
function playerDead(eim, player) {
}
function playerDisconnected(eim, player) {
var party = eim.getPlayers();
if (player.getName().equals(eim.getProperty("leader"))) { //check for party leader
//boot all players and end
var iter = party.iterator();
while (iter.hasNext()) {
var pl = iter.next();
pl.dropMessage(6,"The leader of the instance has disconnected, and the remaining players shall be warped out.");
if (pl.equals(player)) {
removePlayer(eim, pl);
}
else {
eim.unregisterPlayer(pl);
pl.changeMap(exitMap, exitMap.getPortal(0));
}
}
eim.dispose();
}
else { //boot d/ced player and check if enough players left
removePlayer(eim, player);
if (party.size() < 6) { //five after player booted
end(eim,"There are no longer enough players to continue, and those remaining shall be warped out.");
}
}
}
function leftParty(eim, player) { //ignore for GQ
}
function disbandParty(eim) { //ignore for GQ
}
function playerExit(eim, player) {
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
var party = eim.getPlayers();
if (party.size() < 6) { //five after player booted
end(eim,"There are no longer enough players to continue, and those remaining shall be warped out.");
}
}
function end(eim, msg) {
var iter = eim.getPlayers().iterator();
while (iter.hasNext()) {
var player = iter.next();
player.dropMessage(6,msg);
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
}
eim.dispose();
}
//for offline players
function removePlayer(eim, player) {
eim.unregisterPlayer(player);
player.getMap().removePlayer(player);
player.setMap(exitMap);
}
function clearPQ(eim) {
var iter = eim.getPlayers().iterator();
var bonusMap = eim.getMapInstance(990001000);
eim.startEventTimer(40000);
while (iter.hasNext()) {
var player = iter.next();
player.changeMap(bonusMap, bonusMap.getPortal(0));
}
eim.schedule("finish", 40000)
}
function finish(eim) {
var iter = eim.getPlayers().iterator();
while (iter.hasNext()) {
var player = iter.next();
eim.unregisterPlayer(player);
player.changeMap(exitMap, exitMap.getPortal(0));
}
eim.dispose();
}
function allMonstersDead(eim) {
//do nothing; GQ has nothing to do with monster killing
}
function cancelSchedule() {
}
function dispose(eim) {
em.schedule("openGPQ", 5000);
}
function openGPQ() {
em.setProperty("gpqOpen", "true");
}
function timeOut() {
}

View File

@@ -1,3 +0,0 @@
Change reason: Rewrote script file as a whole, now using methods suitable for the server's improved EventManager (queue system and such).
Committed 2017-06-13 (GuildPQ Queue system + revamped Warp mechanic)

View File

@@ -1,14 +0,0 @@
[COMMIT 198]
Licenses for the following files are being changed due to misleading authorship:
- CafePQ NPCs: those NPC script files were not around on OdinMS server, neither before HeavenMS.
- GuildQuest.js: that event script file was completely rewritten to suit well the underlying EIM of HeavenMS.
- Custom NPCs 9000017, 9000036, 9000041: those NPC script files were not around on OdinMS server, neither on Solaxia.
Original dates are summarized on the subfolders, for steadfast conference.
Licenses for the following files are being added:
- Several PQs and boss battles: those event scripts are authored by myself, all following similar pattern and using
common functions introduced on this server (such as getEligibleParty, startEventTimer or isEventTeamLackingNow).
I am expecting no infringements from this action, should any issues arise contact me asap.

View File

@@ -25,23 +25,26 @@ PQs:
* HPQ/KPQ/LPQ/LMPQ/OPQ/EllinPQ/PiratePQ/MagatiaPQ/HorntailPQ/AmoriaPQ/TreasurePQ.
* CWKPQ as Expedition-based event.
* Expeditions: Scarga/Horntail/Showa/Balrog/Zakum/Pinkbean.
* GuildPQ 100% + Guild queue with multi-lobby systems available.
* GuildPQ + Guild queue with multi-lobby systems available.
* Brand-new PQs: BossRushPQ, CafePQ.
* Mu Lung Dojo.
* Capt. Latanica remade as an event (parties can now fight the boss).
Skills:
* Some skills behaving oddly have been patched, such as Venomous Star/Stab and Mystic Doors.
* Maker skill features properly developed.
* Server is using heurisitics to calculate fee costs for the Maker (errors sums up to 8k mesos, reagent errors stacks up comformant with it's level).
* Server is using heuristics to calculate fee costs for the Maker (errors sums up to 8k mesos, reagent errors stacks up comformant with it's level).
* New skill: Chair Mastery (max lv 1) - Players having this passive skill can gain a significant boost of HP/MP recovery when sitting on a field/map chair.
Quests:
* Doll house quest functional.
* Quests can now reward properly items when matching a reward item with the player's job.
* Loads of quests have been patched.
* Quest rewards according to jobs works properly.
* Reward selection and randomed reward works properly.
* Loads of quests have been patched.
* Lots of job questlines (rewarding skills) have been patched/implemented.
* Enchanced rewarding system: checks for stacking opportunities on the inventory before checking for new slots.
* Complete overhaul on the 3rd job quiz (explorers), with all 40-question pool now made available.
@@ -52,6 +55,8 @@ Player Social Network:
* Enhanced synchronization on Player Shops and Hired Merchants. Transactions made are instantly informed to the owner.
* Game minirooms such as match cards and omok now has semi-functional password system.
* Item pickup cooldown on non-owned/non-partyowned items functional.
* Further improved the server's ranking system, to now display properly daily player ranking movement.
* Automated support for Player NPCs and Hall of Fame.
Cash & Items:
@@ -65,6 +70,8 @@ Cash & Items:
* Owl of Minerva.
* Pet item ignore.
* New Year's card (New Year effect sometimes d/c's a player).
* Kite.
* Cash Shop Surprise.
Monsters, Maps & Reactors:
@@ -76,6 +83,7 @@ Monsters, Maps & Reactors:
* Added Boss HP Bar for dozens of bosses (needs provided custom wz).
* If multiple bosses are on the same area, client will prioritize Boss HP bar of the target of the player.
* Boats, elevator and other travelling mechanics fully working.
* Crimson Balrog boat approaching visual effect made functional.
* PQs, Taxis and other event-driven situations warps players at random spawnpoints, GMS-like.
* Some reactors (PQ bonus boxes) now sprays items on the map, instead of dropping everything at once.
* Updated Crimsonwood, World Tour, Nihal Desert and Neo City, enabling quest completion and game progression in these areas.
@@ -102,6 +110,7 @@ Server potentials:
* Enhanced auto-pot system: pet uses as many potions as necessary to reach the desired threshold.
* Enhanced buff system: smartly checks for the best available buff effects to be active on the player.
* Enhanced AP auto-assigner: exactly matches AP with the needed for the player's current level, surplus assigned to the primary attribute.
* Pet item pickup now gives preference to player attacks rather than forcing attack disables when automatically picking up.
* Channel capacity bar functional and world servers with max capacity checks.
* Disease status are now visible for other players, even when changing maps.
* Poison damage value are now visible for other players.
@@ -110,6 +119,7 @@ Server potentials:
* Delete Character (requires ENABLE_PIC activated).
* Autosaver (periodically saves on DB current state of every player in-game).
* Both fixed and randomized versions of HP/MP growth rate available, regarding player job (enable one at ServerConstants). Placeholder for HP/MP washing feature.
* Reallocated mapobjectids utilization throughout the source, preventing issues such as "NPC disappearing mysteriously after some server time" from happening.
* Accounts can be created automatically when trying to login on an inexistent account -- credits to shavit.
* Usage of Bcrypt (up-to-date) as the main password hashing algorithm, replacing old SHA's -- credits to shavit.
@@ -131,9 +141,9 @@ External tools:
* MapleMesoFetcher - Creates meso drop data for mobs with more than 4 items (thus overworld mobs), calculations based on mob level and whether it's a boss or not.
* MapleMobBookIndexer - Generates a SQL table with all relations of cardid and mobid present in the mob book.
* MapleMobBookUpdate - Generates a wz.xml that is a copy of the original MonsterBook.wz.xml, except it updates the drop data info in the book with those currently on DB.
* MapleQuestlineFetcher - Searches the quest WZ files and reports in all questids that currently doesn't have script files.
* MapleQuestItemCountFetcher - Searches the quest WZ files and reports in all relevant data regarding missing "count" labels on item acts at "complete quest".
* MapleQuestItemFetcher - Searches the SQL tables and project files and reports in all relevant data regarding missing/erroneous quest items.
* MapleQuestlineFetcher - Searches the quest WZ files and reports in all questids that currently doesn't have script files.
* MapleQuestMesoFetcher - Searches the quest WZ files and reports in all relevant data regarding missing/erroneous quest fee checks.
* MapleReactorDropFetcher - Searches the DB for reactors with drop data and reports in reactorids that are not yet coded.
* MapleSkillMakerFetcher - Updates the DB Maker-related tables with the current info present on the WZs.
@@ -145,7 +155,9 @@ Project:
* Highly updated drop data.
* Highly configurable server (see all server flags at ServerConstants).
* Fixed/added some missing packets for MoveEnvironment, summons and others.
* Uncovered many Send/Recv opcodes throughout the source.
* Reviewed many Java object aspects that needed concurrency protection.
* Protected many flaws with login management system.
* Heavily reviewed future task management inside the project. Way less trivial schedules are spawned now, relieving task overload on the TimerManager.
* ThreadTracker: embedded auditing tool for run-time deadlock scanning throughout the server source (relies heavily on memory usage, designed only for debugging purposes).
@@ -154,6 +166,7 @@ Exploits patched:
* Player being given free access to any character of any account once they have authenticated their account on login phase.
* Player being given permission to delete any character of any account once they have authenticated their account on login phase.
* Player being able to start/complete any quest freely.
* Several assynchronous-oriented explots patched, highlights on those involving Fredrick & Duey.
Localhost:

View File

@@ -1,315 +0,0 @@
var DISABLED = false;
var SavedLocationType = Packages.server.maps.SavedLocationType;
var MonsterCarnival = Packages.server.partyquest.mcpq.MonsterCarnival;
var MCTracker = Packages.server.partyquest.mcpq.MCTracker;
var MCParty = Packages.server.partyquest.mcpq.MCParty;
var MCField = Packages.server.partyquest.mcpq.MCField;
var status = -1;
var store = false;
var ctx = -1;
var storeInfo;
var purchaseId;
var purchaseCost;
var coinId = 4001129;
var coinIcon = "#i" + coinId + "#";
var infoMaps = [220000000, 200000000, 103000000, 540000000]; // ludi, orbis, kerning, singapore
var gradeS = 600
var gradeA = 500
var gradeB = 400
var gradeC = 300
var gradeD = 200
var gradeE = 100
var expRewards = [[150000, 100000], // S Winner/Loser
[100000, 70000], // A Winner/Loser
[75000, 43250], // B Winner/Loser
[50000, 25000], // C Winner/Loser
[25000, 12500], // D Winner/Loser
[12500, 6250], // E Winner/Loser
[5000, 2500] // F Winner/Loser
];
// Exchange stores
var warrior = [[1302004, 7], [1402006, 7], [1302009, 10], [1402007, 10],
[1302010, 20], [1402003, 20], [1312006, 7], [1412004, 7],
[1312007, 10], [1412005, 10], [1312018, 20], [1412003, 20],
[1322015, 7], [1422008, 7], [1322016, 10], [1422007, 10],
[1322017, 20], [1422005, 20], [1432003, 7], [1442003, 7],
[1432005, 10], [1442009, 10], [1442005, 20], [1432004, 20]];
var magician = [[1372001, 7], [1382018, 7], [1372012, 10], [1382019, 10],
[1382001, 20], [1372007, 20]];
var archer = [[1452006, 7], [1452007, 10], [1452008, 20], [1462005, 7],
[1462006, 10], [1462007, 20]];
var thief = [[1472013, 7], [1472017, 10], [1472021, 20], [1332014, 7],
[1332011, 10], [1332031, 10], [1332016, 20], [1332034, 20]];
var pirate = [[1482005, 7], [1482006, 10], [1482007, 20], [1492005, 7],
[1492006, 10], [1492007, 20]];
var necklace = [[1122007, 50], [2041211, 40]];
var infoText = "You wish to know about the Monster Carnival? Very well. The Monster Carnival is a place of trilling battles and exciting competiton against people just as strong and motivated as yourself. You must summon monsters and defeat the monsters summoned by the opposing party. That's the essence of the Monster Carnival. Once you enter the Carnival Field, the task is to earn CP by hunter monsters from the opposing party and use those CP's to distract the opposing party from hunting monsters. There are three ways to distract the other party; Summon a Monster, Skill or Protector. Please remember this though, it's never a good idea to save up CP just for the sake of it. The CP's you've used will also help determine the winner and the loser of the carnival.";
var no = "You do not have enough Maple Coins for this item. Come back to me when you acquire more!";
function getGrade(cp) {
if (cp >= gradeS) {
return 0;
} else if (cp >= gradeA) {
return 1;
} else if (cp >= gradeB) {
return 2;
} else if (cp >= gradeC) {
return 3;
} else if (cp >= gradeD) {
return 4;
} else if (cp >= gradeE) {
return 5;
} else {
return 6;
}
}
function isTownMap(map) {
for (var i = 0; i < infoMaps.length; i++) {
if (infoMaps[i] == map) {
return true;
}
}
return false;
}
function isExitMap(map) {
return map == 980000010;
}
function isWinnerMap(map) {
return (map >= 980000000 && map <= 980000700 && map % 10 == 3);
}
function isLoserMap(map) {
return (map >= 980000000 && map <= 980000700 && map % 10 == 4);
}
var CONTEXT_NONE = -1;
var CONTEXT_TOWN = 0;
var CONTEXT_EXIT = 1;
var CONTEXT_WIN = 2;
var CONTEXT_LOSE = 3;
function start() {
if (DISABLED) {
cm.sendOk("CPQ is temporarily unavailable.");
cm.dispose();
return;
}
m = cm.getMapId();
if (isTownMap(m)) {
ctx = CONTEXT_TOWN;
} else if (isExitMap(m)) {
ctx = CONTEXT_EXIT;
} else if (isWinnerMap(m)) {
ctx = CONTEXT_WIN;
} else if (isLoserMap(m)) {
ctx = CONTEXT_LOSE;
} else {
ctx = CONTEXT_NONE;
}
action(1, 0, 0);
}
function doLoserMap(mode, type, selection) {
if (cm.getPlayer().getMCPQParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendNext("Unfortunately, you did not manage to win this round. Better luck next time!");
} else if (status == 1) {
var points = cm.getPlayer().getMCPQParty().getTotalCP();
var grade = getGrade(points);
var letterGrade = "ABCDF"[grade];
var expReward = expRewards[grade][1];
cm.sendNext("Your grade is: #b" + letterGrade + "\r\n\r\n#kEXP Reward: " + expReward);
cm.gainExp(expReward);
} else if (status == 2) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
}
}
}
function doWinnerMap(mode, type, selection) {
if (cm.getPlayer().getMCPQParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendNext("Congratulations! You managed to defeat the enemy team!");
} else if (status == 1) {
var points = cm.getPlayer().getMCPQParty().getTotalCP();
var grade = getGrade(points);
var letterGrade = "ABCDF"[grade];
var expReward = expRewards[grade][0];
cm.sendNext("Your grade is: #b" + letterGrade + "\r\n\r\n#kEXP Reward: " + expReward);
cm.gainExp(expReward);
} else if (status == 2) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
}
}
}
function doTown(mode, type, selection) {
if (mode == -1) {
cm.sendOk("Be sure to vote for the server every 24 hours!");
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendSimple("What would you like to do? If you have never participated in the Monster Carnival, you'll need to know a thing or two about it before joining.\r\n\r\n#b#L0#Go to the Monster Carnival Field#l\r\n#L1#Learn about the Monster Carnival#l\r\n#L2#Trade Maple Coin#l");
} else if (status == 1) {
if (selection == 0) {
if (cm.getChar().getLevel() < MonsterCarnival.MIN_LEVEL || cm.getChar().getLevel() > MonsterCarnival.MAX_LEVEL) {
cm.sendOk("You must be between level " + MonsterCarnival.MIN_LEVEL + " and level " + MonsterCarnival.MAX_LEVEL + " to enter.");
cm.dispose();
return;
}
cm.getChar().saveLocation(SavedLocationType.MONSTER_CARNIVAL);
cm.warp(MonsterCarnival.MAP_LOBBY, 4);
cm.dispose();
return;
} else if (selection == 1) {
cm.sendPrev(infoText);
cm.dispose();
return;
} else if (selection == 2) {
store = true;
cm.sendSimple("Select a category:\r\n" +
"#L101##bTrade Maple Coins for Warrior Weapons\r\n" +
"#L102#Trade Maple Coins for Magician Weapons\r\n" +
"#L103#Trade Maple Coins for Bowman Weapons\r\n" +
"#L104#Trade Maple Coins for Thief Weapons\r\n" +
"#L105#Trade Maple Coins for Pirate Weapons\r\n" +
"#L106#Trade Maple Coins for a Necklace");
}
} else if (status == 2) {
if (store) {
switch (selection) {
case 101:
storeInfo = warrior;
break;
case 102:
storeInfo = magician;
break;
case 103:
storeInfo = archer;
break;
case 104:
storeInfo = thief;
break;
case 105:
storeInfo = pirate;
break;
case 106:
storeInfo = necklace;
break;
default:
storeInfo = [];
}
if (storeInfo.length == 0) {
cm.sendOk("That store doesn't exist.");
cm.dispose();
return;
}
var storeText = "";
for (var i = 0; i < storeInfo.length; ++i) {
var wepId = storeInfo[i][0];
var cost = storeInfo[i][1];
storeText += "#L" + i + "##v" + wepId + "# - #z" + wepId + "# - " + cost + " " + coinIcon + "#l\r\n";
}
cm.sendSimple(storeText);
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 2");
}
} else if (status == 3) {
if (store) {
purchaseId = storeInfo[selection][0];
purchaseCost = storeInfo[selection][1];
if (cm.haveItem(coinId, purchaseCost)) {
cm.sendYesNo("Are you sure you want to purchase #i" + purchaseId + "#? You will have #r#e" + (cm.itemQuantity(coinId) - purchaseCost) + " " + coinIcon + "##k#n remaining.");
} else {
cm.sendOk("You don't have enough " + coinIcon + ".");
cm.dispose();
}
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 3");
}
} else if (status == 4) {
if (store) {
if (cm.haveItem(coinId, purchaseCost)) {
cm.gainItem(coinId, -purchaseCost);
cm.gainItem(purchaseId);
cm.sendOk("Congratulations! Enjoy your new item.");
cm.dispose();
}
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 4");
}
}
}
}
function doExit() {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.sendOk("Hope you had fun in the Carnival PQ!");
cm.dispose();
}
function action(mode, type, selection) {
switch (ctx) {
case CONTEXT_TOWN:
doTown(mode, type, selection);
break;
case CONTEXT_EXIT:
doExit();
break;
case CONTEXT_LOSE:
doLoserMap(mode, type, selection);
break;
case CONTEXT_WIN:
doWinnerMap(mode, type, selection);
break;
default:
MCTracker.log("[MCPQ_INFO] Invalid context (value: " + ctx + ")");
cm.dispose();
}
}

View File

@@ -1,464 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import packet.creators.CarnivalPackets;
import packet.creators.PacketCreator;
import client.player.Player;
import server.life.MapleLifeFactory;
import server.life.MapleMonster;
import server.life.MobSkill;
import server.life.MobSkillFactory;
import server.life.SpawnPoint;
import server.life.Spawns;
import server.maps.Field;
import server.maps.FieldObject;
import server.maps.FieldObjectType;
import server.maps.reactors.MapleReactor;
import server.maps.reactors.MapleReactorFactory;
import server.partyquest.mcpq.MCField.MCTeam;
import static server.partyquest.mcpq.MCField.MCTeam.RED;
import server.partyquest.mcpq.MCWZData.MCGuardianGenPos;
import server.partyquest.mcpq.MCWZData.MCMobGenPos;
/**
* Keeps track of guardians and spawns in MCPQ.
*
* @author s4nta
*/
public class MCBattlefield {
private Field map;
private MCWZData wzData;
private int numGuardiansSpawned = 0;
private int numMonstersSpawned = 0;
// These map Guardian IDs (aka codes for status) to the guardian position.
private Map<Integer, MCWZData.MCGuardianGenPos> redGuardianIdToPos = new HashMap<>();
private Map<Integer, MCWZData.MCGuardianGenPos> blueGuardianIdToPos = new HashMap<>();
// These map Reactor Object IDs to guardian objects.
private Map<Integer, MCGuardian> redReactors = new HashMap<>();
private Map<Integer, MCGuardian> blueReactors = new HashMap<>();
// used for divided maps
// we use an arraylist here for easier random element lookup.
private List<MCWZData.MCGuardianGenPos> originalRedGuardianSpawns = new ArrayList<>();
private List<MCWZData.MCGuardianGenPos> originalBlueGuardianSpawns = new ArrayList<>();
// used for undivided map
private List<MCWZData.MCGuardianGenPos> originalGuardianSpawns = new ArrayList<>();
// used for divided maps
// we use an arraylist here for easier random element lookup.
private List<MCWZData.MCMobGenPos> originalRedSpawns = new ArrayList<>();
private List<MCWZData.MCMobGenPos> originalBlueSpawns = new ArrayList<>();
// use for undivided map
private List<MCWZData.MCMobGenPos> originalUnifiedSpawns = new ArrayList<>();
private List<SpawnPoint> originalSpawns = new ArrayList<>();
private List<SpawnPoint> addedSpawns = new ArrayList<>();
public MCBattlefield(Field battleInstance) {
this.map = battleInstance;
fetchCarnivalData();
getOriginalSpawnPoints();
populateGuardianSpawns();
populateMobSpawns();
}
private void fetchCarnivalData() {
wzData = this.map.getMCPQData();
if (wzData == null) {
MCTracker.log("[MCPQ] Fetching carnival failed for map " + map.getId());
}
}
private void getOriginalSpawnPoints() {
for (Spawns sp : this.map.getSpawnPoints()) {
originalSpawns.add((SpawnPoint) sp);
}
}
private void populateGuardianSpawns() {
for (MCWZData.MCGuardianGenPos gpos : wzData.guardianGenPosList) {
switch (gpos.team) {
case 0:
originalRedGuardianSpawns.add(gpos);
break;
case 1:
originalBlueGuardianSpawns.add(gpos);
break;
default:
originalGuardianSpawns.add(gpos);
}
}
}
private void populateMobSpawns() {
for (MCWZData.MCMobGenPos mpos : wzData.mobGenPosList) {
switch (mpos.team) {
case 0:
originalRedSpawns.add(mpos);
break;
case 1:
originalBlueSpawns.add(mpos);
break;
default:
originalUnifiedSpawns.add(mpos);
break;
}
}
}
public void addSpawn(Player chr, int num) {
if (numMonstersSpawned > wzData.mobGenMax) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(3));
return;
}
MCWZData.MCSummonMob mobToSummon = wzData.summons.get(num);
MCWZData.MCMobGenPos spawnPos = getRandomSpawnPos(chr.getMCPQTeam());
MCField.MCTeam team = chr.getMCPQTeam();
if (spawnPos == null) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(2));
return;
}
int spendCp = mobToSummon.spendCP;
if (spendCp > chr.getAvailableCP()) {
readdSpawn(spawnPos, team);
chr.getClient().announce(CarnivalPackets.CarnivalMessage(1));
return;
}
chr.getMCPQField().loseCP(chr, spendCp);
this.map.broadcastMessage(CarnivalPackets.PlayerSummoned(MonsterCarnival.TAB_SPAWNS, num, chr.getName()));
numMonstersSpawned++; // TODO: AtomicInteger this
MapleMonster monster = MapleLifeFactory.getMonster(mobToSummon.id);
Point pos = new Point(spawnPos.x, spawnPos.y);
SpawnPoint sp = new SpawnPoint(monster, pos, mobToSummon.mobTime, chr.getTeam());
addedSpawns.add(sp);
updateMonsterBuffs();
}
public void useSkill(Player chr, int num) {
if (!wzData.skills.containsKey(num)) {
MCTracker.log("Attempting to use a null skill.");
return;
}
int realSkill = wzData.skills.get(num);
MCSkill skill = MCSkillFactory.getMCSkill(realSkill);
// TODO: add skill cooldowns
int spendCp = skill.getSpendCP();
if (spendCp > chr.getAvailableCP()) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(1));
return;
}
MCParty teamToApply = chr.getMCPQParty().getEnemy();
boolean success = teamToApply.applyMCSkill(skill);
if (success) {
chr.getMCPQField().loseCP(chr, spendCp);
map.broadcastMessage(CarnivalPackets.PlayerSummoned(MonsterCarnival.TAB_DEBUFF, num, chr.getName()));
} else {
chr.getClient().getSession().write(CarnivalPackets.CarnivalMessage(5));
}
}
public void readdSpawn(MCWZData.MCMobGenPos pos, MCField.MCTeam team) {
List<MCWZData.MCMobGenPos> lst = null;
if (this.wzData.mapDivided) {
if (null == team) {
return;
} else switch (team) {
case RED:
lst = originalRedSpawns;
break;
case BLUE:
lst = originalBlueSpawns;
break;
default:
return;
}
} else {
lst = originalUnifiedSpawns;
}
if (lst == null) {
return;
}
lst.add(pos);
}
public void spawnGuardian(Player chr, int num) {
if (numGuardiansSpawned > wzData.guardianGenMax) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(3));
return;
}
int guardianId = wzData.guardians.get(num);
MCGuardian guardian = MCSkillFactory.getMCGuardian(guardianId);
if (guardian == null) {
MCTracker.log("Attempting to spawn invalid guardian.");
return;
}
MCField.MCTeam team = chr.getMCPQTeam();
if (team == MCField.MCTeam.RED) {
if (redGuardianIdToPos.containsKey(guardianId)) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(4));
return;
}
} else if (team == MCField.MCTeam.BLUE) {
if (blueGuardianIdToPos.containsKey(guardianId)) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(4));
return;
}
}
int spendCp = guardian.getSpendCP();
if (spendCp > chr.getAvailableCP()) {
chr.getClient().announce(CarnivalPackets.CarnivalMessage(1));
return;
}
chr.getMCPQField().loseCP(chr, spendCp);
this.map.broadcastMessage(CarnivalPackets.PlayerSummoned(MonsterCarnival.TAB_GUARDIAN, num, chr.getName()));
numGuardiansSpawned++; // TODO: AtomicInteger this
MCWZData.MCGuardianGenPos genPos = getRandomGuardianPos(team);
Point spawnPos = new Point(genPos.x, genPos.y);
MapleReactor reactor;
if (null == team) {
return;
} else switch (team) {
case RED:
reactor = new MapleReactor(MapleReactorFactory.getReactor(MonsterCarnival.GUARDIAN_RED), MonsterCarnival.GUARDIAN_RED);
reactor.setPosition(spawnPos);
redGuardianIdToPos.put(num, genPos);
break;
case BLUE:
reactor = new MapleReactor(MapleReactorFactory.getReactor(MonsterCarnival.GUARDIAN_BLUE), MonsterCarnival.GUARDIAN_BLUE);
reactor.setPosition(spawnPos);
blueGuardianIdToPos.put(num, genPos);
break;
default:
return;
}
reactor.setDelay(-1);
map.spawnReactor(reactor);
if (team == MCField.MCTeam.RED) {
redReactors.put(reactor.getObjectId(), MCSkillFactory.getMCGuardian(num));
} else {
blueReactors.put(reactor.getObjectId(), MCSkillFactory.getMCGuardian(num));
}
map.setReactorState(reactor, (byte) 1);
updateMonsterBuffs();
}
public void onGuardianHit(Player chr, MapleReactor reactor) {
if (MonsterCarnival.DEBUG) {
System.out.println("STATE: " + reactor.getState());
}
MCField.MCTeam team = chr.getMCPQTeam();
if (team == MCField.MCTeam.RED && reactor.getId() == MonsterCarnival.GUARDIAN_RED) {
return;
}
if (team == MCField.MCTeam.BLUE && reactor.getId() == MonsterCarnival.GUARDIAN_BLUE) {
return;
}
reactor.setState((byte) (reactor.getState() + 1));
map.broadcastMessage(PacketCreator.TriggerReactor(reactor, reactor.getState()));
if (reactor.getState() > 3) {
int reactorObjId = reactor.getObjectId();
map.destroyReactor(reactorObjId);
MCGuardian guard;
MCWZData.MCGuardianGenPos guardianGenPos;
if (team == MCField.MCTeam.RED) {
guard = blueReactors.remove(reactorObjId);
guardianGenPos = blueGuardianIdToPos.remove(guard.getType());
} else {
guard = redReactors.remove(reactorObjId);
guardianGenPos = redGuardianIdToPos.remove(guard.getType());
}
numGuardiansSpawned--;
if (MonsterCarnival.DEBUG) {
System.out.println("Removing reactor with x = " + guardianGenPos.x);
}
if (wzData.mapDivided) {
if (team == MCField.MCTeam.RED) {
originalBlueGuardianSpawns.add(guardianGenPos);
} else {
originalRedGuardianSpawns.add(guardianGenPos);
}
} else {
originalGuardianSpawns.add(guardianGenPos);
}
if (MonsterCarnival.DEBUG) {
System.out.println("Attempting to remove buff " + guard.getName());
}
updateMonsterBuffs();
}
}
private MCGuardianGenPos getRandomGuardianPos(MCTeam team) {
if (this.wzData.mapDivided) {
if (null == team) {
return null;
} else switch (team) {
case RED: {
int randIndex = (int) Math.floor(Math.random() * this.originalRedGuardianSpawns.size());
return originalRedGuardianSpawns.remove(randIndex);
}
case BLUE: {
int randIndex = (int) Math.floor(Math.random() * this.originalBlueGuardianSpawns.size());
return originalBlueGuardianSpawns.remove(randIndex);
}
default:
return null;
}
} else {
int randIndex = (int) Math.floor(Math.random() * this.originalGuardianSpawns.size());
return originalGuardianSpawns.remove(randIndex);
}
}
private MCMobGenPos getRandomSpawnPos(MCTeam team) {
List<MCMobGenPos> lst = null;
if (this.wzData.mapDivided) {
if (null == team) {
return null;
} else switch (team) {
case RED:
lst = originalRedSpawns;
break;
case BLUE:
lst = originalBlueSpawns;
break;
default:
return null;
}
} else {
lst = originalUnifiedSpawns;
}
if (lst == null) {
return null;
}
if (lst.isEmpty()) {
return null;
}
int randIndex = (int) Math.floor(Math.random() * lst.size());
return lst.remove(randIndex);
}
private void updateMonsterBuffs() {
List<MCGuardian> redGuardians = new ArrayList<>();
List<MCGuardian> blueGuardians = new ArrayList<>();
for (MCGuardian g : this.redReactors.values()) {
redGuardians.add(g);
if (MonsterCarnival.DEBUG) {
System.out.println("update buff red " + g.getMobSkillID());
}
}
for (MCGuardian g : this.blueReactors.values()) {
blueGuardians.add(g);
if (MonsterCarnival.DEBUG) {
System.out.println("update buff blue " + g.getMobSkillID());
}
}
for (FieldObject mmo : map.getAllMonsters()) {
if (mmo.getType() == FieldObjectType.MONSTER) {
MapleMonster mob = ((MapleMonster) mmo);
mob.dispel();
if (mob.getTeam() == MCField.MCTeam.RED.code) {
applyGuardians(mob, redGuardians);
} else if (mob.getTeam() == MCField.MCTeam.BLUE.code) {
applyGuardians(mob, blueGuardians);
} else {
MCTracker.log("[MCPQ] Attempting to give guardians to mob without team.");
}
}
}
}
private void giveMonsterBuffs(MapleMonster mob) {
List<MCGuardian> redGuardians = new ArrayList<>();
List<MCGuardian> blueGuardians = new ArrayList<>();
for (MCGuardian g : this.redReactors.values()) {
redGuardians.add(g);
if (MonsterCarnival.DEBUG) {
System.out.println("update buff red " + g.getMobSkillID());
}
}
for (MCGuardian g : this.blueReactors.values()) {
blueGuardians.add(g);
if (MonsterCarnival.DEBUG) {
System.out.println("update buff blue " + g.getMobSkillID());
}
}
if (mob.getTeam() == MCField.MCTeam.RED.code) {
applyGuardians(mob, redGuardians);
} else if (mob.getTeam() == MCField.MCTeam.BLUE.code) {
applyGuardians(mob, blueGuardians);
} else {
MCTracker.log("[MCPQ] Attempting to give guardians to mob without team.");
}
}
private void applyGuardians(MapleMonster mob, List<MCGuardian> guardians) {
for (MCGuardian g : guardians) {
MobSkill sk = MobSkillFactory.getMobSkill(g.getMobSkillID(), g.getLevel());
sk.applyEffect(null, mob, true);
}
}
public void spawningTask() {
for (SpawnPoint sp : originalSpawns) {
if (sp.shouldSpawn()) {
MapleMonster mob = sp.spawnMonster(this.map);
giveMonsterBuffs(mob);
}
}
for (SpawnPoint sp : addedSpawns) {
if (sp.shouldSpawn()) {
MapleMonster mob = sp.spawnMonster(this.map);
giveMonsterBuffs(mob);
}
}
}
}

View File

@@ -1,861 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import handling.channel.ChannelServer;
import java.util.*;
import java.util.concurrent.ScheduledFuture;
import packet.creators.CarnivalPackets;
import packet.creators.EffectPackets;
import packet.creators.PacketCreator;
import packet.transfer.write.OutPacket;
import client.player.Player;
import server.MapleStatEffect;
import server.itens.MapleItemInformationProvider;
import server.maps.Field;
import server.maps.FieldItem;
import server.maps.reactors.MapleReactor;
import server.maps.portal.Portal;
import tools.TimerTools.EventTimer;
/**
* Keeps track of a specific field (1-6). Handles all packet broadcasting, etc.
* @author s4nta
*/
public class MCField {
/**
* Different teams for MCPQ.
*/
public enum MCTeam {
RED(0),
BLUE(1),
NONE(-1);
public final int code;
MCTeam(int code) {
this.code = code;
}
public final int getEnemyTeamCode() {
return Math.abs(this.code - 1);
}
}
/**
* Represents the current state of the field.
*/
public enum MCState {
LOBBY,
BATTLE,
END;
}
/**
* Keys to access different map instances relating to this field.
*/
public enum MCMaps {
LOBBY(0),
BATTLEFIELD(1),
RESURRECT(2),
VICTORY(3),
DEFEAT(4),
NONE(-1);
private final int code;
MCMaps(int code) {
this.code = code;
}
public static MCMaps getByCode(int code) {
for (MCMaps m : values()) {
if (m.code == code) {
return m;
}
}
return NONE;
}
}
private int arena;
private ChannelServer cserv;
private MCParty red, blue;
private List<MCParty> requests = new ArrayList<>();
private MCState state;
private Map<MCMaps, Field> mapInstances = new HashMap<>();
private long startTime;
private MCBattlefield battlefield;
// Timer Tasks
private ScheduledFuture<?> acceptRequestsTask, validateRoomTask, startBattleTask,
validateBattleTask, runBattleTask, endBattleTask,
spawnMonstersTask;
public MCField(int arena, ChannelServer cserv, MCParty red, MCParty blue) {
this.arena = arena;
this.cserv = cserv;
this.red = red;
this.blue = blue;
this.state = MCState.LOBBY;
}
public boolean isFull() {
if (MonsterCarnival.DEBUG) {
return false;
}
return this.red != null && this.blue != null;
}
public boolean needsRequest() {
return this.red != null && this.blue == null;
}
/**
* Resets the state of the field, warping out players and resetting tasks.
* [MENTION=2000183830]para[/MENTION]m warpPlayers Warp out players or not
* @param warpPlayers
*/
public void deregister(boolean warpPlayers) {
if (warpPlayers) {
if (this.red != null) {
this.red.deregisterPlayers();
}
if (this.blue != null) {
this.blue.deregisterPlayers();
}
}
this.red = null;
this.blue = null;
this.requests.clear();
this.state = MCState.LOBBY;
if (this.acceptRequestsTask != null) {
this.acceptRequestsTask.cancel(true);
this.acceptRequestsTask = null;
}
if (this.validateRoomTask != null) {
this.validateRoomTask.cancel(true);
this.validateRoomTask = null;
}
if (this.startBattleTask != null) {
this.startBattleTask.cancel(true);
this.startBattleTask = null;
}
if (this.endBattleTask != null) {
this.endBattleTask.cancel(true);
this.endBattleTask = null;
}
if (this.runBattleTask != null) {
this.runBattleTask.cancel(true);
this.runBattleTask = null;
}
if (this.validateBattleTask != null) {
this.validateBattleTask.cancel(true);
this.validateBattleTask = null;
}
if (this.spawnMonstersTask != null) {
this.spawnMonstersTask.cancel(true);
this.spawnMonstersTask = null;
}
for (MCMaps mapType : MCMaps.values()) {
this.mapInstances.remove(mapType);
}
}
public MCParty getRed() {
return red;
}
public MCParty getBlue() {
return blue;
}
public void announce(OutPacket pkt) {
if (this.red != null) {
red.broadcast(pkt);
} else {
MCTracker.log("[MCPQ] Trying to announce packet to red when it is null.");
}
if (this.blue != null) {
blue.broadcast(pkt);
} else {
MCTracker.log("[MCPQ] Trying to announce packet to blue when it is null.");
}
}
/**
* Gets a string representing the status of this room for the Spiegelmann NPC.
* [MENTION=850422]return[/MENTION] String representing the room's status.
* @return
*/
public String getStatus() {
if (isFull()) {
return "";
}
if (this.state != MCState.LOBBY) {
return "";
}
String waitingParty = "";
if (this.red != null) {
String fmt = " <Party Size: %d, Average Level: %d>";
waitingParty = String.format(fmt, this.red.getSize(), this.red.getAverageLevel());
}
String fmt = "#L%d#Carnival Field %d%s#l\r\n";
return String.format(fmt, this.arena, this.arena, waitingParty);
}
/**
* Attempts to register a party in this field. If success, then all players in the party
* will be warped to the waiting lobby. All players in the party will also have relevant
* CPQ information assigned to them.
*
* [MENTION=2000183830]para[/MENTION]m party The party to register.
*/
public void register(MCParty party, MCTeam team) {
if (this.red == null && team == MCTeam.RED) {
party.setTeam(team);
this.red = party;
} else if (this.blue == null && team == MCTeam.BLUE) {
party.setTeam(team);
this.blue = party;
} else {
MCTracker.log("Attempting to register party when team is already set.");
return;
}
party.setField(this);
party.updatePlayers();
party.warp(MCMaps.LOBBY);
onPartyRegistered(party, team);
}
/**
* Sends a challenge to the party in this field.
*
* [MENTION=2000183830]para[/MENTION]m party The party requesting a challenge.
*/
public void request(MCParty party) {
if (this.red == null) {
MCTracker.log("Attempting to request when waiting team is null.");
this.deregister(true);
return;
}
requests.add(party);
this.red.notice("[MCPQ] A challenge has arrived! Click on the Assistant in your room to view it.");
}
/**
* Accepts a challenge from a team.
* [MENTION=2000183830]para[/MENTION]m index Index of team in requests.
* [MENTION=850422]return[/MENTION] 1 if the challenge was accepted successfully, 0 otherwise.
*/
public int acceptRequest(int index) {
MCParty toAccept = this.requests.get(index);
register(toAccept, MCTeam.BLUE);
return 1;
}
/**
* Checks for pending requests.
*
* [MENTION=850422]return[/MENTION] True if there are pending requests.
*/
public boolean hasPendingRequests() {
return requests.size() > 0;
}
/**
* Gets a pending list of requests, formatted for use in a NPC. Also cleans up the requests,
* getting rid of MCParties that no longer exist.
*
* [MENTION=850422]return[/MENTION] Formatted list of requests for NPC.
* @return
*/
public String getNPCRequestString() {
StringBuilder sb = new StringBuilder("Here is the list of pending requests:\r\n\r\n#b");
for (MCParty pty : requests) {
if (!pty.exists()) {
continue;
}
sb.append("#L").append(requests.indexOf(pty)).append("#");
String fmt = "<Party Size: %d, Average Level: %d>";
fmt = String.format(fmt, pty.getSize(), pty.getAverageLevel());
sb.append(fmt);
sb.append("#l\r\n");
}
return sb.toString();
}
/**
* Starts a R3 minute waiting timer in the lobby for teams to accept requests.
* If the timer completes the countdown, teams are deregistered and sent back to the lobby.
*/
private void startLobbyTask(MCParty host) {
host.clock(MonsterCarnival.TIME_LOBBYWAIT);
this.acceptRequestsTask = EventTimer.getInstance().schedule(new AcceptingRequestsTask(this, host), 1000 * MonsterCarnival.TIME_LOBBYWAIT); // 3 minutes
this.validateRoomTask = EventTimer.getInstance().register(new ValidateLobbyTask(this), 1000, 1000); // repeat every second
}
/**
* Event handling for when a team registers.
*
* [MENTION=2000183830]para[/MENTION]m party Party that registers.
* [MENTION=2000183830]para[/MENTION]m team Team of party.
*/
private void onPartyRegistered(MCParty party, MCTeam team) {
if (team == MCTeam.RED) {
startLobbyTask(party);
}
if (team == MCTeam.BLUE) { // both teams are in
this.validateRoomTask.cancel(true);
this.acceptRequestsTask.cancel(true);
blue.clock(10);
red.clock(10);
this.startBattleTask = EventTimer.getInstance().schedule(new GoBattlefieldTask(this), 1000 * 10); // 10 seconds
red.notice("[MCPQ] The Carnival PQ will start in 10 seconds!");
blue.notice("[MCPQ] The Carnival PQ will start in 10 seconds!");
}
}
/**
* Warps both parties in the field to the battlefield map.
*/
private void goBattle() {
Field map = getMap(MCMaps.BATTLEFIELD);
if (MonsterCarnival.DEBUG)
System.out.println("warping to battle " + map + " " + map.getId());
if (red != null) {
red.warp(map, "red00");
} else {
MCTracker.log("[MCPQ] Trying to warp red party when it is null.");
}
if (blue != null) {
blue.warp(map, "blue00");
} else {
MCTracker.log("[MCPQ] Trying to warp blue party when it is null.");
}
red.clock(MonsterCarnival.TIME_PREBATTLE);
blue.clock(MonsterCarnival.TIME_PREBATTLE);
red.notice("[MCPQ] The battle will start in 10 seconds!");
blue.notice("[MCPQ] The battle will start in 10 seconds!");
startBattleTask = EventTimer.getInstance().schedule(new BeginCarnivalTask(this), 1000 * MonsterCarnival.TIME_PREBATTLE); // 10 seconds
validateBattleTask = EventTimer.getInstance().register(new ValidateBattlefieldTask(this), 1000, 500); // check every second
battlefield = new MCBattlefield(getMap(MCMaps.BATTLEFIELD));
red.setEnemy(blue);
blue.setEnemy(red);
}
private void beginCarnival() {
red.clock(MonsterCarnival.TIME_BATTLE);
blue.clock(MonsterCarnival.TIME_BATTLE);
startTime = System.currentTimeMillis();
getMap(MCMaps.BATTLEFIELD).broadcastMessage(PacketCreator.ServerNotice(6, "[MCPQ] You have 10 minutes to kill monsters!"));
endBattleTask = EventTimer.getInstance().schedule(new EndBattleTask(this), 1000 * MonsterCarnival.TIME_BATTLE);
spawnMonstersTask = EventTimer.getInstance().register(new SpawnTask(this.battlefield), 1000 * 5);
}
public void endBattle(MCParty winner, MCParty loser) {
endBattle(winner, loser, false);
}
public void endBattle(MCParty winner, MCParty loser, boolean abnormal) {
// TODO: Abnormal win codes to prevent exploits
validateBattleTask.cancel(true);
spawnMonstersTask.cancel(true);
MCWZData cpqData = this.getMap(MCMaps.BATTLEFIELD).getMCPQData();
String effectWin = cpqData.effectWin;
String effectLose = cpqData.effectLose;
String soundWin = cpqData.soundWin;
String soundLose = cpqData.soundLose;
winner.broadcast(EffectPackets.ShowEffect(effectWin));
winner.broadcast(EffectPackets.PlaySound(soundWin));
loser.broadcast(EffectPackets.ShowEffect(effectLose));
loser.broadcast(EffectPackets.PlaySound(soundLose));
this.getMap(MCMaps.BATTLEFIELD).killAllMonsters(false);
this.getMap(MCMaps.BATTLEFIELD).clearDrops();
this.deregister(false);
EventTimer.getInstance().schedule(new WarpEndBattleTask(this, winner, loser), 1000 * 3);
}
/**
* Handles CP gain and packet updates when a monster is killed.
* [MENTION=2000183830]para[/MENTION]m chr Character that kills the monster.
* [MENTION=2000183830]para[/MENTION]m cp CP gained.
*/
public void monsterKilled(Player chr, int cp) {
if (MonsterCarnival.DEBUG) {
// System.out.println(chr.getName() + " killed for +" + cp + " CP");
}
// TODO: Personal stats for CP gain
this.gainCP(chr, cp);
}
/**
* Handles game logic and packet broadcasting for CP gain.
* Broadcasts personal CP update to chr, and broadcasts party CP update
* to the entire field.
*
* [MENTION=2000183830]para[/MENTION]m chr Character that gains CP.
* [MENTION=2000183830]para[/MENTION]m cp CP gained.
*/
public void gainCP(Player chr, int cp) {
if (cp < 0) {
MCTracker.log("[MCPQ] Adding negative CP.");
if (MonsterCarnival.DEBUG) {
System.out.println("Adding negative CP: stacktrace");
new Exception().printStackTrace();
}
}
MCParty pty = chr.getMCPQParty();
chr.gainCP(cp);
pty.gainCP(cp);
chr.getClient().announce(CarnivalPackets.UpdatePersonalCP(chr));
this.announce(CarnivalPackets.UpdatePartyCP(pty));
}
/**
* Subtracts from available CP while leaving total CP untouched.
*
* [MENTION=2000183830]para[/MENTION]m chr Character that loses CP.
* [MENTION=2000183830]para[/MENTION]m cp CP lost (should be positive number).
*/
public void loseCP(Player chr, int cp) {
if (cp < 0) {
MCTracker.log("[MCPQ] Losing negative CP.");
if (MonsterCarnival.DEBUG) {
System.out.println("Adding negative CP: stacktrace");
new Exception().printStackTrace();
}
}
MCParty pty = chr.getMCPQParty();
chr.loseCP(cp);
pty.loseCP(cp);
chr.getClient().announce(CarnivalPackets.UpdatePersonalCP(chr));
this.announce(CarnivalPackets.UpdatePartyCP(pty));
}
/**
* Handles a player looting an item.
* [MENTION=2000183830]para[/MENTION]m player Player that picked up the object.
* [MENTION=2000183830]para[/MENTION]m mapitem Object picked up.
*
* [MENTION=850422]return[/MENTION] True if pickup was successful, false otherwise.
*/
public boolean onItemPickup(Player player, FieldItem mapitem) {
if (mapitem == null) {
MCTracker.log("[MCPQ] Attempting to loot null object.");
return false;
}
int itemid = mapitem.getItem().getItemId();
if (!MonsterCarnival.isCPQConsumeItem(itemid)) {
return false;
}
MCParty pty = player.getMCPQParty();
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
MapleStatEffect itemEffect = ii.getItemEffect(itemid);
if (!itemEffect.isConsumeOnPickup()) {
return false;
}
if (itemEffect.isParty()) {
for (Player chr : pty.getMembers()) {
if (chr.getStat().getCurrentHp() > 0) {
itemEffect.applyTo(chr);
}
}
} else { // Single Target Item
itemEffect.applyTo(player);
}
// Status items
if (itemEffect.getNuffSkill() != -1) {
MCSkill debuff = MCSkillFactory.getMCSkill(itemEffect.getNuffSkill());
if (debuff == null) {
MCTracker.log("[MCPQ] debuff skill is null " + itemEffect.getNuffSkill());
return false;
}
pty.getEnemy().applyMCSkill(debuff);
}
if (itemEffect.getCP() > 0) {
this.gainCP(player, itemEffect.getCP());
}
return true;
}
public void onPlayerRespawn(Player player) {
int cpLoss = Math.min(player.getAvailableCP(), MonsterCarnival.CP_LOSS_ON_DEATH);
this.announce(CarnivalPackets.PlayerDiedMessage(player, cpLoss));
this.loseCP(player, cpLoss);
player.getStat().addMPHP(30000, 30000);
player.changeMap(this.getMap(MCMaps.RESURRECT), this.getMap(MCMaps.RESURRECT).getPortal(0));
player.getClient().getSession().write(PacketCreator.GetClock(getTimeRemaining()));
player.getClient().getSession().write(CarnivalPackets.StartMonsterCarnival(player));
}
public void onPlayerDisconnected(Player player) {
MCParty pty = player.getMCPQParty();
if (pty != null) {
pty.removePlayer(player);
} else {
MCTracker.log("[MCPQ] Attempting to run player disconnect event when party is null for character " + player.getName());
}
}
public void onAddSpawn(Player chr, int num) {
if (this.battlefield != null) {
battlefield.addSpawn(chr, num);
} else {
MCTracker.log("[MCPQ] Summoning guardian with null battlefield.");
}
}
public void onUseSkill(Player chr, int num) {
if (this.battlefield != null) {
battlefield.useSkill(chr, num);
} else {
MCTracker.log("[MCPQ] Summoning guardian with null battlefield.");
}
}
public void onGuardianSummon(Player chr, int num) {
if (this.battlefield != null) {
battlefield.spawnGuardian(chr, num);
} else {
MCTracker.log("[MCPQ] Summoning guardian with null battlefield.");
}
}
public void onGuardianHit(Player chr, MapleReactor reactor) {
if (this.battlefield != null) {
battlefield.onGuardianHit(chr, reactor);
} else {
MCTracker.log("[MCPQ] Hitting reactor with null battlefield.");
}
}
public void onRevive(Player player) {
MCTeam team = player.getMCPQTeam();
Portal portal;
if (team == MCTeam.RED) {
portal = getMap(MCMaps.BATTLEFIELD).getPortal("red_revive");
} else {
portal = getMap(MCMaps.BATTLEFIELD).getPortal("blue_revive");
}
player.changeMap(getMap(MCMaps.BATTLEFIELD), portal);
player.getClient().getSession().write(PacketCreator.GetClock(getTimeRemaining()));
player.getClient().getSession().write(CarnivalPackets.StartMonsterCarnival(player));
}
public int getTimeRemaining() {
// TODO: add support for setting an explicit endTime instead of using the hack with MonsterCarnival variables
return (int) ((startTime + 1000 * MonsterCarnival.TIME_BATTLE) - System.currentTimeMillis()) / 1000;
}
// Map Instances
/**
* Returns the map instance for a requested map. Creates a new map instance if unavailable.
* [MENTION=2000183830]para[/MENTION]m type Map instance to return.
* [MENTION=850422]return[/MENTION] The instanced map.
*/
public Field getMap(MCMaps type) {
if (this.mapInstances.containsKey(type)) {
return this.mapInstances.get(type);
}
return createInstanceMap(type);
}
/**
* Attempts to create an instanced map, based on the type passed in. Also creates a mapping in
* this.mapInstances.
*
* [MENTION=2000183830]para[/MENTION]m type Type of map to generate.
* [MENTION=850422]return[/MENTION] MapleMap for the instanced map if type is supported, otherwise null.
*/
private Field createInstanceMap(MCMaps type) {
int mapid = -1;
switch (type) {
case LOBBY:
mapid = MonsterCarnival.getLobbyMap(this.arena);
break;
case BATTLEFIELD:
mapid = MonsterCarnival.getBattleFieldMap(this.arena);
break;
case RESURRECT:
mapid = MonsterCarnival.getResurrectionMap(this.arena);
break;
case VICTORY:
mapid = MonsterCarnival.getVictoriousMap(this.arena);
break;
case DEFEAT:
mapid = MonsterCarnival.getDefeatedMap(this.arena);
break;
}
if (mapid == -1) return null;
Field mapInstance = this.cserv.getMapFactory().instanceMap(mapid, true, true);
this.mapInstances.put(type, mapInstance);
return mapInstance;
}
// Timer Tasks
public class ValidateLobbyTask implements Runnable {
private final MCField field;
/**
* Timer task to ensure all players are on the right field.
* If anything is wrong with the parties, the field is deregistered.
* [MENTION=2000183830]para[/MENTION]m field Field to run the validation task on.
* @param field
*/
public ValidateLobbyTask(MCField field) {
this.field = field;
}
@Override
public void run() {
if (this.field.red == null) {
this.field.deregister(true);
return;
}
for (Player c : field.red.getMembers()) {
if (c.getMap() != field.getMap(MCMaps.LOBBY)) {
this.field.deregister(true);
return;
}
}
if (this.field.blue != null) {
for (Player c : field.blue.getMembers()) {
if (c.getMap() != field.getMap(MCMaps.LOBBY)) {
this.field.deregister(true);
return;
}
}
}
}
}
public class ValidateBattlefieldTask implements Runnable {
private final MCField field;
/**
* Timer task to ensure all players are on the right field.
* If anything is wrong with the parties, the field is deregistered.
* [MENTION=2000183830]para[/MENTION]m field Field to run the validation task on.
*/
public ValidateBattlefieldTask(MCField field) {
this.field = field;
}
@Override
public void run() {
if (this.field.red == null || field.red.getSize() == 0) {
MCTracker.log("[MCPQ] Red team null when validating battlefield");
field.endBattle(blue, red);
return;
}
Collection<Player> members = Collections.unmodifiableCollection(field.red.getMembers());
for (Player c : members) {
if (c.getMap() != field.getMap(MCMaps.BATTLEFIELD) && c.getMap() != field.getMap(MCMaps.RESURRECT)) {
this.field.announce(CarnivalPackets.CarnivalLeave(MCTeam.RED.code, c.getName()));
red.removePlayer(c); // TODO: fix concurrent modification
}
if (c.getMap() == field.getMap(MCMaps.BATTLEFIELD) && !c.isAlive()) {
this.field.onPlayerRespawn(c);
}
}
if (this.field.blue == null || field.blue.getSize() == 0) {
MCTracker.log("[MCPQ] Blue team null when validating battlefield");
field.endBattle(red, blue);
return;
}
members = Collections.unmodifiableCollection(field.blue.getMembers());
for (Player c : members) {
if (c.getMap() != field.getMap(MCMaps.BATTLEFIELD) && c.getMap() != field.getMap(MCMaps.RESURRECT)) {
this.field.announce(CarnivalPackets.CarnivalLeave(MCTeam.BLUE.code, c.getName()));
blue.removePlayer(c);
}
if (c.getMap() == field.getMap(MCMaps.BATTLEFIELD) && !c.isAlive()) {
this.field.onPlayerRespawn(c);
}
}
}
}
public class AcceptingRequestsTask implements Runnable {
private final MCField field;
private final MCParty host;
/**
* Runs a task that counts down for 3 minutes, then warps the hosting party out.
*
* [MENTION=2000183830]para[/MENTION]m field Field to accept requests on.
* [MENTION=2000183830]para[/MENTION]m host Hosting party that will be warped out if they do not accept a request
* within 3 minutes.
*/
public AcceptingRequestsTask(MCField field, MCParty host) {
this.field = field;
this.host = host;
}
@Override
public void run() {
Collection<Player> chrs = this.host.getMembers();
for (Player c : chrs) {
c.changeMap(MonsterCarnival.MAP_LOBBY);
}
this.field.deregister(true);
}
}
public class GoBattlefieldTask implements Runnable {
private final MCField field;
public GoBattlefieldTask(MCField field) {
this.field = field;
}
@Override
public void run() {
field.goBattle();
field.red.startBattle();
field.blue.startBattle();
field.state = MCState.BATTLE;
}
}
public class BeginCarnivalTask implements Runnable {
private final MCField field;
public BeginCarnivalTask(MCField field) {
this.field = field;
}
@Override
public void run() {
Field map = field.getMap(MCMaps.BATTLEFIELD);
map.beginSpawning();
field.beginCarnival();
}
}
/* I have no idea why this doesn't work normally :/ */
public class SpawnTask implements Runnable {
private final MCBattlefield battleMap;
public SpawnTask(MCBattlefield field) {
this.battleMap = field;
}
@Override
public void run() {
// TODO: adjust spawn rates based on cp
battleMap.spawningTask();
}
}
public class EndBattleTask implements Runnable {
private final MCField field;
public EndBattleTask(MCField field) {
this.field = field;
}
@Override
public void run() {
MCParty winner, loser;
if (field.red.getTotalCP() > field.blue.getTotalCP()) {
winner = field.red;
loser = field.blue;
} else if (field.red.getTotalCP() < field.blue.getTotalCP()) {
winner = field.blue;
loser = field.red;
} else {
// if tied: random chance
// TODO: proper extension of time
if (Math.random() < .5) {
winner = field.red;
loser = field.blue;
} else {
winner = field.blue;
loser = field.red;
}
}
field.state = MCState.END;
field.endBattle(winner, loser);
}
}
public class WarpEndBattleTask implements Runnable {
private final MCField field;
private final MCParty winner, loser;
public WarpEndBattleTask(MCField field, MCParty winner, MCParty loser) {
this.field = field;
this.winner = winner;
this.loser = loser;
}
@Override
public void run() {
winner.warp(field.getMap(MCMaps.VICTORY));
loser.warp(field.getMap(MCMaps.DEFEAT));
}
}
}

View File

@@ -1,68 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
/**
* Object representing MCGuardian in Skill.wz/MCGuardian.img.
*
* @author s4nta
*/
public class MCGuardian {
private final int type, spendCP, mobSkillID, level;
private String name, desc;
public MCGuardian(int type, int spendCP, int mobSkillID, int level) {
this.type = type;
this.mobSkillID = mobSkillID;
this.level = level;
this.spendCP = spendCP;
}
public int getType() {
return type;
}
public int getSpendCP() {
return spendCP;
}
public int getMobSkillID() {
return mobSkillID;
}
public int getLevel() {
return level;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -1,326 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import community.MapleParty;
import community.MaplePartyCharacter;
import handling.channel.ChannelServer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import packet.creators.CarnivalPackets;
import packet.creators.PacketCreator;
import packet.transfer.write.OutPacket;
import client.player.Player;
import client.player.buffs.Disease;
import server.life.MobSkill;
import server.life.MobSkillFactory;
import server.maps.Field;
import server.partyquest.mcpq.MCField.MCTeam;
/**
*
* @author Sammy Guergachi <sguergachi at gmail.com>
*/
/**
* Provides an interface for Monster Carnival-specific party methods and variables.
*
* @author s4nta
*/
public class MCParty {
private MapleParty party;
private List<Player> characters = new ArrayList<>();
private int availCP = 0;
private int totalCP = 0;
private MCField.MCTeam team = MCField.MCTeam.NONE;
private MCField field;
private MCParty enemy;
public MCParty(MapleParty party) {
this.party = party;
for (MaplePartyCharacter chr : party.getMembers()) {
if (!chr.isOnline()) continue;
Player c = ChannelServer.getInstance(chr.getChannel()).getPlayerStorage().getCharacterById(chr.getId());
characters.add(c);
}
}
public int getSize() {
return this.characters.size();
}
/**
* Checks if the underlying MapleParty still exists in the same way it did when it was created.
* That is, if there were no players who left the party.
*
* [MENTION=850422]return[/MENTION] True if the underlying MapleParty still exists in its original format.
*/
public boolean exists() {
Collection<Player> members = getMembers();
for (Player chr : members) {
if (chr.getParty() == null || chr.getParty() != this.party) {
return false;
}
}
return true;
}
public int getAverageLevel() {
int sum = 0, num = 0;
for (Player chr : getMembers()) {
sum += chr.getLevel();
num += 1;
}
return sum / num;
}
public boolean checkLevels() {
if (MonsterCarnival.DEBUG) {
return true;
}
for (Player chr : getMembers()) {
int lv = chr.getLevel();
if (lv < MonsterCarnival.MIN_LEVEL || lv > MonsterCarnival.MAX_LEVEL) {
return false;
}
}
return true;
}
public boolean checkChannels() {
if (MonsterCarnival.DEBUG) {
return true;
}
for (Player chr : getMembers()) {
if (chr.getClient().getChannel() != party.getLeader().getChannel()) return false;
}
return true;
}
public boolean checkMaps() {
if (MonsterCarnival.DEBUG) {
return true;
}
for (Player chr : getMembers()) {
if (chr.getMapId() != MonsterCarnival.MAP_LOBBY) return false;
}
return true;
}
public void warp(int map) {
for (Player chr : getMembers()) {
chr.changeMap(map);
}
}
public void warp(Field map) {
for (Player chr : getMembers()) {
chr.changeMap(map, map.getPortal(0));
}
}
public void warp(Field map, String portal) {
for (Player chr : getMembers()) {
chr.changeMap(map, map.getPortal(portal));
}
}
public void warp(MCField.MCMaps type) {
Field m = this.field.getMap(type);
for (Player chr : getMembers()) {
chr.changeMap(m, m.getPortal(0));
}
}
public void clock(int secs) {
for (Player chr : getMembers()) {
chr.getClient().announce(PacketCreator.GetClock(secs));
}
}
public void notice(String msg) {
broadcast(PacketCreator.ServerNotice(6, msg));
}
public void broadcast(OutPacket pkt) {
for (Player chr : getMembers()) {
chr.getClient().announce(pkt);
}
}
/**
* Sets MCPQTeam, MCPQParty, and MCPQField for a given character.
* [MENTION=2000183830]para[/MENTION]m chr Character to update.
*/
public void updatePlayer(Player chr) {
chr.setMCPQTeam(this.team);
chr.setMCPQParty(this);
chr.setMCPQField(this.field);
}
/**
* Sets MCPQTeam, MCPQParty, and MCPQ field for all characters in the party.
* Unlike deregisterPlayers, this method does NOT warp players to the lobby map.
*/
public void updatePlayers() {
for (Player chr : getMembers()) {
this.updatePlayer(chr);
}
}
/**
* Resets MCPQ variables for a given character.
* [MENTION=2000183830]para[/MENTION]m chr Character to reset.
*/
public static void deregisterPlayer(Player chr) {
chr.setMCPQTeam(MCTeam.NONE);
chr.setMCPQParty(null);
chr.setMCPQField(null);
chr.setAvailableCP(0);
chr.setTotalCP(0);
}
/**
* Resets MCPQ variables for all characters in the party.
* Unlike updatePlayers, this method DOES warp players to the lobby map.
*/
public void deregisterPlayers() {
for (Player chr : getMembers()) {
MCParty.deregisterPlayer(chr);
chr.changeMap(MonsterCarnival.MAP_EXIT);
}
}
public void removePlayer(Player chr) {
characters.remove(chr);
deregisterPlayer(chr);
}
public void startBattle() {
for (Player chr : characters) {
chr.getClient().getSession().write(CarnivalPackets.StartMonsterCarnival(chr));
}
}
/**
* Uses some amount of available CP.
* [MENTION=2000183830]para[/MENTION]m use A positive integer to be subtracted from available CP.
*/
public void loseCP(int use) {
// TODO: locks?
if (use < 0) {
System.err.println("Attempting to use negative CP.");
}
this.availCP -= use;
}
public void gainCP(int gain) {
// TODO: locks?
this.availCP += gain;
this.totalCP += gain;
}
public MCParty getEnemy() {
return enemy;
}
public void setEnemy(MCParty enemy) {
this.enemy = enemy;
}
/**
* Applies a MCSkill to the entire team. This is used on the team's own players
* because it is called when the enemy team uses a debuff/cube of darkness.
* [MENTION=2000183830]para[/MENTION]m skill Skill to apply.
* [MENTION=850422]return[/MENTION] True if skill was applied, false otherwise.
*/
public boolean applyMCSkill(MCSkill skill) {
MobSkill s = MobSkillFactory.getMobSkill(skill.getMobSkillID(), skill.getLevel());
Disease disease = Disease.getType(skill.getMobSkillID());
if (disease == null) {
disease = Disease.DARKNESS;
s = MobSkillFactory.getMobSkill(121, 6); // HACK: darkness
} else if (disease == Disease.POISON) {
return false;
}
// We only target players on the battlefield map.
if (skill.getTarget() == 2) {
for (Player chr : getMembers()) {
if (MonsterCarnival.isBattlefieldMap(chr.getMapId())) {
chr.giveDebuff(disease, s);
}
}
return true;
} else {
if (getRandomMember() != null) {
getRandomMember().giveDebuff(disease, 1, 30000L, disease.getDisease(), 1);
return true;
} else {
return false;
}
}
}
public void setField(MCField field) {
this.field = field;
}
public void setTeam(MCTeam newTeam) {
this.team = newTeam;
}
public MCTeam getTeam() {
return team;
}
/**
* Returns a collection of online members in the party.
* [MENTION=850422]return[/MENTION] Online MCParty members.
*/
public Collection<Player> getMembers() {
return this.characters;
}
public Player getRandomMember() {
List<Player> chrsOnMap = new ArrayList<>();
for (Player chr : this.characters) {
if (MonsterCarnival.isBattlefieldMap(chr.getMapId())) {
chrsOnMap.add(chr);
}
}
if (chrsOnMap.isEmpty()) {
return null;
}
return chrsOnMap.get(new Random().nextInt(chrsOnMap.size()));
}
public int getAvailableCP() {
return availCP;
}
public int getTotalCP() {
return totalCP;
}
}

View File

@@ -1,72 +0,0 @@
package server.partyquest.mcpq;
/*
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/>.
*/
/**
* Object representing MCSkill in Skill.wz/MCSkill.img.
*
* @author s4nta
*/
public class MCSkill {
private final int id, target, mobSkillID, level, spendCP;
private String name, desc;
public MCSkill(int id, int target, int mobSkillID, int level, int spendCP) {
this.id = id;
this.target = target;
this.mobSkillID = mobSkillID;
this.level = level;
this.spendCP = spendCP;
}
public int getId() {
return id;
}
public int getTarget() {
return target;
}
public int getMobSkillID() {
return mobSkillID;
}
public int getLevel() {
return level;
}
public int getSpendCP() {
return spendCP;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}

View File

@@ -1,118 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import provider.MapleData;
import provider.MapleDataProvider;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
/**
*
* @author Sammy Guergachi <sguergachi at gmail.com>
*/
public class MCSkillFactory {
private static Map<Integer, MCSkill> mcSkills = new HashMap<>();
private static Map<Integer, MCGuardian> mcGuardians = new HashMap<>();
private static MapleDataProvider dataSource = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Skill.wz"));
private static MapleData mcSkillRoot = dataSource.getData("MCSkill.img");
private static MapleData mcGuardianRoot = dataSource.getData("MCGuardian.img");
private static ReentrantReadWriteLock skillLock = new ReentrantReadWriteLock();
private static ReentrantReadWriteLock guardianLock = new ReentrantReadWriteLock();
public static MCSkill getMCSkill(int skillId) {
skillLock.readLock().lock();
try {
MCSkill ret = mcSkills.get(skillId);
if (ret != null) {
return ret;
}
} finally {
skillLock.readLock().unlock();
}
skillLock.writeLock().lock();
try {
MCSkill ret;
ret = mcSkills.get(skillId);
if (ret == null) {
MapleData skillData = mcSkillRoot.getChildByPath(String.valueOf(skillId));
if (skillData != null) {
int target = MapleDataTool.getInt("target", skillData, 0);
int spendCP = MapleDataTool.getInt("spendCP", skillData, 0);
int mobSkillID = MapleDataTool.getInt("mobSkillID", skillData, 0);
int level = MapleDataTool.getInt("level", skillData, 0);
ret = new MCSkill(skillId, target, mobSkillID, level, spendCP);
if (MonsterCarnival.DEBUG) {
String name = MapleDataTool.getString("name", skillData, "");
String desc = MapleDataTool.getString("desc", skillData, "");
ret.setName(name);
ret.setDesc(desc);
}
mcSkills.put(skillId, ret);
}
}
return ret;
} finally {
skillLock.writeLock().unlock();
}
}
public static MCGuardian getMCGuardian(int id) {
guardianLock.readLock().lock();
try {
MCGuardian ret = mcGuardians.get(id);
if (ret != null) {
return ret;
}
} finally {
guardianLock.readLock().unlock();
}
guardianLock.writeLock().lock();
try {
MCGuardian ret;
ret = mcGuardians.get(id);
if (ret == null) {
MapleData skillData = mcGuardianRoot.getChildByPath(String.valueOf(id));
if (skillData != null) {
int type = MapleDataTool.getInt("type", skillData, 0);
int spendCP = MapleDataTool.getInt("spendCP", skillData, 0);
int mobSkillID = MapleDataTool.getInt("mobSkillID", skillData, 0);
int level = MapleDataTool.getInt("level", skillData, 0);
ret = new MCGuardian(type, spendCP, mobSkillID, level);
if (MonsterCarnival.DEBUG) {
String name = MapleDataTool.getString("name", skillData, "");
String desc = MapleDataTool.getString("desc", skillData, "");
ret.setName(name);
ret.setDesc(desc);
}
mcGuardians.put(type, ret);
}
}
return ret;
} finally {
guardianLock.writeLock().unlock();
}
}
}

View File

@@ -1,41 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import org.slf4j.LoggerFactory;
/**
* Logs various errors and also keeps data on Carnival PQ runs.
* @author s4nta
*/
public class MCTracker {
static org.slf4j.Logger log = LoggerFactory.getLogger(MCTracker.class);
// TODO:
// Add field-specific info
// Add methods for calls from different files
// Maybe write own version of FilePrinter?
static final String PATH = "Reports/MCPQ.txt";
public static void log(String msg) {
System.out.println(msg);
log.debug(msg);
}
}

View File

@@ -1,164 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import provider.MapleData;
import provider.MapleDataTool;
/**
* Representation of the data tree inside of the Map.wz file.
*
* @author s4nta
*/
public class MCWZData {
public List<MCMobGenPos> mobGenPosList = new ArrayList<>();
public List<MCGuardianGenPos> guardianGenPosList = new ArrayList<>();
public Map<Integer, MCSummonMob> summons = new HashMap<>();
public Map<Integer, Integer> skills = new HashMap<>();
public Map<Integer, Integer> guardians = new HashMap<>();
public String effectWin, effectLose, soundWin, soundLose;
public int rewardMapWin, rewardMapLose;
public int mobGenMax, guardianGenMax;
public boolean mapDivided;
public int deathCP;
public int reactorRed, reactorBlue;
public MCWZData(MapleData src) {
parse(src);
}
public void parse(MapleData src) {
populateMobGenPos(src.getChildByPath("mobGenPos"));
populateSummonMobs(src.getChildByPath("mob"));
effectWin = MapleDataTool.getString("effectWin", src);
effectLose = MapleDataTool.getString("effectLose", src);
soundWin = MapleDataTool.getString("soundWin", src);
soundLose = MapleDataTool.getString("soundLose", src);
rewardMapWin = MapleDataTool.getInt("rewardMapWin", src);
rewardMapLose = MapleDataTool.getInt("rewardMapLose", src);
populateSkills(src.getChildByPath("skill"));
populateGuardianGenPos(src.getChildByPath("guardianGenPos"));
populateGuardians(src.getChildByPath("guardian"));
mobGenMax = MapleDataTool.getInt("mobGenMax", src, 20); // HACK: 20 default
guardianGenMax = MapleDataTool.getInt("guardianGenMax", src, 20); // HACK: 20 default
mapDivided = MapleDataTool.getInt("mapDivided", src) > 0;
deathCP = MapleDataTool.getInt("deathCP", src);
reactorRed = MapleDataTool.getInt("reactorRed", src);
reactorBlue = MapleDataTool.getInt("reactorBlue", src);
}
private void populateMobGenPos(MapleData src) {
for (MapleData n : src) {
MCMobGenPos nn = new MCMobGenPos(MapleDataTool.getInt("x", n, 0),
MapleDataTool.getInt("y", n, 0),
MapleDataTool.getInt("fh", n, 0),
MapleDataTool.getInt("cy", n, 0),
MapleDataTool.getInt("team", n, -1));
mobGenPosList.add(nn);
}
}
private void populateSummonMobs(MapleData src) {
for (MapleData n : src) {
int id = Integer.parseInt(n.getName());
MCSummonMob mcs = new MCSummonMob(
MapleDataTool.getInt("id", n, 0),
MapleDataTool.getInt("spendCP", n, 0),
MapleDataTool.getInt("mobTime", n, 0)
);
this.summons.put(id, mcs);
}
}
private void populateSkills(MapleData src) {
for (MapleData n : src) {
int key = Integer.parseInt(n.getName());
int val = MapleDataTool.getInt(n);
skills.put(key, val);
}
}
private void populateGuardianGenPos(MapleData src) {
for (MapleData n : src) {
MCGuardianGenPos nn = new MCGuardianGenPos(MapleDataTool.getInt("x", n, 0),
MapleDataTool.getInt("y", n, 0),
MapleDataTool.getInt("f", n, 0),
MapleDataTool.getInt("team", n, -1));
guardianGenPosList.add(nn);
}
}
private void populateGuardians(MapleData src) {
for (MapleData n : src) {
int key = Integer.parseInt(n.getName());
int val = MapleDataTool.getInt(n);
guardians.put(key, val);
}
}
public class MCMobGenPos {
public final int x, y, fh, cy, team;
private MCMobGenPos(int x, int y, int fh, int cy, int team) {
this.x = x;
this.y = y;
this.fh = fh;
this.cy = cy;
this.team = team;
}
}
public class MCGuardianGenPos {
public final int x, y, f, team;
private MCGuardianGenPos(int x, int y, int f, int team) {
this.x = x;
this.y = y;
this.f = f;
this.team = team;
}
}
public class MCSummonMob {
public final int id, spendCP, mobTime;
private MCSummonMob(int id, int spendCP, int mobTime) {
this.id = id;
this.spendCP = spendCP;
this.mobTime = mobTime;
}
}
}

View File

@@ -1,371 +0,0 @@
/*
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/>.
*/
package server.partyquest.mcpq;
import community.MapleParty;
import handling.channel.ChannelServer;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.slf4j.LoggerFactory;
import client.player.Player;
import client.player.buffs.Disease;
/**
*
* @author Sammy Guergachi <sguergachi at gmail.com>
*/
/**
* Processes game logic for Monster Carnival PQ.
*
* TODO: Display IGNs/Jobs/Level in Pending Requests
* TODO: fix reactor handling and make it less hacky
* TODO: fix cube of darkness and make it less hacky
*
* @author s4nta
*/
public class MonsterCarnival {
// Logger
static org.slf4j.Logger log = LoggerFactory.getLogger(MonsterCarnival.class);
// Map of channel to a MonsterCarnival instance.
private static final HashMap<Integer, MonsterCarnival> instances = new HashMap<>();
/**
* Returns the MonsterCarnival instance for a channel. Creates a new one and maps it
* if it does not exist.
* [MENTION=2000183830]para[/MENTION]m channel Channel to check for.
* [MENTION=850422]return[/MENTION] MonsterCarnival instance for a channel.
* @param channel
* @return
*/
public static MonsterCarnival getMonsterCarnival(int channel) {
// TODO: synchronization?
if (channel < 1 || channel > 20) {
log.warn("Attempting to get a Monster Carnival instance for invalid channel.");
return null;
}
if (instances.containsKey(channel)) {
return instances.get(channel);
}
ChannelServer cserv = ChannelServer.getInstance(channel);
if (cserv == null) {
log.error("ChannelServer instance for channel " + channel + " is null.");
return null;
}
MonsterCarnival inst = new MonsterCarnival(cserv);
instances.put(channel, inst);
return inst;
}
// Instance variables
private ChannelServer cserv;
private Map<Integer, MCField> fields = new HashMap<>();
/**
* Constructor for a MonsterCarnival instance.
* [MENTION=2000183830]para[/MENTION]m cserv Channel server for this instance.
*/
public MonsterCarnival(ChannelServer cserv) {
this.cserv = cserv;
this.initFields();
}
/**
* Initializes empty fields for the instance.
*/
private void initFields() {
for (int i = 1; i <= NUM_FIELDS; i++) {
fields.put(i, new MCField(i, this.cserv, null, null));
}
}
/**
* Gets the field with a specified ID.
* [MENTION=2000183830]para[/MENTION]m id ID of field to retrieve.
* [MENTION=850422]return[/MENTION]
*/
public MCField getField(int id) {
if (id >= 1 && id <= NUM_FIELDS) {
return fields.get(id);
}
return null;
}
/**
* Checks if a party can join a field or not.
*
* [MENTION=2000183830]para[/MENTION]m pty Party to register.
* [MENTION=2000183830]para[/MENTION]m room Room to join.
* [MENTION=850422]return[/MENTION] Different code based on status. OK if successful.
*/
public int registerStatus(MapleParty pty, int room) {
if (!isValidField(room)) {
return STATUS_FIELD_INVALID;
}
MCField field = this.getField(room);
if (field.isFull()) {
return STATUS_FIELD_FULL;
}
MCParty party = new MCParty(pty);
if (!sizeCheck(party.getSize(), room)) {
return STATUS_PARTY_SIZE;
}
boolean levelCheck = party.checkLevels();
if (!levelCheck) {
return STATUS_PARTY_LEVEL;
}
boolean chanCheck = party.checkChannels();
if (!chanCheck) {
return STATUS_PARTY_MISSING;
}
boolean mapCheck = party.checkMaps();
if (!mapCheck) {
return STATUS_PARTY_MISSING;
}
if (field.needsRequest()) {
return STATUS_REQUEST;
}
return STATUS_PROCEED;
}
/**
* Creates a new MCParty based on a regular MapleParty object.
* [MENTION=2000183830]para[/MENTION]m pty Party to base off of.
* [MENTION=850422]return[/MENTION] Newly created MCParty.
*/
public MCParty createParty(MapleParty pty) {
return new MCParty(pty);
}
public void resetPlayer(Player chr) {
MCParty.deregisterPlayer(chr);
chr.changeMap(MAP_LOBBY);
}
/**
* Returns a String containing information about lobby waiting rooms.
*
* [MENTION=850422]return[/MENTION] String containing lobby information formatted for NPC.
*/
public String getNPCAvailableFields() {
StringBuilder sb = new StringBuilder();
sb.append("Welcome to the #bCarnival PQ#k! Rooms 1-4 can hold 2-4 people, and rooms 5-6 can hold 3-6.\r\n#b");
for (int i = 1; i <= NUM_FIELDS; i++) {
MCField field = this.fields.get(i);
sb.append(field.getStatus());
}
return sb.toString();
}
// Reference Information
// Game Constants
public static final int CP_LOSS_ON_DEATH = 10;
public static final int TIME_PREBATTLE = 10;
public static final int TIME_BATTLE = 600;
public static final int TIME_LOBBYWAIT = 180;
public static final int TAB_SPAWNS = 0;
public static final int TAB_DEBUFF = 1;
public static final int TAB_GUARDIAN = 2;
/**
* Gets a random debuff for (Mini) Cube of Darkness.
* [MENTION=850422]return[/MENTION] Random MapleDisease.
*/
public static Disease getRandomDebuff() {
return DEBUFFS[new Random().nextInt(DEBUFFS.length)];
}
/**
* Checks party size. Information from hidden-street MCPQ page.
* [MENTION=2000183830]para[/MENTION]m size Size of the party.
* [MENTION=2000183830]para[/MENTION]m field Field to check for.
* [MENTION=850422]return[/MENTION] True if party size is okay, False otherwise.
*/
public static final boolean sizeCheck(int size, int field) {
if (DEBUG) {
return true;
}
switch (field) {
case 1:
case 2:
case 3:
case 4:
// return size >= 2 && size <= 4;
return size >= 1 && size <= 4;
case 5:
case 6:
// return size >= 3 && size <= 6;
return size >= 1 && size <= 6;
default:
return false;
}
}
public static final boolean isValidField(int field) {
return field >= 1 && field <= 6;
}
public static final int getLobbyMap(int field) {
if (field < 1 || field > NUM_FIELDS) {
log.warn("Attempting to get lobby map for invalid field.");
return MAP_EXIT;
}
return 980000000 + field * 100;
}
public static final boolean isLobbyMap(int mapid) {
switch (mapid) {
case 980000100:
case 980000200:
case 980000300:
case 980000400:
case 980000500:
case 980000600:
return true;
default:
return false;
}
}
public static final int getBattleFieldMap(int field) {
if (field < 1 || field > NUM_FIELDS) {
log.warn("Attempting to get battlefield map for invalid field.");
return MAP_EXIT;
}
return 980000000 + field * 100 + 1;
}
public static final boolean isBattlefieldMap(int mapid) {
switch (mapid) {
case 980000101:
case 980000201:
case 980000301:
case 980000401:
case 980000501:
case 980000601:
return true;
default:
return false;
}
}
public static final int getResurrectionMap(int field) {
if (field < 1 || field > NUM_FIELDS) {
log.warn("Attempting to get resurrection map for invalid field.");
return MAP_EXIT;
}
return 980000000 + field * 100 + 2;
}
public static final int getVictoriousMap(int field) {
if (field < 1 || field > NUM_FIELDS) {
log.warn("Attempting to get victory map for invalid field.");
return MAP_EXIT;
}
return 980000000 + field * 100 + 3;
}
public static final int getDefeatedMap(int field) {
if (field < 1 || field > NUM_FIELDS) {
log.warn("Attempting to get defeat map for invalid field.");
return MAP_EXIT;
}
return 980000000 + field * 100 + 4;
}
public static final boolean isCPQConsumeItem(int itemid) {
switch (itemid) {
case ITEM_CP_1:
case ITEM_CP_2:
case ITEM_CP_3:
case ITEM_PTY_ELIX:
case ITEM_PTY_PELIX:
case ITEM_PTY_ALLC:
case ITEM_MINICUBE:
case ITEM_DARKCUBE:
case ITEM_STUNNER:
case ITEM_IND_WHITE:
case ITEM_IND_MANA:
case ITEM_IND_ELIX:
case ITEM_IND_PELIX:
case ITEM_IND_ALLC:
case ITEM_PTY_MANA:
return true;
}
return false;
}
// Error Codes
// Note: These would be in an enum, but since these will be used in a NPC, they are not.
public static final int STATUS_FIELD_FULL = 0;
public static final int STATUS_PARTY_SIZE = 1;
public static final int STATUS_PARTY_LEVEL = 2;
public static final int STATUS_PARTY_MISSING = 3;
public static final int STATUS_FIELD_INVALID = 4;
public static final int STATUS_REQUEST = 98;
public static final int STATUS_PROCEED = 99;
// Maps
public static final int MAP_LOBBY = 980000000;
public static final int MAP_EXIT = 980000010;
// NPCs
public static final int NPC_LOBBY = 2042000;
public static final int NPC_ENTER = 2042001; // Warp in from outside
public static final int NPC_INFO = 2042002;
public static final int NPC_ASST_RED = 2042003;
public static final int NPC_ASST_BLUE = 2042004;
// Items
public static final int ITEM_CP_1 = 2022157;
public static final int ITEM_CP_2 = 2022158;
public static final int ITEM_CP_3 = 2022159;
public static final int ITEM_PTY_MANA = 2022160;
public static final int ITEM_PTY_ELIX = 2022161;
public static final int ITEM_PTY_PELIX = 2022162;
public static final int ITEM_PTY_ALLC = 2022163;
public static final int ITEM_MINICUBE = 2022164;
public static final int ITEM_DARKCUBE = 2022165;
public static final int ITEM_STUNNER = 2022166;
public static final int ITEM_IND_WHITE = 2022174;
public static final int ITEM_IND_ELIX = 2022175;
public static final int ITEM_IND_PELIX = 2022176;
public static final int ITEM_IND_MANA = 2022177;
public static final int ITEM_IND_ALLC = 2022178;
// Guardians
public static final int GUARDIAN_RED = 9980000;
public static final int GUARDIAN_BLUE = 9980001;
// Debuffs
public static final Disease[] DEBUFFS = {Disease.STUN, Disease.DARKNESS, Disease.WEAKEN}; // intentionally leave out a few
// Miscellaneous
public static final int MIN_LEVEL = 30;
public static final int MAX_LEVEL = 50;
public static final int NUM_FIELDS = 6;
// Debug
public static final boolean DEBUG = false;
}

View File

@@ -1,3 +0,0 @@
Blob contains extra classes for Monster Carnival. Can possibly be used for implementing MCPQ.
Scripts and Src contains the code changed on OdinMS to have CPQ working.

View File

@@ -1,82 +0,0 @@
/** * [MENTION=19862]id[/MENTION] 2042000
* [MENTION=806871]NPC[/MENTION] Spiegelmann
* [MENTION=836108]Function[/MENTION] Monster Carnival Lobby NPC
* @author s4nta
*/
// Relevant Monster Carnival classes
var MonsterCarnival = net.sf.odinms.server.partyquest.mcpq.MonsterCarnival;
var MCTracker = net.sf.odinms.server.partyquest.mcpq.MCTracker;
var MCParty = net.sf.odinms.server.partyquest.mcpq.MCParty;
var MCField = net.sf.odinms.server.partyquest.mcpq.MCField;
var MCTeam = net.sf.odinms.server.partyquest.mcpq.MCField.MCTeam;
// NPC variables
var status = -1;
var carnival, field;
var room = -1;
function start() {
if (cm.getMapId() != 980000000) {
MCTracker.log("Spiegelmann called on invalid map " + cm.getMapId() + " by player " + cm.getName());
cm.sendOk("You are not authorized to do this.");
cm.dispose();
return;
}
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
return;
}
if (mode == 1) status++;
else status--;
if (status == 0) {
if (cm.getParty() == null) {
cm.sendOk("You are not in a party.");
cm.dispose();
return;
} else if (!cm.isLeader()) {
cm.sendOk("If you want to try Carnival PQ, please tell the #bleader of your party#k to talk to me.");
cm.dispose();
return;
}
carnival = MonsterCarnival.getMonsterCarnival(cm.getChannel());
cm.sendSimple(carnival.getNPCAvailableFields());
} else if (status == 1) {
room = selection;
if (room < 1 || room > 6) {
cm.sendOk("That is not a valid room.");
cm.dispose();
return;
}
var code = carnival.registerStatus(cm.getParty(), selection);
if (code == MonsterCarnival.STATUS_FIELD_FULL) {
cm.sendOk("This room is currently full.")
} else if (code == MonsterCarnival.STATUS_PARTY_SIZE) {
cm.sendOk("Your party is not the right size for this field.");
} else if (code == MonsterCarnival.STATUS_PARTY_LEVEL) {
cm.sendOk("Please check to see that the members in your party are between level 30 and 50.");
} else if (code == MonsterCarnival.STATUS_PARTY_MISSING) {
cm.sendOk("Please make sure everyone in your party is in this lobby.");
} else if (code == MonsterCarnival.STATUS_FIELD_INVALID) {
cm.sendOk("Unauthorized request.");
}
if (code == MonsterCarnival.STATUS_PROCEED) {
field = carnival.getField(room);
party = carnival.createParty(cm.getParty());
field.register(party, MCTeam.RED);
cm.sendOk("You will have 3 minutes to accept challenges from other parties.");
} else if (code == MonsterCarnival.STATUS_REQUEST) {
cm.sendOk("Sending request to room " + room + ". You will be automatically warped in if they accept your challenge.");
field = carnival.getField(room);
party = carnival.createParty(cm.getParty());
field.request(party);
}
cm.dispose();
}
}

View File

@@ -1,326 +0,0 @@
/** * [MENTION=19862]id[/MENTION] 2042002
* [MENTION=806871]NPC[/MENTION] Spiegelmann
* [MENTION=836108]Function[/MENTION] Monster Carnival NPC
* @author s4nta
* [MENTION=497496]cred[/MENTION]its xirengfx (for store code, CPQ description)
*/
var DISABLED = false;
var SavedLocationType = Packages.net.sf.odinms.server.maps.SavedLocationType;
// Relevant Monster Carnival classes
var MonsterCarnival = Packages.net.sf.odinms.server.partyquest.mcpq.MonsterCarnival;
var MCTracker = Packages.net.sf.odinms.server.partyquest.mcpq.MCTracker;
var MCParty = Packages.net.sf.odinms.server.partyquest.mcpq.MCParty;
var MCField = Packages.net.sf.odinms.server.partyquest.mcpq.MCField;
// NPC variables
var status = -1;
var store = false;
var ctx = -1; //context
var storeInfo;
var purchaseId;
var purchaseCost;
// Reference
var coinId = 4001129;
var coinIcon = "#i" + coinId + "#";
var infoMaps = [220000000, 200000000, 103000000, 540000000]; // ludi, orbis, kerning, singapore
var gradeS = 600
var gradeA = 500
var gradeB = 400
var gradeC = 300
var gradeD = 200
var gradeE = 100
var expRewards = [[150000, 100000], // S Winner/Loser
[100000, 70000], // A Winner/Loser
[75000, 43250], // B Winner/Loser
[50000, 25000], // C Winner/Loser
[25000, 12500], // D Winner/Loser
[12500, 6250], // E Winner/Loser
[5000, 2500] // F Winner/Loser
];
// Exchange stores
var warrior = [[1302004, 7], [1402006, 7], [1302009, 10], [1402007, 10],
[1302010, 20], [1402003, 20], [1312006, 7], [1412004, 7],
[1312007, 10], [1412005, 10], [1312018, 20], [1412003, 20],
[1322015, 7], [1422008, 7], [1322016, 10], [1422007, 10],
[1322017, 20], [1422005, 20], [1432003, 7], [1442003, 7],
[1432005, 10], [1442009, 10], [1442005, 20], [1432004, 20]];
var magician = [[1372001, 7], [1382018, 7], [1372012, 10], [1382019, 10],
[1382001, 20], [1372007, 20]];
var archer = [[1452006, 7], [1452007, 10], [1452008, 20], [1462005, 7],
[1462006, 10], [1462007, 20]];
var thief = [[1472013, 7], [1472017, 10], [1472021, 20], [1332014, 7],
[1332011, 10], [1332031, 10], [1332016, 20], [1332034, 20]];
var pirate = [[1482005, 7], [1482006, 10], [1482007, 20], [1492005, 7],
[1492006, 10], [1492007, 20]];
var necklace = [[1122007, 50], [2041211, 40]];
// Long Text Descriptions
var infoText = "You wish to know about the Monster Carnival? Very well. The Monster Carnival is a place of trilling battles and exciting competiton against people just as strong and motivated as yourself. You must summon monsters and defeat the monsters summoned by the opposing party. That's the essence of the Monster Carnival. Once you enter the Carnival Field, the task is to earn CP by hunter monsters from the opposing party and use those CP's to distract the opposing party from hunting monsters. There are three ways to distract the other party; Summon a Monster, Skill or Protector. Please remember this though, it's never a good idea to save up CP just for the sake of it. The CP's you've used will also help determine the winner and the loser of the carnival.";
var no = "You do not have enough Maple Coins for this item. Come back to me when you acquire more!";
function getGrade(cp) {
// Returns index of corresponding expRewards pair.
if (cp >= gradeS) {
return 0;
} else if (cp >= gradeA) {
return 1;
} else if (cp >= gradeB) {
return 2;
} else if (cp >= gradeC) {
return 3;
} else if (cp >= gradeD) {
return 4;
} else if (cp >= gradeE) {
return 5;
} else {
return 6;
}
}
function isTownMap(map) {
for (var i = 0; i < infoMaps.length; i++) {
if (infoMaps[i] == map) {
return true;
}
}
return false;
}
function isExitMap(map) {
return map == 980000010;
}
function isWinnerMap(map) {
return (map >= 980000000 && map <= 980000700 && map % 10 == 3);
}
function isLoserMap(map) {
return (map >= 980000000 && map <= 980000700 && map % 10 == 4);
}
var CONTEXT_NONE = -1;
var CONTEXT_TOWN = 0;
var CONTEXT_EXIT = 1;
var CONTEXT_WIN = 2;
var CONTEXT_LOSE = 3;
function start() {
if (DISABLED) {
cm.sendOk("CPQ is temporarily unavailable.");
cm.dispose();
return;
}
m = cm.getMapId();
if (isTownMap(m)) {
ctx = CONTEXT_TOWN;
} else if (isExitMap(m)) {
ctx = CONTEXT_EXIT;
} else if (isWinnerMap(m)) {
ctx = CONTEXT_WIN;
} else if (isLoserMap(m)) {
ctx = CONTEXT_LOSE;
} else {
ctx = CONTEXT_NONE;
}
action(1, 0, 0);
}
function doLoserMap(mode, type, selection) {
if (cm.getPlayer().getMCPQParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendNext("Unfortunately, you did not manage to win this round. Better luck next time!");
} else if (status == 1) {
var points = cm.getPlayer().getMCPQParty().getTotalCP();
var grade = getGrade(points);
var letterGrade = "ABCDF"[grade];
var expReward = expRewards[grade][1];
cm.sendNext("Your grade is: #b" + letterGrade + "\r\n\r\n#kEXP Reward: " + expReward);
cm.gainExp(expReward);
} else if (status == 2) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
}
}
}
function doWinnerMap(mode, type, selection) {
if (cm.getPlayer().getMCPQParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
if (mode == -1) {
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendNext("Congratulations! You managed to defeat the enemy team!");
} else if (status == 1) {
var points = cm.getPlayer().getMCPQParty().getTotalCP();
var grade = getGrade(points);
var letterGrade = "ABCDF"[grade];
var expReward = expRewards[grade][0];
cm.sendNext("Your grade is: #b" + letterGrade + "\r\n\r\n#kEXP Reward: " + expReward);
cm.gainExp(expReward);
} else if (status == 2) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
}
}
}
function doTown(mode, type, selection) {
if (mode == -1) {
cm.sendOk("Be sure to vote for the server every 24 hours!");
cm.dispose();
} else {
if (mode == 1) status++;
else status--;
if (status == 0) {
cm.sendSimple("What would you like to do? If you have never participated in the Monster Carnival, you'll need to know a thing or two about it before joining.\r\n\r\n#b#L0#Go to the Monster Carnival Field#l\r\n#L1#Learn about the Monster Carnival#l\r\n#L2#Trade Maple Coin#l");
} else if (status == 1) {
if (selection == 0) {
if (cm.getChar().getLevel() < MonsterCarnival.MIN_LEVEL || cm.getChar().getLevel() > MonsterCarnival.MAX_LEVEL) {
cm.sendOk("You must be between level " + MonsterCarnival.MIN_LEVEL + " and level " + MonsterCarnival.MAX_LEVEL + " to enter.");
cm.dispose();
return;
}
cm.getChar().saveLocation(SavedLocationType.MONSTER_CARNIVAL);
cm.warp(MonsterCarnival.MAP_LOBBY, 4);
cm.dispose();
return;
} else if (selection == 1) {
cm.sendPrev(infoText);
cm.dispose();
return;
} else if (selection == 2) {
store = true;
cm.sendSimple("Select a category:\r\n" +
"#L101##bTrade Maple Coins for Warrior Weapons\r\n" +
"#L102#Trade Maple Coins for Magician Weapons\r\n" +
"#L103#Trade Maple Coins for Bowman Weapons\r\n" +
"#L104#Trade Maple Coins for Thief Weapons\r\n" +
"#L105#Trade Maple Coins for Pirate Weapons\r\n" +
"#L106#Trade Maple Coins for a Necklace");
}
} else if (status == 2) {
if (store) {
switch (selection) {
case 101:
storeInfo = warrior;
break;
case 102:
storeInfo = magician;
break;
case 103:
storeInfo = archer;
break;
case 104:
storeInfo = thief;
break;
case 105:
storeInfo = pirate;
break;
case 106:
storeInfo = necklace;
break;
default:
storeInfo = [];
}
if (storeInfo.length == 0) {
cm.sendOk("That store doesn't exist.");
cm.dispose();
return;
}
var storeText = "";
for (var i = 0; i < storeInfo.length; ++i) {
var wepId = storeInfo[i][0];
var cost = storeInfo[i][1];
storeText += "#L" + i + "##v" + wepId + "# - #z" + wepId + "# - " + cost + " " + coinIcon + "#l\r\n";
}
cm.sendSimple(storeText);
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 2");
}
} else if (status == 3) {
if (store) {
purchaseId = storeInfo[selection][0];
purchaseCost = storeInfo[selection][1];
if (cm.haveItem(coinId, purchaseCost)) {
cm.sendYesNo("Are you sure you want to purchase #i" + purchaseId + "#? You will have #r#e" + (cm.itemQuantity(coinId) - purchaseCost) + " " + coinIcon + "##k#n remaining.");
} else {
cm.sendOk("You don't have enough " + coinIcon + ".");
cm.dispose();
}
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 3");
}
} else if (status == 4) {
if (store) {
if (cm.haveItem(coinId, purchaseCost)) {
cm.gainItem(coinId, -purchaseCost);
cm.gainItem(purchaseId);
cm.sendOk("Congratulations! Enjoy your new item.");
cm.dispose();
}
} else {
MCTracker.log("[MCPQ_Info] CONTEXT_TOWN: Invalid status 4");
}
}
}
}
function doExit() {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.sendOk("Hope you had fun in the Carnival PQ!");
cm.dispose();
}
function action(mode, type, selection) {
switch (ctx) {
case CONTEXT_TOWN:
doTown(mode, type, selection);
break;
case CONTEXT_EXIT:
doExit();
break;
case CONTEXT_LOSE:
doLoserMap(mode, type, selection);
break;
case CONTEXT_WIN:
doWinnerMap(mode, type, selection);
break;
default:
MCTracker.log("[MCPQ_INFO] Invalid context (value: " + ctx + ")");
cm.dispose();
}
}

View File

@@ -1,88 +0,0 @@
/** * [MENTION=19862]id[/MENTION] 2042003
* [MENTION=806871]NPC[/MENTION] Assistant Red
* [MENTION=836108]Function[/MENTION] Monster Carnival Waiting Room NPC
* @author s4nta
*/
// Relevant Monster Carnival classes
var MonsterCarnival = net.sf.odinms.server.partyquest.mcpq.MonsterCarnival;
var MCTracker = net.sf.odinms.server.partyquest.mcpq.MCTracker;
var MCParty = net.sf.odinms.server.partyquest.mcpq.MCParty;
var MCField = net.sf.odinms.server.partyquest.mcpq.MCField;
var MCTeam = net.sf.odinms.server.partyquest.mcpq.MCField.MCTeam;
// NPC variables
var status = -1;
var carnival, field;
var room = -1;
function start() {
if (!MonsterCarnival.isLobbyMap(cm.getMapId())) {
MCTracker.log("Assistant called on invalid map " + cm.getMapId() + " by player " + cm.getName());
cm.sendOk("You are not authorized to do this.");
cm.dispose();
return;
}
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
return;
}
if (mode == 1) status++;
else status--;
if (status == 0) {
if (cm.getParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
options = ["#L1#Leave the room #r#e(WARNING: Abusing this will block you from future Carnival PQs)#b#n.#l",
"#L2#Close NPC#l"];
if (cm.isLeader()) {
options.unshift("#L0#View pending challenges#l");
}
text = "Welcome to Carnival PQ. I am #rAssistant Red#k. What can I do for you?#b\r\n";
for (var i = 0; i < options.length; i++) {
text += options[i];
text += "\r\n";
}
cm.sendSimple(text);
} else if (status == 1) {
field = cm.getChar().getMCPQField();
if (selection == 0) {
if (!cm.isLeader()) {
cm.sendOk("You are not authorized to do this.");
cm.dispose();
return;
}
if (!field.hasPendingRequests()) {
cm.sendOk("There are no pending requests at this time.");
cm.dispose();
return;
}
cm.sendSimple(field.getNPCRequestString());
} else if (selection == 1) {
if (field != null) {
field.deregister(true);
} else {
cm.warp(MonsterCarnival.MAP_EXIT);
}
cm.dispose();
} else {
cm.dispose();
}
} else if (status == 2) {
var code = field.acceptRequest(selection);
if (code == 1) {
cm.sendOk("The challenge was accepted.");
} else {
cm.sendOk("An unknown error occurred.");
}
cm.dispose();
}
}

View File

@@ -1,88 +0,0 @@
/** * [MENTION=19862]id[/MENTION] 2042004
* [MENTION=806871]NPC[/MENTION] Assistant Blue
* [MENTION=836108]Function[/MENTION] Monster Carnival Waiting Room NPC
* @author s4nta
*/
// Relevant Monster Carnival classes
var MonsterCarnival = net.sf.odinms.server.partyquest.mcpq.MonsterCarnival;
var MCTracker = net.sf.odinms.server.partyquest.mcpq.MCTracker;
var MCParty = net.sf.odinms.server.partyquest.mcpq.MCParty;
var MCField = net.sf.odinms.server.partyquest.mcpq.MCField;
var MCTeam = net.sf.odinms.server.partyquest.mcpq.MCField.MCTeam;
// NPC variables
var status = -1;
var carnival, field;
var room = -1;
function start() {
if (!MonsterCarnival.isLobbyMap(cm.getMapId())) {
MCTracker.log("Assistant called on invalid map " + cm.getMapId() + " by player " + cm.getName());
cm.sendOk("You are not authorized to do this.");
cm.dispose();
return;
}
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
return;
}
if (mode == 1) status++;
else status--;
if (status == 0) {
if (cm.getParty() == null) {
cm.warp(MonsterCarnival.MAP_LOBBY);
cm.dispose();
return;
}
options = ["#L1#Leave the room #r#e(WARNING: Abusing this will block you from future Carnival PQs)#b#n.#l",
"#L2#Close NPC#l"];
if (cm.isLeader()) {
options.unshift("#L0#View pending challenges#l");
}
text = "Welcome to Carnival PQ. I am #bAssistant Blue#k. What can I do for you?#b\r\n";
for (var i = 0; i < options.length; i++) {
text += options[i];
text += "\r\n";
}
cm.sendSimple(text);
} else if (status == 1) {
field = cm.getChar().getMCPQField();
if (selection == 0) {
if (!cm.isLeader()) {
cm.sendOk("You are not authorized to do this.");
cm.dispose();
return;
}
if (!field.hasPendingRequests()) {
cm.sendOk("There are no pending requests at this time.");
cm.dispose();
return;
}
cm.sendSimple(field.getNPCRequestString());
} else if (selection == 1) {
if (field != null) {
field.deregister(true);
} else {
cm.warp(MonsterCarnival.MAP_EXIT);
}
cm.dispose();
} else {
cm.dispose();
}
} else if (status == 2) {
var code = field.acceptRequest(selection);
if (code == 1) {
cm.sendOk("The challenge was accepted.");
} else {
cm.sendOk("An unknown error occurred.");
}
cm.dispose();
}
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,8 +0,0 @@
function enter(pi) { player = pi.getPlayer();
if (player.getMCPQField() != null) {
player.getMCPQField().onRevive(player);
} else {
pi.warp(980000000);
}
return true;
}

View File

@@ -1,51 +0,0 @@
/*
This file is part of the OdinMS Maple Story Server
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
Matthias Butz <matze@odinms.de>
Jan Christian Meyer <vimes@odinms.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License 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/>.
*/
importPackage(Packages.net.sf.odinms.server.maps);
/*
Return from MCPQ map.
*/
function enter(pi) {
var returnMap = pi.getPlayer().getSavedLocation(SavedLocationType.MONSTER_CARNIVAL);
if (returnMap < 0) {
returnMap = 100000000; // to fix people who entered the fm trough an unconventional way
}
var target = pi.getPlayer().getClient().getChannelServer().getMapFactory().getMap(returnMap);
var targetPortal;
if (returnMap == 230000000) {
targetPortal = target.getPortal("market01");
} else {
targetPortal = target.getPortal("market00");
}
if (targetPortal == null)
targetPortal = target.getPortal(0);
if (pi.getPlayer().getMapId() != target) {
pi.getPlayer().clearSavedLocation(SavedLocationType.MONSTER_CARNIVAL);
pi.getPlayer().changeMap(target, targetPortal);
return true;
}
return false;
}

View File

@@ -1,5 +0,0 @@
Under the respawn map change code (!c.getPlayer().isAlive()), add before executeStandardPath is done:
PHP Code:
if (player.getMCPQField() != null) { player.getMCPQField().onPlayerRespawn(player);
return;
}

View File

@@ -1,22 +0,0 @@
Add before items are added to inventory, or after mesos are handled:
PHP Code:
else if (c.getPlayer().getMCPQField() != null) { // CPQ Handling boolean consumed = c.getPlayer().getMCPQField().onItemPickup(c.getPlayer(), mapitem);
if (consumed) {
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, c.getPlayer().getId()),
mapitem.getPosition());
c.getPlayer().getCheatTracker().pickupComplete();
c.getPlayer().getMap().removeMapObject(ob);
} else {
if (MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), true)) {
c.getPlayer().getMap().broadcastMessage(
MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, c.getPlayer().getId()),
mapitem.getPosition());
c.getPlayer().getCheatTracker().pickupComplete();
c.getPlayer().getMap().removeMapObject(ob);
} else {
c.getPlayer().getCheatTracker().pickupComplete();
return;
}
}
}

View File

@@ -1,73 +0,0 @@
client/MapleCharacter.java
Add fields:
PHP Code:
private MCField.MCTeam MCPQTeam;private MCParty MCPQParty;
private MCField MCPQField;
private int availableCP = 0;
private int totalCP = 0;
under playerDead() method:
PHP Code:
if (player.getMap().isTown()) { XPdummy *= 0.01;
} else if (MonsterCarnival.isBattlefieldMap(player.getMapId())) {
XPdummy = 0;
}
under the giveDebuff() method, add a field that force adds the disease if some variable cpq is set, regardless of buffs.
method signature:
PHP Code:
public void giveDebuff(MapleDisease disease, MobSkill skill, boolean cpq)
Add these methods:
PHP Code:
public int getTeam() { if (this.MCPQTeam == null) {
return -1;
}
return this.MCPQTeam.code;
}
public MCField.MCTeam getMCPQTeam() {
return MCPQTeam;
}
public void setMCPQTeam(MCField.MCTeam MCPQTeam) {
this.MCPQTeam = MCPQTeam;
}
public MCParty getMCPQParty() {
return MCPQParty;
}
public void setMCPQParty(MCParty MCPQParty) {
this.MCPQParty = MCPQParty;
}
public MCField getMCPQField() {
return MCPQField;
}
public void setMCPQField(MCField MCPQField) {
this.MCPQField = MCPQField;
}
public int getAvailableCP() {
return availableCP;
}
public void setAvailableCP(int availableCP) {
this.availableCP = availableCP;
}
public int getTotalCP() {
return totalCP;
}
public void setTotalCP(int totalCP) {
this.totalCP = totalCP;
}
public void gainCP(int cp) {
this.availableCP += cp;
this.totalCP += cp;
}
public void loseCP(int cp) {
this.availableCP -= cp;
}

View File

@@ -1,5 +0,0 @@
Add this under disconnect() (right after event instance calls onPlayerDisconnect, preferably):
PHP Code:
if (chr.getMCPQField() != null) {
chr.getMCPQField().onPlayerDisconnected(player);
}

View File

@@ -1,3 +0,0 @@
Add to getMonster(int monsterId):
PHP Code:
stats.setCp(MapleDataTool.getIntConvert("getCP", monsterInfoData, 0));

View File

@@ -1,80 +0,0 @@
Add fields:
PHP Code:
private boolean respawning = true;
private MCWZData mcpqData;
Add methods:
PHP Code:
public final List<MapleMonster> getAllMonsters() { return getAllMapObjects(MapleMapObjectType.MONSTER);
}
public void addMonsterSpawn(MapleMonster monster, int mobTime, int team) {
Point newpos = calcPointBelow(monster.getPosition());
newpos.y -= 1;
SpawnPoint sp = new SpawnPoint(monster, newpos, mobTime, team);
monsterSpawn.add(sp);
if (!respawning) return;
if (sp.shouldSpawn() || mobTime == -1) {
sp.spawnMonster(this);
}
}
public void setReactorState(MapleReactor reactor, byte state) {
synchronized (this.mapobjects) {
reactor.setState(state);
broadcastMessage(MaplePacketCreator.triggerReactor(reactor, state));
}
}
public <E extends MapleMapObject> List<E> getAllMapObjects(MapleMapObjectType type) {
List<E> ret = new ArrayList<>();
synchronized (mapobjects) {
for (MapleMapObject l : mapobjects.values()) {
if (l.getType() == type) {
ret.add((E) l);
}
}
}
return ret;
}
public void clearDrops() {
List<MapleMapItem> items = getAllMapObjects(MapleMapObjectType.ITEM);
for (MapleMapItem itemmo : items) {
removeMapObject(itemmo);
broadcastMessage(MaplePacketCreator.removeItemFromMap(itemmo.getObjectId(), 0, 0));
}
}
public Collection<SpawnPoint> getSpawnPoints() {
return monsterSpawn;
}
public void respawn() {
for (SpawnPoint sp : this.monsterSpawn) {
if (sp.shouldSpawn()) {
sp.spawnMonster(this);
}
}
}
public void beginSpawning() {
this.respawning = true;
this.respawn();
}
public boolean isRespawning() {
return respawning;
}
public void setRespawning(boolean respawning) {
this.respawning = respawning;
}
public MCWZData getMCPQData() {
return this.mcpqData;
}
public void setMCPQData(MCWZData data) {
this.mcpqData = data;
}

View File

@@ -1,22 +0,0 @@
Add to getMap() method, under where it parses PQ areas:
PHP Code:
MapleData mcData = mapData.getChildByPath("monsterCarnival");if (mcData != null) {
MCWZData mcpqInfo = new MCWZData(mcData);
map.setMCPQData(mcpqInfo);
map.setRespawning(false);
}
Add to getMap() method, under where it parses mobTime:
PHP Code:
int team = MapleDataTool.getInt("team", life, -1);
Change addMonsterSpawn() method call to the following, using the new SpawnPoint construction we defined in MapleMap:
PHP Code:
map.addMonsterSpawn(monster, mobTime, team);
Add the method:
PHP Code:
public MapleMap instanceMap(int mapid, boolean respawns, boolean npcs) { return instanceMap(mapid, respawns, npcs, true);
}
and
PHP Code:
public MapleMap instanceMap(int mapid, boolean respawns, boolean npcs, boolean reactors)
, where the code is the same as getMap but does not try to load from cache and does not store into cache.

View File

@@ -1,31 +0,0 @@
Add fields:
PHP Code:
private int team = -1;
Add methods:
PHP Code:
public int getCP() { return stats.getCp();
}
public int getTeam() {
return team;
}
public void setTeam(int team) {
this.team = team;
}
public void dispel() {
if (!isAlive()) return;
for (MonsterStatus i : MonsterStatus.values()) {
if (monsterBuffs.contains(i)) {
removeMonsterBuff(i);
MaplePacket packet = MaplePacketCreator.cancelMonsterStatus(getObjectId(), Collections.singletonMap(i, Integer.valueOf(1)));
map.broadcastMessage(packet, getPosition());
if (getController() != null && !getController().isMapObjectVisible(MapleMonster.this)) {
getController().getClient().getSession().write(packet);
}
}
}
}

View File

@@ -1,13 +0,0 @@
Add field:
PHP Code:
private int cp;
Add methods:
PHP Code:
public int getCp() {
return cp;
}
public void setCp(int cp) {
this.cp = cp;
}

View File

@@ -1,6 +0,0 @@
Under hitReactor(), add before standard handling:
PHP Code:
if (c.getPlayer().getMCPQField() != null) {
c.getPlayer().getMCPQField().onGuardianHit(c.getPlayer(), this);
return;
}

View File

@@ -1,27 +0,0 @@
Add fields:
PHP Code:
private boolean consumeOnPickup, party;
private int cp, nuffSkill;
Add to stat parsing (loadFromData()):
PHP Code:
ret.cp = MapleDataTool.getInt("cp", source, 0);ret.party = MapleDataTool.getInt("party", source, 0) > 0;
ret.consumeOnPickup = MapleDataTool.getInt("consumeOnPickup", source, 0) > 0;
ret.nuffSkill = MapleDataTool.getInt("nuffSkill", source, -1);
Add methods:
PHP Code:
public int getCP() { return cp;
}
public boolean isParty() {
return party;
}
public boolean isConsumeOnPickup() {
return consumeOnPickup;
}
public int getNuffSkill() {
return nuffSkill;
}

View File

@@ -1,23 +0,0 @@
Add to applyEffect():
PHP Code:
case 150: monStat = MonsterStatus.WEAPON_ATTACK_UP;
break;
case 151:
monStat = MonsterStatus.WEAPON_DEFENSE_UP;
break;
case 152:
monStat = MonsterStatus.MAGIC_ATTACK_UP;
break;
case 153:
monStat = MonsterStatus.MAGIC_DEFENSE_UP;
break;
case 154:
monStat = MonsterStatus.ACC;
break;
case 155:
monStat = MonsterStatus.AVOID;
break;
case 156:
monStat = MonsterStatus.SPEED;
break;

View File

@@ -1,41 +0,0 @@
package net.sf.odinms.net.channel.handler;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.server.partyquest.mcpq.MCField;
import net.sf.odinms.server.partyquest.mcpq.MCTracker;
import net.sf.odinms.server.partyquest.mcpq.MonsterCarnival;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
/**
* Packet handler for Monster Carnival.
* @author s4nta
*/
public class MonsterCarnivalHandler extends AbstractMaplePacketHandler {
@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int tab = slea.readByte();
int num = slea.readByte();
MapleCharacter chr = c.getPlayer();
if (MonsterCarnival.DEBUG) {
MCTracker.log("[MCHandler] " + chr.getName() + " used tab " + tab + " num " + num);
System.out.println("[MCHandler] " + chr.getName() + " used tab " + tab + " num " + num);
}
if (chr.getMCPQField() == null || chr.getMCPQParty() == null) {
MCTracker.log("[MCHandler] " + chr.getName() + " attempting to use Monster Carnival handler without being in Monster Carnival");
return;
}
MCField field = chr.getMCPQField();
if (tab == 0) {
field.onAddSpawn(c.getPlayer(), num);
} else if (tab == 1) {
field.onUseSkill(c.getPlayer(), num);
} else if (tab == 2) { // status
field.onGuardianSummon(c.getPlayer(), num);
}
}
}

View File

@@ -1,20 +0,0 @@
else if (c.getPlayer().getMCPQField() != null) { // CPQ Handling
boolean consumed = c.getPlayer().getMCPQField().onItemPickup(c.getPlayer(), mapitem);
if (consumed) {
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, c.getPlayer().getId()),
mapitem.getPosition());
c.getPlayer().getCheatTracker().pickupComplete();
c.getPlayer().getMap().removeMapObject(ob);
} else {
if (MapleInventoryManipulator.addFromDrop(c, mapitem.getItem(), true)) {
c.getPlayer().getMap().broadcastMessage(
MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 2, c.getPlayer().getId()),
mapitem.getPosition());
c.getPlayer().getCheatTracker().pickupComplete();
c.getPlayer().getMap().removeMapObject(ob);
} else {
c.getPlayer().getCheatTracker().pickupComplete();
return;
}
}
}

View File

@@ -1,35 +0,0 @@
Add field:
PHP Code:
private int team = -1;
Add constructor:
PHP Code:
public SpawnPoint(MapleMonster monster, Point pos, int mobTime, int team) { super();
this.monster = monster;
this.pos = new Point(pos);
this.mobTime = mobTime;
this.immobile = !monster.isMobile();
this.nextPossibleSpawn = System.currentTimeMillis();
this.team = team;
}
Add monster death listener under spawnMonster():
PHP Code:
if (team > -1) { final int cp = mob.getCP();
mob.addListener(new MonsterListener() {
@Override
public void monsterKilled(MapleMonster monster, MapleCharacter highestDamageChar) {
if (highestDamageChar == null) {
return;
}
if (highestDamageChar.getMCPQParty() == null) {
MCTracker.log("Attempted to give CP to character without assigned MCPQ Party.");
return;
}
highestDamageChar.getMCPQField().monsterKilled(highestDamageChar, cp);
}
});
mob.setTeam(team);
}

View File

@@ -938,4 +938,22 @@ Corrigido Body Pressure não mostrando valor de dano para outros jogadores.
Adicionado flag que permite town scrolls atuarem como se fossem "player banishes", permitindo ativação do antibanish scroll.
09 Maio 2018,
Corrigido autopot handler consumindo mais pots que o necessário para pots com ganhos percentuais.
Corrigido autopot handler consumindo mais pots que o necessário para pots com ganhos percentuais.
10 - 11 Maio 2018,
Adicionado suporte para Kite's.
Revisto acesso concorrente com módulos de pet autopot.
Tomado medida paliativa pra tentar resolver o problema com players retidos em certos channels do jogo (que leva ao mesmo não conseguir logar num channel).
Implementado quest da harpa (questid 3314), além de implementado som na harpa podendo ser ouvido por todos os jogadores no mapa.
Adicionado efeito sonoro para destacar ação de metro (sinaliza chegando/saindo similarmente ao usado pelos outros objetos de viagem).
Adicionado suporte para player NPCs e hall da fama.
14 - 19 Maio 2018,
Resolvido bug com NPC prefeito de NLC, permitindo jogador repetir quiz o quanto quiser.
Calibrado sistema de automatização de novas posições para player NPCs.
Adicionado sistema de ranqueamento para player NPCs.
Adicionado flag que define novo requerimento de mobs para questline do Temple of Time.
Corrigido pets permanentes expirando com o tempo.
Adicionado suporte para Cash Shop Surprise.
Revisado sistema de handlers que gerencia login no server.
Resolvido um problema com flag ultra three snails.

View File

@@ -1,206 +0,0 @@
/**
---------------------------------------------------------------------------------------------------
* NPC Name: High Priest John - ID: 9201002.js
* @author Vcoc
* @author Ronan
---------------------------------------------------------------------------------------------------
**/
importPackage(Packages.client);
importPackage(Packages.server);
importPackage(Packages.tools);
var status;
var minLevel = 10;
var maxLevel = 200;
var mySelection = -1;
var rings = Array(1112001, 1112002, 1112003, 1112005, 1112006);
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == 1) {
status++;
} else {
if (type == 1 && mode == 0)
cm.sendOk("...");
cm.dispose();
return;
}
if (cm.getPlayer().getMapId() == 680000000) {
if (status == 0) {
cm.sendSimple("Olá #h #,\r\n#bO que você gostaria de fazer hoje?#b\r\n#L0#Eu quero me casar!#l\r\n#L1#Eu quero ver meus amigos no casamento!#l\r\n#L2#Quero trocar um Bilhete Premium de casamento por 5 convites!#l\r\n#L3#Eu quero comprar um Bilhete de Casamento!#l\r\n#L4#Gostaria de obter uma licença de casamento.#l");
} else if (status == 1) {
if (selection == 0) {
if (cm.getParty() == null) { // no party
cm.sendOk("Para se casar e necessario estar em grupo com a parceira(o)!");
cm.dispose();
} else if (!cm.isLeader()) { // not party leader
cm.sendOk("Por favor, fale ao seu parceiro(a) para falar comigo.");
cm.dispose();
} else {
var party = cm.getParty().getMembers();
var mapId = cm.getPlayer().getMapId();
var levelValid = 0;
var genderRight = 0;
var alreadyMarried = 0;
for (var i = 0; i < party.size(); i++) {
var pPlayer = party.get(i);
if (pPlayer.getLevel() >= minLevel && pPlayer.getLevel() <= maxLevel)
levelValid += 1;
if (pPlayer.getGender() == 0) {
genderRight += 1;
} else if (pPlayer.getGender() == 1) {
genderRight += 2;
}
if (pPlayer.isMarried() == 1) {
alreadyMarried += 1;
}
}
if (party.size() == 2) {
if (party.get(0).getGender() == 0) { // leader.
if (levelValid == 2 || cm.partyMembersInMap() == 2) {
if (genderRight == 3) {
if (alreadyMarried == 0) {
if (cm.haveItem(4031374, 1) && cm.haveItem(5251003, 1)) {
// Kick it into action. Slate says nothing here, just warps you in.
var em = cm.getEventManager("CathedralWedding");
if (em == null) {
cm.sendOk("Indisponivel!");
} else {
// Begin the Wedding o.O
em.startInstance(cm.getParty(), cm.getPlayer().getMap());
party = cm.getPlayer().getEventInstance().getPlayers();
var hname = party.get(0).getName();
var wname = party.get(1).getName();
var StringLine = "[" + hname + " & " + wname + "] Irão se casar na Catedral, no canal (" + cm.getC().getChannel() + ").";
cm.worldMessage(5, StringLine);
var eim = cm.getChar().getEventInstance();
eim.setProperty("husband", party.get(0).getName());
eim.setProperty("wife", party.get(1).getName());
}
} else
cm.sendOk("Você não tem os itens necessários, desculpe!");
} else
cm.sendOk("Você já está casado.");
} else
cm.sendOk("O nosso servidor não suporta este tipo de casamento!");
} else
cm.sendOk("Vocês precisam estar no mesmo mapa e ser pelo menos no nível ["+minLevel+" ~ "+maxLevel+"]");
} else
cm.sendOk("Por favor faça o teu marido lider do grupo.");
} else
cm.sendOk("Somentos marido e mulher no grupo!");
cm.dispose();
}
} else if (selection == 1) {
if (cm.haveItem(5251100, 1)) {
cm.sendGetText("Por favor, insira o nome de um dos membros do casamento .");
} else {
cm.sendOk("Parece que o casal que você quer assistir não te deu um convite ainda.");
cm.dispose();
}
} else if (selection == 2) {
if (cm.haveItem(5251003, 1)) {
cm.gainItem(5251003, -1);
cm.gainItem(5251100,5);
} else {
cm.sendOk("Você não tem o Bilhete de Casamento Premium.");
}
cm.dispose();
} else if (selection == 3) {
cm.sendOk("Você pode comprar um Bilhete de Casamento com a Ria! Localizada no Mercado Livre.");
cm.dispose();
} else if (selection == 4) {
if (cm.getPlayer().getMarriageQuestLevel() == 50) {
cm.sendNext("Por favor, vá visitar a Mom eo Dad em sua casa. Eles vivem em algum lugar Henesys Hunting Ground II.");
cm.getPlayer().addMarriageQuestLevel();
} else if (cm.getPlayer().getMarriageQuestLevel() == 53) {
if (cm.haveItem(4031373, 1)) {
cm.sendNext("Pronto, aqui sua permissão!");
cm.removeAll(4031373);
cm.gainItem(4031374, 1);
cm.getPlayer().setMarriageQuestLevel(100);
} else {
cm.sendNext("Você não tem a benção de Mom e Dad!");
}
} else {
cm.sendNext("Eu não sei o que você está falando.");
}
cm.dispose();
}
} else if (status == 2) {
var chr = cm.getCharByName(cm.getText());
if (chr != null) {
if (chr.getMapId() == 680000200) {
var eim = chrr.getEventInstance();
eim.registerPlayer(cm.getPlayer());
} else {
cm.sendOk("O casamento que você gostaria de participar não foi iniciado.");
}
} else
cm.sendOk("Jogador não encontrado.");
cm.dispose();
}
} else if (cm.getPlayer().getMapId() == 680000210) {
var eim = cm.getPlayer().getEventInstance();
var husbandName = eim.getProperty("husband");
var wifeName = eim.getProperty("wife");
var husband = cm.getCharByName(husbandName);
var wife = cm.getCharByName(wifeName);
var id = cm.getPlayer().getId();
var hclicked = eim.getProperty("hclicked");
var wclicked = eim.getProperty("hclicked");
var otherChar = husband == cm.getPlayer() ? wife : husband;
if (husband != null && wife != null) {
if (status == 0) {
if (id != husband.getId() && id != husband.getId()) {
cm.sendOk("Você não está se casando!");
cm.dispose();
} else if (cm.getPlayer().isMarried() > 0) {
cm.sendOk("Você já foi casado.");
cm.dispose();
} else if (hclicked == 1 && husbandName.equals(cm.getPlayer().getName())) {
cm.sendOk("Você já aceitou casar-se com sua esposa, pergunte à sua esposa a aceitar agora");
cm.dispose();
} else if (wclicked == 1 && wifeName.equals(cm.getPlayer().getName())) {
cm.sendOk("Você já aceitou casar-se com o seu marido , pergunte ao seu marido a aceitar agora");
cm.dispose();
} else {
cm.sendYesNo("Você deseja se casar com seu parceiro?\r\n\r\nIsso será uma decisão final.");
}
} else if (status == 1) {
if (husband == cm.getPlayer())
eim.setProperty("hclicked", 1);
else if (wife == cm.getPlayer())
eim.setProperty("wclicked", 1);
else {
cm.sendOk("Como assim?");
cm.dispose();
}
if (eim.getProperty("hclicked") == 1 && eim.getProperty("hclicked") == 1) {
if (!cm.createMarriage(otherChar.getName())) {
cm.sendOk("O sistema não pode encontrar o seu parceiro.");
cm.dispose();
return;
}
cm.worldMessage(5, "Parabéns a "+husbandName+" e "+wifeName+". São recém-casados, você pode enchê-los de spam agora!");
cm.removeAll(4031374);
MapleInventoryManipulator.removeById(otherChar.getClient(), MapleInventoryType.USE, 4031374, otherChar.getItemQuantity(4031374, false), false, false);
cm.dispose();
}
}
}
}
}

View File

@@ -1,25 +0,0 @@
var status = 0;
function start() {
status = -1;
action(1, 0, 0);
}
function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}else if (mode == 0){
cm.dispose();
return;
} else {
if (mode == 1)
status++;
else
status--;
if (status == 0) {
cm.sendOk("Wow Vickii! You look so beautiful today. Are you ready to move on to the next part of this surprise?\r\n I will be giving you a tour for our chapel.");
cm.getPlayer().startWedding();
}
}
}