Switch to Maven file structure

This commit is contained in:
P0nk
2021-03-30 21:07:35 +02:00
parent 4acc5675d6
commit 813643036b
817 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
/*
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 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.events;
/**
* @author kevintjuh93
*/
public abstract class MapleEvents {
public MapleEvents() {
}
public abstract int getInfo();
}

View File

@@ -0,0 +1,58 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package server.events;
import client.MapleCharacter;
import client.SkillFactory;
/**
*
* @author kevintjuh93
*/
public class RescueGaga extends MapleEvents {
private int completed;
public RescueGaga(int completed) {
super();
this.completed = completed;
}
public int getCompleted() {
return completed;
}
public void complete() {
completed++;
}
@Override
public int getInfo() {
return getCompleted();
}
public void giveSkill(MapleCharacter chr) {
int skillid = 0;
switch (chr.getJobType()) {
case 0:
skillid = 1013;
break;
case 1:
case 2:
skillid = 10001014;
}
long expiration = (System.currentTimeMillis() + 3600 * 24 * 20 * 1000);//20 days
if (completed < 20) {
chr.changeSkillLevel(SkillFactory.getSkill(skillid), (byte) 1, 1, expiration);
chr.changeSkillLevel(SkillFactory.getSkill(skillid + 1), (byte) 1, 1, expiration);
chr.changeSkillLevel(SkillFactory.getSkill(skillid + 2), (byte) 1, 1, expiration);
} else {
chr.changeSkillLevel(SkillFactory.getSkill(skillid), (byte) 2, 2, chr.getSkillExpiration(skillid));
}
}
}

View File

@@ -0,0 +1,206 @@
/*
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 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.events.gm;
import client.MapleCharacter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import server.TimerManager;
import server.maps.MapleMap;
import tools.MaplePacketCreator;
/**
*
* @author kevintjuh93
*/
//Make them better :)
public class MapleCoconut extends MapleEvent {
private MapleMap map = null;
private int MapleScore = 0;
private int StoryScore = 0;
private int countBombing = 80;
private int countFalling = 401;
private int countStopped = 20;
private List<MapleCoconuts> coconuts = new LinkedList<MapleCoconuts>();
public MapleCoconut(MapleMap map) {
super(1, 50);
this.map = map;
}
public void startEvent() {
map.startEvent();
for (int i = 0; i < 506; i++) {
coconuts.add(new MapleCoconuts(i));
}
map.broadcastMessage(MaplePacketCreator.hitCoconut(true, 0, 0));
setCoconutsHittable(true);
map.broadcastMessage(MaplePacketCreator.getClock(300));
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (map.getId() == 109080000) {
if (getMapleScore() == getStoryScore()) {
bonusTime();
} else if (getMapleScore() > getStoryScore()) {
for (MapleCharacter chr : map.getCharacters()) {
if (chr.getTeam() == 0) {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/victory"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Victory"));
} else {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/lose"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Failed"));
}
}
warpOut();
} else {
for (MapleCharacter chr : map.getCharacters()) {
if (chr.getTeam() == 1) {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/victory"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Victory"));
} else {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/lose"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Failed"));
}
}
warpOut();
}
}
}
}, 300000);
}
public void bonusTime() {
map.broadcastMessage(MaplePacketCreator.getClock(120));
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (getMapleScore() == getStoryScore()) {
for (MapleCharacter chr : map.getCharacters()) {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/lose"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Failed"));
}
warpOut();
} else if (getMapleScore() > getStoryScore()) {
for (MapleCharacter chr : map.getCharacters()) {
if (chr.getTeam() == 0) {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/victory"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Victory"));
} else {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/lose"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Failed"));
}
}
warpOut();
} else {
for (MapleCharacter chr : map.getCharacters()) {
if (chr.getTeam() == 1) {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/victory"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Victory"));
} else {
chr.getClient().announce(MaplePacketCreator.showEffect("event/coconut/lose"));
chr.getClient().announce(MaplePacketCreator.playSound("Coconut/Failed"));
}
}
warpOut();
}
}
}, 120000);
}
public void warpOut() {
setCoconutsHittable(false);
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
List<MapleCharacter> chars = new ArrayList<>(map.getCharacters());
for (MapleCharacter chr : chars) {
if ((getMapleScore() > getStoryScore() && chr.getTeam() == 0) || (getStoryScore() > getMapleScore() && chr.getTeam() == 1)) {
chr.changeMap(109050000);
} else {
chr.changeMap(109050001);
}
}
map.setCoconut(null);
}
}, 12000);
}
public int getMapleScore() {
return MapleScore;
}
public int getStoryScore() {
return StoryScore;
}
public void addMapleScore() {
this.MapleScore += 1;
}
public void addStoryScore() {
this.StoryScore += 1;
}
public int getBombings() {
return countBombing;
}
public void bombCoconut() {
countBombing--;
}
public int getFalling() {
return countFalling;
}
public void fallCoconut() {
countFalling--;
}
public int getStopped() {
return countStopped;
}
public void stopCoconut() {
countStopped--;
}
public MapleCoconuts getCoconut(int id) {
return coconuts.get(id);
}
public List<MapleCoconuts> getAllCoconuts() {
return coconuts;
}
public void setCoconutsHittable(boolean hittable) {
for (MapleCoconuts nut : coconuts) {
nut.setHittable(hittable);
}
}
}

