예제 #1
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;
     }
   }
 }
  public static final boolean UseHiredMerchant(MapleClient c, boolean packet) {
    if ((c.getPlayer().getMap() != null) && (c.getPlayer().getMap().allowPersonalShop())) {
      byte state = checkExistance(c.getPlayer().getAccountID(), c.getPlayer().getId());

      switch (state) {
        case 1:
          c.getPlayer().dropMessage(1, "Please claim your items from Fredrick first.");
          break;
        case 0:
          boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId());
          if (!merch) {
            if (c.getChannelServer().isShutdown()) {
              c.getPlayer().dropMessage(1, "The server is about to shut down.");
              return false;
            }
            if (packet) {
              c.getSession().write(PlayerShopPacket.sendTitleBox());
            }
            return true;
          }
          c.getPlayer().dropMessage(1, "Please close the existing store and try again.");

          break;
        default:
          c.getPlayer().dropMessage(1, "An unknown error occured.");
      }
    } else {
      c.getSession().close(true);
    }
    return false;
  }
예제 #3
0
 public void end(MapleClient c, short questid, int npc) {
   MapleQuest quest = MapleQuest.getInstance(questid);
   if (!c.getPlayer().getQuest(quest).getStatus().equals(MapleQuestStatus.Status.STARTED)
       || !c.getPlayer().getMap().containsNPC(npc)) {
     dispose(c);
     return;
   }
   try {
     QuestActionManager qm = new QuestActionManager(c, questid, npc, false);
     if (qms.containsKey(c)) {
       return;
     }
     if (c.canClickNPC()) {
       qms.put(c, qm);
       Invocable iv = getInvocable("quest/" + questid + ".js", c);
       if (iv == null) {
         qm.dispose();
         return;
       }
       engine.put("qm", qm);
       scripts.put(c, iv);
       c.setClickedNPC();
       iv.invokeFunction("end", (byte) 1, (byte) 0, 0);
     }
   } catch (final UndeclaredThrowableException ute) {
     FilePrinter.printError(FilePrinter.QUEST + questid + ".txt", ute);
     dispose(c);
   } catch (final Throwable t) {
     FilePrinter.printError(FilePrinter.QUEST + getQM(c).getQuest() + ".txt", t);
     dispose(c);
   }
 }
 @Override
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   if (c.getPlayer().getEnergyBar() == 15000
       || c.getPlayer().getBuffedValue(MapleBuffStat.BODY_PRESSURE) != null) {
     applyAttack(parseDamage(slea, c.getPlayer(), false), c.getPlayer(), 1);
   }
 }
예제 #5
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);
 }
 public static boolean checkSpace(
     final MapleClient c, final int Id, int quantity, final String owner) {
   final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   final MapleInventoryType type = ii.getInventoryType(Id);
   if (!type.equals(MapleInventoryType.EQUIP)) {
     final short slotMax = ii.getSlotMax(c, Id);
     final List<IItem> existing = c.getPlayer().getInventory(type).listById(Id);
     if (!InventoryConstants.isRechargable(Id)) {
       if (existing.size() > 0) {
         for (IItem eItem : existing) {
           final short oldQ = eItem.getQuantity();
           if (oldQ < slotMax && owner.equals(eItem.getOwner())) {
             final short newQ = (short) Math.min(oldQ + quantity, slotMax);
             quantity -= (newQ - oldQ);
           }
           if (quantity <= 0) {
             break;
           }
         }
       }
     }
     final int numSlotsNeeded;
     if (slotMax > 0) {
       numSlotsNeeded = (int) (Math.ceil(((double) quantity) / slotMax));
     } else if (InventoryConstants.isRechargable(Id)) {
       numSlotsNeeded = 1;
     } else {
       numSlotsNeeded = 1;
       System.out.println("checkSpace error");
     }
     return !c.getPlayer().getInventory(type).isFull(numSlotsNeeded - 1);
   } else {
     return !c.getPlayer().getInventory(type).isFull();
   }
 }
예제 #7
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (c.getPlayer().isInBlockedMap() || c.getPlayer().hasBlockedInventory()) {
     c.getPlayer().dropMessage(5, "You may not use this command here.");
     return 0;
   }
   NPCScriptManager.getInstance().start(c, 9000000, null);
   return 1;
 }
