Search in sources :

Example 11 with MapleMonster

use of server.life.MapleMonster in project HeavenMS by ronancpl.

the class AbstractDealDamageHandler method applyAttack.

protected synchronized void applyAttack(AttackInfo attack, final MapleCharacter player, int attackCount) {
    Skill theSkill = null;
    MapleStatEffect attackEffect = null;
    final int job = player.getJob().getId();
    try {
        if (player.isBanned()) {
            return;
        }
        if (attack.skill != 0) {
            // returns back the skill id if its not a hidden skill so we are gucci
            theSkill = SkillFactory.getSkill(GameConstants.getHiddenSkill(attack.skill));
            attackEffect = attack.getAttackEffect(player, theSkill);
            if (attackEffect == null) {
                player.getClient().announce(MaplePacketCreator.enableActions());
                return;
            }
            if (player.getMp() < attackEffect.getMpCon()) {
                AutobanFactory.MPCON.addPoint(player.getAutobanManager(), "Skill: " + attack.skill + "; Player MP: " + player.getMp() + "; MP Needed: " + attackEffect.getMpCon());
            }
            if (attack.skill != Cleric.HEAL) {
                if (player.isAlive()) {
                    if (// Poison Bomb
                    attack.skill == NightWalker.POISON_BOMB)
                        attackEffect.applyTo(player, new Point(attack.position.x, attack.position.y));
                    else if (// prevent BP refreshing
                    attack.skill != Aran.BODY_PRESSURE)
                        attackEffect.applyTo(player);
                } else {
                    player.getClient().announce(MaplePacketCreator.enableActions());
                }
            }
            int mobCount = attackEffect.getMobCount();
            if (attack.skill == DawnWarrior.FINAL_ATTACK || attack.skill == Page.FINAL_ATTACK_BW || attack.skill == Page.FINAL_ATTACK_SWORD || attack.skill == Fighter.FINAL_ATTACK_SWORD || attack.skill == Fighter.FINAL_ATTACK_AXE || attack.skill == Spearman.FINAL_ATTACK_SPEAR || attack.skill == Spearman.FINAL_ATTACK_POLEARM || attack.skill == WindArcher.FINAL_ATTACK || attack.skill == DawnWarrior.FINAL_ATTACK || attack.skill == Hunter.FINAL_ATTACK || attack.skill == Crossbowman.FINAL_ATTACK) {
                // :(
                mobCount = 15;
            }
            if (attack.skill == Aran.HIDDEN_FULL_DOUBLE || attack.skill == Aran.HIDDEN_FULL_TRIPLE || attack.skill == Aran.HIDDEN_OVER_DOUBLE || attack.skill == Aran.HIDDEN_OVER_TRIPLE) {
                mobCount = 12;
            }
            if (attack.numAttacked > mobCount) {
                AutobanFactory.MOB_COUNT.autoban(player, "Skill: " + attack.skill + "; Count: " + attack.numAttacked + " Max: " + attackEffect.getMobCount());
                return;
            }
        }
        if (!player.isAlive()) {
            return;
        }
        // WTF IS THIS F3,1
        /*if (attackCount != attack.numDamage && attack.skill != ChiefBandit.MESO_EXPLOSION && attack.skill != NightWalker.VAMPIRE && attack.skill != WindArcher.WIND_SHOT && attack.skill != Aran.COMBO_SMASH && attack.skill != Aran.COMBO_FENRIR && attack.skill != Aran.COMBO_TEMPEST && attack.skill != NightLord.NINJA_AMBUSH && attack.skill != Shadower.NINJA_AMBUSH) {
                return;
            }*/
        int totDamage = 0;
        final MapleMap map = player.getMap();
        if (attack.skill == ChiefBandit.MESO_EXPLOSION) {
            int delay = 0;
            for (Integer oned : attack.allDamage.keySet()) {
                MapleMapObject mapobject = map.getMapObject(oned.intValue());
                if (mapobject != null && mapobject.getType() == MapleMapObjectType.ITEM) {
                    final MapleMapItem mapitem = (MapleMapItem) mapobject;
                    if (mapitem.getMeso() == 0) {
                        // Maybe it is possible some how?
                        return;
                    }
                    synchronized (mapitem) {
                        if (mapitem.isPickedUp()) {
                            return;
                        }
                        TimerManager.getInstance().schedule(new Runnable() {

                            @Override
                            public void run() {
                                map.pickItemDrop(MaplePacketCreator.removeItemFromMap(mapitem.getObjectId(), 4, 0), mapitem);
                            }
                        }, delay);
                        delay += 100;
                    }
                } else if (mapobject != null && mapobject.getType() != MapleMapObjectType.MONSTER) {
                    return;
                }
            }
        }
        for (Integer oned : attack.allDamage.keySet()) {
            final MapleMonster monster = map.getMonsterByOid(oned.intValue());
            if (monster != null) {
                double distance = player.getPosition().distanceSq(monster.getPosition());
                double distanceToDetect = 200000.0;
                if (attack.ranged)
                    distanceToDetect += 400000;
                if (attack.magic)
                    distanceToDetect += 200000;
                if (player.getJob().isA(MapleJob.ARAN1))
                    // Arans have extra range over normal warriors.
                    distanceToDetect += 200000;
                if (attack.skill == Aran.COMBO_SMASH || attack.skill == Aran.BODY_PRESSURE)
                    distanceToDetect += 40000;
                else if (attack.skill == Bishop.GENESIS || attack.skill == ILArchMage.BLIZZARD || attack.skill == FPArchMage.METEOR_SHOWER)
                    distanceToDetect += 275000;
                else if (attack.skill == Hero.BRANDISH || attack.skill == DragonKnight.SPEAR_CRUSHER || attack.skill == DragonKnight.POLE_ARM_CRUSHER)
                    distanceToDetect += 40000;
                else if (attack.skill == DragonKnight.DRAGON_ROAR || attack.skill == SuperGM.SUPER_DRAGON_ROAR)
                    distanceToDetect += 250000;
                else if (attack.skill == Shadower.BOOMERANG_STEP)
                    distanceToDetect += 60000;
                if (distance > distanceToDetect) {
                    AutobanFactory.DISTANCE_HACK.alert(player, "Distance Sq to monster: " + distance + " SID: " + attack.skill + " MID: " + monster.getId());
                }
                int totDamageToOneMonster = 0;
                List<Integer> onedList = attack.allDamage.get(oned);
                for (Integer eachd : onedList) {
                    if (eachd < 0)
                        eachd += Integer.MAX_VALUE;
                    totDamageToOneMonster += eachd;
                }
                totDamage += totDamageToOneMonster;
                player.checkMonsterAggro(monster);
                if (player.getBuffedValue(MapleBuffStat.PICKPOCKET) != null && (attack.skill == 0 || attack.skill == Rogue.DOUBLE_STAB || attack.skill == Bandit.SAVAGE_BLOW || attack.skill == ChiefBandit.ASSAULTER || attack.skill == ChiefBandit.BAND_OF_THIEVES || attack.skill == Shadower.ASSASSINATE || attack.skill == Shadower.TAUNT || attack.skill == Shadower.BOOMERANG_STEP)) {
                    Skill pickpocket = SkillFactory.getSkill(ChiefBandit.PICKPOCKET);
                    int picklv = (player.isGM()) ? pickpocket.getMaxLevel() : player.getSkillLevel(pickpocket);
                    if (picklv > 0) {
                        int delay = 0;
                        final int maxmeso = player.getBuffedValue(MapleBuffStat.PICKPOCKET).intValue();
                        for (Integer eachd : onedList) {
                            eachd += Integer.MAX_VALUE;
                            if (pickpocket.getEffect(picklv).makeChanceResult()) {
                                final Integer eachdf;
                                if (eachd < 0)
                                    eachdf = eachd + Integer.MAX_VALUE;
                                else
                                    eachdf = eachd;
                                TimerManager.getInstance().schedule(new Runnable() {

                                    @Override
                                    public void run() {
                                        player.getMap().spawnMesoDrop(Math.min((int) Math.max(((double) eachdf / (double) 20000) * (double) maxmeso, (double) 1), maxmeso), new Point((int) (monster.getPosition().getX() + Randomizer.nextInt(100) - 50), (int) (monster.getPosition().getY())), monster, player, true, (byte) 2);
                                    }
                                }, delay);
                                delay += 100;
                            }
                        }
                    }
                } else if (attack.skill == Marauder.ENERGY_DRAIN || attack.skill == ThunderBreaker.ENERGY_DRAIN || attack.skill == NightWalker.VAMPIRE || attack.skill == Assassin.DRAIN) {
                    player.addHP(Math.min(monster.getMaxHp(), Math.min((int) ((double) totDamage * (double) SkillFactory.getSkill(attack.skill).getEffect(player.getSkillLevel(SkillFactory.getSkill(attack.skill))).getX() / 100.0), player.getMaxHp() / 2)));
                } else if (attack.skill == Bandit.STEAL) {
                    Skill steal = SkillFactory.getSkill(Bandit.STEAL);
                    if (monster.getStolen().size() < 1) {
                        // One steal per mob <3
                        if (steal.getEffect(player.getSkillLevel(steal)).makeChanceResult()) {
                            MapleMonsterInformationProvider mi = MapleMonsterInformationProvider.getInstance();
                            List<Integer> dropPool = mi.retrieveDropPool(monster.getId());
                            if (!dropPool.isEmpty()) {
                                Integer rndPool = (int) Math.floor(Math.random() * dropPool.get(dropPool.size() - 1));
                                int i = 0;
                                while (rndPool >= dropPool.get(i)) i++;
                                List<MonsterDropEntry> toSteal = new ArrayList<>();
                                toSteal.add(mi.retrieveDrop(monster.getId()).get(i));
                                player.getMap().dropItemsFromMonster(toSteal, player, monster);
                                monster.addStolen(toSteal.get(0).itemId);
                            }
                        }
                    }
                } else if (attack.skill == FPArchMage.FIRE_DEMON) {
                    monster.setTempEffectiveness(Element.ICE, ElementalEffectiveness.WEAK, SkillFactory.getSkill(FPArchMage.FIRE_DEMON).getEffect(player.getSkillLevel(SkillFactory.getSkill(FPArchMage.FIRE_DEMON))).getDuration() * 1000);
                } else if (attack.skill == ILArchMage.ICE_DEMON) {
                    monster.setTempEffectiveness(Element.FIRE, ElementalEffectiveness.WEAK, SkillFactory.getSkill(ILArchMage.ICE_DEMON).getEffect(player.getSkillLevel(SkillFactory.getSkill(ILArchMage.ICE_DEMON))).getDuration() * 1000);
                } else if (attack.skill == Outlaw.HOMING_BEACON || attack.skill == Corsair.BULLSEYE) {
                    player.setMarkedMonster(monster.getObjectId());
                    player.announce(MaplePacketCreator.giveBuff(1, attack.skill, Collections.singletonList(new Pair<>(MapleBuffStat.HOMING_BEACON, monster.getObjectId()))));
                }
                if (job == 2111 || job == 2112) {
                    if (player.getBuffedValue(MapleBuffStat.WK_CHARGE) != null) {
                        Skill snowCharge = SkillFactory.getSkill(Aran.SNOW_CHARGE);
                        if (totDamageToOneMonster > 0) {
                            MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, snowCharge.getEffect(player.getSkillLevel(snowCharge)).getX()), snowCharge, null, false);
                            monster.applyStatus(player, monsterStatusEffect, false, snowCharge.getEffect(player.getSkillLevel(snowCharge)).getY() * 1000);
                        }
                    }
                }
                if (player.getBuffedValue(MapleBuffStat.HAMSTRING) != null) {
                    Skill hamstring = SkillFactory.getSkill(Bowmaster.HAMSTRING);
                    if (hamstring.getEffect(player.getSkillLevel(hamstring)).makeChanceResult()) {
                        MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, hamstring.getEffect(player.getSkillLevel(hamstring)).getX()), hamstring, null, false);
                        monster.applyStatus(player, monsterStatusEffect, false, hamstring.getEffect(player.getSkillLevel(hamstring)).getY() * 1000);
                    }
                }
                if (player.getBuffedValue(MapleBuffStat.SLOW) != null) {
                    Skill slow = SkillFactory.getSkill(Evan.SLOW);
                    if (slow.getEffect(player.getSkillLevel(slow)).makeChanceResult()) {
                        MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.SPEED, slow.getEffect(player.getSkillLevel(slow)).getX()), slow, null, false);
                        monster.applyStatus(player, monsterStatusEffect, false, slow.getEffect(player.getSkillLevel(slow)).getY() * 60 * 1000);
                    }
                }
                if (player.getBuffedValue(MapleBuffStat.BLIND) != null) {
                    Skill blind = SkillFactory.getSkill(Marksman.BLIND);
                    if (blind.getEffect(player.getSkillLevel(blind)).makeChanceResult()) {
                        MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.ACC, blind.getEffect(player.getSkillLevel(blind)).getX()), blind, null, false);
                        monster.applyStatus(player, monsterStatusEffect, false, blind.getEffect(player.getSkillLevel(blind)).getY() * 1000);
                    }
                }
                if (job == 121 || job == 122) {
                    for (int charge = 1211005; charge < 1211007; charge++) {
                        Skill chargeSkill = SkillFactory.getSkill(charge);
                        if (player.isBuffFrom(MapleBuffStat.WK_CHARGE, chargeSkill)) {
                            if (totDamageToOneMonster > 0) {
                                if (charge == WhiteKnight.BW_ICE_CHARGE || charge == WhiteKnight.SWORD_ICE_CHARGE) {
                                    monster.setTempEffectiveness(Element.ICE, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
                                    break;
                                }
                                if (charge == WhiteKnight.BW_FIRE_CHARGE || charge == WhiteKnight.SWORD_FIRE_CHARGE) {
                                    monster.setTempEffectiveness(Element.FIRE, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
                                    break;
                                }
                            }
                        }
                    }
                    if (job == 122) {
                        for (int charge = 1221003; charge < 1221004; charge++) {
                            Skill chargeSkill = SkillFactory.getSkill(charge);
                            if (player.isBuffFrom(MapleBuffStat.WK_CHARGE, chargeSkill)) {
                                if (totDamageToOneMonster > 0) {
                                    monster.setTempEffectiveness(Element.HOLY, ElementalEffectiveness.WEAK, chargeSkill.getEffect(player.getSkillLevel(chargeSkill)).getY() * 1000);
                                    break;
                                }
                            }
                        }
                    }
                } else if (player.getBuffedValue(MapleBuffStat.COMBO_DRAIN) != null) {
                    Skill skill;
                    if (player.getBuffedValue(MapleBuffStat.COMBO_DRAIN) != null) {
                        skill = SkillFactory.getSkill(21100005);
                        player.setHp(player.getHp() + ((totDamage * skill.getEffect(player.getSkillLevel(skill)).getX()) / 100), true);
                        player.updateSingleStat(MapleStat.HP, player.getHp());
                    }
                } else if (job == 412 || job == 422 || job == 1411) {
                    Skill type = SkillFactory.getSkill(player.getJob().getId() == 412 ? 4120005 : (player.getJob().getId() == 1411 ? 14110004 : 4220005));
                    if (player.getSkillLevel(type) > 0) {
                        MapleStatEffect venomEffect = type.getEffect(player.getSkillLevel(type));
                        for (int i = 0; i < attackCount; i++) {
                            if (venomEffect.makeChanceResult()) {
                                if (monster.getVenomMulti() < 3) {
                                    monster.setVenomMulti((monster.getVenomMulti() + 1));
                                    MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
                                    monster.applyStatus(player, monsterStatusEffect, false, venomEffect.getDuration(), true);
                                }
                            }
                        }
                    }
                } else if (job == 521 || job == 522) {
                    // from what I can gather this is how it should work
                    if (!monster.isBoss()) {
                        Skill type = SkillFactory.getSkill(Outlaw.FLAME_THROWER);
                        if (player.getSkillLevel(type) > 0) {
                            MapleStatEffect DoT = type.getEffect(player.getSkillLevel(type));
                            MonsterStatusEffect monsterStatusEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), type, null, false);
                            monster.applyStatus(player, monsterStatusEffect, true, DoT.getDuration(), false);
                        }
                    }
                } else if (job >= 311 && job <= 322) {
                    if (!monster.isBoss()) {
                        Skill mortalBlow;
                        if (job == 311 || job == 312) {
                            mortalBlow = SkillFactory.getSkill(Ranger.MORTAL_BLOW);
                        } else {
                            mortalBlow = SkillFactory.getSkill(Sniper.MORTAL_BLOW);
                        }
                        if (player.getSkillLevel(mortalBlow) > 0) {
                            MapleStatEffect mortal = mortalBlow.getEffect(player.getSkillLevel(mortalBlow));
                            if (monster.getHp() <= (monster.getStats().getHp() * mortal.getX()) / 100) {
                                if (Randomizer.rand(1, 100) <= mortal.getY()) {
                                    monster.getMap().killMonster(monster, player, true);
                                }
                            }
                        }
                    }
                }
                if (attack.skill != 0) {
                    if (attackEffect.getFixDamage() != -1) {
                        if (totDamageToOneMonster != attackEffect.getFixDamage() && totDamageToOneMonster != 0) {
                            AutobanFactory.FIX_DAMAGE.autoban(player, String.valueOf(totDamageToOneMonster) + " damage");
                        }
                        if (ServerConstants.USE_ULTRA_THREE_SNAILS) {
                            AbstractPlayerInteraction api = player.getClient().getAbstractPlayerInteraction();
                            int shellId;
                            switch(totDamageToOneMonster) {
                                case 10:
                                    shellId = 4000019;
                                    break;
                                case 25:
                                    shellId = 4000000;
                                    break;
                                default:
                                    shellId = 4000016;
                            }
                            if (api.haveItem(shellId, 1)) {
                                api.gainItem(shellId, (short) -1, false);
                                totDamageToOneMonster *= player.getLevel();
                            } else {
                                player.dropMessage(5, "You ran out of shells to activate the hidden power of Three Snails.");
                            }
                        }
                    }
                }
                if (totDamageToOneMonster > 0 && attackEffect != null && attackEffect.getMonsterStati().size() > 0) {
                    if (attackEffect.makeChanceResult()) {
                        monster.applyStatus(player, new MonsterStatusEffect(attackEffect.getMonsterStati(), theSkill, null, false), attackEffect.isPoison(), attackEffect.getDuration());
                    }
                }
                if (attack.isHH && !monster.isBoss()) {
                    map.damageMonster(player, monster, monster.getHp() - 1);
                } else if (attack.isHH) {
                    int HHDmg = (player.calculateMaxBaseDamage(player.getTotalWatk()) * (SkillFactory.getSkill(Paladin.HEAVENS_HAMMER).getEffect(player.getSkillLevel(SkillFactory.getSkill(Paladin.HEAVENS_HAMMER))).getDamage() / 100));
                    map.damageMonster(player, monster, (int) (Math.floor(Math.random() * (HHDmg / 5) + HHDmg * .8)));
                } else if (attack.isTempest && !monster.isBoss()) {
                    map.damageMonster(player, monster, monster.getHp());
                } else if (attack.isTempest) {
                    int TmpDmg = (player.calculateMaxBaseDamage(player.getTotalWatk()) * (SkillFactory.getSkill(Aran.COMBO_TEMPEST).getEffect(player.getSkillLevel(SkillFactory.getSkill(Aran.COMBO_TEMPEST))).getDamage() / 100));
                    map.damageMonster(player, monster, (int) (Math.floor(Math.random() * (TmpDmg / 5) + TmpDmg * .8)));
                } else {
                    map.damageMonster(player, monster, totDamageToOneMonster);
                }
                if (monster.isBuffed(MonsterStatus.WEAPON_REFLECT)) {
                    for (int i = 0; i < monster.getSkills().size(); i++) {
                        if (monster.getSkills().get(i).left == 145) {
                            MobSkill toUse = MobSkillFactory.getMobSkill(monster.getSkills().get(i).left, monster.getSkills().get(i).right);
                            player.addHP(-toUse.getX());
                            map.broadcastMessage(player, MaplePacketCreator.damagePlayer(0, monster.getId(), player.getId(), toUse.getX(), 0, 0, false, 0, true, monster.getObjectId(), 0, 0), true);
                        }
                    }
                }
                if (monster.isBuffed(MonsterStatus.MAGIC_REFLECT)) {
                    for (int i = 0; i < monster.getSkills().size(); i++) {
                        if (monster.getSkills().get(i).left == 145) {
                            MobSkill toUse = MobSkillFactory.getMobSkill(monster.getSkills().get(i).left, monster.getSkills().get(i).right);
                            player.addMP(-toUse.getY());
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MapleMonsterInformationProvider(server.life.MapleMonsterInformationProvider) MonsterStatusEffect(client.status.MonsterStatusEffect) ArrayList(java.util.ArrayList) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) AbstractPlayerInteraction(scripting.AbstractPlayerInteraction) Point(java.awt.Point) MapleMap(server.maps.MapleMap) Skill(client.Skill) MobSkill(server.life.MobSkill) MapleStatEffect(server.MapleStatEffect) MonsterDropEntry(server.life.MonsterDropEntry) MapleMapItem(server.maps.MapleMapItem) MobSkill(server.life.MobSkill) MapleMonster(server.life.MapleMonster) Pair(tools.Pair)

Example 12 with MapleMonster

use of server.life.MapleMonster in project HeavenMS by ronancpl.

the class Commands method executeHeavenMsCommandLv1.

public static boolean executeHeavenMsCommandLv1(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // Donator
    MapleCharacter player = c.getPlayer();
    switch(sub[0]) {
        case "buffme":
            // GM Skills : Haste(Super) - Holy Symbol - Bless - Hyper Body - Echo of Hero
            SkillFactory.getSkill(4101004).getEffect(SkillFactory.getSkill(4101004).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(2311003).getEffect(SkillFactory.getSkill(2311003).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(1301007).getEffect(SkillFactory.getSkill(1301007).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(2301004).getEffect(SkillFactory.getSkill(2301004).getMaxLevel()).applyTo(player);
            SkillFactory.getSkill(1005).getEffect(SkillFactory.getSkill(1005).getMaxLevel()).applyTo(player);
            player.setHp(player.getMaxHp());
            player.updateSingleStat(MapleStat.HP, player.getMaxHp());
            player.setMp(player.getMaxMp());
            player.updateSingleStat(MapleStat.MP, player.getMaxMp());
            break;
        case "goto":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !goto <map name>");
                break;
            }
            if (gotomaps.containsKey(sub[1])) {
                MapleMap target = c.getChannelServer().getMapFactory().getMap(gotomaps.get(sub[1]));
                MaplePortal targetPortal = target.getPortal(0);
                if (player.getEventInstance() != null) {
                    player.getEventInstance().removePlayer(player);
                }
                player.changeMap(target, targetPortal);
            } else {
                player.dropMessage(5, "That map does not exist.");
            }
            break;
        case "recharge":
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            for (Item torecharge : c.getPlayer().getInventory(MapleInventoryType.USE).list()) {
                if (ItemConstants.isThrowingStar(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isArrow(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isBullet(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                } else if (ItemConstants.isConsumable(torecharge.getItemId())) {
                    torecharge.setQuantity(ii.getSlotMax(c, torecharge.getItemId()));
                    c.getPlayer().forceUpdateItem(torecharge);
                }
            }
            player.dropMessage(5, "USE Recharged.");
            break;
        case "whereami":
            player.yellowMessage("Map ID: " + player.getMap().getId());
            player.yellowMessage("Players on this map:");
            for (MapleMapObject mmo : player.getMap().getPlayers()) {
                MapleCharacter chr = (MapleCharacter) mmo;
                player.dropMessage(5, ">> " + chr.getName() + " - " + chr.getId() + " - Oid: " + chr.getObjectId());
            }
            player.yellowMessage("NPCs on this map:");
            for (MapleMapObject npcs : player.getMap().getMapObjects()) {
                if (npcs instanceof MapleNPC) {
                    MapleNPC npc = (MapleNPC) npcs;
                    player.dropMessage(5, ">> " + npc.getName() + " - " + npc.getId() + " - Oid: " + npc.getObjectId());
                }
            }
            player.yellowMessage("Monsters on this map:");
            for (MapleMapObject mobs : player.getMap().getMapObjects()) {
                if (mobs instanceof MapleMonster) {
                    MapleMonster mob = (MapleMonster) mobs;
                    if (mob.isAlive()) {
                        player.dropMessage(5, ">> " + mob.getName() + " - " + mob.getId() + " - Oid: " + mob.getObjectId());
                    }
                }
            }
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleMap(server.maps.MapleMap) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) MapleCharacter(client.MapleCharacter) MaplePortal(server.MaplePortal) MapleItemInformationProvider(server.MapleItemInformationProvider) MapleMapObject(server.maps.MapleMapObject) MapleNPC(server.life.MapleNPC) MapleMonster(server.life.MapleMonster)

Example 13 with MapleMonster

use of server.life.MapleMonster in project HeavenMS by ronancpl.

the class Commands method executeHeavenMsCommandLv4.

public static boolean executeHeavenMsCommandLv4(Channel cserv, Server srv, MapleClient c, String[] sub) {
    // SuperGM
    MapleCharacter player = c.getPlayer();
    switch(sub[0]) {
        case "servermessage":
            c.getWorldServer().setServerMessage(joinStringFrom(sub, 1));
            break;
        case "proitem":
            if (sub.length < 3) {
                player.yellowMessage("Syntax: !proitem <itemid> <statvalue>");
                break;
            }
            int itemid = Integer.parseInt(sub[1]);
            short multiply = Short.parseShort(sub[2]);
            MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
            MapleInventoryType type = ItemConstants.getInventoryType(itemid);
            if (type.equals(MapleInventoryType.EQUIP)) {
                Item it = ii.getEquipById(itemid);
                it.setOwner(player.getName());
                hardsetItemStats((Equip) it, multiply);
                MapleInventoryManipulator.addFromDrop(c, it);
            } else {
                player.dropMessage(6, "Make sure it's an equippable item.");
            }
            break;
        case "seteqstat":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !seteqstat <statvalue>");
                break;
            }
            int newStat = Integer.parseInt(sub[1]);
            MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
            for (byte i = 1; i <= equip.getSlotLimit(); i++) {
                try {
                    Equip eu = (Equip) equip.getItem(i);
                    if (eu == null)
                        continue;
                    short incval = (short) newStat;
                    eu.setWdef(incval);
                    eu.setAcc(incval);
                    eu.setAvoid(incval);
                    eu.setJump(incval);
                    eu.setMatk(incval);
                    eu.setMdef(incval);
                    eu.setHp(incval);
                    eu.setMp(incval);
                    eu.setSpeed(incval);
                    eu.setWatk(incval);
                    eu.setDex(incval);
                    eu.setInt(incval);
                    eu.setStr(incval);
                    eu.setLuk(incval);
                    byte flag = eu.getFlag();
                    flag |= ItemConstants.UNTRADEABLE;
                    eu.setFlag(flag);
                    player.forceUpdateItem(eu);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            break;
        case "exprate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !exprate <newrate>");
                break;
            }
            int exprate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setExpRate(exprate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Exp Rate has been changed to " + exprate + "x."));
            break;
        case "mesorate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !mesorate <newrate>");
                break;
            }
            int mesorate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setMesoRate(mesorate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Meso Rate has been changed to " + mesorate + "x."));
            break;
        case "droprate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !droprate <newrate>");
                break;
            }
            int droprate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setDropRate(droprate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Drop Rate has been changed to " + droprate + "x."));
            break;
        case "questrate":
            if (sub.length < 2) {
                player.yellowMessage("Syntax: !questrate <newrate>");
                break;
            }
            int questrate = Math.max(Integer.parseInt(sub[1]), 1);
            c.getWorldServer().setQuestRate(questrate);
            c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Quest Rate has been changed to " + questrate + "x."));
            break;
        case "itemvac":
            List<MapleMapObject> list = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
            for (MapleMapObject item : list) {
                player.pickupItem(item);
            }
            break;
        case "forcevac":
            List<MapleMapObject> items = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
            for (MapleMapObject item : items) {
                MapleMapItem mapItem = (MapleMapItem) item;
                if (mapItem.getMeso() > 0) {
                    player.gainMeso(mapItem.getMeso(), true);
                } else if (mapItem.getItemId() == 4031865 || mapItem.getItemId() == 4031866) {
                    // Add NX to account, show effect and make item disappear
                    player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
                } else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
                    int petId = MaplePet.createPet(mapItem.getItem().getItemId());
                    if (petId == -1) {
                        continue;
                    }
                    MapleInventoryManipulator.addById(c, mapItem.getItem().getItemId(), mapItem.getItem().getQuantity(), null, petId);
                } else {
                    MapleInventoryManipulator.addFromDrop(c, mapItem.getItem(), true);
                }
                player.getMap().pickItemDrop(MaplePacketCreator.removeItemFromMap(mapItem.getObjectId(), 2, player.getId()), mapItem);
            }
            break;
        case "zakum":
            player.getMap().spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800000), player.getPosition());
            for (int x = 8800003; x < 8800011; x++) {
                player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(x), player.getPosition());
            }
            break;
        case "horntail":
            final Point targetPoint = player.getPosition();
            final MapleMap targetMap = player.getMap();
            targetMap.spawnHorntailOnGroundBelow(targetPoint);
            break;
        case "pinkbean":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8820001), player.getPosition());
            break;
        case "pap":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8500001), player.getPosition());
            break;
        case "pianus":
            player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8510000), player.getPosition());
            break;
        case "cake":
            MapleMonster monster = MapleLifeFactory.getMonster(9400606);
            if (sub.length > 1) {
                int newHp = Integer.parseInt(sub[1]);
                if (newHp < 0)
                    newHp = Integer.MAX_VALUE;
                monster.getStats().setHp(newHp);
                monster.setStartingHp(newHp);
            }
            player.getMap().spawnMonsterOnGroundBelow(monster, player.getPosition());
            break;
        default:
            return false;
    }
    return true;
}
Also used : MapleCharacter(client.MapleCharacter) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleInventory(client.inventory.MapleInventory) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) SQLException(java.sql.SQLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) MapleMapItem(server.maps.MapleMapItem) Item(client.inventory.Item) Equip(client.inventory.Equip) MapleMap(server.maps.MapleMap) MapleInventoryType(client.inventory.MapleInventoryType) MapleItemInformationProvider(server.MapleItemInformationProvider) MapleMapItem(server.maps.MapleMapItem) MapleMonster(server.life.MapleMonster)

