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