Beispiel #1
0
 public int getRandomTask(int diff) {
   if (diff == EASY_TASK) {
     return easyTask.get(Misc.random(easyTask.size() - 1));
   } else if (diff == MEDIUM_TASK) {
     return mediumTask.get(Misc.random(mediumTask.size() - 1));
   } else if (diff == HARD_TASK) {
     return hardTask.get(Misc.random(hardTask.size() - 1));
   } else if (diff == BOSS_TASK) {
     return bossTask.get(Misc.random(bossTask.size() - 1));
   }
   return easyTask.get(Misc.random(easyTask.size() - 1));
 }
Beispiel #2
0
 public int getTaskAmount(int diff) {
   switch (diff) {
     case 1:
       return 25 + Misc.random(75);
     case 2:
       return 45 + Misc.random(55);
     case 3:
       return 35 + Misc.random(65);
     case 4:
       return 5 + Misc.random(15);
   }
   return 50 + Misc.random(60);
 }
Beispiel #3
0
  public void generateTask() {
    if (hasTask() && !c.needsNewTask) {
      // c.getDH().sendDialogues(103, 1597);
      return;
    }
    if (hasTask() && c.needsNewTask) {
      int difficulty = getDifficulty(slayerTask);
      if (difficulty == EASY_TASK) {
        // c.getDH().sendDialogues(105, 1597);
        c.needsNewTask = false;
        return;
      }
    }
    int taskLevel = getSlayerDifficulty();

    for (Task slayerTask : Task.values()) {
      if (slayerTask.getDifficulty() == taskLevel) {
        if (c.playerLevel[18] >= slayerTask.getLevelReq()) {
          resizeTable(taskLevel);
          if (!c.needsNewTask) {
            int task = getRandomTask(taskLevel);
            for (int i = 0; i < c.removedTasks.length; i++) {
              if (task == c.removedTasks[i]) {
                c.sendMessage("Unavailable task: " + task);
                generateTask();
                return;
              }
            }
            this.slayerTask = task;
            taskAmount = getTaskAmount(taskLevel);
          } else {
            int task = getRandomTask(getDifficulty(taskLevel - 1));
            for (int i = 0; i < c.removedTasks.length; i++) {
              if (task == c.removedTasks[i]) {
                c.sendMessage("Unavailable task: " + task);
                generateTask();
                return;
              }
            }
            this.slayerTask = task;
            taskAmount = getTaskAmount(getDifficulty(this.slayerTask) - 1);
            c.needsNewTask = false;
          }
          // c.getDH().sendDialogues(102, 1597);
          c.sendMessage(
              "You have been assigned "
                  + taskAmount
                  + " "
                  + Misc.optimizeText(getTaskName(this.slayerTask))
                  + "'s, Good luck "
                  + c.playerName
                  + ".");
          return;
        }
      }
    }
  }
Beispiel #4
0
 public void process() {
   if (slayerTask == 0) {
     c.getPA().sendFrame126("@or2@  - Task: @gre@Empty ", 29174);
   } else if (slayerTask > 0) {
     c.getPA()
         .sendFrame126(
             "@or2@  - Task: @gre@"
                 + taskAmount
                 + " "
                 + Misc.optimizeText(getTaskName(slayerTask))
                 + "'s ",
             29174);
   }
 }
  @Override
  public void processPacket(Player player, int packetType, int packetSize) {
    switch (packetType) {
      case ADD_FRIEND:
        player.friendUpdate = true;
        long friendToAdd = player.getInStream().readQWord();
        boolean canAdd = true;

        for (int i1 = 0; i1 < player.friends.length; i1++) {
          if (player.friends[i1] != 0 && player.friends[i1] == friendToAdd) {
            canAdd = false;
            player.sendMessage(friendToAdd + " is already on your friends list.");
          }
        }
        if (canAdd == true) {
          for (int i1 = 0; i1 < player.friends.length; i1++) {
            if (player.friends[i1] == 0) {
              player.friends[i1] = friendToAdd;
              for (int i2 = 1; i2 < Config.MAX_PLAYERS; i2++) {
                if (player.getGame().getPlayerHandler().players[i2] != null
                    && player.getGame().getPlayerHandler().players[i2].isActive
                    && Misc.playerNameToInt64(
                            player.getGame().getPlayerHandler().players[i2].playerName)
                        == friendToAdd) {
                  Player o = player.getGame().getPlayerHandler().players[i2];
                  if (o != null) {
                    if (player.getGame().getPlayerHandler().players[i2].privateChat == 0
                        || (player.getGame().getPlayerHandler().players[i2].privateChat == 1
                            && o.getPA().isInPM(Misc.playerNameToInt64(player.playerName)))) {
                      player.getPA().loadPM(friendToAdd, 1);
                      break;
                    }
                  }
                }
              }
              break;
            }
          }
        }
        break;

      case SEND_PM:
        long sendMessageToFriendId = player.getInStream().readQWord();
        byte pmchatText[] = new byte[100];
        int pmchatTextSize = (byte) (packetSize - 8);
        player.getInStream().readBytes(pmchatText, pmchatTextSize, 0);
        if (ConnectionDetails.isMuted(player)) break;
        for (int i1 = 0; i1 < player.friends.length; i1++) {
          if (player.friends[i1] == sendMessageToFriendId) {
            boolean pmSent = false;

            for (int i2 = 1; i2 < Config.MAX_PLAYERS; i2++) {
              if (player.getGame().getPlayerHandler().players[i2] != null
                  && player.getGame().getPlayerHandler().players[i2].isActive
                  && Misc.playerNameToInt64(
                          player.getGame().getPlayerHandler().players[i2].playerName)
                      == sendMessageToFriendId) {
                Player o = player.getGame().getPlayerHandler().players[i2];
                if (o != null) {
                  if (player.getGame().getPlayerHandler().players[i2].privateChat == 0
                      || (player.getGame().getPlayerHandler().players[i2].privateChat == 1
                          && o.getPA().isInPM(Misc.playerNameToInt64(player.playerName)))) {
                    o.getPA()
                        .sendPM(
                            Misc.playerNameToInt64(player.playerName),
                            player.playerRights,
                            pmchatText,
                            pmchatTextSize);
                    pmSent = true;
                  }
                }
                break;
              }
            }
            if (!pmSent) {
              player.sendMessage("That player is currently offline.");
              break;
            }
          }
        }
        break;

      case REMOVE_FRIEND:
        player.friendUpdate = true;
        long friendToRemove = player.getInStream().readQWord();

        for (int i1 = 0; i1 < player.friends.length; i1++) {
          if (player.friends[i1] == friendToRemove) {
            for (int i2 = 1; i2 < Config.MAX_PLAYERS; i2++) {
              Player o = player.getGame().getPlayerHandler().players[i2];
              if (o != null) {
                if (player.friends[i1]
                    == Misc.playerNameToInt64(
                        player.getGame().getPlayerHandler().players[i2].playerName)) {
                  o.getPA().updatePM(player.playerId, 0);
                  break;
                }
              }
            }
            player.friends[i1] = 0;
            break;
          }
        }
        break;

      case REMOVE_IGNORE:
        int i = player.getInStream().readDWord();
        int i2 = player.getInStream().readDWord();
        int i3 = player.getInStream().readDWord();
        break;

      case CHANGE_PM_STATUS:
        int tradeAndCompete = player.getInStream().readUnsignedByte();
        player.privateChat = player.getInStream().readUnsignedByte();
        int publicChat = player.getInStream().readUnsignedByte();
        for (int i1 = 1; i1 < Config.MAX_PLAYERS; i1++) {
          if (player.getGame().getPlayerHandler().players[i1] != null
              && player.getGame().getPlayerHandler().players[i1].isActive == true) {
            Player o = player.getGame().getPlayerHandler().players[i1];
            if (o != null) {
              o.getPA().updatePM(player.playerId, 1);
            }
          }
        }
        break;

      case ADD_IGNORE:
        //
        break;
    }
  }