Search in sources :

Example 1 with MapleBuffStat

use of client.MapleBuffStat in project HeavenMS by ronancpl.

the class MapleMap method addPlayer.

public void addPlayer(final MapleCharacter chr) {
    int chrSize;
    chrWLock.lock();
    try {
        characters.add(chr);
        chrSize = characters.size();
        addPartyMemberInternal(chr);
    } finally {
        chrWLock.unlock();
    }
    chr.setMapId(mapid);
    itemMonitorTimeout = 1;
    if (chrSize == 1) {
        if (!hasItemMonitor())
            startItemMonitor();
        if (onFirstUserEnter.length() != 0 && !chr.hasEntered(onFirstUserEnter, mapid) && MapScriptManager.getInstance().scriptExists(onFirstUserEnter, true)) {
            chr.enteredScript(onFirstUserEnter, mapid);
            MapScriptManager.getInstance().getMapScript(chr.getClient(), onFirstUserEnter, true);
        }
    }
    if (onUserEnter.length() != 0) {
        if (onUserEnter.equals("cygnusTest") && (mapid < 913040000 || mapid > 913040006)) {
            chr.saveLocation("INTRO");
        }
        MapScriptManager.getInstance().getMapScript(chr.getClient(), onUserEnter, false);
    }
    if (FieldLimit.CANNOTUSEMOUNTS.check(fieldLimit) && chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null) {
        chr.cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
        chr.cancelBuffStats(MapleBuffStat.MONSTER_RIDING);
    }
    if (mapid == 923010000 && getMonsterById(9300102) == null) {
        // Kenta's Mount Quest
        spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(9300102), new Point(77, 426));
    } else if (mapid == 200090060) {
        // To Rien
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090060) {
                    chr.changeMap(140020300, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090070) {
        // To Lith Harbor
        chr.announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090070) {
                    chr.changeMap(104000000, 3);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090030) {
        // To Ereve (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090030) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090031) {
        // To Victoria Island (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090031) {
                    chr.changeMap(101000400, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090021) {
        // To Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090021) {
                    chr.changeMap(200000161, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 200090020) {
        // To Ereve From Orbis (SkyFerry)
        chr.getClient().announce(MaplePacketCreator.getClock(60));
        TimerManager.getInstance().schedule(new Runnable() {

            @Override
            public void run() {
                if (chr.getMapId() == 200090020) {
                    chr.changeMap(130000210, 0);
                }
            }
        }, 60 * 1000);
    } else if (mapid == 103040400) {
        if (chr.getEventInstance() != null) {
            chr.getEventInstance().movePlayer(chr);
        }
    } else if (MapleMiniDungeonInfo.isDungeonMap(mapid)) {
        MapleMiniDungeon mmd = chr.getClient().getChannelServer().getMiniDungeon(mapid);
        if (mmd != null)
            mmd.registerPlayer(chr);
    }
    MaplePet[] pets = chr.getPets();
    for (int i = 0; i < pets.length; i++) {
        if (pets[i] != null) {
            pets[i].setPos(getGroundBelow(chr.getPosition()));
            chr.announce(MaplePacketCreator.showPet(chr, pets[i], false, false));
        } else {
            break;
        }
    }
    if (chr.isHidden()) {
        broadcastGMMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
        chr.announce(MaplePacketCreator.getGMEffect(0x10, (byte) 1));
        List<Pair<MapleBuffStat, Integer>> dsstat = Collections.singletonList(new Pair<MapleBuffStat, Integer>(MapleBuffStat.DARKSIGHT, 0));
        broadcastGMMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), dsstat), false);
    } else {
        broadcastMessage(chr, MaplePacketCreator.spawnPlayerMapObject(chr), false);
    }
    sendObjectPlacement(chr.getClient());
    if (isStartingEventMap() && !eventStarted()) {
        chr.getMap().getPortal("join00").setPortalStatus(false);
    }
    if (hasForcedEquip()) {
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(-1));
    }
    if (specialEquip()) {
        chr.getClient().announce(MaplePacketCreator.coconutScore(0, 0));
        chr.getClient().announce(MaplePacketCreator.showForcedEquip(chr.getTeam()));
    }
    objectWLock.lock();
    try {
        this.mapobjects.put(Integer.valueOf(chr.getObjectId()), chr);
    } finally {
        objectWLock.unlock();
    }
    if (chr.getPlayerShop() != null) {
        addMapObject(chr.getPlayerShop());
    }
    final MapleDragon dragon = chr.getDragon();
    if (dragon != null) {
        dragon.setPosition(chr.getPosition());
        this.addMapObject(dragon);
        if (chr.isHidden()) {
            this.broadcastGMMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        } else {
            this.broadcastMessage(chr, MaplePacketCreator.spawnDragon(dragon));
        }
    }
    MapleStatEffect summonStat = chr.getStatForBuff(MapleBuffStat.SUMMON);
    if (summonStat != null) {
        MapleSummon summon = chr.getSummonByKey(summonStat.getSourceId());
        summon.setPosition(chr.getPosition());
        chr.getMap().spawnSummon(summon);
        updateMapObjectVisibility(chr, summon);
    }
    if (mapEffect != null) {
        mapEffect.sendStartData(chr.getClient());
    }
    chr.getClient().announce(MaplePacketCreator.resetForcedStats());
    if (mapid == 914000200 || mapid == 914000210 || mapid == 914000220) {
        chr.getClient().announce(MaplePacketCreator.aranGodlyStats());
    }
    if (chr.getEventInstance() != null && chr.getEventInstance().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getEventInstance().getTimeLeft() / 1000)));
    }
    if (chr.getFitness() != null && chr.getFitness().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getFitness().getTimeLeft() / 1000)));
    }
    if (chr.getOla() != null && chr.getOla().isTimerStarted()) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (chr.getOla().getTimeLeft() / 1000)));
    }
    if (mapid == 109060000) {
        chr.announce(MaplePacketCreator.rollSnowBall(true, 0, null, null));
    }
    MonsterCarnival carnival = chr.getCarnival();
    MonsterCarnivalParty cparty = chr.getCarnivalParty();
    if (carnival != null && cparty != null && (mapid == 980000101 || mapid == 980000201 || mapid == 980000301 || mapid == 980000401 || mapid == 980000501 || mapid == 980000601)) {
        chr.getClient().announce(MaplePacketCreator.getClock((int) (carnival.getTimeLeft() / 1000)));
        chr.getClient().announce(MaplePacketCreator.startCPQ(chr, carnival.oppositeTeam(cparty)));
    }
    if (hasClock()) {
        Calendar cal = Calendar.getInstance();
        chr.getClient().announce((MaplePacketCreator.getClockTime(cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), cal.get(Calendar.SECOND))));
    }
    if (hasBoat() > 0) {
        if (hasBoat() == 1)
            chr.getClient().announce((MaplePacketCreator.boatPacket(true)));
        else
            chr.getClient().announce(MaplePacketCreator.boatPacket(false));
    }
    chr.receivePartyMemberHP();
}
Also used : MapleBuffStat(client.MapleBuffStat) MonsterCarnival(server.partyquest.MonsterCarnival) Calendar(java.util.Calendar) MonsterCarnivalParty(server.partyquest.MonsterCarnivalParty) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MapleStatEffect(server.MapleStatEffect) MaplePet(client.inventory.MaplePet) Pair(tools.Pair)

Example 2 with MapleBuffStat

use of client.MapleBuffStat in project HeavenMS by ronancpl.

the class CloseRangeDamageHandler 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, 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 (// PE hacking or maybe just lagging
    chr.getDojoEnergy() < 10000 && (attack.skill == 1009 || attack.skill == 10001009 || attack.skill == 20001009))
        return;
    if (chr.getMap().isDojoMap() && attack.numAttacked > 0) {
        chr.setDojoEnergy(chr.getDojoEnergy() + ServerConstants.DOJO_ENERGY_ATK);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
    }
    chr.getMap().broadcastMessage(chr, MaplePacketCreator.closeRangeAttack(chr, attack.skill, attack.skilllevel, attack.stance, attack.numAttackedAndDamage, attack.allDamage, attack.speed, attack.direction, attack.display), false, true);
    int numFinisherOrbs = 0;
    Integer comboBuff = chr.getBuffedValue(MapleBuffStat.COMBO);
    if (GameConstants.isFinisherSkill(attack.skill)) {
        if (comboBuff != null) {
            numFinisherOrbs = comboBuff.intValue() - 1;
        }
        chr.handleOrbconsume();
    } else if (attack.numAttacked > 0) {
        if (attack.skill != 1111008 && comboBuff != null) {
            int orbcount = chr.getBuffedValue(MapleBuffStat.COMBO);
            int oid = chr.isCygnus() ? DawnWarrior.COMBO : Crusader.COMBO;
            int advcomboid = chr.isCygnus() ? DawnWarrior.ADVANCED_COMBO : Hero.ADVANCED_COMBO;
            Skill combo = SkillFactory.getSkill(oid);
            Skill advcombo = SkillFactory.getSkill(advcomboid);
            MapleStatEffect ceffect;
            int advComboSkillLevel = chr.getSkillLevel(advcombo);
            if (advComboSkillLevel > 0) {
                ceffect = advcombo.getEffect(advComboSkillLevel);
            } else {
                int comboLv = chr.getSkillLevel(combo);
                if (comboLv <= 0 || chr.isGM())
                    comboLv = SkillFactory.getSkill(oid).getMaxLevel();
                if (comboLv > 0)
                    ceffect = combo.getEffect(comboLv);
                else
                    ceffect = null;
            }
            if (ceffect != null) {
                if (orbcount < ceffect.getX() + 1) {
                    int neworbcount = orbcount + 1;
                    if (advComboSkillLevel > 0 && ceffect.makeChanceResult()) {
                        if (neworbcount <= ceffect.getX()) {
                            neworbcount++;
                        }
                    }
                    int olv = chr.getSkillLevel(oid);
                    if (olv <= 0)
                        olv = SkillFactory.getSkill(oid).getMaxLevel();
                    int duration = combo.getEffect(olv).getDuration();
                    List<Pair<MapleBuffStat, Integer>> stat = Collections.singletonList(new Pair<>(MapleBuffStat.COMBO, neworbcount));
                    chr.setBuffedValue(MapleBuffStat.COMBO, neworbcount);
                    duration -= (int) (System.currentTimeMillis() - chr.getBuffedStarttime(MapleBuffStat.COMBO));
                    c.announce(MaplePacketCreator.giveBuff(oid, duration, stat));
                    chr.getMap().broadcastMessage(chr, MaplePacketCreator.giveForeignBuff(chr.getId(), stat), false);
                }
            }
        } else if (chr.getSkillLevel(chr.isCygnus() ? SkillFactory.getSkill(15100004) : SkillFactory.getSkill(5110001)) > 0 && (chr.getJob().isA(MapleJob.MARAUDER) || chr.getJob().isA(MapleJob.THUNDERBREAKER2))) {
            for (int i = 0; i < attack.numAttacked; i++) {
                chr.handleEnergyChargeGain();
            }
        }
    }
    if (attack.numAttacked > 0 && attack.skill == DragonKnight.SACRIFICE) {
        // sacrifice attacks only 1 mob with 1 attack
        int totDamageToOneMonster = 0;
        final Iterator<List<Integer>> dmgIt = attack.allDamage.values().iterator();
        if (dmgIt.hasNext()) {
            totDamageToOneMonster = dmgIt.next().get(0).intValue();
        }
        int remainingHP = chr.getHp() - totDamageToOneMonster * attack.getAttackEffect(chr, null).getX() / 100;
        if (remainingHP > 1) {
            chr.setHp(remainingHP);
        } else {
            chr.setHp(1);
        }
        chr.updateSingleStat(MapleStat.HP, chr.getHp());
        chr.checkBerserk(chr.isHidden());
    }
    if (attack.numAttacked > 0 && attack.skill == 1211002) {
        boolean advcharge_prob = false;
        int advcharge_level = chr.getSkillLevel(SkillFactory.getSkill(1220010));
        if (advcharge_level > 0) {
            advcharge_prob = SkillFactory.getSkill(1220010).getEffect(advcharge_level).makeChanceResult();
        }
        if (!advcharge_prob) {
            chr.cancelEffectFromBuffStat(MapleBuffStat.WK_CHARGE);
        }
    }
    int attackCount = 1;
    if (attack.skill != 0) {
        attackCount = attack.getAttackEffect(chr, null).getAttackCount();
    }
    if (numFinisherOrbs == 0 && GameConstants.isFinisherSkill(attack.skill)) {
        return;
    }
    if (attack.skill % 10000000 == 1009) {
        // bamboo
        if (chr.getDojoEnergy() < 10000) {
            // PE hacking or maybe just lagging
            return;
        }
        chr.setDojoEnergy(0);
        c.announce(MaplePacketCreator.getEnergy("energy", chr.getDojoEnergy()));
        c.announce(MaplePacketCreator.serverNotice(5, "As you used the secret skill, your energy bar has been reset."));
    } else 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.getSkillLevel(SkillFactory.getSkill(Rogue.DARK_SIGHT)) > 0) && chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null) {
        // && 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) {
        chr.cancelEffectFromBuffStat(MapleBuffStat.WIND_WALK);
        chr.cancelBuffStats(MapleBuffStat.WIND_WALK);
    }
    applyAttack(attack, chr, attackCount);
}
Also used : MapleBuffStat(client.MapleBuffStat) MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect) List(java.util.List) Pair(tools.Pair)

Example 3 with MapleBuffStat

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

Example 4 with MapleBuffStat

use of client.MapleBuffStat in project HeavenMS by ronancpl.

the class MaplePacketCreator method giveForeignPirateBuff.

public static byte[] giveForeignPirateBuff(int cid, int buffid, int time, List<Pair<MapleBuffStat, Integer>> statups) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    boolean infusion = buffid == Buccaneer.SPEED_INFUSION || buffid == ThunderBreaker.SPEED_INFUSION || buffid == Corsair.SPEED_INFUSION;
    mplew.writeShort(SendOpcode.GIVE_FOREIGN_BUFF.getValue());
    mplew.writeInt(cid);
    writeLongMask(mplew, statups);
    mplew.writeShort(0);
    for (Pair<MapleBuffStat, Integer> statup : statups) {
        mplew.writeInt(statup.getRight().shortValue());
        mplew.writeInt(buffid);
        mplew.skip(infusion ? 10 : 5);
        mplew.writeShort(time);
    }
    mplew.writeShort(0);
    mplew.write(2);
    return mplew.getPacket();
}
Also used : MapleBuffStat(client.MapleBuffStat) MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter)

Example 5 with MapleBuffStat

use of client.MapleBuffStat in project HeavenMS by ronancpl.

the class MaplePacketCreator method giveBuff.