Example 14 with MapleMonster

use of server.life.MapleMonster in project HeavenMS by ronancpl.

the class AbstractPlayerInteraction method spawnMonster.

public void spawnMonster(int id, int x, int y) {
    MapleMonster monster = MapleLifeFactory.getMonster(id);
    monster.setPosition(new Point(x, y));
    getPlayer().getMap().spawnMonster(monster);
}
Also used : Point(java.awt.Point) MapleMonster(server.life.MapleMonster)

Example 15 with MapleMonster

use of server.life.MapleMonster in project HeavenMS by ronancpl.

the class MapleStatEffect method applyMonsterBuff.

private void applyMonsterBuff(MapleCharacter applyfrom) {
    Rectangle bounds = calculateBoundingBox(applyfrom.getPosition(), applyfrom.isFacingLeft());
    List<MapleMapObject> affected = applyfrom.getMap().getMapObjectsInRect(bounds, Arrays.asList(MapleMapObjectType.MONSTER));
    Skill skill_ = SkillFactory.getSkill(sourceid);
    int i = 0;
    for (MapleMapObject mo : affected) {
        MapleMonster monster = (MapleMonster) mo;
        if (isDispel()) {
            monster.debuffMob(skill_.getId());
        } else {
            if (makeChanceResult()) {
                monster.applyStatus(applyfrom, new MonsterStatusEffect(getMonsterStati(), skill_, null, false), isPoison(), getDuration());
                if (isCrash()) {
                    monster.debuffMob(skill_.getId());
                }
            }
        }
        i++;
        if (i >= mobCount) {
            break;
        }
    }
}
Also used : Skill(client.Skill) MonsterStatusEffect(client.status.MonsterStatusEffect) Rectangle(java.awt.Rectangle) MapleMapObject(server.maps.MapleMapObject) Point(java.awt.Point) MapleMonster(server.life.MapleMonster)

Aggregations

MapleMonster (server.life.MapleMonster)37 Point (java.awt.Point)20 MapleCharacter (client.MapleCharacter)15 SpawnPoint (server.life.SpawnPoint)13 ArrayList (java.util.ArrayList)9 MapleMapObject (server.maps.MapleMapObject)9 MapleMap (server.maps.MapleMap)7 Skill (client.Skill)6 MapleStatEffect (server.MapleStatEffect)6 MonsterStatusEffect (client.status.MonsterStatusEffect)5 Item (client.inventory.Item)4 SQLException (java.sql.SQLException)4 Rectangle (java.awt.Rectangle)3 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 MapleItemInformationProvider (server.MapleItemInformationProvider)3 MobSkill (server.life.MobSkill)3 MapleMapItem (server.maps.MapleMapItem)3