Search in sources :

Example 6 with MaplePet

use of client.inventory.MaplePet in project HeavenMS by ronancpl.

the class MapleMap method addPlayer.

public void addPlayer(final MapleCharacter chr) {
    int chrSize;
    chrWLock.lock();
    try {
        characters.add(chr);
        chrSize = characters.size();
        addPartyMemberInternal(chr);
    } finally {
        chrWLock.unlock();
    }
    chr.setMapId(mapid);
    itemMonitorTimeout = 1;
    if (chrSize == 1) {
        if (!hasItemMonitor())
            startItemMonitor();
        if (onFirstUserEnter.length() != 0 && !chr.hasEntered(onFirstUserEnter, mapid) && MapScriptManager.getInstance().scriptExists(onFirstUserEnter, true)) {
            chr.enteredScript(onFirstUserEnter, mapid);
            MapScriptManager.getInstance().getMapScript(chr.getClient(), onFirstUserEnter, true);
        }
    }
    if (onUserEnter.length() != 0) {
        if (onUserEnter.equals("cygnusTest") && (mapid < 913040000 || mapid > 913040006)) {
            chr.saveLocation("INTRO");
        }
        MapScriptManager.getInstance().getMapScript(chr.getClient(), onUserEnter, false);
    }
    if (FieldLimit.CANNOTUSEMOUNTS.check(fieldLimit) && chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) {
        chr.cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
        chr.cancelBuffStats(MapleBuffStat.MONSTER_RIDING);
    }
    if (mapid == 923010000 && getMonsterById(9300102) == null) {
        // Kenta's Mount Quest
        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300102), new Point(77, 426));
    } else if (mapid == 200090060) {
        // To Rien
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090060) {
                    chr.changeMap(140020300, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090070) {
        // To Lith Harbor
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090070) {
                    chr.changeMap(104000000, 3);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090030) {
        // To Ereve (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090030) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090031) {
        // To Victoria Island (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090031) {
                    chr.changeMap(101000400, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090021) {
        // To Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090021) {
                    chr.changeMap(200000161, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090020) {
        // To Ereve From Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090020) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 103040400) {
        if (chr.getEventInstance() != null) {
            chr.getEventInstance().movePlayer(chr);
        }
    } else if (MapleMiniDungeonInfo.isDungeonMap(mapid)) {
        MapleMiniDungeon mmd = chr.getClient().getChannelServer().getMiniDungeon(mapid);
        if (mmd != null)
            mmd.registerPlayer(chr);
    }
    MaplePet[] pets = chr.getPets();
    for (int i = 0; i < pets.length; i++) {
        if (pets[i] != null) {
            pets[i].setPos(getGroundBelow(chr.getPosition()));
            chr.announce(MaplePacketCreator.showPet(chr, pets[i], false, false));
        } else {
            break;
        }
    }
    if (chr.isHidden()) {
        broadcastGMMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
        chr.announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
        List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
        broadcastGMMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), dsstat), false);
    } else {
        broadcastMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
    }
    sendObjectPlacement(chr.getClient());
    if (isStartingEventMap() && !eventStarted()) {
        chr.getMap().getPortal("join00").setPortalStatus(false);
    }
    if (hasForcedEquip()) {
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(-1));
    }
    if (specialEquip()) {
        chr.getClient().announce(MaplePacketCreator.coconutScore(0, 0));
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(chr.getTeam()));
    }
    objectWLock.lock();
    try {
        this.mapobjects.put(Integer.valueOf(chr.getObjectId()), chr);
    } finally {
        objectWLock.unlock();
    }
    if (chr.getPlayerShop() != null) {
        addMapObject(chr.getPlayerShop());
    }
    final MapleDragon dragon = chr.getDragon();
    if (dragon != null) {
        dragon.setPosition(chr.getPosition());
        this.addMapObject(dragon);
        if (chr.isHidden()) {
            this.broadcastGMMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        } else {
            this.broadcastMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        }
    }
    MapleStatEffect summonStat = chr.getStatForBuff(MapleBuffStat.SUMMON);
    if (summonStat != null) {
        MapleSummon summon = chr.getSummonByKey(summonStat.getSourceId());
        summon.setPosition(chr.getPosition());
        chr.getMap().spawnSummon(summon);
        updateMapObjectVisibility(chr, summon);
    }
    if (mapEffect != null) {
        mapEffect.sendStartData(chr.getClient());
    }
    chr.getClient().announce(MaplePacketCreator.resetForcedStats());
    if (mapid == 914000200 || mapid == 914000210 || mapid == 914000220) {
        chr.getClient().announce(MaplePacketCreator.aranGodlyStats());
    }
    if (chr.getEventInstance() != null && chr.getEventInstance().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getEventInstance().getTimeLeft() / 1000)));
    }
    if (chr.getFitness() != null && chr.getFitness().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getFitness().getTimeLeft() / 1000)));
    }
    if (chr.getOla() != null && chr.getOla().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getOla().getTimeLeft() / 1000)));
    }
    if (mapid == 109060000) {
        chr.announce(MaplePacketCreator.rollSnowBall(true, 0, null, null));
    }
    MonsterCarnival carnival = chr.getCarnival();
    MonsterCarnivalParty cparty = chr.getCarnivalParty();
    if (carnival != null && cparty != null && (mapid == 980000101 || mapid == 980000201 || mapid == 980000301 || mapid == 980000401 || mapid == 980000501 || mapid == 980000601)) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (carnival.getTimeLeft() / 1000)));
        chr.getClient().announce(MaplePacketCreator.startCPQ(chr, carnival.oppositeTeam(cparty)));
    }
    if (hasClock()) {
        Calendar cal = Calendar.getInstance();
        chr.getClient().announce((MaplePacketCreator.getClockTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND))));
    }
    if (hasBoat() > 0) {
        if (hasBoat() == 1)
            chr.getClient().announce((MaplePacketCreator.boatPacket(true)));
        else
            chr.getClient().announce(MaplePacketCreator.boatPacket(false));
    }
    chr.receivePartyMemberHP();
}
Also used : MapleBuffStat(client.MapleBuffStat) MonsterCarnival(server.partyquest.MonsterCarnival) Calendar(java.util.Calendar) MonsterCarnivalParty(server.partyquest.MonsterCarnivalParty) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleStatEffect(server.MapleStatEffect) MaplePet(client.inventory.MaplePet) Pair(tools.Pair)