View File

@@ -0,0 +1,63 @@
/*
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 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.events.gm;
/**
*
* @author kevintjuh93
*/
public class MapleCoconuts {
private int id;
private int hits = 0;
private boolean hittable = false;
private long hittime = System.currentTimeMillis();
public MapleCoconuts(int id) {
this.id = id;
}
public void hit() {
this.hittime = System.currentTimeMillis() + 750;
hits++;
}
public int getHits() {
return hits;
}
public void resetHits() {
hits = 0;
}
public boolean isHittable() {
return hittable;
}
public void setHittable(boolean hittable) {
this.hittable = hittable;
}
public long getHitTime() {
return hittime;
}
}

View File

@@ -0,0 +1,53 @@
/*
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 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.events.gm;
/**
*
* @author kevintjuh93
*/
public class MapleEvent {
private int mapid;
private int limit;
public MapleEvent(int mapid, int limit) {
this.mapid = mapid;
this.limit = limit;
}
public int getMapId() {
return mapid;
}
public int getLimit() {
return limit;
}
public void minusLimit() {
this.limit--;
}
public void addLimit() {
this.limit++;
}
}

View File

@@ -0,0 +1,133 @@
/*
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 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.events.gm;
import client.MapleCharacter;
import java.util.concurrent.ScheduledFuture;
import server.TimerManager;
import tools.MaplePacketCreator;
/**
*
* @author kevintjuh93
*/
public class MapleFitness {
private MapleCharacter chr;
private long time = 0;
private long timeStarted = 0;
private ScheduledFuture<?> schedule = null;
private ScheduledFuture<?> schedulemsg = null;
public MapleFitness(final MapleCharacter chr) {
this.chr = chr;
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (chr.getMapId() >= 109040000 && chr.getMapId() <= 109040004)
chr.changeMap(chr.getMap().getReturnMap());
}
}, 900000);
}
public void startFitness() {
chr.getMap().startEvent();
chr.getClient().announce(MaplePacketCreator.getClock(900));
this.timeStarted = System.currentTimeMillis();
this.time = 900000;
checkAndMessage();
chr.getMap().getPortal("join00").setPortalStatus(true);
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The portal has now opened. Press the up arrow key at the portal to enter."));
}
public boolean isTimerStarted() {
return time > 0 && timeStarted > 0;
}
public long getTime() {
return time;
}
public void resetTimes() {
this.time = 0;
this.timeStarted = 0;
schedule.cancel(false);
schedulemsg.cancel(false);
}
public long getTimeLeft() {
return time - (System.currentTimeMillis() - timeStarted);
}
public void checkAndMessage() {
this.schedulemsg = TimerManager.getInstance().register(new Runnable() {
@Override
public void run() {
if (chr.getFitness() == null) {
resetTimes();
}
if (chr.getMap().getId() >= 109040000 && chr.getMap().getId() <= 109040004) {
if (getTimeLeft() > 9000 && getTimeLeft() < 11000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "You have 10 sec left. Those of you unable to beat the game, we hope you beat it next time! Great job everyone!! See you later~"));
} else if (getTimeLeft() > 99000 && getTimeLeft() < 101000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "Alright, you don't have much time remaining. Please hurry up a little!"));
} else if (getTimeLeft() > 239000 && getTimeLeft() < 241000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The 4th stage is the last one for [The Maple Physical Fitness Test]. Please don't give up at the last minute and try your best. The reward is waiting for you at the very top!"));
} else if (getTimeLeft() > 299000 && getTimeLeft() < 301000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The 3rd stage offers traps where you may see them, but you won't be able to step on them. Please be careful of them as you make your way up."));
} else if (getTimeLeft() > 359000 && getTimeLeft() < 361000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "For those who have heavy lags, please make sure to move slowly to avoid falling all the way down because of lags."));
} else if (getTimeLeft() > 499000 && getTimeLeft() < 501000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "Please remember that if you die during the event, you'll be eliminated from the game. If you're running out of HP, either take a potion or recover HP first before moving on."));
} else if (getTimeLeft() > 599000 && getTimeLeft() < 601000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The most important thing you'll need to know to avoid the bananas thrown by the monkeys is *Timing* Timing is everything in this!"));
} else if (getTimeLeft() > 659000 && getTimeLeft() < 661000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The 2nd stage offers monkeys throwing bananas. Please make sure to avoid them by moving along at just the right timing."));
} else if (getTimeLeft() > 699000 && getTimeLeft() < 701000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "Please remember that if you die during the event, you'll be eliminated from the game. You still have plenty of time left, so either take a potion or recover HP first before moving on."));
} else if (getTimeLeft() > 779000 && getTimeLeft() < 781000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "Everyone that clears [The Maple Physical Fitness Test] on time will be given an item, regardless of the order of finish, so just relax, take your time, and clear the 4 stages."));
} else if (getTimeLeft() > 839000 && getTimeLeft() < 841000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "There may be a heavy lag due to many users at stage 1 all at once. It won't be difficult, so please make sure not to fall down because of heavy lag."));
} else if (getTimeLeft() > 869000 && getTimeLeft() < 871000) {
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "[MapleStory Physical Fitness Test] consists of 4 stages, and if you happen to die during the game, you'll be eliminated from the game, so please be careful of that."));
}
} else {
resetTimes();
}
}
}, 5000, 29500);
}
// 14:30 [Notice][MapleStory Physical Fitness Test] consists of 4 stages, and if you happen to die during the game, you'll be eliminated from the game, so please be careful of that.
// 14:00 [Notice]There may be a heavy lag due to many users at stage 1 all at once. It won't be difficult, so please make sure not to fall down because of heavy lag.
// 13:00 [Notice]Everyone that clears [The Maple Physical Fitness Test] on time will be given an item, regardless of the order of finish, so just relax, take your time, and clear the 4 stages.
// 11:40 [Notice]Please remember that if you die during the event, you'll be eliminated from the game. You still have plenty of time left, so either take a potion or recover HP first before moving on.
// 11:00 [Notice]The 2nd stage offers monkeys throwing bananas. Please make sure to avoid them by moving along at just the right timing.
// 10:00 [Notice]The most important thing you'll need to know to avoid the bananas thrown by the monkeys is *Timing* Timing is everything in this!
// 8:20 [Notice]Please remember that if you die during the event, you'll be eliminated from the game. If you're running out of HP, either take a potion or recover HP first before moving on.
// 6:00 [Notice]For those who have heavy lags, please make sure to move slowly to avoid falling all the way down because of lags.
// 5:00 [Notice]The 3rd stage offers traps where you may see them, but you won't be able to step on them. Please be careful of them as you make your way up.
// 4:00 [Notice]The 4th stage is the last one for [The Maple Physical Fitness Test]. Please don't give up at the last minute and try your best. The reward is waiting for you at the very top!
// 1:40 [Notice]Alright, you don't have much time remaining. Please hurry up a little!
// 0:10 [Notice]You have 10 sec left. Those of you unable to beat the game, we hope you beat it next time! Great job everyone!! See you later~
}

