Ejemplo n.º 1
0
 public static final void CurePot(final LittleEndianAccessor slea, final MapleClient c) {
   final int itemid = slea.readInt();
   final Item slot =
       c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((short) slea.readInt());
   if (slot == null
       || slot.getQuantity() <= 0
       || slot.getItemId() != itemid
       || itemid / 10000 != 434) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null
       || c.getPlayer().getImps()[index].getState() != 4) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getPlayer().getImps()[index].setState(1);
   c.getSession()
       .write(
           CWvsContext.updateImp(
               c.getPlayer().getImps()[index], ImpFlag.STATE.getValue(), index, false));
   MapleInventoryManipulator.removeFromSlot(
       c, MapleInventoryType.ETC, slot.getPosition(), (short) 1, false, false);
 }
Ejemplo n.º 2
0
 public static final void UsePot(final LittleEndianAccessor slea, final MapleClient c) {
   final int itemid = slea.readInt();
   final Item slot = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slea.readShort());
   if (slot == null
       || slot.getQuantity() <= 0
       || slot.getItemId() != itemid
       || itemid / 10000 != 244
       || MapleItemInformationProvider.getInstance().getPot(itemid) == null) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getSession().write(CWvsContext.enableActions());
   for (int i = 0; i < c.getPlayer().getImps().length; i++) {
     if (c.getPlayer().getImps()[i] == null) {
       c.getPlayer().getImps()[i] = new MapleImp(itemid);
       c.getSession()
           .write(
               CWvsContext.updateImp(
                   c.getPlayer().getImps()[i], ImpFlag.SUMMONED.getValue(), i, false));
       MapleInventoryManipulator.removeFromSlot(
           c, MapleInventoryType.USE, slot.getPosition(), (short) 1, false, false);
       return;
     }
   }
 }
Ejemplo n.º 3
0
 public static final void ClearPot(final LittleEndianAccessor slea, final MapleClient c) {
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   c.getSession()
       .write(
           CWvsContext.updateImp(
               c.getPlayer().getImps()[index], ImpFlag.REMOVED.getValue(), index, false));
   c.getPlayer().getImps()[index] = null;
 }
Ejemplo n.º 4
0
 public static final void RewardPot(final LittleEndianAccessor slea, final MapleClient c) {
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null
       || c.getPlayer().getImps()[index].getLevel()
           < (MapleItemInformationProvider.getInstance()
                   .getPot(c.getPlayer().getImps()[index].getItemId())
                   .right
               - 1)) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final int itemid =
       GameConstants.getRewardPot(
           c.getPlayer().getImps()[index].getItemId(),
           c.getPlayer().getImps()[index].getCloseness());
   if (itemid <= 0 || !MapleInventoryManipulator.checkSpace(c, itemid, (short) 1, "")) {
     c.getPlayer().dropMessage(1, "Please make some space.");
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   MapleInventoryManipulator.addById(
       c,
       itemid,
       (short) 1,
       "Item Pot from "
           + c.getPlayer().getImps()[index].getItemId()
           + " on "
           + FileoutputUtil.CurrentReadable_Date());
   c.getSession()
       .write(
           CWvsContext.updateImp(
               c.getPlayer().getImps()[index], ImpFlag.REMOVED.getValue(), index, false));
   c.getPlayer().getImps()[index] = null;
 }
Ejemplo n.º 5
0
 public static final void FeedPot(final LittleEndianAccessor slea, final MapleClient c) {
   final int itemid = slea.readInt();
   final Item slot =
       c.getPlayer()
           .getInventory(GameConstants.getInventoryType(itemid))
           .getItem((short) slea.readInt());
   if (slot == null || slot.getQuantity() <= 0 || slot.getItemId() != itemid) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final int level =
       GameConstants.getInventoryType(itemid) == MapleInventoryType.ETC
           ? MapleItemInformationProvider.getInstance().getItemMakeLevel(itemid)
           : MapleItemInformationProvider.getInstance().getReqLevel(itemid);
   if (level <= 0
       || level < (Math.min(120, c.getPlayer().getLevel()) - 50)
       || (GameConstants.getInventoryType(itemid) != MapleInventoryType.ETC
           && GameConstants.getInventoryType(itemid) != MapleInventoryType.EQUIP)) {
     c.getPlayer().dropMessage(1, "The item must be within 50 levels of you.");
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final int index = slea.readInt() - 1;
   if (index < 0
       || index >= c.getPlayer().getImps().length
       || c.getPlayer().getImps()[index] == null
       || c.getPlayer().getImps()[index].getLevel()
           >= (MapleItemInformationProvider.getInstance()
                   .getPot(c.getPlayer().getImps()[index].getItemId())
                   .right
               - 1)
       || c.getPlayer().getImps()[index].getState() != 1) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   int mask = ImpFlag.FULLNESS.getValue();
   mask |= ImpFlag.FULLNESS_2.getValue();
   mask |= ImpFlag.UPDATE_TIME.getValue();
   mask |= ImpFlag.AWAKE_TIME.getValue();
   // this is where the magic happens
   c.getPlayer()
       .getImps()[index]
       .setFullness(
           c.getPlayer().getImps()[index].getFullness()
               + (100
                   * (GameConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP
                       ? 2
                       : 1)));
   if (Randomizer.nextBoolean()) {
     mask |= ImpFlag.CLOSENESS.getValue();
     c.getPlayer()
         .getImps()[index]
         .setCloseness(
             c.getPlayer().getImps()[index].getCloseness()
                 + 1
                 + (Randomizer.nextInt(
                     5
                         * (GameConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP
                             ? 2
                             : 1))));
   } else if (Randomizer.nextInt(5) == 0) { // 1/10 chance of sickness
     c.getPlayer().getImps()[index].setState(4); // sick
     mask |= ImpFlag.STATE.getValue();
   }
   if (c.getPlayer().getImps()[index].getFullness() >= 1000) {
     c.getPlayer().getImps()[index].setState(1);
     c.getPlayer().getImps()[index].setFullness(0);
     c.getPlayer().getImps()[index].setLevel(c.getPlayer().getImps()[index].getLevel() + 1);
     mask |= ImpFlag.SUMMONED.getValue();
     if (c.getPlayer().getImps()[index].getLevel()
         >= (MapleItemInformationProvider.getInstance()
                 .getPot(c.getPlayer().getImps()[index].getItemId())
                 .right
             - 1)) {
       c.getPlayer().getImps()[index].setState(5);
     }
   }
   MapleInventoryManipulator.removeFromSlot(
       c, GameConstants.getInventoryType(itemid), slot.getPosition(), (short) 1, false, false);
   c.getSession().write(CWvsContext.updateImp(c.getPlayer().getImps()[index], mask, index, false));
 }