Example 7 with MaplePet

use of client.inventory.MaplePet in project HeavenMS by ronancpl.

the class MaplePacketCreator method spawnPlayerMapObject.

/**
 * Gets a packet spawning a player as a mapobject to other clients.
 *
 * @param chr The character to spawn to other clients.
 * @return The spawn player packet.
 */
public static byte[] spawnPlayerMapObject(MapleCharacter chr) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.SPAWN_PLAYER.getValue());
    mplew.writeInt(chr.getId());
    // v83
    mplew.write(chr.getLevel());
    mplew.writeMapleAsciiString(chr.getName());
    if (chr.getGuildId() < 1) {
        mplew.writeMapleAsciiString("");
        mplew.write(new byte[6]);
    } else {
        MapleGuildSummary gs = chr.getClient().getWorldServer().getGuildSummary(chr.getGuildId(), chr.getWorld());
        if (gs != null) {
            mplew.writeMapleAsciiString(gs.getName());
            mplew.writeShort(gs.getLogoBG());
            mplew.write(gs.getLogoBGColor());
            mplew.writeShort(gs.getLogo());
            mplew.write(gs.getLogoColor());
        } else {
            mplew.writeMapleAsciiString("");
            mplew.write(new byte[6]);
        }
    }
    mplew.writeInt(0);
    // v83
    mplew.writeShort(0);
    mplew.write(0xFC);
    mplew.write(1);
    if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
        mplew.writeInt(2);
    } else {
        mplew.writeInt(0);
    }
    long buffmask = 0;
    Integer buffvalue = null;
    if (chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null && !chr.isHidden()) {
        buffmask |= MapleBuffStat.DARKSIGHT.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.COMBO) != null) {
        buffmask |= MapleBuffStat.COMBO.getValue();
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.COMBO).intValue());
    }
    if (chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER) != null) {
        buffmask |= MapleBuffStat.SHADOWPARTNER.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.SOULARROW) != null) {
        buffmask |= MapleBuffStat.SOULARROW.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.MORPH).intValue());
    }
    if (chr.getBuffedValue(MapleBuffStat.ENERGY_CHARGE) != null) {
        buffmask |= MapleBuffStat.ENERGY_CHARGE.getValue();
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.ENERGY_CHARGE).intValue());
    }
    // AREN'T THESE
    mplew.writeInt((int) ((buffmask >> 32) & 0xffffffffL));
    if (buffvalue != null) {
        if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
            // TEST
            mplew.writeShort(buffvalue);
        } else {
            mplew.write(buffvalue.byteValue());
        }
    }
    mplew.writeInt((int) (buffmask & 0xffffffffL));
    int CHAR_MAGIC_SPAWN = Randomizer.nextInt();
    mplew.skip(6);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(11);
    // v74
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(11);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    mplew.write(0);
    final Item mount = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -18);
    if (chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null && mount != null) {
        mplew.writeInt(mount.getItemId());
        mplew.writeInt(1004);
    } else {
        mplew.writeLong(0);
    }
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(9);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    // actually not 0, why is it 0 then?
    mplew.writeInt(0);
    mplew.skip(10);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(13);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    mplew.write(0);
    mplew.writeShort(chr.getJob().getId());
    /* replace "mplew.writeShort(chr.getJob().getId())" with this snippet for 3rd person FJ animation on all classes
                if (chr.getJob().isA(MapleJob.HERMIT) || chr.getJob().isA(MapleJob.DAWNWARRIOR2) || chr.getJob().isA(MapleJob.NIGHTWALKER2)) {
			mplew.writeShort(chr.getJob().getId());
                } else {
			mplew.writeShort(412);
                }*/
    addCharLook(mplew, chr, false);
    mplew.writeInt(chr.getInventory(MapleInventoryType.CASH).countById(5110000));
    mplew.writeInt(chr.getItemEffect());
    mplew.writeInt(ItemConstants.getInventoryType(chr.getChair()) == MapleInventoryType.SETUP ? chr.getChair() : 0);
    mplew.writePos(chr.getPosition());
    mplew.write(chr.getStance());
    // chr.getFh()
    mplew.writeShort(0);
    mplew.write(0);
    MaplePet[] pet = chr.getPets();
    for (int i = 0; i < 3; i++) {
        if (pet[i] != null) {
            addPetInfo(mplew, pet[i], false);
        }
    }
    // end of pets
    mplew.write(0);
    if (chr.getMount() == null) {
        // mob level
        mplew.writeInt(1);
        // mob exp + tiredness
        mplew.writeLong(0);
    } else {
        mplew.writeInt(chr.getMount().getLevel());
        mplew.writeInt(chr.getMount().getExp());
        mplew.writeInt(chr.getMount().getTiredness());
    }
    MaplePlayerShop mps = chr.getPlayerShop();
    if (mps != null && mps.isOwner(chr)) {
        if (mps.hasFreeSlot()) {
            addAnnounceBox(mplew, mps, mps.getVisitors().length);
        } else {
            addAnnounceBox(mplew, mps, 1);
        }
    } else if (chr.getMiniGame() != null && chr.getMiniGame().isOwner(chr)) {
        if (chr.getMiniGame().hasFreeSlot()) {
            addAnnounceBox(mplew, chr.getMiniGame(), 1, 0, 1, 0);
        } else {
            addAnnounceBox(mplew, chr.getMiniGame(), 1, 0, 2, 1);
        }
    } else {
        mplew.write(0);
    }
    if (chr.getChalkboard() != null) {
        mplew.write(1);
        mplew.writeMapleAsciiString(chr.getChalkboard());
    } else {
        mplew.write(0);
    }
    // crush
    addRingLook(mplew, chr, true);
    // friendship
    addRingLook(mplew, chr, false);
    addMarriageRingLook(mplew, chr);
    // new year seems to crash sometimes...
    encodeNewYearCardInfo(mplew, chr);
    mplew.skip(2);
    // only needed in specific fields
    mplew.write(chr.getTeam());
    return mplew.getPacket();
}
Also used : MapleMapItem(server.maps.MapleMapItem) SpecialCashItem(server.CashShop.SpecialCashItem) CashItem(server.CashShop.CashItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) MapleShopItem(server.MapleShopItem) MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MapleGuildSummary(net.server.guild.MapleGuildSummary) MaplePlayerShop(server.maps.MaplePlayerShop) MaplePet(client.inventory.MaplePet) Point(java.awt.Point)

