Search in sources :

Example 1 with MapleGuildSummary

use of net.server.guild.MapleGuildSummary in project HeavenMS by ronancpl.

the class MaplePacketCreator method spawnPlayerMapObject.

/**
 * Gets a packet spawning a player as a mapobject to other clients.
 *
 * @param chr The character to spawn to other clients.
 * @return The spawn player packet.
 */
public static byte[] spawnPlayerMapObject(MapleCharacter chr) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.SPAWN_PLAYER.getValue());
    mplew.writeInt(chr.getId());
    // v83
    mplew.write(chr.getLevel());
    mplew.writeMapleAsciiString(chr.getName());
    if (chr.getGuildId() < 1) {
        mplew.writeMapleAsciiString("");
        mplew.write(new byte[6]);
    } else {
        MapleGuildSummary gs = chr.getClient().getWorldServer().getGuildSummary(chr.getGuildId(), chr.getWorld());
        if (gs != null) {
            mplew.writeMapleAsciiString(gs.getName());
            mplew.writeShort(gs.getLogoBG());
            mplew.write(gs.getLogoBGColor());
            mplew.writeShort(gs.getLogo());
            mplew.write(gs.getLogoColor());
        } else {
            mplew.writeMapleAsciiString("");
            mplew.write(new byte[6]);
        }
    }
    mplew.writeInt(0);
    // v83
    mplew.writeShort(0);
    mplew.write(0xFC);
    mplew.write(1);
    if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
        mplew.writeInt(2);
    } else {
        mplew.writeInt(0);
    }
    long buffmask = 0;
    Integer buffvalue = null;
    if (chr.getBuffedValue(MapleBuffStat.DARKSIGHT) != null && !chr.isHidden()) {
        buffmask |= MapleBuffStat.DARKSIGHT.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.COMBO) != null) {
        buffmask |= MapleBuffStat.COMBO.getValue();
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.COMBO).intValue());
    }
    if (chr.getBuffedValue(MapleBuffStat.SHADOWPARTNER) != null) {
        buffmask |= MapleBuffStat.SHADOWPARTNER.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.SOULARROW) != null) {
        buffmask |= MapleBuffStat.SOULARROW.getValue();
    }
    if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.MORPH).intValue());
    }
    if (chr.getBuffedValue(MapleBuffStat.ENERGY_CHARGE) != null) {
        buffmask |= MapleBuffStat.ENERGY_CHARGE.getValue();
        buffvalue = Integer.valueOf(chr.getBuffedValue(MapleBuffStat.ENERGY_CHARGE).intValue());
    }
    // AREN'T THESE
    mplew.writeInt((int) ((buffmask >> 32) & 0xffffffffL));
    if (buffvalue != null) {
        if (chr.getBuffedValue(MapleBuffStat.MORPH) != null) {
            // TEST
            mplew.writeShort(buffvalue);
        } else {
            mplew.write(buffvalue.byteValue());
        }
    }
    mplew.writeInt((int) (buffmask & 0xffffffffL));
    int CHAR_MAGIC_SPAWN = Randomizer.nextInt();
    mplew.skip(6);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(11);
    // v74
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(11);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    mplew.write(0);
    final Item mount = chr.getInventory(MapleInventoryType.EQUIPPED).getItem((short) -18);
    if (chr.getBuffedValue(MapleBuffStat.MONSTER_RIDING) != null && mount != null) {
        mplew.writeInt(mount.getItemId());
        mplew.writeInt(1004);
    } else {
        mplew.writeLong(0);
    }
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(9);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    // actually not 0, why is it 0 then?
    mplew.writeInt(0);
    mplew.skip(10);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.skip(13);
    mplew.writeInt(CHAR_MAGIC_SPAWN);
    mplew.writeShort(0);
    mplew.write(0);
    mplew.writeShort(chr.getJob().getId());
    /* replace "mplew.writeShort(chr.getJob().getId())" with this snippet for 3rd person FJ animation on all classes
                if (chr.getJob().isA(MapleJob.HERMIT) || chr.getJob().isA(MapleJob.DAWNWARRIOR2) || chr.getJob().isA(MapleJob.NIGHTWALKER2)) {
			mplew.writeShort(chr.getJob().getId());
                } else {
			mplew.writeShort(412);
                }*/
    addCharLook(mplew, chr, false);
    mplew.writeInt(chr.getInventory(MapleInventoryType.CASH).countById(5110000));
    mplew.writeInt(chr.getItemEffect());
    mplew.writeInt(ItemConstants.getInventoryType(chr.getChair()) == MapleInventoryType.SETUP ? chr.getChair() : 0);
    mplew.writePos(chr.getPosition());
    mplew.write(chr.getStance());
    // chr.getFh()
    mplew.writeShort(0);
    mplew.write(0);
    MaplePet[] pet = chr.getPets();
    for (int i = 0; i < 3; i++) {
        if (pet[i] != null) {
            addPetInfo(mplew, pet[i], false);
        }
    }
    // end of pets
    mplew.write(0);
    if (chr.getMount() == null) {
        // mob level
        mplew.writeInt(1);
        // mob exp + tiredness
        mplew.writeLong(0);
    } else {
        mplew.writeInt(chr.getMount().getLevel());
        mplew.writeInt(chr.getMount().getExp());
        mplew.writeInt(chr.getMount().getTiredness());
    }
    MaplePlayerShop mps = chr.getPlayerShop();
    if (mps != null && mps.isOwner(chr)) {
        if (mps.hasFreeSlot()) {
            addAnnounceBox(mplew, mps, mps.getVisitors().length);
        } else {
            addAnnounceBox(mplew, mps, 1);
        }
    } else if (chr.getMiniGame() != null && chr.getMiniGame().isOwner(chr)) {
        if (chr.getMiniGame().hasFreeSlot()) {
            addAnnounceBox(mplew, chr.getMiniGame(), 1, 0, 1, 0);
        } else {
            addAnnounceBox(mplew, chr.getMiniGame(), 1, 0, 2, 1);
        }
    } else {
        mplew.write(0);
    }
    if (chr.getChalkboard() != null) {
        mplew.write(1);
        mplew.writeMapleAsciiString(chr.getChalkboard());
    } else {
        mplew.write(0);
    }
    // crush
    addRingLook(mplew, chr, true);
    // friendship
    addRingLook(mplew, chr, false);
    addMarriageRingLook(mplew, chr);
    // new year seems to crash sometimes...
    encodeNewYearCardInfo(mplew, chr);
    mplew.skip(2);
    // only needed in specific fields
    mplew.write(chr.getTeam());
    return mplew.getPacket();
}
Also used : MapleMapItem(server.maps.MapleMapItem) SpecialCashItem(server.CashShop.SpecialCashItem) CashItem(server.CashShop.CashItem) Item(client.inventory.Item) MaplePlayerShopItem(server.maps.MaplePlayerShopItem) MapleShopItem(server.MapleShopItem) MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MapleGuildSummary(net.server.guild.MapleGuildSummary) MaplePlayerShop(server.maps.MaplePlayerShop) MaplePet(client.inventory.MaplePet) Point(java.awt.Point)

