Search in sources :

Example 36 with Item

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

the class MapleItemInformationProvider method isUpgradeable.

public boolean isUpgradeable(int itemId) {
    Item it = this.getEquipById(itemId);
    Equip eq = (Equip) it;
    return (eq.getUpgradeSlots() > 0 || eq.getStr() > 0 || eq.getDex() > 0 || eq.getInt() > 0 || eq.getLuk() > 0 || eq.getWatk() > 0 || eq.getMatk() > 0 || eq.getWdef() > 0 || eq.getMdef() > 0 || eq.getAcc() > 0 || eq.getAvoid() > 0 || eq.getSpeed() > 0 || eq.getJump() > 0 || eq.getHp() > 0 || eq.getMp() > 0);
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip)

Example 37 with Item

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

the class AbstractPlayerInteraction method gainAndEquip.

public void gainAndEquip(int itemid, short slot) {
    final Item old = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(slot);
    if (old != null) {
        MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIPPED, slot, old.getQuantity(), false, false);
    }
    final Item newItem = MapleItemInformationProvider.getInstance().getEquipById(itemid);
    newItem.setPosition(slot);
    c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).addFromDB(newItem);
    c.announce(MaplePacketCreator.modifyInventory(false, Collections.singletonList(new ModifyInventory(0, newItem))));
}
Also used : Item(client.inventory.Item) ModifyInventory(client.inventory.ModifyInventory)

Example 38 with Item

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

the class MapleStatEffect method applyBuffEffect.

private void applyBuffEffect(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary) {
    if (!isMonsterRiding() && !isCouponBuff() && !isMysticDoor()) {
        // last mystic door already dispelled if it has been used before.
        applyto.cancelEffect(this, true, -1);
    }
    List<Pair<MapleBuffStat, Integer>> localstatups = statups;
    int localDuration = duration;
    int localsourceid = sourceid;
    int seconds = localDuration / 1000;
    MapleMount givemount = null;
    if (isMonsterRiding()) {
        int ridingLevel = 0;
        Item mount = applyfrom.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -18);
        if (mount != null) {
            ridingLevel = mount.getItemId();
        }
        if (sourceid == Corsair.BATTLE_SHIP) {
            ridingLevel = 1932000;
        } else if (sourceid == Beginner.SPACESHIP || sourceid == Noblesse.SPACESHIP) {
            ridingLevel = 1932000 + applyto.getSkillLevel(sourceid);
        } else if (sourceid == Beginner.YETI_MOUNT1 || sourceid == Noblesse.YETI_MOUNT1 || sourceid == Legend.YETI_MOUNT1) {
            ridingLevel = 1932003;
        } else if (sourceid == Beginner.YETI_MOUNT2 || sourceid == Noblesse.YETI_MOUNT2 || sourceid == Legend.YETI_MOUNT2) {
            ridingLevel = 1932004;
        } else if (sourceid == Beginner.WITCH_BROOMSTICK || sourceid == Noblesse.WITCH_BROOMSTICK || sourceid == Legend.WITCH_BROOMSTICK) {
            ridingLevel = 1932005;
        } else if (sourceid == Beginner.BALROG_MOUNT || sourceid == Noblesse.BALROG_MOUNT || sourceid == Legend.BALROG_MOUNT) {
            ridingLevel = 1932010;
        } else {
            if (applyto.getMount() == null) {
                applyto.mount(ridingLevel, sourceid);
            }
            applyto.getClient().getWorldServer().registerMountHunger(applyto);
        }
        if (sourceid == Corsair.BATTLE_SHIP) {
            givemount = new MapleMount(applyto, 1932000, sourceid);
        } else if (sourceid == Beginner.SPACESHIP || sourceid == Noblesse.SPACESHIP) {
            givemount = new MapleMount(applyto, 1932000 + applyto.getSkillLevel(sourceid), sourceid);
        } else if (sourceid == Beginner.YETI_MOUNT1 || sourceid == Noblesse.YETI_MOUNT1 || sourceid == Legend.YETI_MOUNT1) {
            givemount = new MapleMount(applyto, 1932003, sourceid);
        } else if (sourceid == Beginner.YETI_MOUNT2 || sourceid == Noblesse.YETI_MOUNT2 || sourceid == Legend.YETI_MOUNT2) {
            givemount = new MapleMount(applyto, 1932004, sourceid);
        } else if (sourceid == Beginner.WITCH_BROOMSTICK || sourceid == Noblesse.WITCH_BROOMSTICK || sourceid == Legend.WITCH_BROOMSTICK) {
            givemount = new MapleMount(applyto, 1932005, sourceid);
        } else if (sourceid == Beginner.BALROG_MOUNT || sourceid == Noblesse.BALROG_MOUNT || sourceid == Legend.BALROG_MOUNT) {
            givemount = new MapleMount(applyto, 1932010, sourceid);
        } else {
            givemount = applyto.getMount();
        }
        localDuration = sourceid;
        localsourceid = ridingLevel;
        localstatups = Collections.singletonList(new Pair<>(MapleBuffStat.MONSTER_RIDING, 0));
    } else if (isSkillMorph()) {
        localstatups = Collections.singletonList(new Pair<>(MapleBuffStat.MORPH, getMorph(applyto)));
    }
    if (primary) {
        localDuration = alchemistModifyVal(applyfrom, localDuration, false);
        applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.showBuffeffect(applyto.getId(), sourceid, 1, (byte) 3), false);
    }
    if (localstatups.size() > 0) {
        byte[] buff = null;
        byte[] mbuff = null;
        if (getSummonMovementType() == null) {
            buff = MaplePacketCreator.giveBuff((skill ? sourceid : -sourceid), localDuration, localstatups);
        }
        if (isDash()) {
            buff = MaplePacketCreator.givePirateBuff(statups, sourceid, seconds);
            mbuff = MaplePacketCreator.giveForeignPirateBuff(applyto.getId(), sourceid, seconds, localstatups);
        } else if (isInfusion()) {
            buff = MaplePacketCreator.givePirateBuff(localstatups, sourceid, seconds);
            mbuff = MaplePacketCreator.giveForeignPirateBuff(applyto.getId(), sourceid, seconds, localstatups);
        } else if (isDs()) {
            List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<>(MapleBuffStat.DARKSIGHT, 0));
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), dsstat);
        } else if (isWw()) {
            List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<>(MapleBuffStat.WIND_WALK, 0));
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), dsstat);
        } else if (isCombo()) {
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), statups);
        } else if (isMonsterRiding()) {
            buff = MaplePacketCreator.giveBuff(localsourceid, localDuration, localstatups);
            mbuff = MaplePacketCreator.showMonsterRiding(applyto.getId(), givemount);
            localDuration = duration;
            if (sourceid == Corsair.BATTLE_SHIP) {
                // hp
                if (applyto.getBattleshipHp() == 0) {
                    applyto.resetBattleshipHp();
                }
            }
        } else if (isShadowPartner()) {
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.SHADOWPARTNER, 0));
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), stat);
        } else if (isSoulArrow()) {
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.SOULARROW, 0));
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), stat);
        } else if (isEnrage()) {
            applyto.handleOrbconsume();
        } else if (isMorph()) {
            List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.MORPH, Integer.valueOf(getMorph(applyto))));
            mbuff = MaplePacketCreator.giveForeignBuff(applyto.getId(), stat);
        }
        if (buff != null) {
            if (!hasNoIcon()) {
                // Thanks flav for such a simple release! :)
                applyto.getClient().announce(buff);
            } else {
                System.out.println("<Error> NO buff icon for id " + sourceid);
            }
        }
        long starttime = System.currentTimeMillis();
        // CancelEffectAction cancelAction = new CancelEffectAction(applyto, this, starttime);
        // ScheduledFuture<?> schedule = TimerManager.getInstance().schedule(cancelAction, localDuration);
        applyto.registerEffect(this, starttime, starttime + localDuration, false);
        if (mbuff != null) {
            applyto.getMap().broadcastMessage(applyto, mbuff, false);
        }
        if (sourceid == Corsair.BATTLE_SHIP) {
            applyto.announce(MaplePacketCreator.skillCooldown(5221999, applyto.getBattleshipHp() / 10));
        }
    }
}
Also used : MapleMount(client.MapleMount) MapleBuffStat(client.MapleBuffStat) Item(client.inventory.Item) List(java.util.List) ArrayList(java.util.ArrayList) Point(java.awt.Point) Pair(tools.Pair)

