Search in sources :

Example 21 with MapleStatEffect

use of server.MapleStatEffect in project HeavenMS by ronancpl.

the class MapleMap method killMonster.

public void killMonster(final MapleMonster monster, final MapleCharacter chr, final boolean withDrops, int animation) {
    if (monster == null)
        return;
    if (chr == null) {
        spawnedMonstersOnMap.decrementAndGet();
        monster.setHpZero();
        removeMapObject(monster);
        monster.dispatchMonsterKilled(false);
        broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), animation), monster.getPosition());
        return;
    }
    if (monster.getStats().getLevel() >= chr.getLevel() + 30 && !chr.isGM()) {
        AutobanFactory.GENERAL.alert(chr, " for killing a " + monster.getName() + " which is over 30 levels higher.");
    }
    /*if (chr.getQuest(MapleQuest.getInstance(29400)).getStatus().equals(MapleQuestStatus.Status.STARTED)) {
         if (chr.getLevel() >= 120 && monster.getStats().getLevel() >= 120) {
         //FIX MEDAL SHET
         } else if (monster.getStats().getLevel() >= chr.getLevel()) {
         }
         }*/
    int buff = monster.getBuffToGive();
    if (buff > -1) {
        MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
        for (MapleMapObject mmo : this.getPlayers()) {
            MapleCharacter character = (MapleCharacter) mmo;
            if (character.isAlive()) {
                MapleStatEffect statEffect = mii.getItemEffect(buff);
                character.getClient().announce(MaplePacketCreator.showOwnBuffEffect(buff, 1));
                broadcastMessage(character, MaplePacketCreator.showBuffeffect(character.getId(), buff, 1), false);
                statEffect.applyTo(character);
            }
        }
    }
    spawnedMonstersOnMap.decrementAndGet();
    monster.setHpZero();
    removeMapObject(monster);
    if (monster.getCP() > 0 && chr.getCarnival() != null) {
        chr.getCarnivalParty().addCP(chr, monster.getCP());
        chr.announce(MaplePacketCreator.updateCP(chr.getCP(), chr.getObtainedCP()));
        broadcastMessage(MaplePacketCreator.updatePartyCP(chr.getCarnivalParty()));
    // they drop items too ):
    }
    if (monster.getId() >= 8800003 && monster.getId() <= 8800010) {
        boolean makeZakReal = true;
        Collection<MapleMapObject> objects = getMapObjects();
        for (MapleMapObject object : objects) {
            MapleMonster mons = getMonsterByOid(object.getObjectId());
            if (mons != null) {
                if (mons.getId() >= 8800003 && mons.getId() <= 8800010) {
                    makeZakReal = false;
                    break;
                }
            }
        }
        if (makeZakReal) {
            MapleMap map = chr.getMap();
            for (MapleMapObject object : objects) {
                MapleMonster mons = map.getMonsterByOid(object.getObjectId());
                if (mons != null) {
                    if (mons.getId() == 8800000) {
                        makeMonsterReal(mons);
                        updateMonsterController(mons);
                        break;
                    }
                }
            }
        }
    }
    MapleCharacter dropOwner = monster.killBy(chr);
    if (withDrops && !monster.dropsDisabled()) {
        if (dropOwner == null) {
            dropOwner = chr;
        }
        dropFromMonster(dropOwner, monster, false);
    }
    if (monster.hasBossHPBar()) {
        for (MapleCharacter mc : this.getAllPlayers()) {
            if (mc.getTargetHpBarHash() == monster.hashCode()) {
                mc.resetPlayerAggro();
            }
        }
    }
    monster.dispatchMonsterKilled(true);
    broadcastMessage(MaplePacketCreator.killMonster(monster.getObjectId(), animation), monster.getPosition());
}
Also used : MapleCharacter(client.MapleCharacter) MapleStatEffect(server.MapleStatEffect) MapleItemInformationProvider(server.MapleItemInformationProvider) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Aggregations

MapleStatEffect (server.MapleStatEffect)21 MapleCharacter (client.MapleCharacter)10 Point (java.awt.Point)10 Skill (client.Skill)9 ArrayList (java.util.ArrayList)6 MapleMonster (server.life.MapleMonster)6 MobSkill (server.life.MobSkill)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Pair (tools.Pair)5 Item (client.inventory.Item)3 MonsterStatusEffect (client.status.MonsterStatusEffect)3 MapleMap (server.maps.MapleMap)3 MapleBuffStat (client.MapleBuffStat)2 MapleInventory (client.inventory.MapleInventory)2 MapleWeaponType (client.inventory.MapleWeaponType)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 SpawnPoint (server.life.SpawnPoint)2 MapleMapItem (server.maps.MapleMapItem)2 MapleMapObject (server.maps.MapleMapObject)2