Advertisement
Guest User

Slayer.java

a guest
Jul 23rd, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.61 KB | None | 0 0
  1. package server.game.entities.player.skills;
  2.  
  3. import server.game.dialogues.Dialogue;
  4. import server.game.dialogues.impl.NPCChat;
  5. import server.game.dialogues.impl.Option;
  6. import server.game.dialogues.impl.PlayerChat;
  7. import server.model.mobile.npcs.NPCDefinitions;
  8. import server.model.mobile.players.Player;
  9.  
  10. /**
  11.  * Ivandis
  12.  *
  13.  * @author Naqash Tanzeel
  14.  * @version 1.0
  15.  */
  16. public class Slayer extends Skill {
  17.  
  18.     private static final int[][] easyTasks = {{18, 1}, {52, 1}, {78, 1}, {92, 1}, {101, 1}, {103, 1}, {117, 1}, {119, 1}, {181, 1}, {1265, 1}, {1612, 15}, {1648, 5}};
  19.  
  20.     private static final int[][] mediumTasks = {{83, 1}, {110, 1}, {112, 1}, {125, 1}, {941, 1}, {1153, 1}, {1154, 1}, {1341, 1}, {1600, 10}, {1612, 15}, {1616, 40}, {1618, 50}, {1637, 52}, {1622, 20}, {1633, 30}, {1643, 45}};
  21.  
  22.     private static final int[][] hardTasks = {{49, 1}, {53, 1}, {55, 1}, {84, 1}, {110, 1}, {941, 1}, {1157, 1}, {1341, 1}, {1590, 1}, {1591, 1}, {1608, 70}, {1610, 75}, {1613, 80}, {1615, 55}, {1616, 40}, {1618, 50}, {1624, 65}, {1632, 55}, {2783, 90}, {3590, 1}};
  23.  
  24.     private static final int[][][] tasks = {easyTasks, mediumTasks, hardTasks};
  25.  
  26.     private Task task;
  27.  
  28.     public Slayer(Player player) {
  29.         super("Slayer", 12122, 12123, 12124, player);
  30.     }
  31.  
  32.     private Task getSlayerTask() {
  33.         return task;
  34.     }
  35.  
  36.     public void setSlayerTask(Task task) {
  37.         this.task = task;
  38.     }
  39.  
  40.     public void getSlayerGem() {
  41.         String[] text;
  42.         if (task.getAmount() > 0)
  43.             text = new String[] {"You're currently assigned to kill " + task.getNPC().getNpcName().replaceAll("_", " ") + ";",
  44.             "Only " + task.getAmount() + " more to go."};
  45.         else text = new String[] {"You're currently not assigned a task.", "Head over to Vannaka in Edgevile for a task."};
  46.         player.getDialogues().sendDialogue(new NPCChat(player, 1597, "Vannaka", 591, text));
  47.     }
  48.  
  49.     public void talkToSlayerMaster() {
  50.         final Dialogue conversation = new NPCChat(player, 1597, "Vannaka", 591, new String[] {"'Ello, and what are you after then?"});
  51.         conversation.setNext(new Option(player, new String[] {"I need another assignment.", "Do you have anything for trade?", "Er.. Nothing.."}) {
  52.             @Override
  53.             public void onContinue() {
  54.                 switch (option) {
  55.                     case 0: getNewTask(); break;
  56.                     case 1: setNext(new NPCChat(player, 1597, "Vannaka", 591,
  57.                             new String[] {"I have a wide selection of Slayer equipment, take a look."}));
  58.                         break;
  59.                 }
  60.             }
  61.         });
  62.         player.getDialogues().sendDialogue(conversation);
  63.     }
  64.  
  65.     private void getNewTask() {
  66.         Dialogue conversation = new PlayerChat(player, new String[] {"I need another assignment"}) {
  67.             @Override
  68.             public void onContinue() {
  69.                 if (task == null) assignTask();
  70.                 else if (task.getLevel() > 1) lowerTask();
  71.                 else setNext(new NPCChat(player, 1597, "Vannaka", 591, new String[] {"You're still hunting something, come back when you've",
  72.                             "finished your task."}));
  73.             }
  74.         };
  75.         player.getDialogues().sendDialogue(conversation);
  76.     }
  77.  
  78.     private void lowerTask() {
  79.         final Dialogue conversation = new NPCChat(player, 1597, "Vannaka", 591, new String[] {"I see you already have an assignment.",
  80.                 "Would you like me to give you an easier one?"});
  81.         conversation.setNext(new Option(player, new String[] {"Yes please, I'd like to start off easy.", "No thanks, I'll stick with the current one."}) {
  82.             @Override
  83.             public void onContinue() {
  84.                 switch (option) {
  85.                     case 0:
  86.                         conversation.setNext(new PlayerChat(player, new String[]{"Yes please, I'd like to start off easy."}) {
  87.                             @Override
  88.                             public void onContinue() { assignTask(getTask(1)); }
  89.                         });
  90.                 }
  91.             }
  92.         });
  93.     }
  94.  
  95.     private void assignTask() {
  96.         assignTask(getTask());
  97.     }
  98.  
  99.     private void assignTask(Task task) {
  100.         this.task = task;
  101.         player.getDialogues().sendDialogue(new NPCChat(player, 1597, "Vannaka", 591, new String[] {
  102.                 "Right, let me have have a look...",
  103.                 "Your new tasks is to kill " + task.getAmount() + " " + task.getNPC().getNpcName().replaceAll("_", " ")
  104.         }));
  105.     }
  106.  
  107.     private Task getTask() {
  108.         int taskLevel = player.nonSummonCombatLevel % 46;
  109.         return getTask(taskLevel);
  110.     }
  111.  
  112.     private Task getTask(int taskLevel) {
  113.         int[] taskInfo = tasks[taskLevel][(int) (Math.random() * tasks[taskLevel].length)];
  114.         while (taskInfo[1] > player.playerLevel[player.playerSlayer])
  115.             taskInfo = tasks[taskLevel][(int) (Math.random() * tasks[taskLevel].length)];
  116.         return new Task(taskInfo[0], taskLevel);
  117.     }
  118.  
  119.     public class Task {
  120.  
  121.         private NPCDefinitions npc;
  122.  
  123.         private int level;
  124.  
  125.         private int amount;
  126.  
  127.         public Task(int npcId, int level) {
  128.             this.npc = NPCDefinitions.forId(npcId);
  129.             this.level = level;
  130.             this.amount = 15 + (level * 5) + (level * (int) (16 * Math.random()));
  131.         }
  132.  
  133.         private NPCDefinitions getNPC() {
  134.             return npc;
  135.         }
  136.  
  137.         private int getAmount() {
  138.             return amount;
  139.         }
  140.  
  141.         private int getLevel() {
  142.             return level;
  143.         }
  144.     }
  145.  
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement