Take damage & Summon packets

Fixed some oddities with other player clients when dealing with summons
(spawning, taking damage or attacking). Fixed damage dealt to player not
apearing if the player is a GM on hiding and other players in the area
are GMs as well.
This commit is contained in:
ronancpl
2017-07-04 15:54:32 -03:00
parent c2cbc96975
commit b3734cbaf7
58 changed files with 100 additions and 48 deletions
@@ -27,25 +27,28 @@ import client.MapleClient;
import client.SkillFactory;
import net.AbstractMaplePacketHandler;
import server.maps.MapleSummon;
import server.maps.MapleMapObject;
import tools.MaplePacketCreator;
import tools.data.input.SeekableLittleEndianAccessor;
public final class DamageSummonHandler extends AbstractMaplePacketHandler {
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
int skillid = slea.readInt(); //Bugged? might not be skillid.
int unkByte = slea.readByte();
int oid = slea.readInt();
slea.skip(1); // -1
int damage = slea.readInt();
int monsterIdFrom = slea.readInt();
if (SkillFactory.getSkill(skillid) != null) {
MapleCharacter player = c.getPlayer();
MapleSummon summon = player.getSummonByKey(skillid);
if (summon != null) {
summon.addHP(-damage);
if (summon.getHP() <= 0) {
player.cancelEffectFromBuffStat(MapleBuffStat.PUPPET);
}
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(), skillid, damage, unkByte, monsterIdFrom), summon.getPosition());
player.getMap().broadcastMessage(player, MaplePacketCreator.damageSummon(player.getId(), oid, damage, monsterIdFrom), summon.getPosition());
}
}
}