/**
 * It is important that statups is in the correct order (see decleration
 * order in MapleBuffStat) since this method doesn't do automagical
 * reordering.
 *
 * @param buffid
 * @param bufflength
 * @param statups
 * @return
 */
// 1F 00 00 00 00 00 03 00 00 40 00 00 00 E0 00 00 00 00 00 00 00 00 E0 01 8E AA 4F 00 00 C2 EB 0B E0 01 8E AA 4F 00 00 C2 EB 0B 0C 00 8E AA 4F 00 00 C2 EB 0B 44 02 8E AA 4F 00 00 C2 EB 0B 44 02 8E AA 4F 00 00 C2 EB 0B 00 00 E0 7A 1D 00 8E AA 4F 00 00 00 00 00 00 00 00 03
public static byte[] giveBuff(int buffid, int bufflength, List<Pair<MapleBuffStat, Integer>> statups) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.GIVE_BUFF.getValue());
    boolean special = false;
    writeLongMask(mplew, statups);
    for (Pair<MapleBuffStat, Integer> statup : statups) {
        if (statup.getLeft().equals(MapleBuffStat.MONSTER_RIDING) || statup.getLeft().equals(MapleBuffStat.HOMING_BEACON)) {
            special = true;
        }
        mplew.writeShort(statup.getRight().shortValue());
        mplew.writeInt(buffid);
        mplew.writeInt(bufflength);
    }
    mplew.writeInt(0);
    mplew.write(0);
    // Homing beacon ...
    mplew.writeInt(statups.get(0).getRight());
    if (special) {
        mplew.skip(3);
    }
    return mplew.getPacket();
}
Also used : MapleBuffStat(client.MapleBuffStat) MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter)

Aggregations

MapleBuffStat (client.MapleBuffStat)8 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)4 Pair (tools.Pair)3 Point (java.awt.Point)2 List (java.util.List)2 MapleStatEffect (server.MapleStatEffect)2 MapleCharacter (client.MapleCharacter)1 MapleMount (client.MapleMount)1 Skill (client.Skill)1 Item (client.inventory.Item)1 MaplePet (client.inventory.MaplePet)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SpawnPoint (server.life.SpawnPoint)1 MonsterCarnival (server.partyquest.MonsterCarnival)1 MonsterCarnivalParty (server.partyquest.MonsterCarnivalParty)1