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());
}
}
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());
}
}
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);
}
}
}
Aggregations