Search in sources :

Example 16 with Item

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

the class MTSHandler method getMTS.

private static byte[] getMTS(int tab, int type, int page) {
    List<MTSItemInfo> items = new ArrayList<>();
    Connection con = null;
    PreparedStatement ps;
    ResultSet rs;
    int pages = 0;
    try {
        con = DatabaseConnection.getConnection();
        if (type != 0) {
            ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
        } else {
            ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
        }
        ps.setInt(1, tab);
        if (type != 0) {
            ps.setInt(2, type);
            ps.setInt(3, page * 16);
        } else {
            ps.setInt(2, page * 16);
        }
        rs = ps.executeQuery();
        while (rs.next()) {
            if (rs.getInt("type") != 1) {
                Item i = new Item(rs.getInt("itemid"), (short) 0, (short) rs.getInt("quantity"));
                i.setOwner(rs.getString("owner"));
                items.add(new MTSItemInfo((Item) i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
            } else {
                Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
                equip.setOwner(rs.getString("owner"));
                equip.setQuantity((short) 1);
                equip.setAcc((short) rs.getInt("acc"));
                equip.setAvoid((short) rs.getInt("avoid"));
                equip.setDex((short) rs.getInt("dex"));
                equip.setHands((short) rs.getInt("hands"));
                equip.setHp((short) rs.getInt("hp"));
                equip.setInt((short) rs.getInt("int"));
                equip.setJump((short) rs.getInt("jump"));
                equip.setVicious((short) rs.getInt("vicious"));
                equip.setLuk((short) rs.getInt("luk"));
                equip.setMatk((short) rs.getInt("matk"));
                equip.setMdef((short) rs.getInt("mdef"));
                equip.setMp((short) rs.getInt("mp"));
                equip.setSpeed((short) rs.getInt("speed"));
                equip.setStr((short) rs.getInt("str"));
                equip.setWatk((short) rs.getInt("watk"));
                equip.setWdef((short) rs.getInt("wdef"));
                equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
                equip.setLevel((byte) rs.getInt("level"));
                equip.setFlag((byte) rs.getInt("flag"));
                items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
            }
        }
        rs.close();
        ps.close();
        ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? " + (type != 0 ? "AND type = ?" : "") + "AND transfer = 0");
        ps.setInt(1, tab);
        if (type != 0) {
            ps.setInt(2, type);
        }
        rs = ps.executeQuery();
        if (rs.next()) {
            pages = rs.getInt(1) / 16;
            if (rs.getInt(1) % 16 > 0) {
                pages++;
            }
        }
        rs.close();
        ps.close();
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    // resniff
    return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
Also used : Item(client.inventory.Item) Equip(client.inventory.Equip) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) MTSItemInfo(server.MTSItemInfo) PreparedStatement(java.sql.PreparedStatement)

Example 17 with Item

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

the class MTSHandler method getMTSSearch.

public byte[] getMTSSearch(int tab, int type, int cOi, String search, int page) {
    List<MTSItemInfo> items = new ArrayList<>();
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    String listaitems = "";
    if (cOi != 0) {
        List<String> retItems = new ArrayList<>();
        for (Pair<Integer, String> itemPair : ii.getAllItems()) {
            if (itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                retItems.add(" itemid=" + itemPair.getLeft() + " OR ");
            }
        }
        listaitems += " AND (";
        if (retItems != null && retItems.size() > 0) {
            for (String singleRetItem : retItems) {
                listaitems += singleRetItem;
            }
            listaitems += " itemid=0 )";
        }
    } else {
        listaitems = " AND sellername LIKE CONCAT('%','" + search + "', '%')";
    }
    Connection con = null;
    PreparedStatement ps;
    ResultSet rs;
    int pages = 0;
    try {
        con = DatabaseConnection.getConnection();
        if (type != 0) {
            ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? " + listaitems + " AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
        } else {
            ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = ? " + listaitems + " AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
        }
        ps.setInt(1, tab);
        if (type != 0) {
            ps.setInt(2, type);
            ps.setInt(3, page * 16);
        } else {
            ps.setInt(2, page * 16);
        }
        rs = ps.executeQuery();
        while (rs.next()) {
            if (rs.getInt("type") != 1) {
                Item i = new Item(rs.getInt("itemid"), (short) 0, (short) rs.getInt("quantity"));
                i.setOwner(rs.getString("owner"));
                items.add(new MTSItemInfo((Item) i, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
            } else {
                Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
                equip.setOwner(rs.getString("owner"));
                equip.setQuantity((short) 1);
                equip.setAcc((short) rs.getInt("acc"));
                equip.setAvoid((short) rs.getInt("avoid"));
                equip.setDex((short) rs.getInt("dex"));
                equip.setHands((short) rs.getInt("hands"));
                equip.setHp((short) rs.getInt("hp"));
                equip.setInt((short) rs.getInt("int"));
                equip.setJump((short) rs.getInt("jump"));
                equip.setVicious((short) rs.getInt("vicious"));
                equip.setLuk((short) rs.getInt("luk"));
                equip.setMatk((short) rs.getInt("matk"));
                equip.setMdef((short) rs.getInt("mdef"));
                equip.setMp((short) rs.getInt("mp"));
                equip.setSpeed((short) rs.getInt("speed"));
                equip.setStr((short) rs.getInt("str"));
                equip.setWatk((short) rs.getInt("watk"));
                equip.setWdef((short) rs.getInt("wdef"));
                equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
                equip.setLevel((byte) rs.getInt("level"));
                equip.setFlag((byte) rs.getInt("flag"));
                items.add(new MTSItemInfo((Item) equip, rs.getInt("price"), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
            }
        }
        rs.close();
        ps.close();
        if (type == 0) {
            ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items WHERE tab = ? " + listaitems + " AND transfer = 0");
            ps.setInt(1, tab);
            if (type != 0) {
                ps.setInt(2, type);
            }
            rs = ps.executeQuery();
            if (rs.next()) {
                pages = rs.getInt(1) / 16;
                if (rs.getInt(1) % 16 > 0) {
                    pages++;
                }
            }
            rs.close();
            ps.close();
        }
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) Item(client.inventory.Item) Equip(client.inventory.Equip) MapleItemInformationProvider(server.MapleItemInformationProvider) ResultSet(java.sql.ResultSet) MTSItemInfo(server.MTSItemInfo)

Example 18 with Item

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

the class MakerSkillHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int type = slea.readInt();
    int toCreate = slea.readInt();
    int toDisassemble = -1, pos = -1;
    boolean makerSucceeded = true;
    MakerItemCreateEntry recipe;
    Map<Integer, Short> reagentids = new LinkedHashMap<>();
    int stimulantid = -1;
    if (type == 3) {
        // building monster crystal
        int fromLeftover = toCreate;
        toCreate = ii.getMakerCrystalFromLeftover(toCreate);
        if (toCreate == -1) {
            c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal conversion."));
            return;
        }
        recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover);
    } else if (type == 4) {
        // disassembling
        // 1... probably inventory type
        slea.readInt();
        pos = slea.readInt();
        Item it = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) pos);
        if (it != null && it.getItemId() == toCreate) {
            Pair<Integer, Integer> p;
            if ((p = generateDisassemblyInfo(toCreate)) != null) {
                recipe = MakerItemFactory.generateDisassemblyCrystalEntry(p.getLeft(), p.getRight());
                toDisassemble = toCreate;
                toCreate = ii.getMakerCrystalFromEquip(toCreate);
            } else {
                c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
                return;
            }
        } else {
            c.announce(MaplePacketCreator.serverNotice(1, "An unknown error occurred when trying to apply that item for disassembly."));
            return;
        }
    } else {
        if (ItemConstants.isEquipment(toCreate)) {
            // only equips uses stimulant and reagents
            if (slea.readByte() != 0) {
                // stimulant
                stimulantid = getMakerStimulant(toCreate);
                if (!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
                    stimulantid = -1;
                }
            }
            int reagents = Math.min(slea.readInt(), getMakerReagentSlots(toCreate));
            for (int i = 0; i < reagents; i++) {
                // crystals
                int reagentid = slea.readInt();
                if (ItemConstants.isMakerReagent(reagentid)) {
                    Short rs = reagentids.get(reagentid);
                    if (rs == null) {
                        reagentids.put(reagentid, (short) 1);
                    } else {
                        reagentids.put(reagentid, (short) (rs + 1));
                    }
                }
            }
            List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
            for (Entry<Integer, Short> r : reagentids.entrySet()) {
                int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
                if (qty < r.getValue()) {
                    toUpdate.add(new Pair<>(r.getKey(), (short) qty));
                }
            }
            // remove those not present on player inventory
            if (!toUpdate.isEmpty()) {
                for (Pair<Integer, Short> rp : toUpdate) {
                    if (rp.getRight() > 0) {
                        reagentids.put(rp.getLeft(), rp.getRight());
                    } else {
                        reagentids.remove(rp.getLeft());
                    }
                }
            }
            if (!reagentids.isEmpty())
                removeOddMakerReagents(toCreate, reagentids);
        }
        recipe = MakerItemFactory.getItemCreateEntry(toCreate, stimulantid, reagentids);
    }
    short createStatus = getCreateStatus(c, recipe);
    switch(createStatus) {
        case // non-available for Maker itemid has been tried to forge
        -1:
            FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
            c.announce(MaplePacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
            break;
        case // no items
        1:
            c.announce(MaplePacketCreator.serverNotice(1, "You don't have all required items in your inventory to make " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
            break;
        case // no meso
        2:
            NumberFormat nf = new DecimalFormat("#,###,###,###");
            c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough mesos (" + nf.format(recipe.getCost()) + ") to complete this operation."));
            break;
        case // no req level
        3:
            c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough level to complete this operation."));
            break;
        case // no req skill level
        4:
            c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
            break;
        default:
            if (MapleInventoryManipulator.checkSpace(c, toCreate, (short) recipe.getRewardAmount(), "")) {
                for (Pair<Integer, Integer> p : recipe.getReqItems()) {
                    c.getAbstractPlayerInteraction().gainItem(p.getLeft(), (short) -p.getRight());
                }
                if (toDisassemble != -1) {
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) pos, (short) 1, false);
                    c.announce(MaplePacketCreator.getShowItemGain(toDisassemble, (short) -1, true));
                }
                int cost = recipe.getCost();
                if (stimulantid == -1 && reagentids.isEmpty()) {
                    if (cost > 0)
                        c.getPlayer().gainMeso(-cost);
                    c.getPlayer().setCS(true);
                    c.getAbstractPlayerInteraction().gainItem(toCreate, (short) recipe.getRewardAmount());
                    c.getPlayer().setCS(false);
                } else {
                    if (stimulantid != -1)
                        c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1);
                    if (!reagentids.isEmpty()) {
                        for (Entry<Integer, Short> r : reagentids.entrySet()) {
                            c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()));
                        }
                    }
                    if (cost > 0)
                        c.getPlayer().gainMeso(-cost);
                    makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
                }
                if (makerSucceeded)
                    c.announce(MaplePacketCreator.serverNotice(1, "You have successfully created " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
                else
                    c.getPlayer().dropMessage(5, "The Maker skill lights up, but the skill winds up as if nothing happened.");
                c.announce(MaplePacketCreator.showMakerEffect(makerSucceeded));
                c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
                if (toCreate == 4260003 && c.getPlayer().getQuestStatus(6033) == 1) {
                    c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
                }
            } else {
                c.announce(MaplePacketCreator.serverNotice(1, "Your inventory is full."));
            }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) LinkedHashMap(java.util.LinkedHashMap) Item(client.inventory.Item) MakerItemCreateEntry(server.MakerItemFactory.MakerItemCreateEntry) Entry(java.util.Map.Entry) List(java.util.List) LinkedList(java.util.LinkedList) MakerItemCreateEntry(server.MakerItemFactory.MakerItemCreateEntry) Pair(tools.Pair) NumberFormat(java.text.NumberFormat)

Example 19 with Item

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

the class PetFoodHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    AutobanManager abm = chr.getAutobanManager();
    if (abm.getLastSpam(2) + 500 > System.currentTimeMillis()) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    abm.spam(2);
    abm.setTimestamp(1, slea.readInt(), 3);
    if (chr.getNoPets() == 0) {
        c.announce(MaplePacketCreator.enableActions());
        return;
    }
    int previousFullness = 100;
    byte slot = 0;
    MaplePet[] pets = chr.getPets();
    for (byte i = 0; i < 3; i++) {
        if (pets[i] != null) {
            if (pets[i].getFullness() < previousFullness) {
                slot = i;
                previousFullness = pets[i].getFullness();
            }
        }
    }
    MaplePet pet = chr.getPet(slot);
    if (pet == null)
        return;
    short pos = slea.readShort();
    int itemId = slea.readInt();
    Item use = chr.getInventory(MapleInventoryType.USE).getItem(pos);
    if (use == null || (itemId / 10000) != 212 || use.getItemId() != itemId) {
        return;
    }
    // 50% chance to get +1 closeness
    pet.gainClosenessFullness(chr, (Randomizer.nextInt(101) <= 50) ? 1 : 0, 30, 1);
    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, pos, (short) 1, false);
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) AutobanManager(client.autoban.AutobanManager) MaplePet(client.inventory.MaplePet)

Example 20 with Item

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

the class RangedAttackHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    chr.setPetLootCd(System.currentTimeMillis());
    /*long timeElapsed = System.currentTimeMillis() - chr.getAutobanManager().getLastSpam(8);
        if(timeElapsed < 300) {
            AutobanFactory.FAST_ATTACK.alert(chr, "Time: " + timeElapsed);
        }
        chr.getAutobanManager().spam(8);*/
    AttackInfo attack = parseDamage(slea, chr, true, false);
    if (chr.getBuffEffect(MapleBuffStat.MORPH) != null) {
        if (chr.getBuffEffect(MapleBuffStat.MORPH).isMorphWithoutAttack()) {
            // How are they attacking when the client won't let them?
            chr.getClient().disconnect(false, false);
            return;
        }
    }
    if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
        chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
    }
    if (attack.skill == Buccaneer.ENERGY_ORB || attack.skill == ThunderBreaker.SPARK || attack.skill == Shadower.TAUNT || attack.skill == NightLord.TAUNT) {
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, 0, attack.allDamage, attack.speed, attack.direction, attack.display), false);
        applyAttack(attack, chr, 1);
    } else if (attack.skill == Aran.COMBO_SMASH || attack.skill == Aran.COMBO_FENRIR || attack.skill == Aran.COMBO_TEMPEST) {
        chr.getMap().broadcastMessage(chr, MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, 0, attack.allDamage, attack.speed, attack.direction, attack.display), false);
        if (attack.skill == Aran.COMBO_SMASH && chr.getCombo() >= 30) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 1);
        } else if (attack.skill == Aran.COMBO_FENRIR && chr.getCombo() >= 100) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 2);
        } else if (attack.skill == Aran.COMBO_TEMPEST && chr.getCombo() >= 200) {
            chr.setCombo((short) 0);
            applyAttack(attack, chr, 4);
        }
    } else {
        Item weapon = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
        MapleWeaponType type = MapleItemInformationProvider.getInstance().getWeaponType(weapon.getItemId());
        if (type == MapleWeaponType.NOT_A_WEAPON) {
            return;
        }
        short slot = -1;
        int projectile = 0;
        byte bulletCount = 1;
        MapleStatEffect effect = null;
        if (attack.skill != 0) {
            effect = attack.getAttackEffect(chr, null);
            bulletCount = effect.getBulletCount();
            if (effect.getCooldown() > 0) {
                c.announce(MaplePacketCreator.skillCooldown(attack.skill, effect.getCooldown()));
            }
        }
        boolean hasShadowPartner = chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER) != null;
        if (hasShadowPartner) {
            bulletCount *= 2;
        }
        MapleInventory inv = chr.getInventory(MapleInventoryType.USE);
        for (short i = 1; i <= inv.getSlotLimit(); i++) {
            Item item = inv.getItem(i);
            if (item != null) {
                int id = item.getItemId();
                slot = item.getPosition();
                boolean bow = ItemConstants.isArrowForBow(id);
                boolean cbow = ItemConstants.isArrowForCrossBow(id);
                if (item.getQuantity() >= bulletCount) {
                    // Fixes the bug where you can't use your last arrow.
                    if (type == MapleWeaponType.CLAW && ItemConstants.isThrowingStar(id) && weapon.getItemId() != 1472063) {
                        if (((id == 2070007 || id == 2070018) && chr.getLevel() < 70) || (id == 2070016 && chr.getLevel() < 50)) {
                        } else {
                            projectile = id;
                            break;
                        }
                    } else if ((type == MapleWeaponType.GUN && ItemConstants.isBullet(id))) {
                        if (id == 2331000 && id == 2332000) {
                            if (chr.getLevel() > 69) {
                                projectile = id;
                                break;
                            }
                        } else if (chr.getLevel() > (id % 10) * 20 + 9) {
                            projectile = id;
                            break;
                        }
                    } else if ((type == MapleWeaponType.BOW && bow) || (type == MapleWeaponType.CROSSBOW && cbow) || (weapon.getItemId() == 1472063 && (bow || cbow))) {
                        projectile = id;
                        break;
                    }
                }
            }
        }
        boolean soulArrow = chr.getBuffedValue(MapleBuffStat.SOULARROW) != null;
        boolean shadowClaw = chr.getBuffedValue(MapleBuffStat.SHADOW_CLAW) != null;
        if (projectile != 0) {
            if (!soulArrow && !shadowClaw && attack.skill != 11101004 && attack.skill != 15111007 && attack.skill != 14101006) {
                byte bulletConsume = bulletCount;
                if (effect != null && effect.getBulletConsume() != 0) {
                    bulletConsume = (byte) (effect.getBulletConsume() * (hasShadowPartner ? 2 : 1));
                }
                if (slot < 0)
                    System.out.println("<ERROR> Projectile to use was unable to be found.");
                else
                    MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, bulletConsume, false, true);
            }
        }
        if (projectile != 0 || soulArrow || attack.skill == 11101004 || attack.skill == 15111007 || attack.skill == 14101006) {
            // visible projectile sent to players
            int visProjectile = projectile;
            if (ItemConstants.isThrowingStar(projectile)) {
                MapleInventory cash = chr.getInventory(MapleInventoryType.CASH);
                for (int i = 1; i <= cash.getSlotLimit(); i++) {
                    // impose order...
                    Item item = cash.getItem((short) i);
                    if (item != null) {
                        if (item.getItemId() / 1000 == 5021) {
                            visProjectile = item.getItemId();
                            break;
                        }
                    }
                }
            } else // bow, crossbow
            if (soulArrow || attack.skill == 3111004 || attack.skill == 3211004 || attack.skill == 11101004 || attack.skill == 15111007 || attack.skill == 14101006) {
                visProjectile = 0;
            }
            byte[] packet;
            switch(attack.skill) {
                // Hurricane
                case 3121004:
                // Pierce
                case 3221001:
                // Rapid Fire
                case 5221004:
                case // KoC Hurricane
                13111002:
                    packet = MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.rangedirection, attack.numAttackedAndDamage, visProjectile, attack.allDamage, attack.speed, attack.direction, attack.display);
                    break;
                default:
                    packet = MaplePacketCreator.rangedAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, visProjectile, attack.allDamage, attack.speed, attack.direction, attack.display);
                    break;
            }
            chr.getMap().broadcastMessage(chr, packet, false, true);
            if (effect != null) {
                int money = effect.getMoneyCon();
                if (money != 0) {
                    int moneyMod = money / 2;
                    money += Randomizer.nextInt(moneyMod);
                    if (money > chr.getMeso()) {
                        money = chr.getMeso();
                    }
                    chr.gainMeso(-money, false);
                }
            }
            if (attack.skill != 0) {
                Skill skill = SkillFactory.getSkill(attack.skill);
                MapleStatEffect effect_ = skill.getEffect(chr.getSkillLevel(skill));
                if (effect_.getCooldown() > 0) {
                    if (chr.skillIsCooling(attack.skill)) {
                        return;
                    } else {
                        c.announce(MaplePacketCreator.skillCooldown(attack.skill, effect_.getCooldown()));
                        chr.addCooldown(attack.skill, System.currentTimeMillis(), effect_.getCooldown() * 1000);
                    }
                }
            }
            if (chr.getSkillLevel(SkillFactory.getSkill(NightWalker.VANISH)) > 0 && chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null && attack.numAttacked > 0 && chr.getBuffSource(MapleBuffStat.DARKSIGHT) != 9101004) {
                chr.cancelEffectFromBuffStat(MapleBuffStat.DARKSIGHT);
                chr.cancelBuffStats(MapleBuffStat.DARKSIGHT);
            } else if (chr.getSkillLevel(SkillFactory.getSkill(WindArcher.WIND_WALK)) > 0 && chr.getBuffedValue(MapleBuffStat.WIND_WALK) != null && attack.numAttacked > 0) {
                chr.cancelEffectFromBuffStat(MapleBuffStat.WIND_WALK);
                chr.cancelBuffStats(MapleBuffStat.WIND_WALK);
            }
            applyAttack(attack, chr, bulletCount);
        }
    }
}
Also used : Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleWeaponType(client.inventory.MapleWeaponType) MapleStatEffect(server.MapleStatEffect) MapleInventory(client.inventory.MapleInventory)

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