View File

@@ -0,0 +1,78 @@
/*
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 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.events.gm;
import client.MapleCharacter;
import java.util.concurrent.ScheduledFuture;
import server.TimerManager;
import tools.MaplePacketCreator;
/**
*
* @author kevintjuh93
*/
public class MapleOla {
private MapleCharacter chr;
private long time = 0;
private long timeStarted = 0;
private ScheduledFuture<?> schedule = null;
public MapleOla(final MapleCharacter chr) {
this.chr = chr;
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (chr.getMapId() >= 109030001 && chr.getMapId() <= 109030303)
chr.changeMap(chr.getMap().getReturnMap());
resetTimes();
}
}, 360000);
}
public void startOla() { // TODO: Messages
chr.getMap().startEvent();
chr.getClient().announce(MaplePacketCreator.getClock(360));
this.timeStarted = System.currentTimeMillis();
this.time = 360000;
chr.getMap().getPortal("join00").setPortalStatus(true);
chr.getClient().announce(MaplePacketCreator.serverNotice(0, "The portal has now opened. Press the up arrow key at the portal to enter."));
}
public boolean isTimerStarted() {
return time > 0 && timeStarted > 0;
}
public long getTime() {
return time;
}
public void resetTimes() {
this.time = 0;
this.timeStarted = 0;
schedule.cancel(false);
}
public long getTimeLeft() {
return time - (System.currentTimeMillis() - timeStarted);
}
}

