Search in sources :

Example 31 with MapleMonster

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

the class MapleMap method spawnMonsterOnGroundBelow.

public void spawnMonsterOnGroundBelow(int id, int x, int y) {
    MapleMonster mob = MapleLifeFactory.getMonster(id);
    spawnMonsterOnGroundBelow(mob, new Point(x, y));
}
Also used : Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Example 32 with MapleMonster

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

the class MapleMap method removePlayer.

/*
    public Collection<MaplePortal> getPortals() {
        return Collections.unmodifiableCollection(portals.values());
    }
    */
public void removePlayer(MapleCharacter chr) {
    chr.unregisterChairBuff();
    chrWLock.lock();
    try {
        removePartyMemberInternal(chr);
        characters.remove(chr);
    } finally {
        chrWLock.unlock();
    }
    if (MapleMiniDungeonInfo.isDungeonMap(mapid)) {
        MapleMiniDungeon mmd = chr.getClient().getChannelServer().getMiniDungeon(mapid);
        if (mmd != null) {
            if (!mmd.unregisterPlayer(chr)) {
                chr.getClient().getChannelServer().removeMiniDungeon(mapid);
            }
        }
    }
    removeMapObject(chr.getObjectId());
    if (!chr.isHidden()) {
        broadcastMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
    } else {
        broadcastGMMessage(MaplePacketCreator.removePlayerFromMap(chr.getId()));
    }
    for (MapleMonster monster : chr.getControlledMonsters()) {
        monster.setController(null);
        monster.setControllerHasAggro(false);
        monster.setControllerKnowsAboutAggro(false);
        updateMonsterController(monster);
    }
    chr.leaveMap();
    for (MapleSummon summon : new ArrayList<>(chr.getSummonsValues())) {
        if (summon.isStationary()) {
            chr.cancelBuffStats(MapleBuffStat.PUPPET);
        } else {
            removeMapObject(summon);
        }
    }
    if (chr.getDragon() != null) {
        removeMapObject(chr.getDragon());
        if (chr.isHidden()) {
            this.broadcastGMMessage(chr, MaplePacketCreator.removeDragon(chr.getId()));
        } else {
            this.broadcastMessage(chr, MaplePacketCreator.removeDragon(chr.getId()));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) MapleMonster(server.life.MapleMonster)

Example 33 with MapleMonster

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

the class MapleMap method monsterCloakingDevice.

public void monsterCloakingDevice() {
    for (MapleMapObject monstermo : getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER))) {
        MapleMonster monster = (MapleMonster) monstermo;
        broadcastMessage(MaplePacketCreator.makeMonsterInvisible(monster));
    }
}
Also used : Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Example 34 with MapleMonster

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

the class MapleMap method killAllMonstersNotFriendly.

public void killAllMonstersNotFriendly() {
    closeMapSpawnPoints();
    for (MapleMapObject monstermo : getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.MONSTER))) {
        MapleMonster monster = (MapleMonster) monstermo;
        if (monster.getStats().isFriendly()) {
            continue;
        }
        killMonster(monster, null, false, 1);
    }
}
Also used : Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint) MapleMonster(server.life.MapleMonster)

Example 35 with MapleMonster

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

the class MapleMap method spawnMist.

public void spawnMist(final MapleMist mist, final int duration, boolean poison, boolean fake, boolean recovery) {
    addMapObject(mist);
    broadcastMessage(fake ? mist.makeFakeSpawnData(30) : mist.makeSpawnData());
    TimerManager tMan = TimerManager.getInstance();
    final ScheduledFuture<?> poisonSchedule;
    if (poison) {
        Runnable poisonTask = new Runnable() {

            @Override
            public void run() {
                List<MapleMapObject> affectedMonsters = getMapObjectsInBox(mist.getBox(), Collections.singletonList(MapleMapObjectType.MONSTER));
                for (MapleMapObject mo : affectedMonsters) {
                    if (mist.makeChanceResult()) {
                        MonsterStatusEffect poisonEffect = new MonsterStatusEffect(Collections.singletonMap(MonsterStatus.POISON, 1), mist.getSourceSkill(), null, false);
                        ((MapleMonster) mo).applyStatus(mist.getOwner(), poisonEffect, true, duration);
                    }
                }
            }
        };
        poisonSchedule = tMan.register(poisonTask, 2000, 2500);
    } else if (recovery) {
        Runnable poisonTask = new Runnable() {

            @Override
            public void run() {
                List<MapleMapObject> players = getMapObjectsInBox(mist.getBox(), Collections.singletonList(MapleMapObjectType.PLAYER));
                for (MapleMapObject mo : players) {
                    if (mist.makeChanceResult()) {
                        MapleCharacter chr = (MapleCharacter) mo;
                        if (mist.getOwner().getId() == chr.getId() || mist.getOwner().getParty() != null && mist.getOwner().getParty().containsMembers(chr.getMPC())) {
                            chr.addMP((int) mist.getSourceSkill().getEffect(chr.getSkillLevel(mist.getSourceSkill().getId())).getX() * chr.getMp() / 100);
                        }
                    }
                }
            }
        };
        poisonSchedule = tMan.register(poisonTask, 2000, 2500);
    } else {
        poisonSchedule = null;
    }
    tMan.schedule(new Runnable() {

        @Override
        public void run() {
            removeMapObject(mist);
            if (poisonSchedule != null) {
                poisonSchedule.cancel(false);
            }
            broadcastMessage(mist.makeDestroyData());
        }
    }, duration);
}
Also used : MapleCharacter(client.MapleCharacter) MonsterStatusEffect(client.status.MonsterStatusEffect) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) TimerManager(server.TimerManager) 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