예제 #8
0
 @Override
 public void sendSpawnData(final MapleClient client) {
   if (questid <= 0
       || (client.getPlayer().getQuestStatus(questid) == 1
           && client.getPlayer().needQuestItem(questid, item.getItemId()))) {
     client.announce(
         MaplePacketCreator.dropItemFromMapObject(this, null, getPosition(), (byte) 2));
   }
 }
예제 #9
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (c.getPlayer().卡图 == c.getPlayer().getMapId() && c.getPlayer().getMapId() / 1000000 != 4) {
     c.getPlayer().changeMap(100000000, 0);
   } else {
     c.getPlayer().dropMessage(1, "你没有卡图啊。");
   }
   return 1;
 }
예제 #10
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (splitted.length < 2) {
     c.getPlayer().dropMessage(6, splitted[0] + " <金额>");
     return 0;
   }
   c.getPlayer().gainMeso(Long.parseLong(splitted[1]), true);
   return 1;
 }
예제 #11
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   for (final ChannelServer cserv : ChannelServer.getAllInstances()) {
     cserv.broadcastGMMessage(
         MaplePacketCreator.multiChat(
             "[管理员帮助] " + c.getPlayer().getName(), StringUtil.joinStringFrom(splitted, 1), 0));
   }
   c.getPlayer().dropMessage(5, "你的消息已经发送成功");
   return 1;
 }
예제 #12
0
 public void autobanDamage(MapleClient c, String reason) {
   if (c.getPlayer() == null) {
     return;
   }
   if (c.getPlayer().isGM()) {
     c.getPlayer().dropMessage(5, new StringBuilder().append("[警告] : ").append(reason).toString());
   } else {
     c.getPlayer().sendPolice(new StringBuilder().append("[警告] : ").append(reason).toString());
   }
 }
예제 #13
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   c.getPlayer()
       .setExp(
           c.getPlayer().getExp() - GameConstants.getExpNeededForLevel(c.getPlayer().getLevel())
                   >= 0
               ? GameConstants.getExpNeededForLevel(c.getPlayer().getLevel())
               : 0);
   return 1;
 }
예제 #14
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   for (final ChannelServer cserv : ChannelServer.getAllInstances()) {
     cserv.broadcastGMMessage(
         tools.packet.CField.multiChat(
             "[GM Help] " + c.getPlayer().getName(), StringUtil.joinStringFrom(splitted, 1), 6));
   }
   c.getPlayer().dropMessage(5, "Your message had been sent successfully.");
   return 1;
 }
예제 #15
0
  public void addPoints(MapleClient c, int points, long expiration, String reason) {
    this.lock.lock();
    try {
      int acc = c.getPlayer().getAccountID();

      if (this.points.containsKey(acc)) {
        int SavedPoints = (this.points.get(Integer.valueOf(acc)));
        if (SavedPoints >= AUTOBAN_POINTS) {
          return;
        }
        this.points.put(acc, SavedPoints + points);
        List reasonList = (List) this.reasons.get(Integer.valueOf(acc));
        reasonList.add(reason);
      } else {
        this.points.put(acc, points);
        List reasonList = new LinkedList();
        reasonList.add(reason);
        this.reasons.put(acc, reasonList);
      }

      if ((this.points.get(acc)) >= AUTOBAN_POINTS) {
        System.out.println(
            new StringBuilder()
                .append("[作弊] 玩家 ")
                .append(c.getPlayer().getName())
                .append(" A/b 触发 ")
                .append(reason)
                .toString());
        if (c.getPlayer().isGM()) {
          c.getPlayer()
              .dropMessage(
                  5, new StringBuilder().append("[警告] A/b 触发 : ").append(reason).toString());
          return;
        }
        StringBuilder sb = new StringBuilder("A/b ");
        sb.append(c.getPlayer().getName());
        sb.append(" (IP ");
        sb.append(c.getSession().getRemoteAddress().toString());
        sb.append("): ");
        for (String s : reasons.get(acc)) {
          sb.append(s);
          sb.append(", ");
        }
        //
        // WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.serverNotice(0,
        // new StringBuilder().append(" <").append(c.getPlayer().getName()).append("> 被系统封号 (原因:
        // ").append(reason).append(")").toString()));
      } else if (expiration > 0L) {
        this.expirations.add(
            new ExpirationEntry(System.currentTimeMillis() + expiration, acc, points));
      }
    } finally {
      this.lock.unlock();
    }
  }
