Excellzone

Forum and disscussions since 2010


You are not connected. Please login or register

View previous topic View next topic Go down Message [Page 1 of 1]

#1


Hey guys, here's an overview of what Maple Race is.

Every 5 hours(Which can be changed in ServerConstants.java), the server will put a notice to everyone who wishes to join the Maple Race. This took me 2-3 days of doing it while I had my spare time and I hope you guys enjoy it.

In server, add the "MapleRace" class.
server.Events.MapleRace.java:
PHP Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package server.Events;
import client.MapleCharacter;
import client.MapleStat;
import server.maps.MapleMap;


/**
*
* @author fatejiki
*
* map 0 : x=1746
* map 1 : y=-2685
*/

public class MapleRace {
public static
boolean isOpen = false;
public static
java.util.List<MapleCharacter> toWarpIn = new java.util.ArrayList<MapleCharacter>();
public static
void warpToNextMap(MapleCharacter player){
player.changeMap(getNextMap(player));
String message = "Welcome to stage " + player.raceStage + " ";
switch((int)
player.raceStage){
case
1:
player.deathMap = player.getMapId();
message += "|| HURRY! Go EAST! (Or you'll explode?";
scheduleDeath(player, true, 25000, false);
break;
case
2:
player.deathMap = player.getMapId();
message += "|| Get as high as you can..Bowser's coming O:";
scheduleDeath(player, true, 360000, false);
break;
case
3:
player.deathMap = player.getMapId();
message += "|| Kill, kill and kill until you find the way..";
scheduleDeath(player, true, 60000, false);
break;
case
4:
player.deathMap = player.getMapId();
message += "|| Say the password to be warped to the next stage.. I'll give you a hint : What's the name of ONE of the developers?";
scheduleDeath(player, true, 15000, false);
break;
case
5: // TODO - Make bigfoot warp you out. // done
player.deathMap = player.getMapId();
server.maps.MapleMap theMap = player.getMap();
theMap.toggleDrops();
theMap.killAllMonsters();
theMap.toggleDrops();
theMap.spawnMonsterOnGroudBelow(server.life.MapleLifeFactory.getMonster(9400575), new java.awt.Point(1846, 208));
message += "|| Attack the bigfoot. He'll warp you, but be careful, he bites.";
scheduleDeath(player, true, 120000, false);
break;
case
6: // TODO - Do the infection handling and T-CURE dropping, then it warps you out and countdown
player.deathMap = player.getMapId();
message += "|| All of you will die in 35 seconds. Unless if you can find a T-CURE that's dropped from the nearby monsters.";
player.infectPlayer();
scheduleDeath(player, true, 35000, true);
break;
case
7: // hehe , spawn silver slimes
player.deathMap = player.getMapId();
for(
MapleCharacter mc : player.getClient().getChannelServer().getPlayerStorage().getAllCharacters()){
if(
mc.getMapId() == 100000203 && mc.raceStage == (byte)7){
mc.getMap().spawnMonsterOnGroundBelow(server.life.MapleLifeFactory.getMonster(7120104), mc.getPosition());
for(
byte i = 0;i < 10;i++){
mc.getMap().spawnMonsterOnGroundBelow(server.life.MapleLifeFactory.getMonster(9400552), mc.getPosition());
}
}
}
message += "|| Thank you for participating, now here's the last stage. Different monsters will spawn and only 25% of them will warp you to the end.";
scheduleDeath(player, true, 360000, false);
break;
case
8: // out of PQ.
player.deathMap = player.getMapId();
player.racing = false;
player.raceStage = (byte)0;
message += "|| Thank you for playing the game. This was created by FateJiki of RaGeZONE.";
giveMaplePrize(player);
for(
MapleCharacter chr : toWarpIn){
chr.racing = false;
chr.raceStage = 0;
toWarpIn.remove(chr);
if(
toWarpIn.size() == 0){
isOpen = false;
chr.getClient().getChannelServer().broadcastPacket(tools.MaplePacketCreator.serverNotice(5, "The MapleFace is now over, the last player to leave the event was " + chr.getName() + ". Wish him/her congratulations."));
}
}
break;
default:
player.deathMap = player.getMapId();
message += "|| An error occurred.";
break;
}
player.dropMessage(message);
}
public static
int getNextMap(MapleCharacter player){
int nextmap = 0;
int maps[] = {110000000, 105040310, 680000400, 300020200, 610010100, 102010000, 100000203, 100000000};
if(
nextmap == 100000000){
player.racing = false;
}
switch(
player.getMapId()){
case
110000000:
nextmap = 105040310;
player.raceStage = (byte)2;
break;
case
105040310:
nextmap = 680000400;
player.raceStage = (byte)3;
break;
case
680000400:
nextmap = 300020200;
player.raceStage = (byte)4;
break;
case
300020200:
nextmap = 610010100;
player.raceStage = (byte)5;
break;
case
610010100:
nextmap = 102010000;
player.raceStage = (byte)6;
break;
case
102010000:
nextmap = 100000203;
player.raceStage = (byte)7;
break;
case
100000203:
nextmap = 100000000;
player.raceStage = (byte)0;
break;
default:
nextmap = 110000000;
player.raceStage = (byte)1;
break;
}
return
nextmap;
}
public static
void giveMaplePrize(MapleCharacter player){
int prize = 0;
// return prize;
// do prize handling here!
}
public static
void scheduleDeath(MapleCharacter player, boolean timer, int delay, boolean infectStage){
if(
timer){
player.getClient().getSession().write(tools.MaplePacketCreator.getClock(delay / 1000));
}
final
MapleCharacter fplayer = player;
final
boolean fs = infectStage;
server.TimerManager tMan = server.TimerManager.getInstance();
tMan.schedule(new Runnable(){
@
Override
public void run(){
if(
fs){
if(
fplayer.infected){
fplayer.setHp(0);
fplayer.updateSingleStat(client.MapleStat.HP, 0);
} else {
fplayer.dropMessage(5, "You have survived the infection. Congratulations , you may now pass to the final stage..");
warpToNextMap(fplayer);
}
} else if(
fplayer.deathMap == fplayer.getMapId()){
fplayer.setHp(0);
fplayer.updateSingleStat(client.MapleStat.HP, 0);
fplayer.dropMessage(5, "Sorry, you didn't make it out in time.");
}
}
},
delay);

}
}


