For those that hate the event script I created what simply is a "Boat Worker" kinda like the Login Worker that came with the original odinms.
I have compiled a way to have working boats that is easy to modify and works very efficiently. The only problem is that I haven't quite figured out how to make the Crimson Balrog Boat appear on the Ellinia to Orbis ( Or Visa-Versa ) boat.
So if you want here is everything you'll need.
First you need the Scheduler:
Create the file SRC > Net > Sf > Odinms > Server > MapleBoatSchedules.java
Now since this is a blank file; Lets write what we need!
Put all of this in that file and make sure ONLY this is in the file:
Then you will need to open MapleMap.java which can be found in SRC > Net > Sf > Odinms > Server > MapsCode:package net.sf.odinms.server; import java.util.*; import net.sf.odinms.tools.Pair; /** * * @author Inu */ public class MapleBoatSchedules { private Map<Integer, List<Integer>> schedules = new HashMap<Integer, List<Integer>>(); private int orbis = 0; // Global Schedule? I don't feel like making em all D= private int ludi = 1; // Nor do I know em all x.x... public MapleBoatSchedules(){ List<Integer> schedule; schedule = new LinkedList<Integer>(); schedule.add(0); schedule.add(5);// gone for 10 minutes schedule.add(15); schedule.add(20);// gone for 10 minutes schedule.add(30); schedule.add(35);// gone for 10 minutes schedule.add(45); schedule.add(50);// gone for 10 minutes ( Return to 0 =3 ) schedules.put(0, schedule); // Lets stay with one schedule for now?... o.o... schedule = new LinkedList<Integer>(); schedule.add(0); schedule.add(5); schedule.add(10); schedule.add(15); schedule.add(20); schedule.add(25); schedule.add(30); schedule.add(35); schedule.add(40); schedule.add(45); schedule.add(50); schedule.add(55); schedules.put(1, schedule); } public int getKey(int mapid){ switch(mapid){ case 101000300: // Ellinia >> Orbis Station case 200000111: // Orbis >> Ellinia Station case 101000301: // Ellinia >> Orbis ( Waiting ) case 200000112: // Orbis >> Ellinia ( Waiting ) case 200090010: // Ellinia >> orbis ( In Boat ) case 200090000: // Orbis >> Ellinia ( In Boat ) case 200090011: // Ellinia >> Orbis ( In Cabin ) case 200090001: // Orbis >> Ellinia ( In Cabin ) return orbis; case 260000100: // Ariant >> Orbis Station case 200000151: // Orbis >> Ariant Station case 260000110: // Ariant >> Orbis ( Waiting ) case 200000152: // Orbis >> Ariant ( Waiting ) case 200090410: // Ariant >> Orbis ( In Boat ) case 200090400: // Orbis >> Ariant ( In Boat ) return ludi; case 240000110: // Leafre >> Orbis Station case 200000131: // Orbis >> Leafre Station case 240000111: // Leafre >> Orbis ( Waiting ) case 200000132: // Orbis >> Leafre ( Waiting ) case 200090210: // Leafre >> Orbis ( In Boat ) case 200090200: // Orbis >> Leafre ( In Boat ) return ludi; case 220000110: // Ludibrium >> Orbis Station case 200000121: // Orbis >> Ludibrium Station case 220000111: // Ludibrium >> Orbis ( Waiting ) case 200000122: // Orbis >> Ludibrium ( Waiting ) case 200090110: // Ludibrium >> Orbis ( In Boat ) case 200090100: // Orbis >> Ludibrium ( In Boat ) return ludi; case 200090310: // Mu Lung >> Orbis ( In Boat ) // Clueless how to do this... D=... case 200090300: // Orbis >> Mu Lung ( In Boat ) return orbis; // I need to fix this D=... } return -1; } public int timeTilNextDock(int key,int minute){ List<Integer> schedule = schedules.get(key); int size = schedule.size(); int buff = 0; int timleft; while(buff < size){ //System.out.println("Beginning: " + schedule.get(buff) + "\r\n End: " + schedule.get(buff+1)); if(schedule.get(buff) <= minute && schedule.get(buff+1) > minute){ if(buff == 0 || buff == 2 || buff == 4 || buff == 6){ return 0; }else{ timleft = schedule.get(buff+1) - minute; return timleft; } }else{ buff++; } } return -1; } public int timTilLeaves(int key, int minute){ return -1; } public boolean isDocked(int key, int minute){ // I hope this works =D List<Integer> schedule = schedules.get(key); int size = schedule.size(); int buff = 0; while(buff < size){ //System.out.println("Beginning: " + schedule.get(buff) + "\r\n End: " + schedule.get(buff+1)); if(schedule.get(buff) <= minute && schedule.get(buff+1) > minute){ //System.out.println(minute + " is >= to " + schedule.get(buff) + " and is < then " + schedule.get(buff+1) + " ... o_O"); return true; }else{ buff++; buff++; } } return false; } }
Add Imports ( So that we know when the boat is there. )
Find the constructor then find "this.spawnable = spawnable;"Code:import net.sf.odinms.server.MapleBoatSchedules; import net.sf.odinms.server.life.MapleLifeFactory; // For spawning.
and put this underneath it
then add this underneath it out of the constructorCode:if(mapid == 101000300 // Ellinia Station Map ID || mapid == 200000111 // Orbis >> Ellinia Station || mapid == 220000110 // Ludibrum >> Orbis Station || mapid == 200000121 // Orbis >> Ludibrium Station || mapid == 260000100 // Ariant >> Orbis Station || mapid == 200000151 // Orbis >> Ariant Station || mapid == 240000110 // Leafre >> Orbis Station || mapid == 200000131 // Orbis >> Leafre Station || getMapToPassTo(mapid) != -1 ){ // On a boat TimerManager.getInstance().register(new GenericMapleBoat(), 2500); }
Code:public int getMapToPassTo(int map){ int next = -1; switch(map){ // To orbis ( Waiting ) case 101000301: // Ellinia >> Orbis ( Waiting ) next = 200090010; break; case 260000110: // Ariant >> Orbis ( Waiting ) next = 200090410; break; case 220000111: // Ludibrium >> Orbis ( Waiting ) next = 200090110; break; case 240000111: // Leafre >> Orbis ( Waiting ) next = 200090210; break; // All from orbis case 200000112: // Orbis >> Ellinia ( Waiting ) next = 200090000; break; case 200090000: // Orbis >> Ellinia ( In Boat ) case 200090001: // Orbis >> Ellinia ( In Boat ) ( Cabin ) next = 101000300; break; case 200000152: // Orbis >> Ariant ( Waiting ) next = 200090400; break; case 200090400: // Orbis >> Ariant ( In boat ) next = 260000100; break; case 200000122: // Orbis >> Ludibrium ( Waiting ) next = 200090100; break; case 200090100: // Orbis >> Ludibrium ( In Boat ) next = 220000100; break; case 200090300: // Orbis >> Mu Lung ( In Boat ) next = 250000100; break; case 200000132: // Orbis >> Leafre ( Waiting ) next = 200090200; break; case 200090200: // Orbis >> Leafre ( In Boat ) next = 240000100; break; // All to orbis case 200090010: // Ellinia >> Orbis ( In Boat ) case 200090011: // Ellinia >> Orbis ( In Boat ) ( Cabin ) case 200090210: // Leafre >> Orbis ( In Boat ) case 200090110: // Ludibrium >> Orbis ( In Boat ) case 200090310: // Mu Lung >> Orbis ( In Boat ) case 200090410: // Ariant >> Orbis ( In boat ) next = 200000100; break; } return next; } /** * * @author Inu */ public class GenericMapleBoat implements Runnable { // This is my first runnable so stfu >=O //private boolean isDocked = false; // Never used?... private MapleBoatSchedules schedule = new MapleBoatSchedules(); private boolean isboredable = true; private MapleMap nextmap; private MapleMap map; private int minute; private boolean isdocked; boolean triedtospawn = false; public void run(){ minute = Calendar.getInstance().get(Calendar.MINUTE); map = MapleMap.this; // I don't like calling MapleMap.this. xD //log.info("Running~"); if(schedule.isDocked(schedule.getKey(map.mapid),minute)){ isdocked = true; }else{ isdocked = false; } //log.info("Is docked: " + isdocked); // Simple as that. //log.info("Running on mapid: "+ map.mapid); if(map.hasBoat() > 0 && map.mapid != 200090000 && map.mapid != 200090010){ // Has a boat or it's docked. map.broadcastJustDocked(isdocked); // Lets save time =3 map.setDocked(isdocked); //log.info("Broadcasting " + isdocked + " in boat map (" + map.mapid + ")"); }else{ // On boat... //int lastportal = -1; //int totalportals; int nextmapid = map.getMapToPassTo(map.mapid); if(nextmapid != -1){ // Should only happen when it doesn't belong here. nextmap = ChannelServer.getInstance(channel).getMapFactory().getMap(map.getMapToPassTo(map.mapid)); // Load next map //totalportals = nextmap.getPortals().size(); // Get total portals to help with randomness. if(map.getMapToPassTo(nextmapid) == -1){ // We took off and now we're flying. xD if(isdocked){ // We landed. Lets unload. //log.info("We landed (" + map.mapid + ") Lets unload..."); for(MapleCharacter chr : map.getCharacters()){ chr.changeMap(nextmap, nextmap.getPortal(0)); } map.killAllMonsters(); triedtospawn = false; // To respawn next time >=3 }else{ //log.info("We're flying ( Do nothing. ) (" + map.mapid + ")"); /*Point spawnpoint = map.getPortal(0).getPosition(); // Yes. Right on top of them =3... int randomness = new Random().nextInt(); int max = 2147483647; // Lol hax. =3 if(triedtospawn == false && map.mapid != 200090011 && map.mapid != 200090001){ triedtospawn = true; if((randomness > (max / 2 )) && map.getCharacters().size() > 0){ for(MapleCharacter chr : map.getCharacters()){ try{ chr.getClient().getChannelServer().getWorldInterface().broadcastMessage("MapleMap ( Boat Spawn )", MaplePacketCreator.serverNotice(6, "Oh no! The All Mighty Zakum has been released upon a boat in channel "+chr.getClient().getChannel()+"!").getBytes()); break; // Lol otherwise it'll send a broadcast for every player xD... }catch(RemoteException e){ } } map.spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(8800000), spawnpoint, false); for (int x = 8800003; x <= 8800010; x++) { // Lets just spawn a zakum... It'll make things interesting ^_^. map.spawnMonsterOnGroudBelow(MapleLifeFactory.getMonster(x), spawnpoint, false); } } }*/ // This is all for spawning ( I put a zakum since it seemed more fun ^_^ ) } }else{ // We're waiting for take off. if(isdocked){ // Do nothing we're waiting. //log.info("We're waiting for take off ( Do nothing. ) (" + map.mapid + ")"); }else{ // We're taking off. //log.info("We're taking off lets send them to flying map."); for(MapleCharacter chr : map.getCharacters()){ chr.changeMap(nextmap, nextmap.getPortal(0)); // Fuck randomness. } map.killAllMonsters(); } } } } } }



Reply With Quote