예제 #16
0
 public void autoban(MapleClient c, String reason) {
   if (c.getPlayer() == null) {
     return;
   }
   if (c.getPlayer().isGM()) {
     c.getPlayer()
         .dropMessage(5, new StringBuilder().append("[警告] A/b 触发: ").append(reason).toString());
     return;
   }
   addPoints(c, AUTOBAN_POINTS, 0L, reason);
 }
 public static final void MerchantItemStore(LittleEndianAccessor slea, MapleClient c) {
   if (c.getPlayer() == null) {
     return;
   }
   byte operation = slea.readByte();
   if ((operation == 27) || (operation == 28)) {
     requestItems(c, operation == 27);
   } else if (operation == 30) {
     c.getPlayer().setConversation(0);
   }
 }
예제 #18
0
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int itemId = slea.readInt();
   if (c.getPlayer().getInventory(MapleInventoryType.SETUP).findById(itemId) == null) {
     return;
   }
   c.getPlayer().setChair(itemId);
   c.getPlayer()
       .getMap()
       .broadcastMessage(
           c.getPlayer(), MaplePacketCreator.showChair(c.getPlayer().getId(), itemId), false);
   c.announce(MaplePacketCreator.enableActions());
 }
예제 #19
0
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   if (!c.getPlayer().isAlive()) {
     c.announce(MaplePacketCreator.enableActions());
     return;
   }
   slea.readInt();
   byte slot = (byte) slea.readShort();
   int itemId = slea.readInt();
   MapleCharacter player = c.getPlayer();
   IItem toUse = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slot);
   if (toUse != null && toUse.getQuantity() == 1) {
     if (toUse.getItemId() != itemId) {
       return;
     }
     Map<String, Integer> skilldata =
         MapleItemInformationProvider.getInstance()
             .getSkillStats(toUse.getItemId(), c.getPlayer().getJob().getId());
     boolean canuse = false;
     boolean success = false;
     int skill = 0;
     int maxlevel = 0;
     if (skilldata == null) {
       return;
     }
     if (skilldata.get("skillid") == 0) {
       canuse = false;
     } else if (player.getMasterLevel(SkillFactory.getSkill(skilldata.get("skillid")))
             >= skilldata.get("reqSkillLevel")
         || skilldata.get("reqSkillLevel") == 0) {
       canuse = true;
       if (Randomizer.nextInt(101) < skilldata.get("success") && skilldata.get("success") != 0) {
         success = true;
         ISkill skill2 = SkillFactory.getSkill(skilldata.get("skillid"));
         player.changeSkillLevel(
             skill2,
             player.getSkillLevel(skill2),
             Math.max(skilldata.get("masterLevel"), player.getMasterLevel(skill2)),
             -1);
       } else {
         success = false;
         player.message(
             "The skill book lights up, but the skill winds up as if nothing happened.");
       }
       MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short) 1, false);
     } else {
       canuse = false;
     }
     player
         .getClient()
         .announce(MaplePacketCreator.skillBookSuccess(player, skill, maxlevel, canuse, success));
   }
 }
예제 #20
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (c.getPlayer().isInBlockedMap() || c.getPlayer().hasBlockedInventory()) {
     c.getPlayer().dropMessage(5, "You may not use this command here.");
     return 0;
   } else if (c.getPlayer().getLevel() < 30) {
     c.getPlayer().dropMessage(5, "You need to be at least lvl 30 in order to advance.");
     return 0;
   } else {
     NPCScriptManager.getInstance().start(c, 2300001, null);
     return 1;
   }
 }
예제 #21
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;
 }
