Search in sources :

Example 1 with Equip

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

the class MapleCharacter method increaseEquipExp.

public void increaseEquipExp(int expGain) {
    if (expGain < 0)
        expGain = Integer.MAX_VALUE;
    for (Item item : getInventory(MapleInventoryType.EQUIPPED).list()) {
        Equip nEquip = (Equip) item;
        String itemName = ii.getName(nEquip.getItemId());
        if (itemName == null) {
            continue;
        }
        if ((nEquip.getItemLevel() < ServerConstants.USE_EQUIPMNT_LVLUP) || (itemName.contains("Reverse") && nEquip.getItemLevel() < 4) || (itemName.contains("Timeless") && nEquip.getItemLevel() < 6)) {
            nEquip.gainItemExp(client, expGain);
        }
    }
}
Also used : MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) Equip(client.inventory.Equip)

Example 2 with Equip

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

the class MapleCharacter method recalcLocalStats.

private void recalcLocalStats() {
    int oldmaxhp = localmaxhp;
    localmaxhp = getMaxHp();
    localmaxmp = getMaxMp();
    localdex = getDex();
    localint_ = getInt();
    localstr = getStr();
    localluk = getLuk();
    int speed = 100, jump = 100;
    magic = localint_;
    watk = 0;
    for (Item item : getInventory(MapleInventoryType.EQUIPPED)) {
        Equip equip = (Equip) item;
        localmaxhp += equip.getHp();
        localmaxmp += equip.getMp();
        localdex += equip.getDex();
        localint_ += equip.getInt();
        localstr += equip.getStr();
        localluk += equip.getLuk();
        magic += equip.getMatk() + equip.getInt();
        watk += equip.getWatk();
        speed += equip.getSpeed();
        jump += equip.getJump();
    }
    magic = Math.min(magic, 2000);
    Integer hbhp = getBuffedValue(MapleBuffStat.HYPERBODYHP);
    if (hbhp != null) {
        localmaxhp += (hbhp.doubleValue() / 100) * localmaxhp;
    }
    Integer hbmp = getBuffedValue(MapleBuffStat.HYPERBODYMP);
    if (hbmp != null) {
        localmaxmp += (hbmp.doubleValue() / 100) * localmaxmp;
    }
    localmaxhp = Math.min(30000, localmaxhp);
    localmaxmp = Math.min(30000, localmaxmp);
    Integer watkbuff = getBuffedValue(MapleBuffStat.WATK);
    if (watkbuff != null) {
        watk += watkbuff.intValue();
    }
    MapleStatEffect combo = getBuffEffect(MapleBuffStat.ARAN_COMBO);
    if (combo != null) {
        watk += combo.getX();
    }
    if (energybar == 15000) {
        Skill energycharge = isCygnus() ? SkillFactory.getSkill(ThunderBreaker.ENERGY_CHARGE) : SkillFactory.getSkill(Marauder.ENERGY_CHARGE);
        MapleStatEffect ceffect = energycharge.getEffect(getSkillLevel(energycharge));
        watk += ceffect.getWatk();
    }
    Integer mwarr = getBuffedValue(MapleBuffStat.MAPLE_WARRIOR);
    if (mwarr != null) {
        localstr += getStr() * mwarr / 100;
        localdex += getDex() * mwarr / 100;
        localint_ += getInt() * mwarr / 100;
        localluk += getLuk() * mwarr / 100;
    }
    if (job.isA(MapleJob.BOWMAN)) {
        Skill expert = null;
        if (job.isA(MapleJob.MARKSMAN)) {
            expert = SkillFactory.getSkill(3220004);
        } else if (job.isA(MapleJob.BOWMASTER)) {
            expert = SkillFactory.getSkill(3120005);
        }
        if (expert != null) {
            int boostLevel = getSkillLevel(expert);
            if (boostLevel > 0) {
                watk += expert.getEffect(boostLevel).getX();
            }
        }
    }
    Integer matkbuff = getBuffedValue(MapleBuffStat.MATK);
    if (matkbuff != null) {
        magic += matkbuff.intValue();
    }
    Integer speedbuff = getBuffedValue(MapleBuffStat.SPEED);
    if (speedbuff != null) {
        speed += speedbuff.intValue();
    }
    Integer jumpbuff = getBuffedValue(MapleBuffStat.JUMP);
    if (jumpbuff != null) {
        jump += jumpbuff.intValue();
    }
    Integer blessing = getSkillLevel(10000000 * getJobType() + 12);
    if (blessing > 0) {
        watk += blessing;
        magic += blessing * 2;
    }
    if (job.isA(MapleJob.THIEF) || job.isA(MapleJob.BOWMAN) || job.isA(MapleJob.PIRATE) || job.isA(MapleJob.NIGHTWALKER1) || job.isA(MapleJob.WINDARCHER1)) {
        Item weapon_item = getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
        if (weapon_item != null) {
            MapleWeaponType weapon = ii.getWeaponType(weapon_item.getItemId());
            boolean bow = weapon == MapleWeaponType.BOW;
            boolean crossbow = weapon == MapleWeaponType.CROSSBOW;
            boolean claw = weapon == MapleWeaponType.CLAW;
            boolean gun = weapon == MapleWeaponType.GUN;
            if (bow || crossbow || claw || gun) {
                // Also calc stars into this.
                MapleInventory inv = getInventory(MapleInventoryType.USE);
                for (short i = 1; i <= inv.getSlotLimit(); i++) {
                    Item item = inv.getItem(i);
                    if (item != null) {
                        if ((claw && ItemConstants.isThrowingStar(item.getItemId())) || (gun && ItemConstants.isBullet(item.getItemId())) || (bow && ItemConstants.isArrowForBow(item.getItemId())) || (crossbow && ItemConstants.isArrowForCrossBow(item.getItemId()))) {
                            if (item.getQuantity() > 0) {
                                // Finally there!
                                watk += ii.getWatkForProjectile(item.getItemId());
                                break;
                            }
                        }
                    }
                }
            }
        }
    // Add throwing stars to dmg.
    }
    if (oldmaxhp != 0 && oldmaxhp != localmaxhp) {
        updatePartyMemberHP();
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) Equip(client.inventory.Equip) MobSkill(server.life.MobSkill) MapleStatEffect(server.MapleStatEffect) MapleWeaponType(client.inventory.MapleWeaponType) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point)

