use of client.MapleQuestStatus in project HeavenMS by ronancpl.
the class MaplePacketCreator method charInfo.
/**
* @param chr
* @param isSelf
* @return
*/
public static byte[] charInfo(MapleCharacter chr) {
// 3D 00 0A 43 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
mplew.writeShort(SendOpcode.CHAR_INFO.getValue());
mplew.writeInt(chr.getId());
mplew.write(chr.getLevel());
mplew.writeShort(chr.getJob().getId());
mplew.writeShort(chr.getFame());
mplew.write(chr.getMarriageRing() != null ? 1 : 0);
String guildName = "";
String allianceName = "";
if (chr.getGuildId() > 0) {
MapleGuild mg = Server.getInstance().getGuild(chr.getGuildId());
guildName = mg.getName();
MapleAlliance alliance = Server.getInstance().getAlliance(chr.getGuild().getAllianceId());
if (alliance != null) {
allianceName = alliance.getName();
}
}
mplew.writeMapleAsciiString(guildName);
// does not seems to work
mplew.writeMapleAsciiString(allianceName);
mplew.write(0);
MaplePet[] pets = chr.getPets();
Item inv = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -114);
for (int i = 0; i < 3; i++) {
if (pets[i] != null) {
mplew.write(pets[i].getUniqueId());
// petid
mplew.writeInt(pets[i].getItemId());
mplew.writeMapleAsciiString(pets[i].getName());
// pet level
mplew.write(pets[i].getLevel());
// pet closeness
mplew.writeShort(pets[i].getCloseness());
// pet fullness
mplew.write(pets[i].getFullness());
mplew.writeShort(0);
mplew.writeInt(inv != null ? inv.getItemId() : 0);
}
}
// end of pets
mplew.write(0);
// mounts can potentially crash the client if the player's level is not properly checked
Item mount;
if (chr.getMount() != null && (mount = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -18)) != null && MapleItemInformationProvider.getInstance().getEquipStats(mount.getItemId()).get("reqLevel") <= chr.getLevel()) {
// mount
mplew.write(chr.getMount().getId());
// level
mplew.writeInt(chr.getMount().getLevel());
// exp
mplew.writeInt(chr.getMount().getExp());
// tiredness
mplew.writeInt(chr.getMount().getTiredness());
} else {
mplew.write(0);
}
mplew.write(chr.getCashShop().getWishList().size());
for (int sn : chr.getCashShop().getWishList()) {
mplew.writeInt(sn);
}
mplew.writeInt(chr.getMonsterBook().getBookLevel());
mplew.writeInt(chr.getMonsterBook().getNormalCard());
mplew.writeInt(chr.getMonsterBook().getSpecialCard());
mplew.writeInt(chr.getMonsterBook().getTotalCards());
mplew.writeInt(chr.getMonsterBookCover() > 0 ? MapleItemInformationProvider.getInstance().getCardMobId(chr.getMonsterBookCover()) : 0);
Item medal = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -49);
if (medal != null) {
mplew.writeInt(medal.getItemId());
} else {
mplew.writeInt(0);
}
ArrayList<Short> medalQuests = new ArrayList<>();
List<MapleQuestStatus> completed = chr.getCompletedQuests();
for (MapleQuestStatus q : completed) {
if (q.getQuest().getId() >= 29000) {
// && q.getQuest().getId() <= 29923
medalQuests.add(q.getQuest().getId());
}
}
Collections.sort(medalQuests);
mplew.writeShort(medalQuests.size());
for (Short s : medalQuests) {
mplew.writeShort(s);
}
return mplew.getPacket();
}
Aggregations