armark1ng

Untitled

Jul 21st, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.14 KB | None | 0 0
  1. package com.rs.game.player.dialogues.impl;
  2.  
  3. import com.rs.game.item.Item;
  4. import com.rs.game.player.FarmingManager.FarmingSpot;
  5. import com.rs.game.player.FarmingManager.Gardeners;
  6. import com.rs.game.player.FarmingManager.SpotInfo;
  7. import com.rs.game.player.dialogues.Dialogue;
  8.  
  9. public class GardenersD extends Dialogue {
  10.  
  11. private int npcId;
  12. private int STAGE;
  13. private Gardeners gardeners;
  14. private FarmingSpot spot;
  15.  
  16. @Override
  17. public void start() {
  18. npcId = (Integer) parameters[0];
  19. STAGE = (Integer) parameters[1];
  20. gardeners = Gardeners.getGardeners(npcId);
  21. SpotInfo info = SpotInfo.getInfo(STAGE == 2 ? gardeners.getSouthObject() : gardeners.getObjectId());
  22. spot = player.getFarmingManager().getSpot(info);
  23. if (STAGE != -1) {
  24. if (spot == null || spot.productInfo == null)
  25. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  26. "You don't have anything planted in that patch. Plant something and i might agree to look after it for you.");
  27. else if (spot.reachedMaxStage())
  28. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  29. "I don't know what you're talking about - Your crops are already fully grown.");
  30. else if (spot.isProtected()) {
  31. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  32. "I don't know what you're talking about - I'm already looking after that patch for you.");
  33. } else {
  34. Item protectionItem = spot.productInfo.getProtectionItem();
  35. String pItemName = protectionItem.getName();
  36. int pItemAmount = protectionItem.getAmount();
  37. stage = 2;
  38. sendNPCDialogue(npcId, NORMAL,
  39. "If you like, but i want " + pItemAmount + " " + pItemName + " for that");
  40. }
  41. } else
  42. sendOptionsDialogue("CHOOSE AN OPTION", "Would you look after crops for me?",
  43. "Can you " + (player.getFarmingManager().isAlwaysWeeded ? "stop weeding my patches for me please?"
  44. : "keep my farming patches weeded please?"),
  45. "Can you sell me something?", "Thats all, thanks.");
  46. }
  47.  
  48. @Override
  49. public void run(int interfaceId, int componentId) {
  50. if (stage == -1) {
  51. if (componentId == OPTION_1) {
  52. if (gardeners.getType() == 0) {// allotment
  53. stage = 1;
  54. sendOptionsDialogue("SELECT AN OPTION", "The north-western allotment",
  55. "The south-eastern allotment");
  56. } else {
  57. if (spot == null || spot.productInfo == null)
  58. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  59. "You don't have anything planted in that patch. Plant something and i might agree to look after it for you.");
  60. else if (spot.reachedMaxStage())
  61. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  62. "I don't know what you're talking about - Your crops are already fully grown.");
  63. else if (spot.isProtected()) {
  64. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  65. "I don't know what you're talking about - I'm already looking after that patch for you.");
  66. } else if (gardeners.getObjectId() == 18816) {
  67. spot.setIsProtected(true);
  68. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  69. "That'll do nicely, Sir. Leave it with me - i'll make sure it grows for you.");
  70. } else {
  71. Item protectionItem = spot.productInfo.getProtectionItem();
  72. String pItemName = protectionItem.getName();
  73. int pItemAmount = protectionItem.getAmount();
  74. stage = 2;
  75. this.sendNPCDialogue(npcId, NORMAL,
  76. "If you like, but i want " + pItemAmount + " " + pItemName + " for that");
  77. }
  78. }
  79. } else if (componentId == OPTION_2) {
  80. player.getFarmingManager().isAlwaysWeeded = !player.getFarmingManager().isAlwaysWeeded;
  81. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  82. (player.getFarmingManager().isAlwaysWeeded ? "Sure, i will keep crops weeded for you."
  83. : "Sure, i will stop weeding crops for you."));
  84. } else if (componentId == OPTION_3) {
  85. end();
  86. } else
  87. end();
  88. } else if (stage == 1) {
  89. SpotInfo info = SpotInfo
  90. .getInfo((componentId == OPTION_1) ? gardeners.getObjectId() : gardeners.getSouthObject());
  91. spot = player.getFarmingManager().getSpot(info);
  92. if (spot == null || spot.productInfo == null)
  93. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  94. "You don't have anything planted in that patch. Plant something and i might agree to look after it for you.");
  95. else if (spot.reachedMaxStage())
  96. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  97. "I don't know what you're talking about - Your crops are already fully grown.");
  98. else if (spot.isProtected()) {
  99. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  100. "I don't know what you're talking about - I'm already looking after that patch for you.");
  101. } else {
  102. Item protectionItem = spot.productInfo.getProtectionItem();
  103. String pItemName = protectionItem.getName();
  104. int pItemAmount = protectionItem.getAmount();
  105. stage = 2;
  106. this.sendNPCDialogue(npcId, NORMAL,
  107. "If you like, but i want " + pItemAmount + " " + pItemName + " for that");
  108. }
  109. } else if (stage == 2) {
  110. stage = 3;
  111. sendOptionsDialogue("CHOOSE AN OPTION", "Yes, please look after them.", "No, thats too much.");
  112. } else if (stage == 3) {
  113. if (componentId == OPTION_1) {
  114. stage = 4;
  115. sendPlayerDialogue(9827, "Yes, i would like you to look after them please.");
  116. } else {
  117. player.getDialogueManager().startDialogue("SimplePlayerMessage",
  118. "No thanks, that will be too much for me.");
  119. }
  120. } else if (stage == 4) {
  121. Item protectionItem = spot.productInfo.getProtectionItem();
  122. int pItemAmount = protectionItem.getAmount();
  123. int pItemAmountInv = player.getInventory().getAmountOf(protectionItem.getId())
  124. + player.getInventory().getAmountOf(protectionItem.getId() + 1);// noted
  125. // +
  126. // unnoted
  127. // amounts
  128. if (pItemAmountInv >= pItemAmount) {// amount >= required
  129. int itemsRemoved = 0;
  130. while (player.getInventory().containsItem(protectionItem.getId(), 1) && itemsRemoved < pItemAmount)// while
  131. // inventory
  132. // contains
  133. // unnoted
  134. // items
  135. // and
  136. // we
  137. // still
  138. // got
  139. // items
  140. // to
  141. // be
  142. // removed
  143. {
  144. player.getInventory().deleteItem(protectionItem.getId(), 1);
  145. itemsRemoved++;
  146. }
  147. if (itemsRemoved < pItemAmount)// we still got items to be
  148. // removed
  149. player.getInventory().deleteItem(protectionItem.getId() + 1, pItemAmount - itemsRemoved);
  150. spot.setIsProtected(true);
  151. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  152. "That'll do nicely, Sir. Leave it with me - i'll make sure it grows for you.");
  153. } else {
  154. player.getDialogueManager().startDialogue("SimpleNPCMessage", npcId,
  155. "You don't have the required items.");
  156. }
  157. }
  158. }
  159.  
  160. @Override
  161. public void finish() {
  162. // TODO Auto-generated method stub
  163.  
  164. }
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment