Search in sources :

Example 26 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleStatEffect method applyTo.

// primary: the player caster of the buff
private boolean applyTo(MapleCharacter applyfrom, MapleCharacter applyto, boolean primary, Point pos, boolean useMaxRange) {
    if (skill && (sourceid == GM.HIDE || sourceid == SuperGM.HIDE)) {
        applyto.toggleHide(false);
        return true;
    }
    int hpchange = calcHPChange(applyfrom, primary);
    int mpchange = calcMPChange(applyfrom, primary);
    if (primary) {
        if (itemConNo != 0) {
            if (!applyto.getClient().getAbstractPlayerInteraction().hasItem(itemCon, itemConNo)) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            }
            MapleInventoryManipulator.removeById(applyto.getClient(), ItemConstants.getInventoryType(itemCon), itemCon, itemConNo, false, true);
        }
    }
    List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
    if (!primary) {
        if (isResurrection()) {
            hpchange = applyto.getMaxHp();
            applyto.setStance(0);
            applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
            applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
        }
    }
    if (isDispel() && makeChanceResult()) {
        applyto.dispelDebuffs();
    } else if (isCureAllAbnormalStatus()) {
        applyto.dispelDebuff(MapleDisease.SEDUCE);
        applyto.dispelDebuff(MapleDisease.ZOMBIFY);
        applyto.dispelDebuffs();
    } else if (isComboReset()) {
        applyto.setCombo((short) 0);
    }
    /*if (applyfrom.getMp() < getMpCon()) {
         AutobanFactory.MPCON.addPoint(applyfrom.getAutobanManager(), "mpCon hack for skill:" + sourceid + "; Player MP: " + applyto.getMp() + " MP Needed: " + getMpCon());
         } */
    if (hpchange != 0) {
        if (hpchange < 0 && (-hpchange) >= applyto.getHp() && (!applyto.hasDisease(MapleDisease.ZOMBIFY) || hpCon > 0)) {
            if (!applyto.isGM()) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            }
        }
        int newHp = applyto.getHp() + hpchange;
        if (newHp < 1) {
            newHp = 1;
        }
        applyto.setHp(newHp);
        hpmpupdate.add(new Pair<>(MapleStat.HP, Integer.valueOf(applyto.getHp())));
    }
    int newMp = applyto.getMp() + mpchange;
    if (mpchange != 0) {
        if (mpchange < 0 && -mpchange > applyto.getMp()) {
            if (!applyto.isGM()) {
                applyto.getClient().announce(MaplePacketCreator.enableActions());
                return false;
            } else {
                newMp = 0;
            }
        }
        applyto.setMp(newMp);
        hpmpupdate.add(new Pair<>(MapleStat.MP, Integer.valueOf(applyto.getMp())));
    }
    applyto.getClient().announce(MaplePacketCreator.updatePlayerStats(hpmpupdate, true, applyto));
    if (moveTo != -1) {
        if (moveTo != applyto.getMapId()) {
            MapleMap target;
            MaplePortal pt;
            if (moveTo == 999999999) {
                if (sourceid != 2030100) {
                    target = applyto.getMap().getReturnMap();
                    pt = target.getRandomPlayerSpawnpoint();
                } else {
                    if (!applyto.canRecoverLastBanish())
                        return false;
                    Pair<Integer, Integer> lastBanishInfo = applyto.getLastBanishData();
                    target = applyto.getWarpMap(lastBanishInfo.getLeft());
                    pt = target.getPortal(lastBanishInfo.getRight());
                }
            } else {
                target = applyto.getClient().getWorldServer().getChannel(applyto.getClient().getChannel()).getMapFactory().getMap(moveTo);
                int targetid = target.getId() / 10000000;
                if (targetid != 60 && applyto.getMapId() / 10000000 != 61 && targetid != applyto.getMapId() / 10000000 && targetid != 21 && targetid != 20 && targetid != 12 && (applyto.getMapId() / 10000000 != 10 && applyto.getMapId() / 10000000 != 12)) {
                    return false;
                }
                pt = target.getRandomPlayerSpawnpoint();
            }
            applyto.changeMap(target, pt);
        } else {
            return false;
        }
    }
    if (isShadowClaw()) {
        int projectile = 0;
        MapleInventory use = applyto.getInventory(MapleInventoryType.USE);
        for (int i = 1; i <= use.getSlotLimit(); i++) {
            // impose order...
            Item item = use.getItem((short) i);
            if (item != null) {
                if (ItemConstants.isThrowingStar(item.getItemId()) && item.getQuantity() >= 200) {
                    projectile = item.getItemId();
                    break;
                }
            }
        }
        if (projectile == 0) {
            return false;
        } else {
            MapleInventoryManipulator.removeById(applyto.getClient(), MapleInventoryType.USE, projectile, 200, false, true);
        }
    }
    SummonMovementType summonMovementType = getSummonMovementType();
    if (overTime || isCygnusFA() || summonMovementType != null) {
        if (summonMovementType != null && pos != null) {
            if (summonMovementType.getValue() == summonMovementType.STATIONARY.getValue())
                applyto.cancelBuffStats(MapleBuffStat.PUPPET);
            else
                applyto.cancelBuffStats(MapleBuffStat.SUMMON);
        }
        applyBuffEffect(applyfrom, applyto, primary);
    }
    if (primary && (overTime || isHeal())) {
        applyBuff(applyfrom, useMaxRange);
    }
    if (primary && isMonsterBuff()) {
        applyMonsterBuff(applyfrom);
    }
    if (this.getFatigue() != 0) {
        applyto.getMount().setTiredness(applyto.getMount().getTiredness() + this.getFatigue());
    }
    if (summonMovementType != null && pos != null) {
        final MapleSummon tosummon = new MapleSummon(applyfrom, sourceid, pos, summonMovementType);
        applyfrom.getMap().spawnSummon(tosummon);
        applyfrom.addSummon(sourceid, tosummon);
        tosummon.addHP(x);
        if (isBeholder()) {
            tosummon.addHP(1);
        }
    }
    if (isMagicDoor() && !FieldLimit.DOOR.check(applyto.getMap().getFieldLimit())) {
        // Magic Door
        int y = applyto.getFh();
        if (y == 0) {
            y = applyto.getPosition().y;
        }
        Point doorPosition = new Point(applyto.getPosition().x, y);
        MapleDoor door = new MapleDoor(applyto, doorPosition);
        if (door.getOwnerId() >= 0) {
            if (applyto.getParty() != null) {
                for (MaplePartyCharacter partyMember : applyto.getParty().getMembers()) {
                    partyMember.getPlayer().addDoor(door.getOwnerId(), door);
                    partyMember.addDoor(door.getOwnerId(), door);
                }
                applyto.silentPartyUpdate();
            } else {
                applyto.addDoor(door.getOwnerId(), door);
            }
            door.getTarget().spawnDoor(door.getAreaDoor());
            door.getTown().spawnDoor(door.getTownDoor());
            applyto.disableDoorSpawn();
        } else {
            MapleInventoryManipulator.addFromDrop(applyto.getClient(), new Item(4006000, (short) 0, (short) 1), false);
            if (door.getOwnerId() == -3)
                applyto.dropMessage(5, "Mystic Door cannot be cast far from a spawn point. Nearest one is at " + door.getDoorStatus().getRight() + "pts " + door.getDoorStatus().getLeft());
            else if (door.getOwnerId() == -2)
                applyto.dropMessage(5, "Mystic Door cannot be cast on a slope, try elsewhere.");
            else
                applyto.dropMessage(5, "There are no door portals available for the town at this moment. Try again later.");
            // cancel door buff
            applyto.cancelBuffStats(MapleBuffStat.SOULARROW);
        }
    } else if (isMist()) {
        Rectangle bounds = calculateBoundingBox(sourceid == NightWalker.POISON_BOMB ? pos : applyfrom.getPosition(), applyfrom.isFacingLeft());
        MapleMist mist = new MapleMist(bounds, applyfrom, this);
        applyfrom.getMap().spawnMist(mist, getDuration(), mist.isPoisonMist(), false, mist.isRecoveryMist());
    } else if (isTimeLeap()) {
        applyto.removeAllCooldownsExcept(Buccaneer.TIME_LEAP, true);
    } else if (isHyperBody() && !primary) {
        applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.removePlayerFromMap(applyto.getId()), false);
        applyto.getMap().broadcastMessage(applyto, MaplePacketCreator.spawnPlayerMapObject(applyto), false);
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Point(java.awt.Point) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point) MapleMap(server.maps.MapleMap) Item(client.inventory.Item) MapleMist(server.maps.MapleMist) MapleSummon(server.maps.MapleSummon) Pair(tools.Pair) SummonMovementType(server.maps.SummonMovementType) MapleDoor(server.maps.MapleDoor) MaplePartyCharacter(net.server.world.MaplePartyCharacter)

