• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Completed UseCatchItemHandler for v75

Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
PHP:
/*
	This file is part of the OdinMS Maple Story Server
    Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
		       Matthias Butz <matze@odinms.de>
		       Jan Christian Meyer <vimes@odinms.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation version 3 as published by
    the Free Software Foundation. You may not use, modify or distribute
    this program under any other version of the GNU Affero General Public
    License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package net.channel.handler;

import client.MapleCharacter;
import client.MapleClient;
import client.MapleInventoryType;
import net.AbstractMaplePacketHandler;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.life.MapleMonster;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;

/**
 *
 * @author kevintjuh93
 */
public final class UseCatchItemHandler extends AbstractMaplePacketHandler {
    private long messagedelay = System.currentTimeMillis();
    public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
        slea.readInt();
        slea.readShort();
        int itemId = slea.readInt();
        int monsterid = slea.readInt();

        MapleMonster mob = c.getPlayer().getMap().getMonsterByOid(monsterid);
    if (c.getPlayer().getInventory(MapleItemInformationProvider.getInstance().getInventoryType(itemId)).countById(itemId) <= 0) {
           return;
    }
    if (mob == null) {
           return;
    }
        switch (itemId) {
            case 2270000:
                    if (mob.getId() == 9300101) {
                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                            mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                            MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                            MapleInventoryManipulator.addById(c, 1902000, (short) 1, "", -1);                        
                    }
                    c.getSession().write(MaplePacketCreator.enableActions());                
                break;
            case 2270001:
                if (mob.getId() == 9500197) {
                if (System.currentTimeMillis() < c.getPlayer().getCatchDelay()) {
                    return;
                }
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 4)) {
                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                            mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                            MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                            MapleInventoryManipulator.addById(c, 4031830, (short) 1, "", -1);
                    } else {
                        c.getPlayer().catchDelay(1000);
                        c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                    c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270002:
                if (mob.getId() == 9300157) {
                if (System.currentTimeMillis() < c.getPlayer().getCatchDelay()) {
                   if (!(System.currentTimeMillis() < this.messagedelay)) {
                    this.messagedelay = System.currentTimeMillis() + 1000;
                    c.getSession().write(MaplePacketCreator.catchMessage(1));
                    return;
                   }
                   return;
                }
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 4)) {
                        if (Math.random() < 0.5) { // 50% chance
                            c.getPlayer().catchDelay(800);
                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                            mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                            MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                            MapleInventoryManipulator.addById(c, 4031868, (short) 1, "", -1);
                        } else {
                            c.getPlayer().catchDelay(800);
                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 0));
                        }
                    } else {
                        c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270003:
                if (mob.getId() == 9500320) {
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 4)) {
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                        mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                        MapleInventoryManipulator.addById(c, 4031887, (short) 1, "", -1);
                    } else {
                        c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270005:
                if (mob.getId() == 9300187) {
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 3)) {
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                        mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                        MapleInventoryManipulator.addById(c, 2109001, (short) 1, "", -1);
                    } else {
                        c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270006:
                if (mob.getId() == 9300189) {
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 3)) {
                    c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                    mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                    MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                    MapleInventoryManipulator.addById(c, 2109002, (short) 1, "", -1);
                    } else {
                    c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270007:
                if (mob.getId() == 9300191) {
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 3)) {
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                        mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                        MapleInventoryManipulator.addById(c, 2109003, (short) 1, "", -1);
                    } else {
                        c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270004:
                if (mob.getId() == 9300175) {
                    if (mob.getHp() < ((mob.getMaxHp() / 10) * 4)) {
                    c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                    mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                    MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                    MapleInventoryManipulator.addById(c, 4001169, (short) 1, "", -1);
                    } else {
                    c.getSession().write(MaplePacketCreator.catchMessage(0));
                    }
                }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            case 2270008:
                if (mob.getId() == 9500336) {
                    if (System.currentTimeMillis() < c.getPlayer().getCatchDelay()) {
                      if (!(System.currentTimeMillis() < this.messagedelay)) {
                        this.messagedelay = System.currentTimeMillis() + 1000;
                        c.getPlayer().message("You cannot use the Fishing Net yet.");
                        return;
                      }
                      return;
                    }
                        c.getPlayer().catchDelay(3000);
                        c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.catchMonster(monsterid, itemId, (byte) 1));
                        mob.getMap().killMonster(mob, (MapleCharacter) mob.getMap().getAllPlayer().get(0), false, true, false, 0);
                        MapleInventoryManipulator.removeById(c, MapleInventoryType.USE, itemId, 1, true, true);
                        MapleInventoryManipulator.addById(c, 2022323, (short) 1, "", -1);
                    }
                c.getSession().write(MaplePacketCreator.enableActions());
                break;
            default:
                System.out.println("UseCatchItemHandler: \r\n" + slea.toString());
        }
    }
}

In MapleCharacter:
PHP:
private long catchdelay = System.currentTimeMillis();

    public void catchDelay(long time) {
        this.catchdelay = System.currentTimeMillis() + time;
    }

    public long getCatchDelay() {
        return catchdelay;
    }

MapleMonster: (Use expDisabled() == true at every giveExpToCharacter)
PHP:
private boolean expDisabled = false;

    public void disableExp() {
        this.expDisabled = true;
    }

    public boolean expDisabled() {
        return expDisabled;
    }

MapleMap (killMonster):
PHP:
    public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops) {
        killMonster(monster, chr, withDrops, false, false, 1);
    }

    public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops, final boolean catched, final boolean secondTime, int animation) {
        MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
        if (catched) {
            monster.disableExp();
        }
        if (monster.getId() == 8810018 && !secondTime) {
            TimerManager.getInstance().schedule(new Runnable() {
                @Override
                public void run() {
                    killMonster(monster, chr, withDrops, false, true, 1);
                    killAllMonsters();
                }
            }, 3000);
            return;
        }
        if (monster.getBuffToGive() > -1) {
            for (MapleMapObject mmo : this.getAllPlayer()) {
                MapleCharacter character = (MapleCharacter) mmo;
                if (character.isAlive()) {
                    MapleStatEffect statEffect = mii.getItemEffect(monster.getBuffToGive());
                    statEffect.applyTo(character);
                }
            }
        }
        if (monster.getId() == 8810018 || monster.getId() == 8810026) {
            for (ChannelServer cserv : ChannelServer.getAllInstances()) {
                for (MapleCharacter player : cserv.getPlayerStorage().getAllCharacters()) {
                    if (player.getMapId() == 240000000) {
                        player.message("Mysterious power arose as I heard the powerful cry of the Nine Spirit Baby Dragon.");
                        player.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(2022109, 13)); // The Breath of Nine Spirit
                        player.getMap().broadcastMessage(player, MaplePacketCreator.showBuffeffect(player.getId(), 2022109, 13), false); // The Breath of Nine Spirit
                        mii.getItemEffect(2022109).applyTo(player);
                    } else {
                        player.dropMessage("To the crew that have finally conquered Horned Tail after numerous attempts, I salute thee! You are the true heroes of Leafre!!");
                        if (player.isGM()) {
                            player.message("[GM-Message] Horntail was killed by : " + chr.getName());
                        }
                        if (player.isAlive()) {
                            player.getClient().getSession().write(MaplePacketCreator.showOwnBuffEffect(2022108, 11));
                        }
                        player.getMap().broadcastMessage(player, MaplePacketCreator.showBuffeffect(player.getId(), 2022108, 11), false); // HT nine spirit
                    }
                }
            }
        }
        spawnedMonstersOnMap.decrementAndGet();
        monster.setHp(0);
        broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), true), monster.getPosition());
        removeMapObject(monster);
        if (monster.getId() >= 8800003 && monster.getId() <= 8800010) {
            boolean makeZakReal = true;
            Collection<MapleMapObject> objects = getMapObjects();
            for (MapleMapObject object : objects) {
                MapleMonster mons = getMonsterByOid(object.getObjectId());
                if (mons != null) {
                    if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
                        makeZakReal = false;
                        break;
                    }
                }
            }
            if (makeZakReal) {
                for (MapleMapObject object : objects) {
                    MapleMonster mons = chr.getMap().getMonsterByOid(object.getObjectId());
                    if (mons != null) {
                        if (mons.getId() == 8800000) {
                            makeMonsterReal(mons);
                            updateMonsterController(mons);
                            break;
                        }
                    }
                }
            }
        }
        MapleCharacter dropOwner = monster.killBy(chr);
        if (withDrops && !monster.dropsDisabled()) {
            if (dropOwner == null) {
                dropOwner = chr;
            }
            dropFromMonster(dropOwner, monster);
        }
        if (monster.getDropPeriod() != null) {
            monster.getDropPeriod().cancel(true);
        }
    }

