Jump Quest Event.
This is to help GMs host jump quests so that they can participate in them and not have to worry about watching who is first, second, third, etc...
It keeps a point system keeping track of how many times they were first/second/third meaning;
Everytime they are in first: 3 points
Second: 2 points
Third: 1 point.
Everytime they go to another map, they get the chance to get points.
It should automatically tell when someone has come close to the portal to the next map.
Please note I haven't had much time to test this so I'm not garunteeing it'll work 100%.
net.sf.odinms.server.JumpQuestEvent:
Spoiler:
Code:/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.sf.odinms.server;
import net.sf.odinms.client.MapleCharacter;
import net.sf.odinms.client.MapleClient;
import java.util.Collection;
import java.util.List;
import java.util.LinkedList;
import net.sf.odinms.server.maps.*;
import net.sf.odinms.tools.*;
import net.sf.odinms.net.MaplePacket;
import net.sf.odinms.net.channel.ChannelServer;
/**
*
* @author Inu
*/
public class JumpQuestEvent {
public MapleCharacter owner;
public List<MapleMap> maps = new LinkedList<MapleMap>();
public List<MapleCharacter> players = new LinkedList<MapleCharacter>();
public boolean running = false;
TimerManager timer = TimerManager.getInstance();
public JumpQuestEvent(MapleCharacter starter){
this.maps.add(starter.getMap());
this.owner = starter;
this.players.add(starter);
ChannelServer channel = starter.getClient().getChannelServer();
for(ChannelServer ch : channel.getAllInstances()){ // o_o... Your mom is static.
ch.broadcastPacket(MaplePacketCreator.serverMessage("There is about to be a jump quest in channel " + starter.getClient().getChannel() + " if you are in that channel you will be automatically warped to it when it begins."));
}
}
public void addMap(MapleMap map){
this.maps.add(map);
}
public void addCharacter(MapleCharacter who){
this.players.add(who);
}
public void broadcastMessage(MapleCharacter source, MaplePacket packet, boolean repeattosource){
synchronized(players){ // Your face is final. o_o...
for(MapleCharacter chara : players){
if(chara == source){
if(repeattosource){
chara.getClient().getSession().write(packet);
}else{
// Do nothing. o_o...
}
}else{
chara.getClient().getSession().write(packet);
}
}
}
}
public void start(int howlong){
running = true;
timer.schedule(new Runnable() {
@Override
public void run() {
end();
}
}, howlong);
MaplePacket mypack = MaplePacketCreator.serverNotice(0, "The jump quest event has begun!");
ChannelServer channel = owner.getClient().getChannelServer();
for(ChannelServer ch : channel.getAllInstances()){
ch.broadcastPacket(mypack);
}
//this.broadcastMessage(owner, mypack, true);
}
public void start(int howlong, int delay){
final int howlo = howlong;
timer.schedule(new Runnable() {
@Override
public void run() {
start(howlo);
}
}, delay);
MaplePacket mypack = MaplePacketCreator.serverNotice(0, "The jump quest event is about to begin in channel " + owner.getClient().getChannel() + " in " + delay + " second(s).");
ChannelServer channel = owner.getClient().getChannelServer();
for(ChannelServer ch : channel.getAllInstances()){
ch.broadcastPacket(mypack);
}
}
public void warpEntireChannel(MapleCharacter doer){
net.sf.odinms.net.channel.ChannelServer channel = doer.getClient().getChannelServer();
for(MapleCharacter chara : channel.getPlayerStorage().getAllCharacters()){
if(doer.getMap().getPortal("start00") != null){
chara.changeMap(doer.getMap(), doer.getMap().getPortal("start00"));
}else if(doer.getMap().getPortal("join00") != null){
chara.changeMap(doer.getMap(), doer.getMap().getPortal("join00"));
}else{
chara.changeMap(doer.getMap(), doer.getMap().getPortal(0)); // Fuck you. xD
}
}
}
public void end(){
List<MapleCharacter> winners = new LinkedList<MapleCharacter>();
for(MapleMap map : maps){ // Calculate the points.
if(map.thirdplace != null){
map.thirdplace.jumpquestpoints += 1;
map.secondplace.jumpquestpoints += 2;
map.firstplace.jumpquestpoints += 3;
}else if(map.secondplace != null){
map.secondplace.jumpquestpoints += 2;
map.firstplace.jumpquestpoints += 3;
}else if(map.firstplace != null){
map.firstplace.jumpquestpoints += 3;
}
if(!winners.contains(map.thirdplace) && map.thirdplace != null){
winners.add(map.thirdplace);
}
if(!winners.contains(map.secondplace) && map.secondplace != null){
winners.add(map.secondplace);
}
if(!winners.contains(map.firstplace) && map.firstplace != null){
winners.add(map.firstplace);
}
}
final MapleMap returningmap = owner.getClient().getChannelServer().getMapFactory().getMap(100000000);
final MapleMap rewardmap = owner.getClient().getChannelServer().getMapFactory().getMap(109050000);
for(MapleCharacter chara : players){
if(chara != owner){
if(!winners.contains(chara)){
chara.dropMessage("Thanks for participating in the event! Better luck next time!");
final MapleCharacter character = chara;
chara.getClient().getSession().write(MaplePacketCreator.showEffect("quest/carnival/lose"));
timer.schedule(new Runnable() {
@Override
public void run() {
character.changeMap(returningmap, returningmap.getPortal(0));
character.myjump = null;
}
}, 5000);
}else{
chara.dropMessage("Congratulations! You have earned a reward!");
final MapleCharacter character = chara;
chara.getClient().getSession().write(MaplePacketCreator.showEffect("quest/carnival/win"));
timer.schedule(new Runnable() {
@Override
public void run() {
character.changeMap(rewardmap, rewardmap.getPortal(0));
character.myjump = null;
}
}, 5000);
}
}else{
chara.dropMessage("People with points:");
for(MapleCharacter chr : winners){
chara.dropMessage(chr.getName() + " has " + chr.jumpquestpoints + " points.");
}
chara.changeMap(rewardmap, rewardmap.getPortal(0));
chara.myjump = null;
}
}
for (int i = 1; i <= ChannelServer.getAllInstances().size(); i++) {
ChannelServer.getInstance(i).setServerMessage("The jump quest has ended.");
}
this.running = false; // Your mom is running. After that twinky. o_o.
timer.schedule(new Runnable() {
@Override
public void run() {
for (int i = 1; i <= ChannelServer.getAllInstances().size(); i++) {
ChannelServer.getInstance(i).setServerMessage("");
}
}
}, 120000);
}
}
Modifications:
net.sf.odinms.client.MapleCharacter:
Added:
Spoiler:
Code:public JumpQuestEvent myjump = null;
public int jumpquestpoints = 0;
net.sf.odinms.client.messages.GMCommand:
Added:
Spoiler:
Code:else if (splitted[0].equals("!jmpquest")) {
if(player.myjump == null){
player.myjump = new JumpQuestEvent(player);
}
if(splitted[1].equals("start")){
if(splitted.length == 4){
player.myjump.start(Integer.parseInt(splitted[2]), Integer.parseInt(splitted[3]));
}else if(splitted.length == 3){
player.myjump.start(Integer.parseInt(splitted[2]));
}
}
if(splitted[1].equals("end")){
player.myjump.end();
}
}
net.sf.odinms.server.maps.MapleMap:
Spoiler:
Added:
AddPlayer{Code:public MapleCharacter firstplace, secondplace, thirdplace; // I'm tired of privates so fuck off.
public JumpQuestEvent myjump = null;
Added:
}Code:if(myjump != null){ // Initialize the player into this jumpquest.
if(!myjump.running){
myjump = null;
}
if(myjump.players.contains(chr)){
// LOL. xD
}else{
myjump.addCharacter(chr);
chr.myjump = myjump;
}
}
if(chr.myjump != null && myjump == null && chr.myjump.owner == chr){ // Initialize this map.
myjump = chr.myjump;
chr.myjump.addMap(this);
}
if(chr.myjump != null && chr.myjump == myjump){ // If they are already a part of this jump quest... o.o...
if(!chr.myjump.running){
chr.myjump = null; // o_o.
}else{
if(myjump.players.contains(chr)){
// Do what? o_O...
}else{
if(myjump.running){
myjump.players.add(chr);
}
}
}
}
I made this to work with the Maple Fitness maps. Nothing else. If it does work on other maps please post here.
I'm not going to fix this for you. I'm not gonna help you make it work. If it doesn't work and I find the problem in my downtime I'll fix it.
I'm releasing this now without testing it because I now have to go back to work on my C# source since I took a week off because of school. Good luck to those testing it :thumbup:

