Jump Quest Event Script

Results 1 to 10 of 10
  1. #1
    Not a programmer. inumedia is offline
    MemberRank
    Jul 2008 Join Date
    Ohai, candleja-Location
    222Posts

    Jump Quest Event Script

    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:
    Code:
          public MapleCharacter firstplace, secondplace, thirdplace; // I'm tired of privates so fuck off.
          public JumpQuestEvent myjump = null;
    AddPlayer{
    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
    Last edited by inumedia; 22-08-09 at 07:43 PM.


  2. #2
    offonline King Grub is offline
    MemberRank
    Aug 2009 Join Date
    Spring fieldLocation
    3,303Posts

    Re: Jump Quest Event Script

    Woah!

    Good job dude.

  3. #3
    Not a programmer. inumedia is offline
    MemberRank
    Jul 2008 Join Date
    Ohai, candleja-Location
    222Posts

    Re: Jump Quest Event Script

    Quote Originally Posted by PirateOwh View Post
    Woah!

    Good job dude.
    o_o.

    Not really. I do suggest revising/modifying some parts of the coding though. Just to make sure it works.

    I know the timing and warping works but I'm not sure about everything else xD

  4. #4
    offonline King Grub is offline
    MemberRank
    Aug 2009 Join Date
    Spring fieldLocation
    3,303Posts

    Re: Jump Quest Event Script

    Quote Originally Posted by inumedia View Post
    o_o.

    Not really. I do suggest revising/modifying some parts of the coding though. Just to make sure it works.

    I know the timing and warping works but I'm not sure about everything else xD
    Well i like it.
    Sent you a pm btw, read it<3

  5. #5
    Account Upgraded | Title Enabled! wietse02 is offline
    MemberRank
    Jul 2008 Join Date
    NetherlandsLocation
    657Posts

    Re: Jump Quest Event Script

    Great release! Maybe tell us some more info?

  6. #6
    Not a programmer. inumedia is offline
    MemberRank
    Jul 2008 Join Date
    Ohai, candleja-Location
    222Posts

    Re: Jump Quest Event Script

    Quote Originally Posted by wietse02 View Post
    Great release! Maybe tell us some more info?
    THis script is basically ment to be a timed jump quest event that will automatically tell when someone is close to the portal to the next map and it will give them points for getting there if they are first,second, or third.

    Once the timer runs out or if the starter says !jmpquest end everyone will be warped out and the starter will be told the name and the points they have.

    !jmpquest is the main command you'll use.

  7. #7
    warp(california, "home"); LameJacob is offline
    MemberRank
    Sep 2008 Join Date
    CaliforniaLocation
    537Posts

    Re: Jump Quest Event Script

    What happened to MyMimirDev?

  8. #8
    Member Kenman is offline
    MemberRank
    Aug 2009 Join Date
    CanadaLocation
    52Posts

    Re: Jump Quest Event Script

    Where do we even put the files? Please make this Noob Friendly.

  9. #9
    offonline King Grub is offline
    MemberRank
    Aug 2009 Join Date
    Spring fieldLocation
    3,303Posts

    Re: Jump Quest Event Script

    Quote Originally Posted by Kenman View Post
    Where do we even put the files? Please make this Noob Friendly.
    Its Noob friendly.
    Read the whole thread.

  10. #10
    Gamma Samus. is offline
    MemberRank
    Jun 2008 Join Date
    wvndesign.nlLocation
    3,216Posts

    Re: Jump Quest Event Script

    Going to test this :]



Advertisement