Example 2 with MapleGuildSummary

use of net.server.guild.MapleGuildSummary in project HeavenMS by ronancpl.

the class World method getGuild.

public MapleGuild getGuild(MapleGuildCharacter mgc) {
    if (mgc == null)
        return null;
    int gid = mgc.getGuildId();
    MapleGuild g = Server.getInstance().getGuild(gid, mgc.getWorld(), mgc.getCharacter());
    if (gsStore.get(gid) == null) {
        gsStore.put(gid, new MapleGuildSummary(g));
    }
    return g;
}
Also used : MapleGuildSummary(net.server.guild.MapleGuildSummary) MapleGuild(net.server.guild.MapleGuild)

Example 3 with MapleGuildSummary

use of net.server.guild.MapleGuildSummary in project HeavenMS by ronancpl.

the class World method reloadGuildSummary.

public void reloadGuildSummary() {
    MapleGuild g;
    Server server = Server.getInstance();
    for (int i : gsStore.keySet()) {
        g = server.getGuild(i, getId(), null);
        if (g != null) {
            gsStore.put(i, new MapleGuildSummary(g));
        } else {
            gsStore.remove(i);
        }
    }
}
Also used : MapleGuildSummary(net.server.guild.MapleGuildSummary) Server(net.server.Server) MapleGuild(net.server.guild.MapleGuild)

Aggregations

MapleGuildSummary (net.server.guild.MapleGuildSummary)3 MapleGuild (net.server.guild.MapleGuild)2 Item (client.inventory.Item)1 MaplePet (client.inventory.MaplePet)1 Point (java.awt.Point)1 Server (net.server.Server)1 CashItem (server.CashShop.CashItem)1 SpecialCashItem (server.CashShop.SpecialCashItem)1 MapleShopItem (server.MapleShopItem)1 MapleMapItem (server.maps.MapleMapItem)1 MaplePlayerShop (server.maps.MaplePlayerShop)1 MaplePlayerShopItem (server.maps.MaplePlayerShopItem)1 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)1