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 final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) { int objectid = slea.readInt(); short moveid = slea.readShort(); MapleMapObject mmo = c.getPlayer().getMap().getMapObject(objectid); if (mmo == null || mmo.getType() != MapleMapObjectType.MONSTER) { return; } MapleMonster monster = (MapleMonster) mmo; List<LifeMovementFragment> res = null; byte skillByte = slea.readByte(); byte skill = slea.readByte(); int skill_1 = slea.readByte() & 0xFF; byte skill_2 = slea.readByte(); byte skill_3 = slea.readByte(); slea.readByte(); slea.readLong(); // v88 change MobSkill toUse = null; if (skillByte == 1 && monster.getNoSkills() > 0) { int random = Randomizer.getInstance().nextInt(monster.getNoSkills()); Pair<Integer, Integer> skillToUse = monster.getSkills().get(random); toUse = MobSkillFactory.getMobSkill(skillToUse.getLeft(), skillToUse.getRight()); int percHpLeft = (monster.getHp() / monster.getMaxHp()) * 100; if (toUse.getHP() < percHpLeft || !monster.canUseSkill(toUse)) { toUse = null; } } if ((skill_1 >= 100 && skill_1 <= 200) && monster.hasSkill(skill_1, skill_2)) { MobSkill skillData = MobSkillFactory.getMobSkill(skill_1, skill_2); if (skillData != null && monster.canUseSkill(skillData)) { skillData.applyEffect(c.getPlayer(), monster, true); } } slea.readByte(); slea.readInt(); // whatever slea.skip(12); // v88 skip short start_x = slea.readShort(); // hmm.. startpos? short start_y = slea.readShort(); // hmm... slea.readInt(); // v88 skip Point startPos = new Point(start_x, start_y); res = parseMovement(slea); if (monster.getController() != c.getPlayer()) { if (monster.isAttackedBy(c.getPlayer())) { // aggro and controller change monster.switchController(c.getPlayer(), true); } else { return; } } else if (skill == -1 && monster.isControllerKnowsAboutAggro() && !monster.isMobile() && !monster.isFirstAttack()) { monster.setControllerHasAggro(false); monster.setControllerKnowsAboutAggro(false); } boolean aggro = monster.isControllerHasAggro(); if (toUse != null) { c.getSession() .write( MaplePacketCreator.moveMonsterResponse( objectid, moveid, monster.getMp(), aggro, toUse.getSkillId(), toUse.getSkillLevel())); } else { c.getSession() .write(MaplePacketCreator.moveMonsterResponse(objectid, moveid, monster.getMp(), aggro)); } if (aggro) { monster.setControllerKnowsAboutAggro(true); } if (res != null && slea.available() == 17) { c.getPlayer() .getMap() .broadcastMessage( c.getPlayer(), MaplePacketCreator.moveMonster( skillByte, skill, skill_1, skill_2, skill_3, objectid, startPos, res), monster.getPosition()); updatePosition(res, monster, -1); c.getPlayer().getMap().moveMonster(monster, monster.getPosition()); } }