Example 27 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleStatEffect method loadFromData.

private static MapleStatEffect loadFromData(MapleData source, int sourceid, boolean skill, boolean overTime) {
    MapleStatEffect ret = new MapleStatEffect();
    ret.duration = MapleDataTool.getIntConvert("time", source, -1);
    ret.hp = (short) MapleDataTool.getInt("hp", source, 0);
    ret.hpR = MapleDataTool.getInt("hpR", source, 0) / 100.0;
    ret.mp = (short) MapleDataTool.getInt("mp", source, 0);
    ret.mpR = MapleDataTool.getInt("mpR", source, 0) / 100.0;
    ret.mpCon = (short) MapleDataTool.getInt("mpCon", source, 0);
    ret.hpCon = (short) MapleDataTool.getInt("hpCon", source, 0);
    int iprop = MapleDataTool.getInt("prop", source, 100);
    ret.prop = iprop / 100.0;
    ret.mobCount = MapleDataTool.getInt("mobCount", source, 1);
    ret.cooldown = MapleDataTool.getInt("cooltime", source, 0);
    ret.morphId = MapleDataTool.getInt("morph", source, 0);
    ret.ghost = MapleDataTool.getInt("ghost", source, 0);
    ret.fatigue = MapleDataTool.getInt("incFatigue", source, 0);
    ret.repeatEffect = MapleDataTool.getInt("repeatEffect", source, 0) > 0;
    ret.sourceid = sourceid;
    ret.skill = skill;
    if (!ret.skill && ret.duration > -1) {
        ret.overTime = true;
    } else {
        // items have their times stored in ms, of course
        ret.duration *= 1000;
        ret.overTime = overTime;
    }
    ArrayList<Pair<MapleBuffStat, Integer>> statups = new ArrayList<>();
    ret.watk = (short) MapleDataTool.getInt("pad", source, 0);
    ret.wdef = (short) MapleDataTool.getInt("pdd", source, 0);
    ret.matk = (short) MapleDataTool.getInt("mad", source, 0);
    ret.mdef = (short) MapleDataTool.getInt("mdd", source, 0);
    ret.acc = (short) MapleDataTool.getIntConvert("acc", source, 0);
    ret.avoid = (short) MapleDataTool.getInt("eva", source, 0);
    ret.speed = (short) MapleDataTool.getInt("speed", source, 0);
    ret.jump = (short) MapleDataTool.getInt("jump", source, 0);
    ret.mapProtection = mapProtection(sourceid);
    addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MAP_PROTECTION, Integer.valueOf(ret.mapProtection));
    if (ret.overTime && ret.getSummonMovementType() == null) {
        if (!skill) {
            if (isPyramidBuff(sourceid)) {
                ret.berserk = MapleDataTool.getInt("berserk", source, 0);
                ret.booster = MapleDataTool.getInt("booster", source, 0);
                addBuffStatPairToListIfNotZero(statups, MapleBuffStat.BERSERK, Integer.valueOf(ret.berserk));
                addBuffStatPairToListIfNotZero(statups, MapleBuffStat.BOOSTER, Integer.valueOf(ret.booster));
            } else if (isDojoBuff(sourceid) || isHpMpRecovery(sourceid)) {
                ret.mhpR = (byte) MapleDataTool.getInt("mhpR", source, 0);
                ret.mhpRRate = (short) (MapleDataTool.getInt("mhpRRate", source, 0) * 100);
                ret.mmpR = (byte) MapleDataTool.getInt("mmpR", source, 0);
                ret.mmpRRate = (short) (MapleDataTool.getInt("mmpRRate", source, 0) * 100);
                addBuffStatPairToListIfNotZero(statups, MapleBuffStat.HPREC, Integer.valueOf(ret.mhpR));
                addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MPREC, Integer.valueOf(ret.mmpR));
            } else if (isRateCoupon(sourceid)) {
                switch(MapleDataTool.getInt("expR", source, 0)) {
                    case 1:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_EXP1, 1);
                        break;
                    case 2:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_EXP2, 1);
                        break;
                    case 3:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_EXP3, 1);
                        break;
                    case 4:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_EXP4, 1);
                        break;
                }
                switch(MapleDataTool.getInt("drpR", source, 0)) {
                    case 1:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_DRP1, 1);
                        break;
                    case 2:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_DRP2, 1);
                        break;
                    case 3:
                        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.COUPON_DRP3, 1);
                        break;
                }
            }
        } else {
            if (isMapChair(sourceid)) {
                addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MAP_CHAIR, 1);
            } else if ((sourceid == Beginner.NIMBLE_FEET || sourceid == Noblesse.NIMBLE_FEET || sourceid == Evan.NIMBLE_FEET || sourceid == Legend.AGILE_BODY) && ServerConstants.USE_ULTRA_NIMBLE_FEET == true) {
                ret.jump = (short) (ret.speed * 4);
                ret.speed *= 15;
            }
        }
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WATK, Integer.valueOf(ret.watk));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.WDEF, Integer.valueOf(ret.wdef));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MATK, Integer.valueOf(ret.matk));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.MDEF, Integer.valueOf(ret.mdef));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.ACC, Integer.valueOf(ret.acc));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.AVOID, Integer.valueOf(ret.avoid));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.SPEED, Integer.valueOf(ret.speed));
        addBuffStatPairToListIfNotZero(statups, MapleBuffStat.JUMP, Integer.valueOf(ret.jump));
    }
    MapleData ltd = source.getChildByPath("lt");
    if (ltd != null) {
        ret.lt = (Point) ltd.getData();
        ret.rb = (Point) source.getChildByPath("rb").getData();
        if (ServerConstants.USE_MAXRANGE_ECHO_OF_HERO && (sourceid == Beginner.ECHO_OF_HERO || sourceid == Noblesse.ECHO_OF_HERO || sourceid == Legend.ECHO_OF_HERO || sourceid == Evan.ECHO_OF_HERO)) {
            ret.lt = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
            ret.rb = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
        }
    }
    int x = MapleDataTool.getInt("x", source, 0);
    if ((sourceid == Beginner.RECOVERY || sourceid == Noblesse.RECOVERY || sourceid == Evan.RECOVERY || sourceid == Legend.RECOVERY) && ServerConstants.USE_ULTRA_RECOVERY == true) {
        x *= 10;
    }
    ret.x = x;
    ret.y = MapleDataTool.getInt("y", source, 0);
    ret.damage = MapleDataTool.getIntConvert("damage", source, 100);
    ret.fixdamage = MapleDataTool.getIntConvert("fixdamage", source, -1);
    ret.attackCount = MapleDataTool.getIntConvert("attackCount", source, 1);
    ret.bulletCount = (byte) MapleDataTool.getIntConvert("bulletCount", source, 1);
    ret.bulletConsume = (byte) MapleDataTool.getIntConvert("bulletConsume", source, 0);
    ret.moneyCon = MapleDataTool.getIntConvert("moneyCon", source, 0);
    ret.itemCon = MapleDataTool.getInt("itemCon", source, 0);
    ret.itemConNo = MapleDataTool.getInt("itemConNo", source, 0);
    ret.moveTo = MapleDataTool.getInt("moveTo", source, -1);
    Map<MonsterStatus, Integer> monsterStatus = new ArrayMap<>();
    if (skill) {
        switch(sourceid) {
            // BEGINNER
            case Beginner.RECOVERY:
            case Noblesse.RECOVERY:
            case Legend.RECOVERY:
            case Evan.RECOVERY:
                statups.add(new Pair<>(MapleBuffStat.RECOVERY, Integer.valueOf(x)));
                break;
            case Beginner.ECHO_OF_HERO:
            case Noblesse.ECHO_OF_HERO:
            case Legend.ECHO_OF_HERO:
            case Evan.ECHO_OF_HERO:
                statups.add(new Pair<>(MapleBuffStat.ECHO_OF_HERO, Integer.valueOf(ret.x)));
                break;
            case Beginner.MONSTER_RIDER:
            case Noblesse.MONSTER_RIDER:
            case Legend.MONSTER_RIDER:
            case Corsair.BATTLE_SHIP:
            case Beginner.SPACESHIP:
            case Noblesse.SPACESHIP:
            case Beginner.YETI_MOUNT1:
            case Beginner.YETI_MOUNT2:
            case Noblesse.YETI_MOUNT1:
            case Noblesse.YETI_MOUNT2:
            case Legend.YETI_MOUNT1:
            case Legend.YETI_MOUNT2:
            case Beginner.WITCH_BROOMSTICK:
            case Noblesse.WITCH_BROOMSTICK:
            case Legend.WITCH_BROOMSTICK:
            case Beginner.BALROG_MOUNT:
            case Noblesse.BALROG_MOUNT:
            case Legend.BALROG_MOUNT:
                statups.add(new Pair<>(MapleBuffStat.MONSTER_RIDING, Integer.valueOf(sourceid)));
                break;
            case Beginner.INVINCIBLE_BARRIER:
            case Noblesse.INVINCIBLE_BARRIER:
            case Legend.INVICIBLE_BARRIER:
            case Evan.INVINCIBLE_BARRIER:
                statups.add(new Pair<>(MapleBuffStat.DIVINE_BODY, Integer.valueOf(1)));
                break;
            case Fighter.POWER_GUARD:
            case Page.POWER_GUARD:
                statups.add(new Pair<>(MapleBuffStat.POWERGUARD, Integer.valueOf(x)));
                break;
            case Spearman.HYPER_BODY:
            case GM.HYPER_BODY:
            case SuperGM.HYPER_BODY:
                statups.add(new Pair<>(MapleBuffStat.HYPERBODYHP, Integer.valueOf(x)));
                statups.add(new Pair<>(MapleBuffStat.HYPERBODYMP, Integer.valueOf(ret.y)));
                break;
            case Crusader.COMBO:
            case DawnWarrior.COMBO:
                statups.add(new Pair<>(MapleBuffStat.COMBO, Integer.valueOf(1)));
                break;
            case WhiteKnight.BW_FIRE_CHARGE:
            case WhiteKnight.BW_ICE_CHARGE:
            case WhiteKnight.BW_LIT_CHARGE:
            case WhiteKnight.SWORD_FIRE_CHARGE:
            case WhiteKnight.SWORD_ICE_CHARGE:
            case WhiteKnight.SWORD_LIT_CHARGE:
            case Paladin.BW_HOLY_CHARGE:
            case Paladin.SWORD_HOLY_CHARGE:
            case DawnWarrior.SOUL_CHARGE:
            case ThunderBreaker.LIGHTNING_CHARGE:
                statups.add(new Pair<>(MapleBuffStat.WK_CHARGE, Integer.valueOf(x)));
                break;
            case DragonKnight.DRAGON_BLOOD:
                statups.add(new Pair<>(MapleBuffStat.DRAGONBLOOD, Integer.valueOf(ret.x)));
                break;
            case DragonKnight.DRAGON_ROAR:
                ret.hpR = -x / 100.0;
                break;
            case Hero.STANCE:
            case Paladin.STANCE:
            case DarkKnight.STANCE:
            case Aran.FREEZE_STANDING:
                statups.add(new Pair<>(MapleBuffStat.STANCE, Integer.valueOf(iprop)));
                break;
            case DawnWarrior.FINAL_ATTACK:
            case WindArcher.FINAL_ATTACK:
                statups.add(new Pair<>(MapleBuffStat.FINALATTACK, Integer.valueOf(x)));
                break;
            // MAGICIAN
            case Magician.MAGIC_GUARD:
            case BlazeWizard.MAGIC_GUARD:
            case Evan.MAGIC_GUARD:
                statups.add(new Pair<>(MapleBuffStat.MAGIC_GUARD, Integer.valueOf(x)));
                break;
            case Cleric.INVINCIBLE:
                statups.add(new Pair<>(MapleBuffStat.INVINCIBLE, Integer.valueOf(x)));
                break;
            case Priest.HOLY_SYMBOL:
            case SuperGM.HOLY_SYMBOL:
                statups.add(new Pair<>(MapleBuffStat.HOLY_SYMBOL, Integer.valueOf(x)));
                break;
            case FPArchMage.INFINITY:
            case ILArchMage.INFINITY:
            case Bishop.INFINITY:
                statups.add(new Pair<>(MapleBuffStat.INFINITY, Integer.valueOf(x)));
                break;
            case FPArchMage.MANA_REFLECTION:
            case ILArchMage.MANA_REFLECTION:
            case Bishop.MANA_REFLECTION:
                statups.add(new Pair<>(MapleBuffStat.MANA_REFLECTION, Integer.valueOf(1)));
                break;
            case Bishop.HOLY_SHIELD:
                statups.add(new Pair<>(MapleBuffStat.HOLY_SHIELD, Integer.valueOf(x)));
                break;
            case BlazeWizard.ELEMENTAL_RESET:
            case Evan.ELEMENTAL_RESET:
                statups.add(new Pair<>(MapleBuffStat.ELEMENTAL_RESET, Integer.valueOf(x)));
                break;
            case Evan.MAGIC_SHIELD:
                statups.add(new Pair<>(MapleBuffStat.MAGIC_SHIELD, Integer.valueOf(x)));
                break;
            case Evan.MAGIC_RESISTANCE:
                statups.add(new Pair<>(MapleBuffStat.MAGIC_RESISTANCE, Integer.valueOf(x)));
                break;
            case Evan.SLOW:
                statups.add(new Pair<>(MapleBuffStat.SLOW, Integer.valueOf(x)));
            // BOWMAN
            case Priest.MYSTIC_DOOR:
            case Hunter.SOUL_ARROW:
            case Crossbowman.SOUL_ARROW:
            case WindArcher.SOUL_ARROW:
                statups.add(new Pair<>(MapleBuffStat.SOULARROW, Integer.valueOf(x)));
                break;
            case Ranger.PUPPET:
            case Sniper.PUPPET:
            case WindArcher.PUPPET:
            case Outlaw.OCTOPUS:
            case Corsair.WRATH_OF_THE_OCTOPI:
                statups.add(new Pair<>(MapleBuffStat.PUPPET, Integer.valueOf(1)));
                break;
            case Bowmaster.CONCENTRATE:
                statups.add(new Pair<>(MapleBuffStat.CONCENTRATE, x));
                break;
            case Bowmaster.HAMSTRING:
                statups.add(new Pair<>(MapleBuffStat.HAMSTRING, Integer.valueOf(x)));
                monsterStatus.put(MonsterStatus.SPEED, x);
                break;
            case Marksman.BLIND:
                statups.add(new Pair<>(MapleBuffStat.BLIND, Integer.valueOf(x)));
                monsterStatus.put(MonsterStatus.ACC, x);
                break;
            case Bowmaster.SHARP_EYES:
            case Marksman.SHARP_EYES:
                statups.add(new Pair<>(MapleBuffStat.SHARP_EYES, Integer.valueOf(ret.x << 8 | ret.y)));
                break;
            case WindArcher.WIND_WALK:
                statups.add(new Pair<>(MapleBuffStat.WIND_WALK, Integer.valueOf(x)));
                break;
            case Rogue.DARK_SIGHT:
            case NightWalker.DARK_SIGHT:
                statups.add(new Pair<>(MapleBuffStat.DARKSIGHT, Integer.valueOf(x)));
                break;
            case Hermit.MESO_UP:
                statups.add(new Pair<>(MapleBuffStat.MESOUP, Integer.valueOf(x)));
                break;
            case Hermit.SHADOW_PARTNER:
            case NightWalker.SHADOW_PARTNER:
                statups.add(new Pair<>(MapleBuffStat.SHADOWPARTNER, Integer.valueOf(x)));
                break;
            case ChiefBandit.MESO_GUARD:
                statups.add(new Pair<>(MapleBuffStat.MESOGUARD, Integer.valueOf(x)));
                break;
            case ChiefBandit.PICKPOCKET:
                statups.add(new Pair<>(MapleBuffStat.PICKPOCKET, Integer.valueOf(x)));
                break;
            case NightLord.SHADOW_STARS:
                statups.add(new Pair<>(MapleBuffStat.SHADOW_CLAW, Integer.valueOf(0)));
                break;
            // PIRATE
            case Pirate.DASH:
            case ThunderBreaker.DASH:
            case Beginner.SPACE_DASH:
            case Noblesse.SPACE_DASH:
                statups.add(new Pair<>(MapleBuffStat.DASH2, Integer.valueOf(ret.x)));
                statups.add(new Pair<>(MapleBuffStat.DASH, Integer.valueOf(ret.y)));
                break;
            case Corsair.SPEED_INFUSION:
            case Buccaneer.SPEED_INFUSION:
            case ThunderBreaker.SPEED_INFUSION:
                statups.add(new Pair<>(MapleBuffStat.SPEED_INFUSION, Integer.valueOf(x)));
                break;
            case Outlaw.HOMING_BEACON:
            case Corsair.BULLSEYE:
                statups.add(new Pair<>(MapleBuffStat.HOMING_BEACON, Integer.valueOf(x)));
                break;
            case ThunderBreaker.SPARK:
                statups.add(new Pair<>(MapleBuffStat.SPARK, Integer.valueOf(x)));
                break;
            // MULTIPLE
            case Aran.POLEARM_BOOSTER:
            case Fighter.AXE_BOOSTER:
            case Fighter.SWORD_BOOSTER:
            case Page.BW_BOOSTER:
            case Page.SWORD_BOOSTER:
            case Spearman.POLEARM_BOOSTER:
            case Spearman.SPEAR_BOOSTER:
            case Hunter.BOW_BOOSTER:
            case Crossbowman.CROSSBOW_BOOSTER:
            case Assassin.CLAW_BOOSTER:
            case Bandit.DAGGER_BOOSTER:
            case FPMage.SPELL_BOOSTER:
            case ILMage.SPELL_BOOSTER:
            case Brawler.KNUCKLER_BOOSTER:
            case Gunslinger.GUN_BOOSTER:
            case DawnWarrior.SWORD_BOOSTER:
            case BlazeWizard.SPELL_BOOSTER:
            case WindArcher.BOW_BOOSTER:
            case NightWalker.CLAW_BOOSTER:
            case ThunderBreaker.KNUCKLER_BOOSTER:
            case Evan.MAGIC_BOOSTER:
            case Beginner.POWER_EXPLOSION:
            case Noblesse.POWER_EXPLOSION:
            case Legend.POWER_EXPLOSION:
                statups.add(new Pair<>(MapleBuffStat.BOOSTER, Integer.valueOf(x)));
                break;
            case Hero.MAPLE_WARRIOR:
            case Paladin.MAPLE_WARRIOR:
            case DarkKnight.MAPLE_WARRIOR:
            case FPArchMage.MAPLE_WARRIOR:
            case ILArchMage.MAPLE_WARRIOR:
            case Bishop.MAPLE_WARRIOR:
            case Bowmaster.MAPLE_WARRIOR:
            case Marksman.MAPLE_WARRIOR:
            case NightLord.MAPLE_WARRIOR:
            case Shadower.MAPLE_WARRIOR:
            case Corsair.MAPLE_WARRIOR:
            case Buccaneer.MAPLE_WARRIOR:
            case Aran.MAPLE_WARRIOR:
            case Evan.MAPLE_WARRIOR:
                statups.add(new Pair<>(MapleBuffStat.MAPLE_WARRIOR, Integer.valueOf(ret.x)));
                break;
            // SUMMON
            case Ranger.SILVER_HAWK:
            case Sniper.GOLDEN_EAGLE:
                statups.add(new Pair<>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
                monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
                break;
            case FPArchMage.ELQUINES:
            case Marksman.FROST_PREY:
                statups.add(new Pair<>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
                monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
                break;
            case Priest.SUMMON_DRAGON:
            case Bowmaster.PHOENIX:
            case ILArchMage.IFRIT:
            case Bishop.BAHAMUT:
            case DarkKnight.BEHOLDER:
            case Outlaw.GAVIOTA:
            case DawnWarrior.SOUL:
            case BlazeWizard.FLAME:
            case WindArcher.STORM:
            case NightWalker.DARKNESS:
            case ThunderBreaker.LIGHTNING:
            case BlazeWizard.IFRIT:
                statups.add(new Pair<>(MapleBuffStat.SUMMON, Integer.valueOf(1)));
                break;
            // ----------------------------- MONSTER STATUS ---------------------------------- //
            case Crusader.ARMOR_CRASH:
            case DragonKnight.POWER_CRASH:
            case WhiteKnight.MAGIC_CRASH:
                monsterStatus.put(MonsterStatus.SEAL_SKILL, Integer.valueOf(1));
                break;
            case Rogue.DISORDER:
                monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
                monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
                break;
            case Corsair.HYPNOTIZE:
                monsterStatus.put(MonsterStatus.INERTMOB, 1);
                break;
            case NightLord.NINJA_AMBUSH:
            case Shadower.NINJA_AMBUSH:
                monsterStatus.put(MonsterStatus.NINJA_AMBUSH, Integer.valueOf(ret.damage));
                break;
            case Page.THREATEN:
                monsterStatus.put(MonsterStatus.WATK, Integer.valueOf(ret.x));
                monsterStatus.put(MonsterStatus.WDEF, Integer.valueOf(ret.y));
                break;
            case Crusader.AXE_COMA:
            case Crusader.SWORD_COMA:
            case Crusader.SHOUT:
            case WhiteKnight.CHARGE_BLOW:
            case Hunter.ARROW_BOMB:
            case ChiefBandit.ASSAULTER:
            case Shadower.BOOMERANG_STEP:
            case Brawler.BACK_SPIN_BLOW:
            case Brawler.DOUBLE_UPPERCUT:
            case Buccaneer.DEMOLITION:
            case Buccaneer.SNATCH:
            case Buccaneer.BARRAGE:
            case Gunslinger.BLANK_SHOT:
            case DawnWarrior.COMA:
            case Aran.ROLLING_SPIN:
            case Evan.FIRE_BREATH:
            case Evan.BLAZE:
                monsterStatus.put(MonsterStatus.STUN, Integer.valueOf(1));
                break;
            case NightLord.TAUNT:
            case Shadower.TAUNT:
                monsterStatus.put(MonsterStatus.SHOWDOWN, ret.x);
                monsterStatus.put(MonsterStatus.MDEF, ret.x);
                monsterStatus.put(MonsterStatus.WDEF, ret.x);
                break;
            case ILWizard.COLD_BEAM:
            case ILMage.ICE_STRIKE:
            case ILArchMage.BLIZZARD:
            case ILMage.ELEMENT_COMPOSITION:
            case Sniper.BLIZZARD:
            case Outlaw.ICE_SPLITTER:
            case FPArchMage.PARALYZE:
            case Aran.COMBO_TEMPEST:
            case Evan.ICE_BREATH:
                monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
                // freezing skills are a little strange
                ret.duration *= 2;
                break;
            case FPWizard.SLOW:
            case ILWizard.SLOW:
            case BlazeWizard.SLOW:
                monsterStatus.put(MonsterStatus.SPEED, Integer.valueOf(ret.x));
                break;
            case FPWizard.POISON_BREATH:
            case FPMage.ELEMENT_COMPOSITION:
                monsterStatus.put(MonsterStatus.POISON, Integer.valueOf(1));
                break;
            case Priest.DOOM:
                monsterStatus.put(MonsterStatus.DOOM, Integer.valueOf(1));
                break;
            case ILMage.SEAL:
            case FPMage.SEAL:
                monsterStatus.put(MonsterStatus.SEAL, Integer.valueOf(1));
                break;
            // shadow web
            case Hermit.SHADOW_WEB:
            case NightWalker.SHADOW_WEB:
                monsterStatus.put(MonsterStatus.SHADOW_WEB, Integer.valueOf(1));
                break;
            case FPArchMage.FIRE_DEMON:
            case ILArchMage.ICE_DEMON:
                monsterStatus.put(MonsterStatus.POISON, Integer.valueOf(1));
                monsterStatus.put(MonsterStatus.FREEZE, Integer.valueOf(1));
                break;
            case Evan.PHANTOM_IMPRINT:
                monsterStatus.put(MonsterStatus.PHANTOM_IMPRINT, Integer.valueOf(x));
            // ARAN
            case Aran.COMBO_ABILITY:
                statups.add(new Pair<>(MapleBuffStat.ARAN_COMBO, Integer.valueOf(100)));
                break;
            case Aran.COMBO_BARRIER:
                statups.add(new Pair<>(MapleBuffStat.COMBO_BARRIER, Integer.valueOf(ret.x)));
                break;
            case Aran.COMBO_DRAIN:
                statups.add(new Pair<>(MapleBuffStat.COMBO_DRAIN, Integer.valueOf(ret.x)));
                break;
            case Aran.SMART_KNOCKBACK:
                statups.add(new Pair<>(MapleBuffStat.SMART_KNOCKBACK, Integer.valueOf(ret.x)));
                break;
            case Aran.BODY_PRESSURE:
                statups.add(new Pair<>(MapleBuffStat.BODY_PRESSURE, Integer.valueOf(ret.x)));
                break;
            case Aran.SNOW_CHARGE:
                statups.add(new Pair<>(MapleBuffStat.WK_CHARGE, Integer.valueOf(ret.duration)));
                break;
            default:
                break;
        }
    }
    if (ret.isMorph()) {
        statups.add(new Pair<>(MapleBuffStat.MORPH, Integer.valueOf(ret.getMorph())));
    }
    if (ret.ghost > 0 && !skill) {
        statups.add(new Pair<>(MapleBuffStat.GHOST_MORPH, Integer.valueOf(ret.ghost)));
    }
    ret.monsterStatus = monsterStatus;
    statups.trimToSize();
    ret.statups = statups;
    return ret;
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList) MonsterStatus(client.status.MonsterStatus) ArrayMap(tools.ArrayMap) Point(java.awt.Point) Point(java.awt.Point) Pair(tools.Pair)

Example 28 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class CashShop method loadGifts.

public List<Pair<Item, String>> loadGifts() {
    List<Pair<Item, String>> gifts = new ArrayList<>();
    Connection con = null;
    try {
        con = DatabaseConnection.getConnection();
        PreparedStatement ps = con.prepareStatement("SELECT * FROM `gifts` WHERE `to` = ?");
        ps.setInt(1, characterId);
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            notes++;
            CashItem cItem = CashItemFactory.getItem(rs.getInt("sn"));
            Item item = cItem.toItem();
            Equip equip = null;
            item.setGiftFrom(rs.getString("from"));
            if (item.getInventoryType().equals(MapleInventoryType.EQUIP)) {
                equip = (Equip) item;
                equip.setRingId(rs.getInt("ringid"));
                gifts.add(new Pair<Item, String>(equip, rs.getString("message")));
            } else
                gifts.add(new Pair<>(item, rs.getString("message")));
            if (CashItemFactory.isPackage(cItem.getItemId())) {
                // Packages never contains a ring
                for (Item packageItem : CashItemFactory.getPackage(cItem.getItemId())) {
                    packageItem.setGiftFrom(rs.getString("from"));
                    addToInventory(packageItem);
                }
            } else {
                addToInventory(equip == null ? item : equip);
            }
        }
        rs.close();
        ps.close();
        ps = con.prepareStatement("DELETE FROM `gifts` WHERE `to` = ?");
        ps.setInt(1, characterId);
        ps.executeUpdate();
        ps.close();
        con.close();
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    }
    return gifts;
}
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) PreparedStatement(java.sql.PreparedStatement) Pair(tools.Pair)

Example 29 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class CashShop method save.

public void save(Connection con) throws SQLException {
    PreparedStatement ps = con.prepareStatement("UPDATE `accounts` SET `nxCredit` = ?, `maplePoint` = ?, `nxPrepaid` = ? WHERE `id` = ?");
    ps.setInt(1, nxCredit);
    ps.setInt(2, maplePoint);
    ps.setInt(3, nxPrepaid);
    ps.setInt(4, accountId);
    ps.executeUpdate();
    ps.close();
    List<Pair<Item, MapleInventoryType>> itemsWithType = new ArrayList<>();
    List<Item> inv = getInventory();
    for (Item item : inv) {
        itemsWithType.add(new Pair<>(item, item.getInventoryType()));
    }
    factory.saveItems(itemsWithType, accountId, con);
    ps = con.prepareStatement("DELETE FROM `wishlists` WHERE `charid` = ?");
    ps.setInt(1, characterId);
    ps.executeUpdate();
    ps.close();
    ps = con.prepareStatement("INSERT INTO `wishlists` VALUES (DEFAULT, ?, ?)");
    ps.setInt(1, characterId);
    for (int sn : wishList) {
        ps.setInt(2, sn);
        ps.executeUpdate();
    }
    ps.close();
}
Also used : Item(client.inventory.Item) ArrayList(java.util.ArrayList) PreparedStatement(java.sql.PreparedStatement) Pair(tools.Pair)

