Search in sources :

Example 16 with MapleQuestStatus

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();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) ArrayList(java.util.ArrayList) Point(java.awt.Point) MapleMapItem(server.maps.MapleMapItem) SpecialCashItem(server.CashShop.SpecialCashItem) CashItem(server.CashShop.CashItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) MapleShopItem(server.MapleShopItem) MapleGuild(net.server.guild.MapleGuild) MapleAlliance(net.server.guild.MapleAlliance) MaplePet(client.inventory.MaplePet) MapleQuestStatus(client.MapleQuestStatus)

Aggregations

MapleQuestStatus (client.MapleQuestStatus)16 MapleQuest (server.quest.MapleQuest)2 Item (client.inventory.Item)1 MaplePet (client.inventory.MaplePet)1 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 MapleAlliance (net.server.guild.MapleAlliance)1 MapleGuild (net.server.guild.MapleGuild)1 CashItem (server.CashShop.CashItem)1 SpecialCashItem (server.CashShop.SpecialCashItem)1 MapleShopItem (server.MapleShopItem)1 MapleMapItem (server.maps.MapleMapItem)1 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)1 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)1