View File

@@ -0,0 +1,111 @@
/*
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 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.events.gm;
import client.MapleCharacter;
import tools.Randomizer;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import provider.MapleDataProvider;
import provider.MapleDataProviderFactory;
import provider.MapleDataTool;
import server.TimerManager;
import server.maps.MapleMap;
import tools.MaplePacketCreator;
/**
*
* @author FloppyDisk
*/
public final class MapleOxQuiz {
private int round = 1;
private int question = 1;
private MapleMap map = null;
private int expGain = 200;
private static MapleDataProvider stringData = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Etc.wz"));
public MapleOxQuiz(MapleMap map) {
this.map = map;
this.round = Randomizer.nextInt(9);
this.question = 1;
}
private boolean isCorrectAnswer(MapleCharacter chr, int answer) {
double x = chr.getPosition().getX();
double y = chr.getPosition().getY();
if ((x > -234 && y > -26 && answer == 0) || (x < -234 && y > -26 && answer == 1)) {
chr.dropMessage("Correct!");
return true;
}
return false;
}
public void sendQuestion() {
int gm = 0;
for (MapleCharacter mc : map.getCharacters()) {
if (mc.gmLevel() > 1) {
gm++;
}
}
final int number = gm;
map.broadcastMessage(MaplePacketCreator.showOXQuiz(round, question, true));
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
map.broadcastMessage(MaplePacketCreator.showOXQuiz(round, question, true));
List<MapleCharacter> chars = new ArrayList<>(map.getCharacters());
for (MapleCharacter chr : chars) {
if (chr != null) // make sure they aren't null... maybe something can happen in 12 seconds.
{
if (!isCorrectAnswer(chr, getOXAnswer(round, question)) && !chr.isGM()) {
chr.changeMap(chr.getMap().getReturnMap());
} else {
chr.gainExp(expGain, true, true);
}
}
}
//do question
if ((round == 1 && question == 29) || ((round == 2 || round == 3) && question == 17) || ((round == 4 || round == 8) && question == 12) || (round == 5 && question == 26) || (round == 9 && question == 44) || ((round == 6 || round == 7) && question == 16)) {
question = 100;
} else {
question++;
}
//send question
if (map.getCharacters().size() - number <= 2) {
map.broadcastMessage(MaplePacketCreator.serverNotice(6, "The event has ended"));
map.getPortal("join00").setPortalStatus(true);
map.setOx(null);
map.setOxQuiz(false);
//prizes here
return;
}
sendQuestion();
}
}, 30000); // Time to answer = 30 seconds ( Ox Quiz packet shows a 30 second timer.
}
private static int getOXAnswer(int imgdir, int id) {
return MapleDataTool.getInt(stringData.getData("OXQuiz.img").getChildByPath("" + imgdir + "").getChildByPath("" + id + "").getChildByPath("a"));
}
}