Example 30 with Pair

use of tools.Pair in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getItemLevelupStats.

public List<Pair<String, Integer>> getItemLevelupStats(int itemId, int level) {
    List<Pair<String, Integer>> list = new LinkedList<>();
    MapleData data = getItemData(itemId);
    MapleData data1 = data.getChildByPath("info").getChildByPath("level");
    if (data1 != null) {
        MapleData data2 = data1.getChildByPath("info").getChildByPath(Integer.toString(level));
        if (data2 != null) {
            for (MapleData da : data2.getChildren()) {
                if (Math.random() < 0.9) {
                    if (da.getName().startsWith("incDEXMin")) {
                        list.add(new Pair<>("incDEX", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incDEXMax")))));
                    } else if (da.getName().startsWith("incSTRMin")) {
                        list.add(new Pair<>("incSTR", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incSTRMax")))));
                    } else if (da.getName().startsWith("incINTMin")) {
                        list.add(new Pair<>("incINT", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incINTMax")))));
                    } else if (da.getName().startsWith("incLUKMin")) {
                        list.add(new Pair<>("incLUK", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incLUKMax")))));
                    } else if (da.getName().startsWith("incMHPMin")) {
                        list.add(new Pair<>("incMHP", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incMHPMax")))));
                    } else if (da.getName().startsWith("incMMPMin")) {
                        list.add(new Pair<>("incMMP", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incMMPMax")))));
                    } else if (da.getName().startsWith("incPADMin")) {
                        list.add(new Pair<>("incPAD", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incPADMax")))));
                    } else if (da.getName().startsWith("incMADMin")) {
                        list.add(new Pair<>("incMAD", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incMADMax")))));
                    } else if (da.getName().startsWith("incPDDMin")) {
                        list.add(new Pair<>("incPDD", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incPDDMax")))));
                    } else if (da.getName().startsWith("incMDDMin")) {
                        list.add(new Pair<>("incMDD", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incMDDMax")))));
                    } else if (da.getName().startsWith("incACCMin")) {
                        list.add(new Pair<>("incACC", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incACCMax")))));
                    } else if (da.getName().startsWith("incEVAMin")) {
                        list.add(new Pair<>("incEVA", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incEVAMax")))));
                    } else if (da.getName().startsWith("incSpeedMin")) {
                        list.add(new Pair<>("incSpeed", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incSpeedMax")))));
                    } else if (da.getName().startsWith("incJumpMin")) {
                        list.add(new Pair<>("incJump", Randomizer.rand(MapleDataTool.getInt(da), MapleDataTool.getInt(data2.getChildByPath("incJumpMax")))));
                    }
                }
            }
        }
    }
    return list;
}
Also used : MapleData(provider.MapleData) LinkedList(java.util.LinkedList) Pair(tools.Pair)

Aggregations

Pair (tools.Pair)51 ArrayList (java.util.ArrayList)34 Point (java.awt.Point)16 Item (client.inventory.Item)15 LinkedList (java.util.LinkedList)12 MapleData (provider.MapleData)11 SQLException (java.sql.SQLException)10 PreparedStatement (java.sql.PreparedStatement)7 List (java.util.List)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 MobSkill (server.life.MobSkill)6 MapleCharacter (client.MapleCharacter)5 Connection (java.sql.Connection)5 ResultSet (java.sql.ResultSet)5 MapleMap (server.maps.MapleMap)5 LinkedHashMap (java.util.LinkedHashMap)4 CharacterIdChannelPair (net.server.channel.CharacterIdChannelPair)4 MaplePartyCharacter (net.server.world.MaplePartyCharacter)4 MapleStatEffect (server.MapleStatEffect)4 DatabaseConnection (tools.DatabaseConnection)4