[Add-On][v75+] Custom Fishing System

Page 1 of 3 123 LastLast
Results 1 to 15 of 44
  1. #1
    Ooo, shiny! FateJiki is offline
    True MemberRank
    Feb 2008 Join Date
    1,064Posts

    [Add-On][v75+] Custom Fishing System


    RaGEZONE Recommends

    RaGEZONE Recommends

    Due to a forum bug, the thread was deleted, so here, I just reposted it. Thanks to Shawn for finding my thread.

    Made this a few months ago. I just wanted to give to the community a bit, I'm in a release mood.

    Remember to give proper credits if you repost this thread anywhere else, no help will be given. Also, remember to 'thank' me if this helped you!



    server.Fishing.java
    PHP Code:
    /**
     *
     * @author FateJiki of RaGeZONE
     */
    public class Fishing {
        public static 
    void doFishing(client.MapleCharacter chr){
            
    int mesoMultiplier 1;
            
    int expMultiplier 1;
            switch(
    chr.getWorld()){
                case 
    0:
                    
    mesoMultiplier constants.ServerConstants.MESO_RATE;
                    
    expMultiplier constants.ServerConstants.EXP_RATE;
                    break;
                case 
    1// if you have bera
                    
    mesoMultiplier constants.ServerConstants.WORLD_1_MESORATE;
                    
    expMultiplier constants.ServerConstants.WORLD_1_EXPRATE;
                    break;
                case 
    2// if you have broa
                    
    mesoMultiplier constants.ServerConstants.WORLD_2_MESORATE;
                    
    expMultiplier constants.ServerConstants.WORLD_2_EXPRATE;
                    break;
            }
            
    int mesoAward = (int)(1400.0 Math.random() + 1201) * mesoMultiplier + (15 chr.getLevel() / 5);
            
    int expAward = (int)(645.0 Math.random()) * expMultiplier + (15 chr.getLevel() / 2) / 6;
            if(
    chr.getLevel() >= 30 && chr.getMapId() == 251000100){
                
    int rand = (int)(3.0 Math.random());
                switch(
    rand){
                    case 
    0:
                        
    chr.gainMeso(mesoAwardtruetruetrue);
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break;
                    case 
    1:
                        
    chr.gainExp(expAwardtruetrue);
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break;
                    case 
    2:
                        
    chr.gainItem(getRandomItem(), (short)1true);
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break;
                    case 
    3// if you have occupations
                        
    chr.gainOccEXP((int)((rand + (5.0 Math.random())) * Math.random()));
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break;
                }
              
            } else {
                
    chr.dropMessage("You must be above level 30 to fish!");
            }
        }
        public static 
    int getRandomItem(){
            
    int finalID 0;
            
    int rand = (int)(100.0 Math.random());
            
    int[] commons = {100285120020202002020200000620000182002018200202420020272002027200001820000182000018 2000018200203020020182000016}; // filler' up
            
    int[] uncommons = {1000025100266210028121002850100288110028801012072402000920432202043022204054320444202040943204371320442202044120204042920432202040943}; // filler' uptoo
            
    int[] rares = {1002859100255301002762010027630100276401002765010027660100266310027881002949204910023400002040822,2040822,2040822,2040822,2040822,2040822,2040822,2040822}; // filler' uplast
            
    if(rand >= 25){
                return 
    commons[(int)(commons.length Math.random())];
            } else if(
    rand <= && rand >= 5){
                return 
    uncommons[(int)(uncommons.length Math.random())];
            } else if(
    rand <= 3){
                return 
    rares[(int)(rares.length Math.random())];
            }

            return 
    finalID;
        }

    Replace net.channel.handler.useChairHandler.java with this :
    PHP Code:
    package net.channel.handler;

    import client.MapleClient;
    import client.MapleInventoryType;
    import net.AbstractMaplePacketHandler;
    import tools.MaplePacketCreator;
    import tools.data.input.SeekableLittleEndianAccessor;
    import server.TimerManager;
    import java.util.concurrent.ScheduledFuture;

    public final class 
    UseChairHandler extends AbstractMaplePacketHandler {
        public final 
    void handlePacket(SeekableLittleEndianAccessor sleaMapleClient c) {
            
    int itemId slea.readInt();
            if (
    c.getPlayer().getInventory(MapleInventoryType.SETUP).findById(itemId) == null) {
                return;
            }
            if(
    c.getPlayer().getMapId() == 251000100 && itemId == 3011000 && !c.getPlayer().isFishing){
            
    c.getPlayer().isFishing true;
            }
            
    c.getPlayer().setChair(itemId);
            
    c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showChair(c.getPlayer().getId(), itemId), false);
            
    c.getSession().write(MaplePacketCreator.enableActions());
        }

    Replace net.channel.handler.cancelChairHandler.java with this :
    PHP Code:
    package net.channel.handler;

    import client.MapleClient;
    import net.AbstractMaplePacketHandler;
    import tools.MaplePacketCreator;
    import tools.data.input.SeekableLittleEndianAccessor;

    public final class 
    CancelChairHandler extends AbstractMaplePacketHandler {
        public final 
    void handlePacket(SeekableLittleEndianAccessor sleaMapleClient c) {
            
    int id slea.readShort();
            if (
    id == -1) { // Cancel Chair
                
    c.getPlayer().setChair(0);
                
    c.getPlayer().isFishing false;
                
    c.getSession().write(MaplePacketCreator.cancelChair(-1));
                
    c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showChair(c.getPlayer().getId(), 0), false);
            } else { 
    // Use In-Map Chair
                
    c.getPlayer().setChair(id);
                
    c.getSession().write(MaplePacketCreator.cancelChair(id));
            }
        }

    And finally, go in ChannelServer.java and add this :
    PHP Code:
                @Override
                
    public void run(){
                    for(
    MapleCharacter chr getPlayerStorage().getAllCharacters()){
                        if(
    chr.isFishing && chr.getMapId() == 251000100){
                            
    server.Events.Fishing.doFishing(chr);
                        }
                    }
                }
                }, 
    30000); 
    under tMan.register , (in the run method.)
    Last edited by Shawn; 17-01-11 at 11:24 AM.


  2. #2
    Account Upgraded | Title Enabled! .:LastBreath:. is offline
    True MemberRank
    Oct 2009 Join Date
    Under your bedLocation
    1,314Posts

    Re: [v75+] Custom Fishing System

    Re-thanks for this :)

  3. #3
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

    Re: [v75+] Custom Fishing System

    Eh, umm, could I ask why when i use the catch function, the catch effect won't show?..O.o

  4. #4
    Account Upgraded | Title Enabled! JakeK is offline
    True MemberRank
    Sep 2010 Join Date
    Top of you.Location
    196Posts

    Re: [v75+] Custom Fishing System

    Still Loving this thread lol
    Press "Thanks" if i helped :)
    Learning packet .... :)

  5. #5
    Account Upgraded | Title Enabled! natkemon is offline
    True MemberRank
    Jul 2008 Join Date
    424Posts

    Re: [v75+] Custom Fishing System

    Ooo its finally unbugged.

    Just wandering. Do you actually catch fish? Cause i catch mesos only...

    I had to make a function in maplecharacter for cm.gainitem and cm.gainOccEXP

    so respectively they look like this :

    cm.gainitem:
    PHP Code:
        public void gainItem(int randomItemshort sboolean b) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    cm.gainoccexp:
    PHP Code:
        public void gainOccEXP(int i) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    What do i replace instead of these 2 functions?
    Last edited by natkemon; 20-11-10 at 01:29 PM.

  6. #6
    Ooo, shiny! FateJiki is offline
    True MemberRank
    Feb 2008 Join Date
    1,064Posts

    Re: [v75+] Custom Fishing System

    Yeah, I forgot to remove that packet-part. No, you won't see the catch animation.

  7. #7
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

    Re: [v75+] Custom Fishing System

    Quote Originally Posted by natkemon View Post
    Ooo its finally unbugged.

    Just wandering. Do you actually catch fish? Cause i catch mesos only...

    I had to make a function in maplecharacter for cm.gainitem and cm.gainOccEXP

    so respectively they look like this :

    cm.gainitem:
    PHP Code:
        public void gainItem(int randomItemshort sboolean b) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    cm.gainoccexp:
    PHP Code:
        public void gainOccEXP(int i) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    What do i replace instead of these 2 functions?
    Remove this from Fishing.java:
    PHP Code:
                    case 3// if you have occupations
                        
    chr.gainOccEXP((int)((rand + (5.0 Math.random())) * Math.random()));
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break; 
    Remove this as well in MapleCharacter.java
    PHP Code:
    public void gainOccEXP(int i) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    those are if you have Occupation system, guessing you don't have it.. also the gainItem not sure yet you should have it in MapleCharacter.java o.o
    Last edited by iAkira; 20-11-10 at 04:38 PM.

  8. #8
    Account Inactive JvlShiz(fail) is offline
    InactiveRank
    Oct 2010 Join Date
    62Posts

    Re: [v75+] Custom Fishing System

    I can understand why sources are so buggy and slow now.

  9. #9
    Ooo, shiny! FateJiki is offline
    True MemberRank
    Feb 2008 Join Date
    1,064Posts

    Re: [v75+] Custom Fishing System

    Quote Originally Posted by JvlShiz View Post
    I can understand why sources are so buggy and slow now.
    I'd like you to elaborate yourself a bit more.


    What can I do to improve my code?

  10. #10
    may web.very maple.pls. iAkira is offline
    Alpha MaleRank
    Aug 2009 Join Date
    somewhere..Location
    2,383Posts

    Re: [v75+] Custom Fishing System

    wait quick question, wouldn't this make the srv slow by reading that function in channelserver alot and check all character over and over o.O? idk not sure on how the servers works xD

  11. #11
    Ooo, shiny! FateJiki is offline
    True MemberRank
    Feb 2008 Join Date
    1,064Posts

    Re: [v75+] Custom Fishing System

    Quote Originally Posted by iAkira View Post
    wait quick question, wouldn't this make the srv slow by reading that function in channelserver alot and check all character over and over o.O? idk not sure on how the servers works xD
    I don't think so.

    I haven't really noticed.

  12. #12
    Account Inactive JvlShiz(fail) is offline
    InactiveRank
    Oct 2010 Join Date
    62Posts

    Re: [v75+] Custom Fishing System

    Quote Originally Posted by FateJiki View Post
    I'd like you to elaborate yourself a bit more.


    What can I do to improve my code?
    The main bottleneck here is that you're iterating over the WHOLE server. I know that if you had like 10 players that wouldn't be a problem, but try 900 and you'll see what I mean...

    To speed it up, create a separate HashMap<Integer, Player> somewhere else. When somebody requests fishing or whatever, insert them into the hash map. Then in your timer method, iterate through this HashMap.

    This means that if you have 900 players and only 10 of them chose fishing, the iterator would only have to iterate 10 times instead of 900. This greatly speeds it up by a ratio of 1:90.

    This is only part of the performance problems.

    - David

  13. #13
    Account Upgraded | Title Enabled! natkemon is offline
    True MemberRank
    Jul 2008 Join Date
    424Posts

    Re: [v75+] Custom Fishing System

    Quote Originally Posted by iAkira View Post
    Remove this from Fishing.java:
    PHP Code:
                    case 3// if you have occupations
                        
    chr.gainOccEXP((int)((rand + (5.0 Math.random())) * Math.random()));
                        
    chr.getClient().getSession().write(MaplePacketCreator.catchMonster(95003362000017, (byte)1));
                        
    chr.getMap().broadcastMessage(chrMaplePacketCreator.catchMonster(95003362000017, (byte)1), false);
                        break; 
    Remove this as well in MapleCharacter.java
    PHP Code:
    public void gainOccEXP(int i) {
            throw new 
    UnsupportedOperationException("Not yet implemented");
        } 
    those are if you have Occupation system, guessing you don't have it.. also the gainItem not sure yet you should have it in MapleCharacter.java o.o

    I'm using MapleBlade and it doesn't seem to have the function :S thats why its not picking it up.

  14. #14
    Gamma Sparrow is offline
    GammaRank
    Mar 2009 Join Date
    SydneyLocation
    2,968Posts

    Re: [v75+] Custom Fishing System

    Lol at above,

    Release Multi Worlds :P

  15. #15
    Member dmnhao is offline
    MemberRank
    Oct 2007 Join Date
    64Posts

    Re: [v75+] Custom Fishing System

    can u also release the isFishing thingy under maplecharacter.java ?




Page 1 of 3 123 LastLast

Advertisement