Search in sources :

Example 1 with MapleMount

use of client.MapleMount 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)

Aggregations

MapleBuffStat (client.MapleBuffStat)1 MapleMount (client.MapleMount)1 Item (client.inventory.Item)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Pair (tools.Pair)1