Search in sources :

Example 1 with PetCommand

use of client.inventory.PetCommand in project HeavenMS by ronancpl.

the class PetCommandHandler method handlePacket.

@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
    MapleCharacter chr = c.getPlayer();
    int petId = slea.readInt();
    byte petIndex = chr.getPetIndex(petId);
    MaplePet pet;
    if (petIndex == -1) {
        return;
    } else {
        pet = chr.getPet(petIndex);
    }
    slea.readInt();
    slea.readByte();
    byte command = slea.readByte();
    PetCommand petCommand = PetDataFactory.getPetCommand(pet.getItemId(), (int) command);
    if (petCommand == null) {
        return;
    }
    if (Randomizer.nextInt(101) <= petCommand.getProbability()) {
        pet.gainClosenessFullness(chr, petCommand.getIncrease(), 0, command);
    } else {
        chr.getMap().broadcastMessage(MaplePacketCreator.commandResponse(chr.getId(), petIndex, command, false));
        if (chr.getMount() != null)
            chr.getMap().broadcastMessage(MaplePacketCreator.updateMount(chr.getId(), chr.getMount(), false));
    }
}
Also used : MapleCharacter(client.MapleCharacter) PetCommand(client.inventory.PetCommand) MaplePet(client.inventory.MaplePet)

Aggregations

MapleCharacter (client.MapleCharacter)1 MaplePet (client.inventory.MaplePet)1 PetCommand (client.inventory.PetCommand)1