MapleCharacter.java :
PHP Code:
public void dropTCure(Point pos){
IItem toDrop;
toDrop = new Item(2050000, (byte) 0, (short) 1);
toDrop.setGiftFrom("Medical Team");
toDrop.setTCure();
getMap().spawnItemDrop(this, this, toDrop, pos, true, true);
}


IItem.java :
PHP Code:
boolean isTCure();


Item.java
PHP Code:
public void setTCure(){
isTCure = (byte)1;
}
public
boolean isTCure(){
return
isTCure == (byte)1;
}


ItemPickupHandler.java :
After
PHP Code:
if (ob instanceof MapleMapItem) {
MapleMapItem mapitem = (MapleMapItem) ob;
synchronized (mapitem) {


add:
PHP Code:
if(mapitem.getItem().isTCure()){
byte e = (byte)(10.0 * Math.random());
if(
e >= 5){
c.getPlayer().disinfectPlayer();
} else {
c.getPlayer().dropMessage("The infection resisted to the T-CURE. Hurry, find another.");
}
}


MapleMap.java@DamagerMonster:
PHP Code:
if(chr.raceStage == (byte)3){
int rand = (int)(100.0 * Math.random());
if(
rand <= 11){
server.Events.MapleRace.warpToNextMap(chr);
}
} else
if(
chr.raceStage == (byte)5 && monster.getId() == 9400575 && chr.isAlive()){
byte e = (byte)(10.0 * Math.random());
if(
e < 5){
server.Events.MapleRace.warpToNextMap(chr);
} else {
chr.dropMessage(5, "OH! Looks like we can't warp you this time. Keep trying!(IF you're not already dead, of course.)");
}
} else if(
chr.raceStage == (byte)7 ){
byte e = (byte)(100.0 * Math.random());
if(
e >= 75){
server.Events.MapleRace.warpToNextMap(chr);
}
}
else if(
chr.raceStage == (byte) 6 && (int) (100.0 * Math.random()) >= 90)
{
chr.dropTCure(monster.getPosition());
}


MovePlayerHandler.java :
PHP Code:
if(c.getPlayer().raceStage == (byte)1 && c.getPlayer().getPosition().x == 1746 || c.getPlayer().raceStage == (byte)2 && c.getPlayer().getPosition().y == -2685){
MapleRace.warpToNextMap(c.getPlayer());
}


PlayerCommands.java :
PHP Code:
else if(splitted[0].equalsIgnoreCase("joinrace")){
if(
server.Events.MapleRace.isOpen){
server.Events.MapleRace.toWarpIn.add(player);
player.dropMessage(5, "Your candidature has been added to our list!");
} else {
player.dropMessage(5, "The race is not even open or you are already in the list.");
}
}


ChannelServer.java :
after
PHP Code:
tMan.start();


add :
PHP Code:
tMan.schedule(new Runnable(){

@
Override
public void run(){
for(
MapleCharacter chr : getPlayerStorage().getAllCharacters()){
chr.dropMessage(5, "Yes! The great Maple Race is now accepting more candidates!");
chr.dropMessage(5, "Just type in @joinrace, and you'll automatically warp as soon as it starts!");
chr.dropMessage(5, "The Maple Race is starting in one minute.");
server.Events.MapleRace.isOpen = true;
ftMan.schedule(new Runnable(){
@
Override
public void run(){
for(
MapleCharacter chr : getPlayerStorage().getAllCharacters()){
server.Events.MapleRace.isOpen = false;
for(
MapleCharacter chr2 : server.Events.MapleRace.toWarpIn){
chr2.raceStage = 0;
server.Events.MapleRace.warpToNextMap(chr2);
}
}
}
},
1000 * 60);
}
}
},
1000 * 60 * 60 * ServerConstants.mapleRaceInt);



ServerConstants.java
:
PHP Code:
public static final int mapleRaceInt = 5; // (in hours)




It's not very advanced but it's easy to modify and to work with.



CREDITS GO TO (FateJIKI)

View user profile

View previous topic View next topic Back to top Message [Page 1 of 1]


Permissions in this forum:
You cannot reply to topics in this forum