Search in sources :

Example 1 with MapleWeaponType

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

the class MapleCharacter method calculateMaxBaseDamage.

public int calculateMaxBaseDamage(int watk) {
    int maxbasedamage;
    Item weapon_item = getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
    if (weapon_item != null) {
        MapleWeaponType weapon = ii.getWeaponType(weapon_item.getItemId());
        int mainstat, secondarystat;
        if (getJob().isA(MapleJob.THIEF) && weapon == MapleWeaponType.DAGGER_OTHER) {
            weapon = MapleWeaponType.DAGGER_THIEVES;
        }
        if (weapon == MapleWeaponType.BOW || weapon == MapleWeaponType.CROSSBOW || weapon == MapleWeaponType.GUN) {
            mainstat = localdex;
            secondarystat = localstr;
        } else if (weapon == MapleWeaponType.CLAW || weapon == MapleWeaponType.DAGGER_THIEVES) {
            mainstat = localluk;
            secondarystat = localdex + localstr;
        } else {
            mainstat = localstr;
            secondarystat = localdex;
        }
        maxbasedamage = (int) (((weapon.getMaxDamageMultiplier() * mainstat + secondarystat) / 100.0) * watk);
    } else {
        if (job.isA(MapleJob.PIRATE) || job.isA(MapleJob.THUNDERBREAKER1)) {
            double weapMulti = 3;
            if (job.getId() % 100 != 0) {
                weapMulti = 4.2;
            }
            int attack = (int) Math.min(Math.floor((2 * getLevel() + 31) / 3), 31);
            maxbasedamage = (int) (localstr * weapMulti + localdex) * attack / 100;
        } else {
            maxbasedamage = 1;
        }
    }
    return maxbasedamage;
}
Also used : MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) MapleWeaponType(client.inventory.MapleWeaponType) Point(java.awt.Point)

Example 2 with MapleWeaponType

use of client.inventory.MapleWeaponType 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 MapleWeaponType

use of client.inventory.MapleWeaponType 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)3 MapleWeaponType (client.inventory.MapleWeaponType)3 MapleInventory (client.inventory.MapleInventory)2 Point (java.awt.Point)2 MapleStatEffect (server.MapleStatEffect)2 MapleMapItem (server.maps.MapleMapItem)2 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)2 MapleCharacter (client.MapleCharacter)1 Skill (client.Skill)1 Equip (client.inventory.Equip)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MobSkill (server.life.MobSkill)1