Search in sources :

Example 1 with MapleStatEffect

use of server.MapleStatEffect 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 2 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MapleCharacter method commitBuffCoupon.

private void commitBuffCoupon(int couponid) {
    if (!isLoggedin() || getCashShop().isOpened())
        return;
    MapleStatEffect mse = ii.getItemEffect(couponid);
    mse.applyTo(this);
}
Also used : MapleStatEffect(server.MapleStatEffect)

Example 3 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MapleCharacter method cancelAllBuffs.

public void cancelAllBuffs(boolean softcancel) {
    if (softcancel) {
        effLock.lock();
        chrLock.lock();
        try {
            effects.clear();
            for (Integer srcid : new ArrayList<>(buffEffects.keySet())) {
                removeItemEffectHolder(srcid);
            }
        } finally {
            chrLock.unlock();
            effLock.unlock();
        }
    } else {
        Map<MapleStatEffect, Long> mseBuffs = new LinkedHashMap<>();
        effLock.lock();
        chrLock.lock();
        try {
            for (Entry<Integer, Map<MapleBuffStat, MapleBuffStatValueHolder>> bpl : buffEffects.entrySet()) {
                for (Entry<MapleBuffStat, MapleBuffStatValueHolder> mbse : bpl.getValue().entrySet()) {
                    mseBuffs.put(mbse.getValue().effect, mbse.getValue().startTime);
                }
            }
        } finally {
            chrLock.unlock();
            effLock.unlock();
        }
        for (Entry<MapleStatEffect, Long> mse : mseBuffs.entrySet()) {
            cancelEffect(mse.getKey(), false, mse.getValue());
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleStatEffect(server.MapleStatEffect) ArrayList(java.util.ArrayList) Map(java.util.Map) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) MapleMap(server.maps.MapleMap) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MapleCharacter method registerEffect.

public void registerEffect(MapleStatEffect effect, long starttime, long expirationtime, boolean isSilent) {
    if (effect.isDragonBlood()) {
        prepareDragonBlood(effect);
    } else if (effect.isBerserk()) {
        checkBerserk(isHidden());
    } else if (effect.isBeholder()) {
        final int beholder = DarkKnight.BEHOLDER;
        if (beholderHealingSchedule != null) {
            beholderHealingSchedule.cancel(false);
        }
        if (beholderBuffSchedule != null) {
            beholderBuffSchedule.cancel(false);
        }
        Skill bHealing = SkillFactory.getSkill(DarkKnight.AURA_OF_BEHOLDER);
        int bHealingLvl = getSkillLevel(bHealing);
        if (bHealingLvl > 0) {
            final MapleStatEffect healEffect = bHealing.getEffect(bHealingLvl);
            int healInterval = healEffect.getX() * 1000;
            beholderHealingSchedule = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (awayFromWorld.get())
                        return;
                    addHP(healEffect.getHp());
                    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder, 2));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), beholder, 5), true);
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showOwnBuffEffect(beholder, 2), false);
                }
            }, healInterval, healInterval);
        }
        Skill bBuff = SkillFactory.getSkill(DarkKnight.HEX_OF_BEHOLDER);
        if (getSkillLevel(bBuff) > 0) {
            final MapleStatEffect buffEffect = bBuff.getEffect(getSkillLevel(bBuff));
            int buffInterval = buffEffect.getX() * 1000;
            beholderBuffSchedule = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (awayFromWorld.get())
                        return;
                    buffEffect.applyTo(MapleCharacter.this);
                    client.announce(MaplePacketCreator.showOwnBuffEffect(beholder, 2));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.summonSkill(getId(), beholder, (int) (Math.random() * 3) + 6), true);
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showBuffeffect(getId(), beholder, 2), false);
                }
            }, buffInterval, buffInterval);
        }
    } else if (effect.isRecovery()) {
        int healInterval = (ServerConstants.USE_ULTRA_RECOVERY) ? 2000 : 5000;
        final byte heal = (byte) effect.getX();
        chrLock.lock();
        try {
            if (recoveryTask != null) {
                recoveryTask.cancel(false);
            }
            recoveryTask = TimerManager.getInstance().register(new Runnable() {

                @Override
                public void run() {
                    if (getBuffSource(MapleBuffStat.RECOVERY) == -1) {
                        chrLock.lock();
                        try {
                            if (recoveryTask != null) {
                                recoveryTask.cancel(false);
                                recoveryTask = null;
                            }
                        } finally {
                            chrLock.unlock();
                        }
                        return;
                    }
                    addHP(heal);
                    client.announce(MaplePacketCreator.showOwnRecovery(heal));
                    getMap().broadcastMessage(MapleCharacter.this, MaplePacketCreator.showRecovery(id, heal), false);
                }
            }, healInterval, healInterval);
        } finally {
            chrLock.unlock();
        }
    } else if (effect.getHpRRate() > 0 || effect.getMpRRate() > 0) {
        if (effect.getHpRRate() > 0) {
            extraHpRec = effect.getHpR();
            extraRecInterval = effect.getHpRRate();
        }
        if (effect.getMpRRate() > 0) {
            extraMpRec = effect.getMpR();
            extraRecInterval = effect.getMpRRate();
        }
        stopExtraTask();
        // HP & MP sharing the same task holder
        startExtraTask(extraHpRec, extraMpRec, extraRecInterval);
    } else if (effect.isMapChair()) {
        startChairTask();
    }
    effLock.lock();
    chrLock.lock();
    try {
        Integer sourceid = effect.getBuffSourceId();
        Map<MapleBuffStat, MapleBuffStatValueHolder> toDeploy;
        Map<MapleBuffStat, MapleBuffStatValueHolder> appliedStatups = new LinkedHashMap<>();
        for (Pair<MapleBuffStat, Integer> ps : effect.getStatups()) {
            appliedStatups.put(ps.getLeft(), new MapleBuffStatValueHolder(effect, starttime, ps.getRight()));
        }
        if (ServerConstants.USE_BUFF_MOST_SIGNIFICANT) {
            toDeploy = new LinkedHashMap<>();
            Map<Integer, Pair<MapleStatEffect, Long>> retrievedEffects = new LinkedHashMap<>();
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : appliedStatups.entrySet()) {
                MapleBuffStatValueHolder mbsvh = effects.get(statup.getKey());
                if (mbsvh == null || mbsvh.value <= statup.getValue().value) {
                    toDeploy.put(statup.getKey(), statup.getValue());
                } else {
                    retrievedEffects.put(mbsvh.effect.getBuffSourceId(), new Pair<>(mbsvh.effect, mbsvh.startTime));
                }
                Byte val = buffEffectsCount.get(statup.getKey());
                if (val != null)
                    val = (byte) (val + 1);
                else
                    val = (byte) 1;
                buffEffectsCount.put(statup.getKey(), val);
            }
            if (!isSilent) {
                for (Entry<Integer, Pair<MapleStatEffect, Long>> lmse : retrievedEffects.entrySet()) {
                    lmse.getValue().getLeft().updateBuffEffect(this, getActiveStatupsFromSourceid(lmse.getKey()), lmse.getValue().getRight());
                }
            }
        } else {
            for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : appliedStatups.entrySet()) {
                Byte val = buffEffectsCount.get(statup.getKey());
                if (val != null)
                    val = (byte) (val + 1);
                else
                    val = (byte) 1;
                buffEffectsCount.put(statup.getKey(), val);
            }
            toDeploy = appliedStatups;
        }
        addItemEffectHolder(sourceid, expirationtime, appliedStatups);
        for (Entry<MapleBuffStat, MapleBuffStatValueHolder> statup : toDeploy.entrySet()) {
            effects.put(statup.getKey(), statup.getValue());
        }
    } finally {
        chrLock.unlock();
        effLock.unlock();
    }
    recalcLocalStats();
}
Also used : Point(java.awt.Point) LinkedHashMap(java.util.LinkedHashMap) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MobSkill(server.life.MobSkill) MapleStatEffect(server.MapleStatEffect) Pair(tools.Pair)

Example 5 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MagicDamageHandler 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, false, true);
    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()));
    }
    int charge = (attack.skill == Evan.FIRE_BREATH || attack.skill == Evan.ICE_BREATH || attack.skill == FPArchMage.BIG_BANG || attack.skill == ILArchMage.BIG_BANG || attack.skill == Bishop.BIG_BANG) ? attack.charge : -1;
    byte[] packet = MaplePacketCreator.magicAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, attack.allDamage, charge, attack.speed, attack.direction, attack.display);
    chr.getMap().broadcastMessage(chr, packet, false, true);
    MapleStatEffect effect = attack.getAttackEffect(chr, null);
    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);
        }
    }
    applyAttack(attack, chr, effect.getAttackCount());
    // MP Eater, works with right job
    Skill eaterSkill = SkillFactory.getSkill((chr.getJob().getId() - (chr.getJob().getId() % 10)) * 10000);
    int eaterLevel = chr.getSkillLevel(eaterSkill);
    if (eaterLevel > 0) {
        for (Integer singleDamage : attack.allDamage.keySet()) {
            eaterSkill.getEffect(eaterLevel).applyPassive(chr, chr.getMap().getMapObject(singleDamage), 0);
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect)

Aggregations

MapleStatEffect (server.MapleStatEffect)21 MapleCharacter (client.MapleCharacter)10 Point (java.awt.Point)10 Skill (client.Skill)9 ArrayList (java.util.ArrayList)6 MapleMonster (server.life.MapleMonster)6 MobSkill (server.life.MobSkill)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Pair (tools.Pair)5 Item (client.inventory.Item)3 MonsterStatusEffect (client.status.MonsterStatusEffect)3 MapleMap (server.maps.MapleMap)3 MapleBuffStat (client.MapleBuffStat)2 MapleInventory (client.inventory.MapleInventory)2 MapleWeaponType (client.inventory.MapleWeaponType)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 SpawnPoint (server.life.SpawnPoint)2 MapleMapItem (server.maps.MapleMapItem)2 MapleMapObject (server.maps.MapleMapObject)2