Search in sources :

Example 1 with MapleDoorObject

use of server.maps.MapleDoorObject in project HeavenMS by ronancpl.

the class DoorHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    int ownerid = slea.readInt();
    // specifies if backwarp or not, 1 town to target, 0 target to town
    boolean mode = (slea.readByte() == 0);
    for (MapleMapObject obj : c.getPlayer().getMap().getMapObjects()) {
        if (obj instanceof MapleDoorObject) {
            MapleDoorObject door = (MapleDoorObject) obj;
            if (door.getOwnerId() == ownerid) {
                door.warp(c.getPlayer(), mode);
                return;
            }
        }
    }
}
Also used : MapleDoorObject(server.maps.MapleDoorObject) MapleMapObject(server.maps.MapleMapObject)

Example 2 with MapleDoorObject

use of server.maps.MapleDoorObject in project HeavenMS by ronancpl.

the class MaplePacketCreator method partyCreated.

public static byte[] partyCreated(MaplePartyCharacter partychar) {
    final MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
    mplew.writeShort(SendOpcode.PARTY_OPERATION.getValue());
    mplew.write(8);
    mplew.writeShort(0x8b);
    mplew.writeShort(1);
    if (partychar.getDoors().size() > 0) {
        boolean deployedPortal = false;
        for (MapleDoor door : partychar.getDoors()) {
            if (door.getOwnerId() == partychar.getId()) {
                MapleDoorObject mdo = door.getAreaDoor();
                mplew.writeInt(mdo.getTo().getId());
                mplew.writeInt(mdo.getFrom().getId());
                mplew.writeInt(mdo.getPosition().x);
                mplew.writeInt(mdo.getPosition().y);
                deployedPortal = true;
            }
        }
        if (!deployedPortal) {
            mplew.writeInt(999999999);
            mplew.writeInt(999999999);
            mplew.writeInt(0);
            mplew.writeInt(0);
        }
    } else {
        mplew.writeInt(999999999);
        mplew.writeInt(999999999);
        mplew.writeInt(0);
        mplew.writeInt(0);
    }
    return mplew.getPacket();
}
Also used : MaplePacketLittleEndianWriter(tools.data.output.MaplePacketLittleEndianWriter) MapleDoorObject(server.maps.MapleDoorObject) MapleDoor(server.maps.MapleDoor)

Example 3 with MapleDoorObject

use of server.maps.MapleDoorObject in project HeavenMS by ronancpl.

the class MaplePacketCreator method addPartyStatus.

private static void addPartyStatus(int forchannel, MapleParty party, LittleEndianWriter lew, boolean leaving) {
    List<MaplePartyCharacter> partymembers = new ArrayList<>(party.getMembers());
    while (partymembers.size() < 6) {
        partymembers.add(new MaplePartyCharacter());
    }
    for (MaplePartyCharacter partychar : partymembers) {
        lew.writeInt(partychar.getId());
    }
    for (MaplePartyCharacter partychar : partymembers) {
        lew.writeAsciiString(getRightPaddedStr(partychar.getName(), '\0', 13));
    }
    for (MaplePartyCharacter partychar : partymembers) {
        lew.writeInt(partychar.getJobId());
    }
    for (MaplePartyCharacter partychar : partymembers) {
        lew.writeInt(partychar.getLevel());
    }
    for (MaplePartyCharacter partychar : partymembers) {
        if (partychar.isOnline()) {
            lew.writeInt(partychar.getChannel() - 1);
        } else {
            lew.writeInt(-2);
        }
    }
    lew.writeInt(party.getLeader().getId());
    for (MaplePartyCharacter partychar : partymembers) {
        if (partychar.getChannel() == forchannel) {
            lew.writeInt(partychar.getMapId());
        } else {
            lew.writeInt(0);
        }
    }
    for (MaplePartyCharacter partychar : partymembers) {
        if (partychar.getChannel() == forchannel && !leaving) {
            if (partychar.getDoors().size() > 0) {
                boolean deployedPortal = false;
                for (MapleDoor door : partychar.getDoors()) {
                    if (door.getOwnerId() == partychar.getId()) {
                        MapleDoorObject mdo = door.getTownDoor();
                        lew.writeInt(mdo.getTown().getId());
                        lew.writeInt(mdo.getArea().getId());
                        lew.writeInt(mdo.getPosition().x);
                        lew.writeInt(mdo.getPosition().y);
                        deployedPortal = true;
                    }
                }
                if (!deployedPortal) {
                    lew.writeInt(999999999);
                    lew.writeInt(999999999);
                    lew.writeInt(0);
                    lew.writeInt(0);
                }
            } else {
                lew.writeInt(999999999);
                lew.writeInt(999999999);
                lew.writeInt(0);
                lew.writeInt(0);
            }
        } else {
            lew.writeInt(999999999);
            lew.writeInt(999999999);
            lew.writeInt(0);
            lew.writeInt(0);
        }
    }
}
Also used : MapleDoorObject(server.maps.MapleDoorObject) ArrayList(java.util.ArrayList) MaplePartyCharacter(net.server.world.MaplePartyCharacter) MapleDoor(server.maps.MapleDoor)

Aggregations

MapleDoorObject (server.maps.MapleDoorObject)3 MapleDoor (server.maps.MapleDoor)2 ArrayList (java.util.ArrayList)1 MaplePartyCharacter (net.server.world.MaplePartyCharacter)1 MapleMapObject (server.maps.MapleMapObject)1 MaplePacketLittleEndianWriter (tools.data.output.MaplePacketLittleEndianWriter)1