I usually don't like releasing my crap here on RZ since all I really get here are flames and no constructive criticism, but I'll just make an exception and copy+paste it over from KDev.
The Great Victoria Island Race
Info: Do not ask me where I got inspired to make this, because I don't even remember. I had this done for a while now, I might as well release it rather than it just sitting there. Sorry if it's useless to some of you.
Basically this is an event where players gather up in Henesys and race around Victoria Island, back to Henesys. Of course, there's more to this. There is a custom waiting time, I've included a primitive anti-cheat system, total number of players is announced, winner is auto-announced, the event gives you messages to guide you on your path and race auto-ends when winner gets to Henesys.
This event is almost entirely automatic. All the GMs have to do is type one command, and hand out the prize.
There are 32 maps in total to race on. It should be a blast with like 5+ players. Alright, let's begin. I'll group the code in chunks to make it easier to copy+paste for some of you. D:
MapleCharacter.java
Code:private int entryNumber = 0; private int progress = 0;Replace your:Code:public int getEntryNumber() { return entryNumber; } public void setEntryNumber(int number) { this.entryNumber = number; } public int getProgress() { return progress; } public void setProgress(int number) { this.progress = number; } public void setWinnerAndEndRace() { client.getChannelServer().setRace(false); client.getChannelServer().setCompetitors(0); client.getChannelServer().setWaiting(false); try { client.getChannelServer().getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event]: Congradulations to " + getName() + " on winning the Great Victoria Island Race! Thanks to those who played!").getBytes()); } catch (RemoteException x) { client.getChannelServer().reconnectWorld(); } } public void raceStatus (){ if (getProgress() == 4){ dropMessage("[Notice]: You're off to a nice start!"); } if (getProgress() == 7){ dropMessage("[Notice]: Nice, you made it to the Magician town, Ellinia!"); } if (getProgress() == 8){ dropMessage("[Notice]: You're making good progress."); } if (getProgress() == 15){ dropMessage("[Notice]: You are halfway there! Don't give up now!"); } if (getProgress() == 16){ dropMessage("[Notice]: You made it to the Desert town of Perion!"); } if (getProgress() == 22){ dropMessage("[Notice]: You made it to the hood, Kerning City."); } if (getProgress() == 24){ dropMessage("[Notice]: You're almost there."); } if (getProgress() == 31){ dropMessage("[Notice]: Just one more map!"); } if (getProgress() == 32){ dropMessage("[Notice]: You did it! You have won the race!"); setWinnerAndEndRace(); } }
with this:Code:public void changeMap(final MapleMap to, final MaplePortal pto) {
Code:public void changeMap(final MapleMap to, final MaplePortal pto) { int z = getProgress(); if ((to.getId() == 100010000 && z == 0) || (to.getId() == 100020000 && z == 1) || (to.getId() == 100030000 && z == 2) || (to.getId() == 100040000 && z == 3) || (to.getId() == 100040100 && z == 4) || (to.getId() == 100050000 && z == 5) || (to.getId() == 101000000 && z == 6) || (to.getId() == 101010000 && z == 7) || (to.getId() == 101010100 && z == 8) || (to.getId() == 101030000 && z == 9) || (to.getId() == 101030100 && z == 10) || (to.getId() == 101030200 && z == 11) || (to.getId() == 101030300 && z == 12) || (to.getId() == 101030400 && z == 13) || (to.getId() == 101040000 && z == 14) || (to.getId() == 102000000 && z == 15) || (to.getId() == 102010000 && z == 16) || (to.getId() == 102020000 && z == 17) || (to.getId() == 102030000 && z == 18) || (to.getId() == 102040000 && z == 19) || (to.getId() == 102050000 && z == 20) || (to.getId() == 103000000 && z == 21) || (to.getId() == 103010000 && z == 22) || (to.getId() == 103020000 && z == 23) || (to.getId() == 103020100 && z == 24) || (to.getId() == 103020200 && z == 25) || (to.getId() == 103030000 && z == 26) || (to.getId() == 104010000 && z == 27) || (to.getId() == 104020000 && z == 28) || (to.getId() == 104030000 && z == 29) || (to.getId() == 104040000 && z == 30) || (to.getId() == 100000000 && z == 31)) { changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this)); if (client.getChannelServer().getRace() == true && client.getChannelServer().getWaiting() == false){ setProgress(getProgress() + 1); raceStatus(); } } else if (client.getChannelServer().getRace() == true && client.getChannelServer().getWaiting() == false) { changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this)); dropMessage("[Notice]: You are either cheating, or going the wrong direction. Your progress is not being counted."); } else if (to.getId() == 100000200 || to.getId() == 211000100 || to.getId() == 220000300) { changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId() - 2, this)); } else { changeMapInternal(to, pto.getPosition(), MaplePacketCreator.getWarpToMap(to, pto.getId(), this)); } }GM Commands file
Code:} else if (splitted[0].equals("startrace")) { if (!cserv.getRace() && !cserv.getWaiting()){ cserv.setWaiting(true); cserv.setWaitingTime(X); //Replace with time in minutes you want to wait. cserv.raceCountdown(); try { cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event]: The Great Victoria Island Race will begin soon! Please head to Henesys!").getBytes()); } catch (RemoteException e) { cserv.reconnectWorld(); } try { cserv.getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "Use @joinrace to join and @rules to see the rules and regulations of this event.").getBytes()); } catch (RemoteException e) { cserv.reconnectWorld(); } }else{ player.dropMessage("[Notice]: A race is still in progress."); }ChannelServer.java
Code:private boolean hasWaitingStarted = false; private boolean race = false; private int competitors = 0; private int waitingTime;Code:public int getWaitingTime() { return waitingTime; } public void setWaitingTime(int set){ this.waitingTime = set; } public void raceCountdown() { TimerManager.getInstance().schedule(new Runnable() { public void run() { if (getWaiting() && getWaitingTime() > 1) { setWaitingTime(getWaitingTime() - 1); if (getWaitingTime() > 1){ try { getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event]: The Great Victoria Island Race will start in " + getWaitingTime() + " minutes! There are " + getCompetitors() + " players in the race.").getBytes()); } catch (RemoteException e) { reconnectWorld(); } } else { try { getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event]: The Great Victoria Island Race will start in " + getWaitingTime() + " minute! There are " + getCompetitors() + " players in the race.").getBytes()); } catch (RemoteException e) { reconnectWorld(); } } raceCountdown(); } else if (getWaiting() && getWaitingTime() <= 1) { setRace(true); setWaiting(false); try { getWorldInterface().broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event]: The Great Victoria Island Race has begun! Race all the way around Victoria Island going East, to win!").getBytes()); } catch (RemoteException c) { reconnectWorld(); } } } }, 1 * 60 * 1000); } public boolean getRace() { return race; } public void setRace(boolean set){ this.race = set; } public boolean getWaiting() { return hasWaitingStarted; } public void setWaiting(boolean set){ this.hasWaitingStarted = set; } public int getCompetitors() { return competitors; } public void setCompetitors(int set){ this.competitors = set; }Player Commands file
Code:} else if (splitted[0].equals("joinrace")) { if (c.getPlayer().getEntryNumber() < 1) { if (c.getPlayer().getMapId() == 100000000){ if (cserv.getWaiting()){ c.getPlayer().setEntryNumber(cserv.getCompetitors() + 1); cserv.setCompetitors(cserv.getCompetitors() + 1); player.dropMessage("[Notice]: You have successfully joined the race! Your entry number is " + c.getPlayer().getEntryNumber() + "."); } else { player.dropMessage("There is no event currently taking place."); } } else { player.dropMessage("You are not at Henesys."); } }else{ player.dropMessage("You have already joined this race."); } } else if (splitted[0].equals("rules")) { if (cserv.getWaiting() || cserv.getRace()) { player.message("The Official Rules and Regulations of the Great Victoria Island Race:"); player.message("-------------------------------------------------------------------------------------------"); player.message("To win you must race from Henesys all the way to Henesys going Eastward."); player.message("Rule #1: No cheating. You can't use any warping commands, or you'll be disqualified."); player.message("Rule #2: You may use any form of transportation. This includes Teleport, Flash Jump and Mounts."); player.message("Rule #3: You are NOT allowed to kill any monsters in your way. They are obstacles."); player.message("Rule #4: You may start from anywhere in Henesys, but moving on to the next map before the start won't work."); } else { player.message("There is no event currently taking place."); }To-do list:
-Make Anti-Cheat system 100% accurate.
-Make joining the race actually matter. (A simple check fixes this.)
-Add "is in the lead" messages.
-Fix that slight ChangeMap error which wrongly displays an error messages.
Screenshots:
Do what you want with this, it's better than nothing. Have fun and good luck adding this without errors.












Reply With Quote


