Search in sources :

Example 36 with MapleMonster

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

the class MapleMap method spawnHorntailOnGroundBelow.

public void spawnHorntailOnGroundBelow(final Point targetPoint) {
    // ayy lmao
    MapleMonster htIntro = MapleLifeFactory.getMonster(8810026);
    spawnMonsterOnGroundBelow(htIntro, targetPoint);
    final MapleMonster ht = MapleLifeFactory.getMonster(8810018);
    ht.setParentMobOid(htIntro.getObjectId());
    ht.addListener(new MonsterListener() {

        @Override
        public void monsterKilled(int aniTime) {
        }

        @Override
        public void monsterDamaged(MapleCharacter from, int trueDmg) {
            ht.addHp(trueDmg);
        }

        @Override
        public void monsterHealed(int trueHeal) {
            ht.addHp(-trueHeal);
        }
    });
    spawnMonsterOnGroundBelow(ht, targetPoint);
    for (int x = 8810002; x <= 8810009; x++) {
        MapleMonster m = MapleLifeFactory.getMonster(x);
        m.setParentMobOid(htIntro.getObjectId());
        m.addListener(new MonsterListener() {

            @Override
            public void monsterKilled(int aniTime) {
            }

            @Override
            public void monsterDamaged(MapleCharacter from, int trueDmg) {
                ht.applyAndGetHpDamage(trueDmg, true);
                ht.broadcastMobHpBar(from);
            }

            @Override
            public void monsterHealed(int trueHeal) {
                ht.addHp(trueHeal);
            }
        });
        spawnMonsterOnGroundBelow(m, targetPoint);
    }
}
Also used : MonsterListener(server.life.MonsterListener) MapleCharacter(client.MapleCharacter) MapleMonster(server.life.MapleMonster) Point(java.awt.Point) SpawnPoint(server.life.SpawnPoint)

Example 37 with MapleMonster

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

the class MaplePacketCreator method spawnMonsterInternal.

/**
 * Internal function to handler monster spawning and controlling.
 *
 * @param life The mob to perform operations with.
 * @param requestController Requesting control of mob?
 * @param newSpawn New spawn (fade in?)
 * @param aggro Aggressive mob?
 * @param effect The spawn effect to use.
 * @return The spawn/control packet.
 */
private static byte[] spawnMonsterInternal(MapleMonster life, boolean requestController, boolean newSpawn, boolean aggro, int effect, boolean makeInvis) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    if (makeInvis) {
        mplew.writeShort(SendOpcode.SPAWN_MONSTER_CONTROL.getValue());
        mplew.write(0);
        mplew.writeInt(life.getObjectId());
        return mplew.getPacket();
    }
    if (requestController) {
        mplew.writeShort(SendOpcode.SPAWN_MONSTER_CONTROL.getValue());
        mplew.write(aggro ? 2 : 1);
    } else {
        mplew.writeShort(SendOpcode.SPAWN_MONSTER.getValue());
    }
    mplew.writeInt(life.getObjectId());
    mplew.write(life.getController() == null ? 5 : 1);
    mplew.writeInt(life.getId());
    mplew.skip(15);
    mplew.write(0x88);
    mplew.skip(6);
    mplew.writePos(life.getPosition());
    mplew.write(life.getStance());
    // Origin FH //life.getStartFh()
    mplew.writeShort(0);
    mplew.writeShort(life.getFh());
    if (life.getParentMobOid() != 0) {
        MapleMonster parentMob = life.getMap().getMonsterByOid(life.getParentMobOid());
        if (parentMob != null && parentMob.isAlive()) {
            mplew.write(effect != 0 ? effect : -3);
            mplew.writeInt(life.getParentMobOid());
        } else {
            encodeParentlessMobSpawnEffect(mplew, newSpawn, effect);
        }
    } else {
        encodeParentlessMobSpawnEffect(mplew, newSpawn, effect);
    }
    mplew.write(life.getTeam());
    // getItemEffect
    mplew.writeInt(0);
    return mplew.getPacket();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) 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