View File

@@ -0,0 +1,165 @@
/*
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 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.events.gm;
import client.MapleCharacter;
import java.util.LinkedList;
import java.util.List;
import server.TimerManager;
import server.maps.MapleMap;
import tools.MaplePacketCreator;
/**
*
* @author kevintjuh93
*/
public class MapleSnowball {
private MapleMap map;
private int position = 0;
private int hits = 3;
private int snowmanhp = 1000;
private boolean hittable = false;
private int team;
private boolean winner = false;
List<MapleCharacter> characters = new LinkedList<MapleCharacter>();
public MapleSnowball(int team, MapleMap map) {
this.map = map;
this.team = team;
for (MapleCharacter chr : map.getCharacters()) {
if (chr.getTeam() == team)
characters.add(chr);
}
}
public void startEvent() {
if (hittable == true) return;
for (MapleCharacter chr : characters) {
if (chr != null) {
chr.announce(MaplePacketCreator.rollSnowBall(false, 1, map.getSnowball(0), map.getSnowball(1)));
chr.announce(MaplePacketCreator.getClock(600));
}
}
hittable = true;
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (map.getSnowball(team).getPosition() > map.getSnowball(team == 0 ? 1 : 0).getPosition()) {
for (MapleCharacter chr : characters) {
if (chr != null)
chr.announce(MaplePacketCreator.rollSnowBall(false, 3, map.getSnowball(0), map.getSnowball(0)));
}
winner = true;
} else if (map.getSnowball(team == 0 ? 1 : 0).getPosition() > map.getSnowball(team).getPosition()) {
for (MapleCharacter chr : characters) {
if (chr != null)
chr.announce(MaplePacketCreator.rollSnowBall(false, 4, map.getSnowball(0), map.getSnowball(0)));
}
winner = true;
} //Else
warpOut();
}
}, 600000);
}
public boolean isHittable() {
return hittable;
}
public void setHittable(boolean hit) {
this.hittable = hit;
}
public int getPosition() {
return position;
}
public int getSnowmanHP() {
return snowmanhp;
}
public void setSnowmanHP(int hp) {
this.snowmanhp = hp;
}
public void hit(int what, int damage) {
if (what < 2)
if (damage > 0)
this.hits--;
else {
if (this.snowmanhp - damage < 0) {
this.snowmanhp = 0;
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
setSnowmanHP(7500);
message(5);
}
}, 10000);
} else
this.snowmanhp -= damage;
map.broadcastMessage(MaplePacketCreator.rollSnowBall(false, 1, map.getSnowball(0), map.getSnowball(1)));
}
if (this.hits == 0) {
this.position += 1;
if (this.position == 45)
map.getSnowball(team == 0 ? 1 : 0).message(1);
else if (this.position == 290)
map.getSnowball(team == 0 ? 1 : 0).message(2);
else if (this.position == 560)
map.getSnowball(team == 0 ? 1 : 0).message(3);
this.hits = 3;
map.broadcastMessage(MaplePacketCreator.rollSnowBall(false, 0, map.getSnowball(0), map.getSnowball(1)));
map.broadcastMessage(MaplePacketCreator.rollSnowBall(false, 1, map.getSnowball(0), map.getSnowball(1)));
}
map.broadcastMessage(MaplePacketCreator.hitSnowBall(what, damage));
}
public void message(int message) {
for (MapleCharacter chr : characters) {
if (chr != null)
chr.announce(MaplePacketCreator.snowballMessage(team, message));
}
}
public void warpOut() {
TimerManager.getInstance().schedule(new Runnable() {
@Override
public void run() {
if (winner == true)
map.warpOutByTeam(team, 109050000);
else
map.warpOutByTeam(team, 109050001);
map.setSnowball(team, null);
}
}, 10000);
}
}