Пример #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);
 }
Пример #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;
     }
   }
 }
Пример #3
0
 public void copy() {
   while (type.queue.get(ch).size() > 0
       && ChannelServer.getInstance(ch).getMapleSquad(type) == null) {
     int index = 0;
     long lowest = 0;
     for (int i = 0; i < type.queue.get(ch).size(); i++) {
       if (lowest == 0 || type.queue.get(ch).get(i).right < lowest) {
         index = i;
         lowest = type.queue.get(ch).get(i).right;
       }
     }
     final String nextPlayerId = type.queue.get(ch).remove(index).left;
     final int theirCh = World.Find.findChannel(nextPlayerId);
     if (theirCh > 0) {
       final MapleCharacter lead =
           ChannelServer.getInstance(theirCh).getPlayerStorage().getCharacterByName(nextPlayerId);
       if (lead != null && lead.getMapId() == beginMapId && lead.getClient().getChannel() == ch) {
         final MapleSquad squad = new MapleSquad(ch, type.name(), lead, expiration, toSay);
         if (ChannelServer.getInstance(ch).addMapleSquad(squad, type.name())) {
           getBeginMap().broadcastMessage(CField.getClock(expiration / 1000));
           getBeginMap().broadcastMessage(CWvsContext.serverNotice(6, nextPlayerId + toSay));
           type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Success"));
         } else {
           squad.clear();
           type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Skipped"));
         }
         break;
       } else {
         if (lead != null) {
           lead.dropMessage(
               6,
               "Your squad has been skipped due to you not being in the right channel and map.");
         }
         getBeginMap()
             .broadcastMessage(
                 CWvsContext.serverNotice(
                     6,
                     nextPlayerId
                         + "'s squad has been skipped due to the player not being in the right channel and map."));
         type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not in map"));
       }
     } else {
       getBeginMap()
           .broadcastMessage(
               CWvsContext.serverNotice(
                   6,
                   nextPlayerId
                       + "'s squad has been skipped due to the player not being online."));
       type.queuedPlayers.get(ch).add(new Pair<String, String>(nextPlayerId, "Not online"));
     }
   }
 }
Пример #4
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;
 }
Пример #5
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   c.removeClickedNPC();
   NPCScriptManager.getInstance().dispose(c);
   c.getSession().write(CWvsContext.enableActions());
   return 1;
 }
  public static void displayMerch(MapleClient c) {
    int conv = c.getPlayer().getConversation();
    boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId());
    MerchItemPackage pack;
    if (merch) {
      c.getPlayer().dropMessage(1, "Please close the existing store and try again.");
      c.getPlayer().setConversation(0);
    } else if (c.getChannelServer().isShutdown()) {
      c.getPlayer().dropMessage(1, "The world is going to shut down.");
      c.getPlayer().setConversation(0);
    } else if (conv == 3) {
      pack = loadItemFrom_Database(c.getPlayer().getAccountID());

      if (pack == null) {
        c.getPlayer().dropMessage(1, "You do not have any item(s) with Fredrick.");
        c.getPlayer().setConversation(0);
      } else if (pack.getItems().size() <= 0) {
        if (!check(c.getPlayer(), pack)) {
          c.getSession().write(PlayerShopPacket.merchItem_Message(33));
          return;
        }
        if (deletePackage(
            c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) {
          c.getPlayer().fakeRelog();
          c.getPlayer().gainMeso(pack.getMesos(), false);
          c.getSession().write(PlayerShopPacket.merchItem_Message(29));
          c.getPlayer().dropMessage(1, "You have retrieved your mesos.");
        } else {
          c.getPlayer().dropMessage(1, "An unknown error occured.");
        }
        c.getPlayer().setConversation(0);
      } else {
        c.getSession().write(PlayerShopPacket.merchItemStore_ItemData(pack));
        MapleInventoryManipulator.checkSpace(c, conv, conv, null);
        for (Item item : pack.getItems()) {
          if (c.getPlayer()
              .getInventory(GameConstants.getInventoryType(item.getItemId()))
              .isFull()) {
            c.removeClickedNPC();
            c.getPlayer().dropMessage(1, "Your inventory is full (Please relog)");
            break;
          }
          MapleInventoryManipulator.addFromDrop(c, item, true);
          deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId());

          c.removeClickedNPC();
        }
        c.getPlayer().dropMessage(1, "Items have been returned to you, please relog.");
      }
    }

    c.getSession().write(CWvsContext.enableActions());
  }
Пример #7
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;
 }
Пример #8
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   c.getPlayer()
       .dropMessage(
           6,
           "You currently have "
               + c.getPlayer().getCSPoints(1)
               + " Cash, "
               + c.getPlayer().getEPoints()
               + " Event Points, "
               + c.getPlayer().getDPoints()
               + " Donation Points, "
               + c.getPlayer().getVPoints()
               + " voting points and "
               + c.getPlayer().getIntNoRecord(GameConstants.BOSS_PQ)
               + " Boss Party Quest points.");
   c.getPlayer()
       .dropMessage(
           6,
           "The time is currently "
               + FileoutputUtil.CurrentReadable_TimeGMT()
               + " GMT. | EXP "
               + (Math.round(c.getPlayer().getEXPMod()) * 100)
                   * Math.round(c.getPlayer().getStat().expBuff / 100.0)
               + "%, Drop "
               + (Math.round(c.getPlayer().getDropMod()) * 100)
                   * Math.round(c.getPlayer().getStat().dropBuff / 100.0)
               + "%, Meso "
               + Math.round(c.getPlayer().getStat().mesoBuff / 100.0) * 100
               + "%");
   c.getPlayer()
       .dropMessage(6, "EXP: " + c.getPlayer().getExp() + " / " + c.getPlayer().getNeededExp());
   c.removeClickedNPC();
   NPCScriptManager.getInstance().dispose(c);
   c.getSession().write(CWvsContext.enableActions());
   return 1;
 }