Example 8 with MaplePet

use of client.inventory.MaplePet in project HeavenMS by ronancpl.

the class MaplePacketCreator method addItemInfo.

private static void addItemInfo(final MaplePacketLittleEndianWriter mplew, Item item, boolean zeroPosition) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    boolean isCash = ii.isCash(item.getItemId());
    boolean isPet = item.getPetId() > -1;
    boolean isRing = false;
    Equip equip = null;
    short pos = item.getPosition();
    byte itemType = item.getItemType();
    if (itemType == 1) {
        equip = (Equip) item;
        isRing = equip.getRingId() > -1;
    }
    if (!zeroPosition) {
        if (equip != null) {
            if (pos < 0) {
                pos *= -1;
            }
            mplew.writeShort(pos > 100 ? pos - 100 : pos);
        } else {
            mplew.write(pos);
        }
    }
    mplew.write(itemType);
    mplew.writeInt(item.getItemId());
    mplew.writeBool(isCash);
    if (isCash) {
        mplew.writeLong(isPet ? item.getPetId() : isRing ? equip.getRingId() : item.getCashId());
    }
    addExpirationTime(mplew, item.getExpiration());
    if (isPet) {
        MaplePet pet = item.getPet();
        mplew.writeAsciiString(StringUtil.getRightPaddedStr(pet.getName(), '\0', 13));
        mplew.write(pet.getLevel());
        mplew.writeShort(pet.getCloseness());
        mplew.write(pet.getFullness());
        addExpirationTime(mplew, item.getExpiration());
        mplew.writeInt(0);
        // wonder what this is
        mplew.write(new byte[] { (byte) 0x50, (byte) 0x46 });
        mplew.writeInt(0);
        return;
    }
    if (equip == null) {
        mplew.writeShort(item.getQuantity());
        mplew.writeMapleAsciiString(item.getOwner());
        // flag
        mplew.writeShort(item.getFlag());
        if (ItemConstants.isRechargable(item.getItemId())) {
            mplew.writeInt(2);
            mplew.write(new byte[] { (byte) 0x54, 0, 0, (byte) 0x34 });
        }
        return;
    }
    // upgrade slots
    mplew.write(equip.getUpgradeSlots());
    // level
    mplew.write(equip.getLevel());
    // str
    mplew.writeShort(equip.getStr());
    // dex
    mplew.writeShort(equip.getDex());
    // int
    mplew.writeShort(equip.getInt());
    // luk
    mplew.writeShort(equip.getLuk());
    // hp
    mplew.writeShort(equip.getHp());
    // mp
    mplew.writeShort(equip.getMp());
    // watk
    mplew.writeShort(equip.getWatk());
    // matk
    mplew.writeShort(equip.getMatk());
    // wdef
    mplew.writeShort(equip.getWdef());
    // mdef
    mplew.writeShort(equip.getMdef());
    // accuracy
    mplew.writeShort(equip.getAcc());
    // avoid
    mplew.writeShort(equip.getAvoid());
    // hands
    mplew.writeShort(equip.getHands());
    // speed
    mplew.writeShort(equip.getSpeed());
    // jump
    mplew.writeShort(equip.getJump());
    // owner name
    mplew.writeMapleAsciiString(equip.getOwner());
    // Item Flags
    mplew.writeShort(equip.getFlag());
    if (isCash) {
        for (int i = 0; i < 10; i++) {
            mplew.write(0x40);
        }
    } else {
        mplew.write(0);
        // Item Level
        mplew.write(equip.getItemLevel());
        mplew.writeShort(0);
        // Works pretty weird :s
        mplew.writeShort(equip.getItemExp());
        // WTF NEXON ARE YOU SERIOUS?
        mplew.writeInt(equip.getVicious());
        mplew.writeLong(0);
    }
    mplew.writeLong(getTime(-2));
    mplew.writeInt(-1);
}
Also used : Equip(client.inventory.Equip) MapleItemInformationProvider(server.MapleItemInformationProvider) MaplePet(client.inventory.MaplePet) Point(java.awt.Point)

Example 9 with MaplePet

use of client.inventory.MaplePet in project HeavenMS by ronancpl.

the class MaplePacketCreator method petStatUpdate.

public static byte[] petStatUpdate(MapleCharacter chr) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.STAT_CHANGED.getValue());
    int mask = 0;
    mask |= MapleStat.PET.getValue();
    mplew.write(0);
    mplew.writeInt(mask);
    MaplePet[] pets = chr.getPets();
    for (int i = 0; i < 3; i++) {
        if (pets[i] != null) {
            mplew.writeInt(pets[i].getUniqueId());
            mplew.writeInt(0);
        } else {
            mplew.writeLong(0);
        }
    }
    mplew.write(0);
    return mplew.getPacket();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MaplePet(client.inventory.MaplePet) Point(java.awt.Point)

Example 10 with MaplePet

use of client.inventory.MaplePet in project HeavenMS by ronancpl.

the class AbstractPlayerInteraction method gainItem.

public Item gainItem(int id, short quantity, boolean randomStats, boolean showMessage, long expires, MaplePet from) {
    Item item = null;
    MaplePet evolved;
    int petId = -1;
    if (quantity >= 0) {
        if (ItemConstants.isPet(id)) {
            petId = MaplePet.createPet(id);
            if (from != null) {
                evolved = MaplePet.loadFromDb(id, (short) 0, petId);
                Point pos = getPlayer().getPosition();
                pos.y -= 12;
                evolved.setPos(pos);
                evolved.setFh(getPlayer().getMap().getFootholds().findBelow(evolved.getPos()).getId());
                evolved.setStance(0);
                evolved.setSummoned(true);
                evolved.setName(from.getName().compareTo(MapleItemInformationProvider.getInstance().getName(from.getItemId())) != 0 ? from.getName() : MapleItemInformationProvider.getInstance().getName(id));
                evolved.setCloseness(from.getCloseness());
                evolved.setFullness(from.getFullness());
                evolved.setLevel(from.getLevel());
                evolved.saveToDb();
            }
        // MapleInventoryManipulator.addById(c, id, (short) 1, null, petId, expires == -1 ? -1 : System.currentTimeMillis() + expires);
        }
        MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
        if (ItemConstants.getInventoryType(id).equals(MapleInventoryType.EQUIP)) {
            item = ii.getEquipById(id);
            if (item != null) {
                Equip it = (Equip) item;
                if (ItemConstants.isAccessory(item.getItemId()) && it.getUpgradeSlots() <= 0)
                    it.setUpgradeSlots(3);
                if (ServerConstants.USE_ENHANCED_CRAFTING == true && c.getPlayer().getCS() == true) {
                    Equip eqp = (Equip) item;
                    if (!(c.getPlayer().isGM() && ServerConstants.USE_PERFECT_GM_SCROLL)) {
                        eqp.setUpgradeSlots((byte) (eqp.getUpgradeSlots() + 1));
                    }
                    item = MapleItemInformationProvider.getInstance().scrollEquipWithId(item, 2049100, true, 2049100, c.getPlayer().isGM());
                }
            }
        } else {
            item = new Item(id, (short) 0, quantity, petId);
        }
        if (expires >= 0)
            item.setExpiration(System.currentTimeMillis() + expires);
        item.setPetId(petId);
        if (!MapleInventoryManipulator.checkSpace(c, id, quantity, "")) {
            c.getPlayer().dropMessage(1, "Your inventory is full. Please remove an item from your " + ItemConstants.getInventoryType(id).name() + " inventory.");
            return null;
        }
        if (ItemConstants.getInventoryType(id) == MapleInventoryType.EQUIP) {
            if (randomStats) {
                item = ii.randomizeStats((Equip) item);
                MapleInventoryManipulator.addFromDrop(c, ii.randomizeStats((Equip) item), false, petId);
            } else {
                MapleInventoryManipulator.addFromDrop(c, (Equip) item, false, petId);
            }
        } else {
            MapleInventoryManipulator.addFromDrop(c, item, false, petId);
        }
    } else {
        MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(id), id, -quantity, true, false);
    }
    if (showMessage) {
        c.announce(MaplePacketCreator.getShowItemGain(id, quantity, true));
    }
    return item;
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) MaplePet(client.inventory.MaplePet) Point(java.awt.Point)

Aggregations

MaplePet (client.inventory.MaplePet)17 Item (client.inventory.Item)9 Point (java.awt.Point)9 MapleCharacter (client.MapleCharacter)7 MapleMapItem (server.maps.MapleMapItem)5 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)5 Equip (client.inventory.Equip)4 SQLException (java.sql.SQLException)3 MapleItemInformationProvider (server.MapleItemInformationProvider)3 Pair (tools.Pair)3 AutobanManager (client.autoban.AutobanManager)2 MapleInventoryType (client.inventory.MapleInventoryType)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 MapleAlliance (net.server.guild.MapleAlliance)2 MapleGuild (net.server.guild.MapleGuild)2 MaplePartyCharacter (net.server.world.MaplePartyCharacter)2 CashItem (server.CashShop.CashItem)2 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)2 BuddylistEntry (client.BuddylistEntry)1