MaplePacketCreator:
PHP:
    public static MaplePacket catchMonster(int mobid, int itemid, byte success) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.CATCH_MONSTER.getValue());
        mplew.writeInt(mobid);
        mplew.writeInt(itemid);
        mplew.write(success);
        return mplew.getPacket();
    }

    public static MaplePacket catchMessage(int message) { // not done, I guess
        // 4C 00 00 00 00 00 00 00 00 00 00
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        mplew.writeShort(SendPacketOpcode.CATCH_MESSAGE.getValue());
        mplew.write(message); // 1 = too strong, 2 = Elemental Rock
        mplew.writeInt(0);
        mplew.writeInt(0);
        return mplew.getPacket();
    }

SendOps:
PHP:
CATCH_MESSAGE = 0x4C
CATCH_MONSTER = 0xE0
Have fun, g2g for now xD
 
Last edited:
Newbie Spellweaver
Joined
Mar 25, 2008
Messages
51
Reaction score
3
btw, if you guys have this:
Code:
public static MaplePacket catchMonster(int monsobid, int itemid, byte success) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        if (itemid == 2270002) {
            mplew.writeShort(SendPacketOpcode.CATCH_MONSTER.getValue());
        } else {
            mplew.writeShort(SendPacketOpcode.CATCH_MOUNT.getValue());
        }
        mplew.writeInt(monsobid);
        mplew.writeInt(itemid);
        mplew.write(success);
        return mplew.getPacket();
    }
Delete that code. CATCH_MONSTER might be CATCH_ARIANT for most of you.
 
Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
btw, if you guys have this:
Code:
public static MaplePacket catchMonster(int monsobid, int itemid, byte success) {
        MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
        if (itemid == 2270002) {
            mplew.writeShort(SendPacketOpcode.CATCH_MONSTER.getValue());
        } else {
            mplew.writeShort(SendPacketOpcode.CATCH_MOUNT.getValue());
        }
        mplew.writeInt(monsobid);
        mplew.writeInt(itemid);
        mplew.write(success);
        return mplew.getPacket();
    }
Delete that code. CATCH_MONSTER might be CATCH_ARIANT for most of you.
Yeah, like I said many times. That packet is gey. I checked youtube. And all monsters that can be catched uses the same header. The one people use it for dragging monsters lol
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
You know..

PHP:
/**
 *
 * @author kevintjuh93
 */

I made UseCatchItemHandler and set it to "bubblesdev" as the project team.


Yeah, like I said many times. That packet is gey. I checked youtube. And all monsters that can be catched uses the same header. The one people use it for dragging monsters lol

You know, I know why I made 2 headers. You truly have no idea what you're talking about.
 
Last edited:
Skilled Illusionist
Joined
Jul 28, 2009
Messages
339
Reaction score
200
whats 83 opcode for the message?

if someone shares them ill share all info on them.
 
Last edited:
Newbie Spellweaver
Joined
Oct 24, 2008
Messages
65
Reaction score
2
v83

Send
CATCH_MESSAGE = 0x4F
CATCH_MONSTER = 0xFC

Recv
USE_CATCH_ITEM = 0x51
 
Back
Top