Пример #9
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));
 }
Пример #10
0
 public static final void HandleAlliance(
     final LittleEndianAccessor slea, final MapleClient c, boolean denied) {
   if (c.getPlayer().getGuildId() <= 0) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   final MapleGuild gs = World.Guild.getGuild(c.getPlayer().getGuildId());
   if (gs == null) {
     c.getSession().write(CWvsContext.enableActions());
     return;
   }
   // System.out.println("Unhandled GuildAlliance \n" + slea.toString());
   byte op = slea.readByte();
   if (c.getPlayer().getGuildRank() != 1 && op != 1) { // only updating doesn't need guild leader
     return;
   }
   if (op == 22) {
     denied = true;
   }
   int leaderid = 0;
   if (gs.getAllianceId() > 0) {
     leaderid = World.Alliance.getAllianceLeader(gs.getAllianceId());
   }
   // accept invite, and deny invite don't need allianceid.
   if (op != 4 && !denied) {
     if (gs.getAllianceId() <= 0 || leaderid <= 0) {
       return;
     }
   } else if (leaderid > 0
       || gs.getAllianceId() > 0) { // infact, if they have allianceid it's suspicious
     return;
   }
   if (denied) {
     DenyInvite(c, gs);
     return;
   }
   MapleCharacter chr;
   int inviteid;
   switch (op) {
     case 1: // load... must be in world op
       for (byte[] pack : World.Alliance.getAllianceInfo(gs.getAllianceId(), false)) {
         if (pack != null) {
           c.getSession().write(pack);
         }
       }
       break;
     case 3: // invite
       final int newGuild = World.Guild.getGuildLeader(slea.readMapleAsciiString());
       if (newGuild > 0
           && c.getPlayer().getAllianceRank() == 1
           && leaderid == c.getPlayer().getId()) {
         chr = c.getChannelServer().getPlayerStorage().getCharacterById(newGuild);
         if (chr != null && chr.getGuildId() > 0 && World.Alliance.canInvite(gs.getAllianceId())) {
           chr.getClient()
               .getSession()
               .write(
                   AlliancePacket.sendAllianceInvite(
                       World.Alliance.getAlliance(gs.getAllianceId()).getName(), c.getPlayer()));
           World.Guild.setInvitedId(chr.getGuildId(), gs.getAllianceId());
         } else {
           c.getPlayer()
               .dropMessage(1, "Make sure the leader of the guild is online and in your channel.");
         }
       } else {
         c.getPlayer()
             .dropMessage(
                 1,
                 "That Guild was not found. Please enter the correct Guild Name. (Not the player name)");
       }
       break;
     case 4: // accept invite... guildid that invited(int, a/b check) -> guildname that was
             // invited? but we dont care about that
       inviteid = World.Guild.getInvitedId(c.getPlayer().getGuildId());
       if (inviteid > 0) {
         if (!World.Alliance.addGuildToAlliance(inviteid, c.getPlayer().getGuildId())) {
           c.getPlayer().dropMessage(5, "An error occured when adding guild.");
         }
         World.Guild.setInvitedId(c.getPlayer().getGuildId(), 0);
       }
       break;
     case 2: // leave; nothing
     case 6: // expel, guildid(int) -> allianceid(don't care, a/b check)
       final int gid;
       if (op == 6 && slea.available() >= 4) {
         gid = slea.readInt();
         if (slea.available() >= 4 && gs.getAllianceId() != slea.readInt()) {
           break;
         }
       } else {
         gid = c.getPlayer().getGuildId();
       }
       if (c.getPlayer().getAllianceRank() <= 2
           && (c.getPlayer().getAllianceRank() == 1 || c.getPlayer().getGuildId() == gid)) {
         if (!World.Alliance.removeGuildFromAlliance(
             gs.getAllianceId(), gid, c.getPlayer().getGuildId() != gid)) {
           c.getPlayer().dropMessage(5, "An error occured when removing guild.");
         }
       }
       break;
     case 7: // change leader
       if (c.getPlayer().getAllianceRank() == 1 && leaderid == c.getPlayer().getId()) {
         if (!World.Alliance.changeAllianceLeader(gs.getAllianceId(), slea.readInt())) {
           c.getPlayer().dropMessage(5, "An error occured when changing leader.");
         }
       }
       break;
     case 8: // title update
       if (c.getPlayer().getAllianceRank() == 1 && leaderid == c.getPlayer().getId()) {
         String[] ranks = new String[5];
         for (int i = 0; i < 5; i++) {
           ranks[i] = slea.readMapleAsciiString();
         }
         World.Alliance.updateAllianceRanks(gs.getAllianceId(), ranks);
       }
       break;
     case 9:
       if (c.getPlayer().getAllianceRank() <= 2) {
         if (!World.Alliance.changeAllianceRank(
             gs.getAllianceId(), slea.readInt(), slea.readByte())) {
           c.getPlayer().dropMessage(5, "An error occured when changing rank.");
         }
       }
       break;
     case 10: // notice update
       if (c.getPlayer().getAllianceRank() <= 2) {
         final String notice = slea.readMapleAsciiString();
         if (notice.length() > 100) {
           break;
         }
         World.Alliance.updateAllianceNotice(gs.getAllianceId(), notice);
       }
       break;
     default:
       System.out.println("Unhandled GuildAlliance op: " + op + ", \n" + slea.toString());
       break;
   }
   // c.getSession().write(CWvsContext.enableActions());
 }