예제 #22
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (splitted.length < 3) {
     c.getPlayer().dropMessage(6, splitted[0] + " <怪物ID> <数量>");
     return 0;
   }
   int mobid = Integer.parseInt(splitted[1]);
   int mobTime = Integer.parseInt(splitted[2]);
   MapleMonster npc;
   try {
     npc = MapleLifeFactory.getMonster(mobid);
   } catch (RuntimeException e) {
     c.getPlayer().dropMessage(5, "错误: " + e.getMessage());
     return 0;
   }
   if (npc != null) {
     final int xpos = c.getPlayer().getPosition().x;
     final int ypos = c.getPlayer().getPosition().y;
     final int fh =
         c.getPlayer().getMap().getFootholds().findBelow(c.getPlayer().getPosition()).getId();
     npc.setPosition(c.getPlayer().getPosition());
     npc.setCy(ypos);
     npc.setRx0(xpos);
     npc.setRx1(xpos);
     npc.setFh(fh);
     c.getPlayer().getMap().addMonsterSpawn(npc, mobTime, (byte) -1, null);
     c.getPlayer().dropMessage(6, "请不要重载此地图, 否则服务器重启后怪物会消失");
   } else {
     c.getPlayer().dropMessage(6, "你输入了一个无效的怪物ID");
     return 0;
   }
   return 1;
 }
 private static final void dropItem(MapleClient c, IItem target, Point dropPos) {
   if (MapleItemInformationProvider.getInstance().isDropRestricted(target.getId())
       || c.getPlayer().gmLevel() == 1
       || c.getPlayer().gmLevel() == 2) {
     c.getPlayer()
         .getMap()
         .disappearingItemDrop(
             c.getPlayer().getObjectId(),
             c.getPlayer().getPosition(),
             c.getPlayer(),
             target,
             dropPos);
   } else {
     c.getPlayer()
         .getMap()
         .spawnItemDrop(
             c.getPlayer().getObjectId(),
             c.getPlayer().getPosition(),
             c.getPlayer(),
             target,
             dropPos,
             true,
             !c.getPlayer().getMap().getEverlast());
   }
 }
예제 #24
0
 @Override
 public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   int id = slea.readShort();
   if (id == -1) { // Cancel Chair
     c.getPlayer().setChair(0);
     c.announce(MaplePacketCreator.cancelChair(-1));
     c.getPlayer()
         .getMap()
         .broadcastMessage(
             c.getPlayer(), MaplePacketCreator.showChair(c.getPlayer().getId(), 0), false);
   } else { // Use In-Map Chair
     c.getPlayer().setChair(id);
     c.announce(MaplePacketCreator.cancelChair(id));
   }
 }
 public static void removeFromSlot(
     final MapleClient c,
     final MapleInventoryType type,
     final short slot,
     final short quantity,
     final boolean fromDrop,
     final boolean consume) {
   final IItem item = c.getPlayer().getInventory(type).getItem(slot);
   final boolean allowZero = consume && InventoryConstants.isRechargable(item.getId());
   c.getPlayer().getInventory(type).removeItem(slot, quantity, allowZero);
   if (item.getQuantity() == 0 && !allowZero) {
     c.announce(InventoryFactory.clearInventoryItem(type, item.getPosition(), fromDrop));
   } else {
     c.announce(InventoryFactory.updateInventorySlot(type, (Item) item, fromDrop));
   }
 }
예제 #26
0
 @Override
 public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
   MapleCharacter player = c.getPlayer();
   if (player.getJob().equals(MapleJob.LEGEND)
       || player.getJob().equals(MapleJob.ARAN1)
       || player.getJob().equals(MapleJob.ARAN2)
       || player.getJob().equals(MapleJob.ARAN3)
       || player.getJob().equals(MapleJob.ARAN4)) {
     final long currentTime = System.currentTimeMillis();
     short combo = player.getCombo();
     if ((currentTime - player.getLastCombo()) > 3000 && combo > 0) {
       combo = 0;
       player.cancelEffectFromBuffStat(MapleBuffStat.ARAN_COMBO);
     }
     combo++;
     switch (combo) {
       case 10:
       case 20:
       case 30:
       case 40:
       case 50:
       case 60:
       case 70:
       case 80:
       case 90:
       case 100:
         SkillFactory.getSkill(21000000).getEffect(combo / 10).applyComboBuff(player, combo);
         break;
     }
     player.setLastCombo(currentTime);
     player.setCombo(combo);
   }
 }
예제 #27
0
 @Override
 public void execute(MapleClient c, MessageCallback mc, String[] splitted)
     throws Exception, IllegalCommandSyntaxException {
   if (splitted[0].equals("!whosthere")) {
     MessageCallback callback = new ServernoticeMapleClientMessageCallback(c);
     StringBuilder builder = new StringBuilder("Players on Map: ");
     for (MapleCharacter chr : c.getPlayer().getMap().getCharacters()) {
       if (builder.length() > 150) { // wild guess :o
         builder.setLength(builder.length() - 2);
         callback.dropMessage(builder.toString());
         builder = new StringBuilder();
       }
       builder.append(MapleCharacter.makeMapleReadable(chr.getName()));
       builder.append(", ");
     }
     builder.setLength(builder.length() - 2);
     c.getSession().write(MaplePacketCreator.serverNotice(6, builder.toString()));
   } else if (splitted[0].equals("!cheaters")) {
     try {
       List<CheaterData> cheaters =
           c.getChannelServer().getWorldInterface().getCheaters(c.getWorld());
       for (int x = cheaters.size() - 1; x >= 0; x--) {
         CheaterData cheater = cheaters.get(x);
         mc.dropMessage(cheater.getInfo());
       }
     } catch (RemoteException e) {
       c.getChannelServer().reconnectWorld();
     }
   }
 }
 public static void removeById(
     final MapleClient c,
     final MapleInventoryType type,
     final int Id,
     final int quantity,
     final boolean fromDrop,
     final boolean consume) {
   List<IItem> items = c.getPlayer().getInventory(type).listById(Id);
   int remremove = quantity;
   for (IItem item : items) {
     if (remremove <= item.getQuantity()) {
       removeFromSlot(c, type, item.getPosition(), (short) remremove, fromDrop, consume);
       remremove = 0;
       break;
     } else {
       remremove -= item.getQuantity();
       removeFromSlot(c, type, item.getPosition(), item.getQuantity(), fromDrop, consume);
     }
   }
   if (remremove > 0) {
     throw new RuntimeException(
         "[h4x] Not enough items available ("
             + Id
             + ", "
             + (quantity - remremove)
             + "/"
             + quantity
             + ")");
   }
 }
예제 #29
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   if (c.getPlayer().getMapId() != 109010100) {
     c.getPlayer().dropMessage(5, "You may only spawn bomb in the event map.");
     return 0;
   }
   if (!c.getChannelServer().bombermanActive()) {
     c.getPlayer().dropMessage(5, "You may not spawn bombs yet.");
     return 0;
   }
   c.getPlayer()
       .getMap()
       .spawnMonsterOnGroudBelow(
           MapleLifeFactory.getMonster(9300166), c.getPlayer().getPosition());
   return 1;
 }
예제 #30
0
 @Override
 public int execute(MapleClient c, String[] splitted) {
   StringBuilder sb = new StringBuilder();
   sb.append("\r\n@str, @dex, @int, @luk, @hp, @mp <amount to add or subtract>");
   sb.append("\r\n@mob < Information on the closest monster >");
   sb.append(
       "\r\n@check < Displays various information; also use if you are stuck or unable to talk to NPC >");
   // sb.append("\r\n@npc < Universal NPC >");
   sb.append("\r\n@callgm < Send a message to all online GameMasters.");
   sb.append("\r\n@home < Warp to Acernis base >");
   sb.append("\r\n@fm < Warp to the FreeMarket instantly. >");
   sb.append("\r\n@job < Job advancements! >");
   sb.append("\r\n@save < Fixes your experience and saves your character >");
   /*sb.append("\r\n@joinevent < Join ongoing event >");
   sb.append("\r\n@crescent < Universal Town Warp / Event NPC>");
   sb.append("\r\n@dcash < Universal Cash Item Dropper >");
   sb.append("\r\n@tsmega < Toggle super megaphone on/off >");
   sb.append("\r\n@ea < If you are unable to attack or talk to NPC >");
   sb.append("\r\n@clearslot < Cleanup that trash in your inventory >");
   sb.append("\r\n@ranking < Use @ranking for more details >");
   sb.append("\r\n@checkdrop < Use @checkdrop for more details >");
   sb.append("\r\n@style < Styler >");
   sb.append("\r\n@advance < Job Advancer >");
   sb.append("\r\n@bosswarp < Boss Warper >");
   sb.append("\r\n@fly < Makes you fly if you're in the Free Market >");*/
   if (c.canClickNPC()) {
     NPCPacket.getNPCTalk(9010000, (byte) 0, sb.toString(), "00 00", (byte) 0);
   }
   for (String command : sb.toString().split("\r\n")) {
     c.getPlayer().dropMessage(5, command);
   }
   return 1;
 }