Example 3 with Equip

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

the class DueyHandler method addItemToDB.

private void addItemToDB(Item item, int quantity, int mesos, String sName, int recipientID) {
    Connection con = null;
    try {
        con = DatabaseConnection.getConnection();
        try (PreparedStatement ps = con.prepareStatement("INSERT INTO dueypackages (RecieverId, SenderName, Mesos, TimeStamp, Checked, Type) VALUES (?, ?, ?, ?, ?, ?)")) {
            ps.setInt(1, recipientID);
            ps.setString(2, sName);
            ps.setInt(3, mesos);
            ps.setString(4, getCurrentDate());
            ps.setInt(5, 1);
            if (item == null) {
                ps.setInt(6, 3);
                ps.executeUpdate();
            } else {
                ps.setInt(6, item.getItemType());
                ps.executeUpdate();
                try (ResultSet rs = ps.getGeneratedKeys()) {
                    rs.next();
                    PreparedStatement ps2;
                    if (item.getInventoryType().equals(MapleInventoryType.EQUIP)) {
                        ps2 = con.prepareStatement("INSERT INTO dueyitems (PackageId, itemid, quantity, upgradeslots, level, str, dex, `int`, luk, hp, mp, watk, matk, wdef, mdef, acc, avoid, hands, speed, jump, owner) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
                        Equip eq = (Equip) item;
                        ps2.setInt(2, eq.getItemId());
                        ps2.setInt(3, 1);
                        ps2.setInt(4, eq.getUpgradeSlots());
                        ps2.setInt(5, eq.getLevel());
                        ps2.setInt(6, eq.getStr());
                        ps2.setInt(7, eq.getDex());
                        ps2.setInt(8, eq.getInt());
                        ps2.setInt(9, eq.getLuk());
                        ps2.setInt(10, eq.getHp());
                        ps2.setInt(11, eq.getMp());
                        ps2.setInt(12, eq.getWatk());
                        ps2.setInt(13, eq.getMatk());
                        ps2.setInt(14, eq.getWdef());
                        ps2.setInt(15, eq.getMdef());
                        ps2.setInt(16, eq.getAcc());
                        ps2.setInt(17, eq.getAvoid());
                        ps2.setInt(18, eq.getHands());
                        ps2.setInt(19, eq.getSpeed());
                        ps2.setInt(20, eq.getJump());
                        ps2.setString(21, eq.getOwner());
                    } else {
                        ps2 = con.prepareStatement("INSERT INTO dueyitems (PackageId, itemid, quantity, owner) VALUES (?, ?, ?, ?)");
                        ps2.setInt(2, item.getItemId());
                        ps2.setInt(3, quantity);
                        ps2.setString(4, item.getOwner());
                    }
                    ps2.setInt(1, rs.getInt(1));
                    ps2.executeUpdate();
                    ps2.close();
                }
            }
        }
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
Also used : Equip(client.inventory.Equip) SQLException(java.sql.SQLException) DatabaseConnection(tools.DatabaseConnection) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 4 with Equip

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

the class EnterMTSHandler method getTransfer.

private List<MTSItemInfo> getTransfer(int cid) {
    List<MTSItemInfo> items = new ArrayList<>();
    try {
        Connection con = DatabaseConnection.getConnection();
        try (PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE transfer = 1 AND seller = ? ORDER BY id DESC")) {
            ps.setInt(1, cid);
            try (ResultSet 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")));
                    }
                }
            }
        }
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return items;
}
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 5 with Equip

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

the class EnterMTSHandler method getNotYetSold.

private List<MTSItemInfo> getNotYetSold(int cid) {
    List<MTSItemInfo> items = new ArrayList<>();
    try {
        Connection con = DatabaseConnection.getConnection();
        try (PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE seller = ? AND transfer = 0 ORDER BY id DESC")) {
            ps.setInt(1, cid);
            try (ResultSet 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")));
                    }
                }
            }
        }
        con.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return items;
}
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)

Aggregations

Equip (client.inventory.Equip)39 Item (client.inventory.Item)31 SQLException (java.sql.SQLException)16 ArrayList (java.util.ArrayList)13 Connection (java.sql.Connection)12 PreparedStatement (java.sql.PreparedStatement)12 ResultSet (java.sql.ResultSet)12 DatabaseConnection (tools.DatabaseConnection)12 MapleItemInformationProvider (server.MapleItemInformationProvider)10 Point (java.awt.Point)8 MTSItemInfo (server.MTSItemInfo)8 MapleCharacter (client.MapleCharacter)6 MapleInventory (client.inventory.MapleInventory)6 MapleMapItem (server.maps.MapleMapItem)5 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)5 MapleInventoryType (client.inventory.MapleInventoryType)4 MaplePet (client.inventory.MaplePet)4 ModifyInventory (client.inventory.ModifyInventory)4 LinkedList (java.util.LinkedList)3 Pair (tools.Pair)3