Search in sources :

Example 1 with MapleMist

use of server.maps.MapleMist in project HeavenMS by ronancpl.

the class MobSkill method applyEffect.

public void applyEffect(MapleCharacter player, MapleMonster monster, boolean skill, List<MapleCharacter> banishPlayers) {
    MapleDisease disease = null;
    Map<MonsterStatus, Integer> stats = new ArrayMap<MonsterStatus, Integer>();
    List<Integer> reflection = new LinkedList<Integer>();
    switch(skillId) {
        case 100:
        case 110:
        case 150:
            stats.put(MonsterStatus.WEAPON_ATTACK_UP, Integer.valueOf(x));
            break;
        case 101:
        case 111:
        case 151:
            stats.put(MonsterStatus.MAGIC_ATTACK_UP, Integer.valueOf(x));
            break;
        case 102:
        case 112:
        case 152:
            stats.put(MonsterStatus.WEAPON_DEFENSE_UP, Integer.valueOf(x));
            break;
        case 103:
        case 113:
        case 153:
            stats.put(MonsterStatus.MAGIC_DEFENSE_UP, Integer.valueOf(x));
            break;
        case 114:
            if (lt != null && rb != null && skill) {
                List<MapleMapObject> objects = getObjectsInRange(monster, MapleMapObjectType.MONSTER);
                final int hps = (getX() / 1000) * (int) (950 + 1050 * Math.random());
                for (MapleMapObject mons : objects) {
                    ((MapleMonster) mons).heal(hps, getY());
                }
            } else {
                monster.heal(getX(), getY());
            }
            break;
        case 120:
            disease = MapleDisease.SEAL;
            break;
        case 121:
            disease = MapleDisease.DARKNESS;
            break;
        case 122:
            disease = MapleDisease.WEAKEN;
            break;
        case 123:
            disease = MapleDisease.STUN;
            break;
        case 124:
            disease = MapleDisease.CURSE;
            break;
        case 125:
            disease = MapleDisease.POISON;
            break;
        case // Slow
        126:
            disease = MapleDisease.SLOW;
            break;
        case 127:
            if (lt != null && rb != null && skill) {
                for (MapleCharacter character : getPlayersInRange(monster, player)) {
                    character.dispel();
                }
            } else {
                player.dispel();
            }
            break;
        case // Seduce
        128:
            disease = MapleDisease.SEDUCE;
            break;
        case // Banish
        129:
            if (lt != null && rb != null && skill) {
                for (MapleCharacter chr : getPlayersInRange(monster, player)) {
                    banishPlayers.add(chr);
                }
            } else {
                banishPlayers.add(player);
            }
            break;
        case // Mist
        131:
            monster.getMap().spawnMist(new MapleMist(calculateBoundingBox(monster.getPosition(), true), monster, this), x * 10, false, false, false);
            break;
        case 132:
            disease = MapleDisease.CONFUSE;
            break;
        case // zombify
        133:
            disease = MapleDisease.ZOMBIFY;
            break;
        case 140:
            if (makeChanceResult() && !monster.isBuffed(MonsterStatus.MAGIC_IMMUNITY)) {
                stats.put(MonsterStatus.WEAPON_IMMUNITY, Integer.valueOf(x));
            }
            break;
        case 141:
            if (makeChanceResult() && !monster.isBuffed(MonsterStatus.WEAPON_IMMUNITY)) {
                stats.put(MonsterStatus.MAGIC_IMMUNITY, Integer.valueOf(x));
            }
            break;
        case // Weapon Reflect
        143:
            stats.put(MonsterStatus.WEAPON_REFLECT, Integer.valueOf(x));
            stats.put(MonsterStatus.WEAPON_IMMUNITY, Integer.valueOf(x));
            reflection.add(x);
            break;
        case // Magic Reflect
        144:
            stats.put(MonsterStatus.MAGIC_REFLECT, Integer.valueOf(x));
            stats.put(MonsterStatus.MAGIC_IMMUNITY, Integer.valueOf(x));
            reflection.add(x);
            break;
        case // Weapon / Magic reflect
        145:
            stats.put(MonsterStatus.WEAPON_REFLECT, Integer.valueOf(x));
            stats.put(MonsterStatus.WEAPON_IMMUNITY, Integer.valueOf(x));
            stats.put(MonsterStatus.MAGIC_REFLECT, Integer.valueOf(x));
            stats.put(MonsterStatus.MAGIC_IMMUNITY, Integer.valueOf(x));
            reflection.add(x);
            break;
        // accuracy up
        case 154:
        // avoid up
        case 155:
        case // speed up
        156:
            break;
        case // summon
        200:
            if (monster.getMap().getSpawnedMonstersOnMap() < 80) {
                for (Integer mobId : getSummons()) {
                    MapleMonster toSpawn = MapleLifeFactory.getMonster(mobId);
                    if (toSpawn != null) {
                        // no littering on BRPQ pls
                        if (GameConstants.isBossRush(monster.getMap().getId()))
                            toSpawn.disableDrops();
                        toSpawn.setPosition(monster.getPosition());
                        int ypos, xpos;
                        xpos = (int) monster.getPosition().getX();
                        ypos = (int) monster.getPosition().getY();
                        switch(mobId) {
                            case // Pap bomb high
                            8500003:
                                toSpawn.setFh((int) Math.ceil(Math.random() * 19.0));
                                ypos = -590;
                                break;
                            case // Pap bomb
                            8500004:
                                xpos = (int) (monster.getPosition().getX() + Randomizer.nextInt(1000) - 500);
                                if (ypos != -590) {
                                    ypos = (int) monster.getPosition().getY();
                                }
                                break;
                            case // Pianus bomb
                            8510100:
                                if (Math.ceil(Math.random() * 5) == 1) {
                                    ypos = 78;
                                    xpos = (int) Randomizer.nextInt(5) + (Randomizer.nextInt(2) == 1 ? 180 : 0);
                                } else {
                                    xpos = (int) (monster.getPosition().getX() + Randomizer.nextInt(1000) - 500);
                                }
                                break;
                        }
                        switch(monster.getMap().getId()) {
                            case // Pap map
                            220080001:
                                if (xpos < -890) {
                                    xpos = (int) (Math.ceil(Math.random() * 150) - 890);
                                } else if (xpos > 230) {
                                    xpos = (int) (230 - Math.ceil(Math.random() * 150));
                                }
                                break;
                            case // Pianus map
                            230040420:
                                if (xpos < -239) {
                                    xpos = (int) (Math.ceil(Math.random() * 150) - 239);
                                } else if (xpos > 371) {
                                    xpos = (int) (371 - Math.ceil(Math.random() * 150));
                                }
                                break;
                        }
                        toSpawn.setPosition(new Point(xpos, ypos));
                        if (toSpawn.getId() == 8500004) {
                            monster.getMap().spawnFakeMonster(toSpawn);
                        } else {
                            monster.getMap().spawnMonsterWithEffect(toSpawn, getSpawnEffect(), toSpawn.getPosition());
                        }
                    }
                }
            }
            break;
        default:
            System.out.println("Unhandled Mob skill: " + skillId);
            break;
    }
    if (stats.size() > 0) {
        if (lt != null && rb != null && skill) {
            for (MapleMapObject mons : getObjectsInRange(monster, MapleMapObjectType.MONSTER)) {
                ((MapleMonster) mons).applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
            }
        } else {
            monster.applyMonsterBuff(stats, getX(), getSkillId(), getDuration(), this, reflection);
        }
    }
    if (disease != null) {
        if (lt != null && rb != null && skill) {
            int i = 0;
            for (MapleCharacter character : getPlayersInRange(monster, player)) {
                if (!character.isActiveBuffedValue(2321005)) {
                    if (disease.equals(MapleDisease.SEDUCE)) {
                        if (i < 10) {
                            character.giveDebuff(MapleDisease.SEDUCE, this);
                            i++;
                        }
                    } else {
                        character.giveDebuff(disease, this);
                    }
                }
            }
        } else {
            player.giveDebuff(disease, this);
        }
    }
    monster.usedSkill(skillId, skillLevel, cooltime);
    monster.setMp(monster.getMp() - getMpCon());
}
Also used : MapleDisease(client.MapleDisease) MapleCharacter(client.MapleCharacter) MonsterStatus(client.status.MonsterStatus) ArrayMap(tools.ArrayMap) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) LinkedList(java.util.LinkedList) Point(java.awt.Point) MapleMist(server.maps.MapleMist)

Example 2 with MapleMist

use of server.maps.MapleMist 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)

Aggregations

Point (java.awt.Point)2 MapleMist (server.maps.MapleMist)2 MapleCharacter (client.MapleCharacter)1 MapleDisease (client.MapleDisease)1 Item (client.inventory.Item)1 MapleInventory (client.inventory.MapleInventory)1 MonsterStatus (client.status.MonsterStatus)1 Rectangle (java.awt.Rectangle)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 MaplePartyCharacter (net.server.world.MaplePartyCharacter)1 MapleDoor (server.maps.MapleDoor)1 MapleMap (server.maps.MapleMap)1 MapleMapObject (server.maps.MapleMapObject)1 MapleSummon (server.maps.MapleSummon)1 SummonMovementType (server.maps.SummonMovementType)1 ArrayMap (tools.ArrayMap)1 Pair (tools.Pair)1