public static byte[] damageFriendlyMob(MapleMonster mob, long damage, boolean display) { if (ServerProperties.ShowPacket()) { System.out.println("调用: " + new java.lang.Throwable().getStackTrace()[0]); } MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.DAMAGE_MONSTER.getValue()); mplew.writeInt(mob.getObjectId()); mplew.write(display ? 1 : 2); if (damage > 2147483647L) { mplew.writeInt(2147483647); } else { mplew.writeInt((int) damage); } if (mob.getHp() > 2147483647L) { mplew.writeInt((int) (mob.getHp() / mob.getMobMaxHp() * 2147483647.0D)); } else { mplew.writeInt((int) mob.getHp()); } if (mob.getMobMaxHp() > 2147483647L) { mplew.writeInt(2147483647); } else { mplew.writeInt((int) mob.getMobMaxHp()); } return mplew.getPacket(); }
public static byte[] getNodeProperties(MapleMonster objectid, MapleMap map) { if (objectid.getNodePacket() != null) { return objectid.getNodePacket(); } if (ServerProperties.ShowPacket()) { System.out.println("调用: " + new java.lang.Throwable().getStackTrace()[0]); } MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.MONSTER_PROPERTIES.getValue()); mplew.writeInt(objectid.getObjectId()); mplew.writeInt(map.getNodes().size()); mplew.writeInt(objectid.getPosition().x); mplew.writeInt(objectid.getPosition().y); for (MapleNodes.MapleNodeInfo mni : map.getNodes()) { mplew.writeInt(mni.x); mplew.writeInt(mni.y); mplew.writeInt(mni.attr); if (mni.attr == 2) { mplew.writeInt(500); } } mplew.writeZero(6); objectid.setNodePacket(mplew.getPacket()); return objectid.getNodePacket(); }
public static byte[] applyMonsterPoisonStatus(MapleMonster mons, List<MonsterStatusEffect> mse) { if (ServerProperties.ShowPacket()) { System.out.println("调用: " + new java.lang.Throwable().getStackTrace()[0]); } if ((mse.size() <= 0) || (mse.get(0) == null)) { return MaplePacketCreator.enableActions(); } MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.APPLY_MONSTER_STATUS.getValue()); mplew.writeInt(mons.getObjectId()); MonsterStatusEffect ms = (MonsterStatusEffect) mse.get(0); if (ms.getStati() == MonsterStatus.中毒) { PacketHelper.writeMonsterStatusMask(mplew, MonsterStatus.持续掉血); mplew.write(mse.size()); for (MonsterStatusEffect m : mse) { mplew.writeInt(m.getFromID()); if (m.isMonsterSkill()) { mplew.writeShort(m.getMobSkill().getSkillId()); mplew.writeShort(m.getMobSkill().getSkillLevel()); } else if (m.getSkill() > 0) { mplew.writeInt(m.getSkill()); } mplew.writeInt(m.getX()); mplew.writeInt(1000); mplew.writeInt(0); mplew.writeInt(10000); mplew.writeInt((int) (m.getDotTime() / 1000L)); mplew.writeInt(0); } mplew.writeShort(1000); mplew.write(1); } else { PacketHelper.writeSingleMask(mplew, ms.getStati()); mplew.writeInt(ms.getX()); if (ms.isMonsterSkill()) { mplew.writeShort(ms.getMobSkill().getSkillId()); mplew.writeShort(ms.getMobSkill().getSkillLevel()); } else if (ms.getSkill() > 0) { mplew.writeInt(ms.getSkill()); } mplew.writeShort(0); mplew.writeShort(0); mplew.write(1); mplew.write(1); } return mplew.getPacket(); }
public static byte[] applyMonsterStatus(MapleMonster mons, MonsterStatusEffect ms) { MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.APPLY_MONSTER_STATUS.getValue()); mplew.writeInt(mons.getObjectId()); PacketHelper.writeMonsterStatusMask(mplew, ms.getStati()); mplew.writeShort(ms.getX()); if (ms.isMonsterSkill()) { mplew.writeShort(ms.getMobSkill().getSkillId()); mplew.writeShort(ms.getMobSkill().getSkillLevel()); } else if (ms.getSkill() > 0) { mplew.writeInt(ms.getSkill()); } mplew.writeShort(100); mplew.writeShort(1); // delay in ms return mplew.getPacket(); }
public static byte[] controlMonster(MapleMonster life, boolean newSpawn, boolean aggro) { MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.SPAWN_MONSTER_CONTROL.getValue()); mplew.write(aggro ? 2 : 1); mplew.writeInt(life.getObjectId()); mplew.writeInt(life.getId()); mplew.writePos(life.getTruePosition()); mplew.write(2); mplew.writeShort(life.getFh()); mplew.write(life.getStance()); mplew.write(newSpawn ? -2 : life.isFake() ? -4 : -1); mplew.write(0); mplew.writeLong(0); return mplew.getPacket(); }
/** * 召唤怪物 * * @param life * @param spawnType * @param link * @return */ public static byte[] spawnMonster(MapleMonster life, int spawnType, int link) { MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter(); mplew.write(SendPacketOpcode.SPAWN_MONSTER.getValue()); mplew.writeInt(life.getObjectId()); mplew.writeInt(life.getId()); mplew.writePos(life.getTruePosition()); mplew.write((life.getController() != null ? 0x08 : 0x02)); mplew.writeShort(life.getFh()); mplew.write(life.getStance()); // if (effect > 0) { // mplew.write(effect); // mplew.writeInt(life.getObjectId()); // } mplew.write(spawnType); mplew.write(1); // 召唤的时候特效,在wz中有对应的值 mplew.writeLong(0); return mplew.getPacket(); }
public static void SummonAttack( final LittleEndianAccessor slea, final MapleClient c, final MapleCharacter chr) { if (chr == null || !chr.isAlive() || chr.getMap() == null) { return; } final MapleMap map = chr.getMap(); final MapleMapObject obj = map.getMapObject(slea.readInt(), MapleMapObjectType.SUMMON); if (obj == null || !(obj instanceof MapleSummon)) { chr.dropMessage(5, "The summon has disappeared."); return; } final MapleSummon summon = (MapleSummon) obj; if (summon.getOwnerId() != chr.getId() || summon.getSkillLevel() <= 0) { chr.dropMessage(5, "Error."); return; } final SummonSkillEntry sse = SkillFactory.getSummonData(summon.getSkill()); if (summon.getSkill() / 1000000 != 35 && summon.getSkill() != 33101008 && sse == null) { chr.dropMessage(5, "Error in processing attack."); return; } if (!GameConstants.GMS) { slea.skip(8); } int tick = slea.readInt(); if (sse != null && sse.delay > 0) { chr.updateTick(tick); // summon.CheckSummonAttackFrequency(chr, tick); // chr.getCheatTracker().checkSummonAttack(); } if (!GameConstants.GMS) { slea.skip(8); } final byte animation = slea.readByte(); if (!GameConstants.GMS) { slea.skip(8); } final byte numAttacked = slea.readByte(); if (sse != null && numAttacked > sse.mobCount) { chr.dropMessage(5, "Warning: Attacking more monster than summon can do"); chr.getCheatTracker().registerOffense(CheatingOffense.SUMMON_HACK_MOBS); // AutobanManager.getInstance().autoban(c, "Attacking more monster that summon can do (Skillid // : "+summon.getSkill()+" Count : " + numAttacked + ", allowed : " + sse.mobCount + ")"); return; } slea.skip(summon.getSkill() == 35111002 ? 24 : 12); // some pos stuff final List<Pair<Integer, Integer>> allDamage = new ArrayList<Pair<Integer, Integer>>(); for (int i = 0; i < numAttacked; i++) { final MapleMonster mob = map.getMonsterByOid(slea.readInt()); if (mob == null) { continue; } slea.skip(22); // who knows final int damge = slea.readInt(); allDamage.add(new Pair<Integer, Integer>(mob.getObjectId(), damge)); } // if (!summon.isChangedMap()) { map.broadcastMessage( chr, SummonPacket.summonAttack( summon.getOwnerId(), summon.getObjectId(), animation, allDamage, chr.getLevel(), false), summon.getTruePosition()); // } final Skill summonSkill = SkillFactory.getSkill(summon.getSkill()); final MapleStatEffect summonEffect = summonSkill.getEffect(summon.getSkillLevel()); if (summonEffect == null) { chr.dropMessage(5, "Error in attack."); return; } for (Pair<Integer, Integer> attackEntry : allDamage) { final int toDamage = attackEntry.right; final MapleMonster mob = map.getMonsterByOid(attackEntry.left); if (mob == null) { continue; } if (sse != null && sse.delay > 0 && summon.getMovementType() != SummonMovementType.STATIONARY && summon.getMovementType() != SummonMovementType.CIRCLE_STATIONARY && summon.getMovementType() != SummonMovementType.WALK_STATIONARY && chr.getTruePosition().distanceSq(mob.getTruePosition()) > 400000.0) { // chr.getCheatTracker().registerOffense(CheatingOffense.ATTACK_FARAWAY_MONSTER_SUMMON); } if (toDamage > 0 && summonEffect.getMonsterStati().size() > 0) { if (summonEffect.makeChanceResult()) { for (Map.Entry<MonsterStatus, Integer> z : summonEffect.getMonsterStati().entrySet()) { mob.applyStatus( chr, new MonsterStatusEffect(z.getKey(), z.getValue(), summonSkill.getId(), null, false), summonEffect.isPoison(), 4000, true, summonEffect); } } } if (chr.isGM() || toDamage < (chr.getStat().getCurrentMaxBaseDamage() * 5.0 * (summonEffect.getSelfDestruction() + summonEffect.getDamage() + chr.getStat().getDamageIncrease(summonEffect.getSourceId())) / 100.0)) { // 10 x dmg.. eh mob.damage(chr, toDamage, true); chr.checkMonsterAggro(mob); if (!mob.isAlive()) { chr.getClient().getSession().write(MobPacket.killMonster(mob.getObjectId(), 1)); } } else { chr.dropMessage(5, "Warning - high damage."); // AutobanManager.getInstance().autoban(c, "High Summon Damage (" + toDamage + " to " + // attackEntry.right + ")"); // TODO : Check player's stat for damage checking. break; } } if (!summon.isMultiAttack()) { chr.getMap().broadcastMessage(SummonPacket.removeSummon(summon, true)); chr.getMap().removeMapObject(summon); chr.removeVisibleMapObject(summon); chr.removeSummon(summon); if (summon.getSkill() != 35121011) { chr.cancelEffectFromBuffStat(MapleBuffStat.SUMMON); } } }