Search in sources :

Example 6 with MapleSummon

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

the class DamageSummonHandler method handlePacket.

public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int oid = slea.readInt();
    // -1
    slea.skip(1);
    int damage = slea.readInt();
    int monsterIdFrom = slea.readInt();
    MapleCharacter player = c.getPlayer();
    MapleMapObject mmo = player.getMap().getMapObject(oid);
    if (mmo != null && mmo instanceof MapleSummon) {
        MapleSummon summon = (MapleSummon) mmo;
        summon.addHP(-damage);
        if (summon.getHP() <= 0) {
            player.cancelEffectFromBuffStat(MapleBuffStat.PUPPET);
        }
        player.getMap().broadcastMessage(player, MaplePacketCreator.damageSummon(player.getId(), oid, damage, monsterIdFrom), summon.getPosition());
    }
}
Also used : MapleCharacter(client.MapleCharacter) MapleMapObject(server.maps.MapleMapObject) MapleSummon(server.maps.MapleSummon)

Example 7 with MapleSummon

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

the class MoveSummonHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int oid = slea.readInt();
    Point startPos = new Point(slea.readShort(), slea.readShort());
    List<LifeMovementFragment> res = parseMovement(slea);
    MapleCharacter player = c.getPlayer();
    Collection<MapleSummon> summons = player.getSummonsValues();
    MapleSummon summon = null;
    for (MapleSummon sum : summons) {
        if (sum.getObjectId() == oid) {
            summon = sum;
            break;
        }
    }
    if (summon != null) {
        updatePosition(res, summon, 0);
        player.getMap().broadcastMessage(player, MaplePacketCreator.moveSummon(player.getId(), oid, startPos, res), summon.getPosition());
    }
}
Also used : MapleCharacter(client.MapleCharacter) LifeMovementFragment(server.movement.LifeMovementFragment) Point(java.awt.Point) Point(java.awt.Point) MapleSummon(server.maps.MapleSummon)

Example 8 with MapleSummon

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

the class SummonDamageHandler method handlePacket.

@Override
public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int oid = slea.readInt();
    MapleCharacter player = c.getPlayer();
    if (!player.isAlive()) {
        return;
    }
    MapleSummon summon = null;
    for (MapleSummon sum : player.getSummonsValues()) {
        if (sum.getObjectId() == oid) {
            summon = sum;
        }
    }
    if (summon == null) {
        return;
    }
    Skill summonSkill = SkillFactory.getSkill(summon.getSkill());
    MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel());
    slea.skip(4);
    List<SummonAttackEntry> allDamage = new ArrayList<>();
    byte direction = slea.readByte();
    int numAttacked = slea.readByte();
    // Thanks Gerald :D, I failed lol (mob x,y and summon x,y)
    slea.skip(8);
    for (int x = 0; x < numAttacked; x++) {
        // attacked oid
        int monsterOid = slea.readInt();
        slea.skip(18);
        int damage = slea.readInt();
        allDamage.add(new SummonAttackEntry(monsterOid, damage));
    }
    player.getMap().broadcastMessage(player, MaplePacketCreator.summonAttack(player.getId(), summon.getObjectId(), direction, allDamage), summon.getPosition());
    for (SummonAttackEntry attackEntry : allDamage) {
        int damage = attackEntry.getDamage();
        MapleMonster target = player.getMap().getMonsterByOid(attackEntry.getMonsterOid());
        if (target != null) {
            if (damage > 0 && summonEffect.getMonsterStati().size() > 0) {
                if (summonEffect.makeChanceResult()) {
                    target.applyStatus(player, new MonsterStatusEffect(summonEffect.getMonsterStati(), summonSkill, null, false), summonEffect.isPoison(), 4000);
                }
            }
            player.getMap().damageMonster(player, target, damage);
        }
    }
}
Also used : MapleCharacter(client.MapleCharacter) Skill(client.Skill) MapleStatEffect(server.MapleStatEffect) MonsterStatusEffect(client.status.MonsterStatusEffect) ArrayList(java.util.ArrayList) MapleSummon(server.maps.MapleSummon) MapleMonster(server.life.MapleMonster)

Aggregations

MapleSummon (server.maps.MapleSummon)8 Point (java.awt.Point)4 MapleCharacter (client.MapleCharacter)3 ArrayList (java.util.ArrayList)3 Pair (tools.Pair)3 MapleMonster (server.life.MapleMonster)2 SummonMovementType (server.maps.SummonMovementType)2 Skill (client.Skill)1 Item (client.inventory.Item)1 MapleInventory (client.inventory.MapleInventory)1 MonsterStatusEffect (client.status.MonsterStatusEffect)1 Rectangle (java.awt.Rectangle)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 MaplePartyCharacter (net.server.world.MaplePartyCharacter)1 MapleStatEffect (server.MapleStatEffect)1 MapleDoor (server.maps.MapleDoor)1 MapleMap (server.maps.MapleMap)1 MapleMapObject (server.maps.MapleMapObject)1 MapleMist (server.maps.MapleMist)1 LifeMovementFragment (server.movement.LifeMovementFragment)1