Example 39 with Item

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

the class MapleStorage method saveToDB.

public void saveToDB(Connection con) {
    try {
        try (PreparedStatement ps = con.prepareStatement("UPDATE storages SET slots = ?, meso = ? WHERE storageid = ?")) {
            ps.setInt(1, slots);
            ps.setInt(2, meso);
            ps.setInt(3, id);
            ps.executeUpdate();
        }
        List<Pair<Item, MapleInventoryType>> itemsWithType = new ArrayList<>();
        List<Item> list = getItems();
        for (Item item : list) {
            itemsWithType.add(new Pair<>(item, item.getInventoryType()));
        }
        ItemFactory.STORAGE.saveItems(itemsWithType, id, con);
    } catch (SQLException ex) {
        ex.printStackTrace();
    }
}
Also used : Item(client.inventory.Item) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) Pair(tools.Pair)

Example 40 with Item

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

the class MapleStorage method filterItems.

private List<Item> filterItems(MapleInventoryType type) {
    List<Item> storageItems = getItems();
    List<Item> ret = new LinkedList<>();
    for (Item item : storageItems) {
        if (item.getInventoryType() == type) {
            ret.add(item);
        }
    }
    return ret;
}
Also used : Item(client.inventory.Item) LinkedList(java.util.LinkedList)

Aggregations

Item (client.inventory.Item)124 MapleMapItem (server.maps.MapleMapItem)33 Equip (client.inventory.Equip)31 ArrayList (java.util.ArrayList)31 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)31 Point (java.awt.Point)29 SQLException (java.sql.SQLException)25 MapleCharacter (client.MapleCharacter)21 MapleInventoryType (client.inventory.MapleInventoryType)20 PreparedStatement (java.sql.PreparedStatement)20 Connection (java.sql.Connection)19 DatabaseConnection (tools.DatabaseConnection)19 MapleInventory (client.inventory.MapleInventory)18 MapleItemInformationProvider (server.MapleItemInformationProvider)18 ResultSet (java.sql.ResultSet)16 Pair (tools.Pair)15 CashItem (server.CashShop.CashItem)13 SpecialCashItem (server.CashShop.SpecialCashItem)12 MapleShopItem (server.MapleShopItem)12 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)11