Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.38 KB | None | 0 0
  1. package com.arlania.world.content.skill.impl.dungeoneering;
  2.  
  3. import com.arlania.GameSettings;
  4. import com.arlania.engine.task.Task;
  5. import com.arlania.engine.task.TaskManager;
  6. import com.arlania.model.GameObject;
  7. import com.arlania.model.GroundItem;
  8. import com.arlania.model.Item;
  9. import com.arlania.model.Position;
  10. import com.arlania.model.Skill;
  11. import com.arlania.model.container.impl.PriceChecker;
  12. import com.arlania.util.Misc;
  13. import com.arlania.world.World;
  14. import com.arlania.world.content.CustomObjects;
  15. import com.arlania.world.content.combat.prayer.CurseHandler;
  16. import com.arlania.world.content.combat.prayer.PrayerHandler;
  17. import com.arlania.world.content.dialogue.DialogueManager;
  18. import com.arlania.world.entity.impl.GroundItemManager;
  19. import com.arlania.world.entity.impl.npc.NPC;
  20. import com.arlania.world.entity.impl.player.Player;
  21.  
  22. /**
  23. * yeye
  24. * @author Gabriel Hannason
  25. */
  26. public class Dungeoneering {
  27.  
  28. public static void start(final Player p) {
  29. p.getPacketSender().sendInterfaceRemoval();
  30. /*if(p.getRights() != PlayerRights.DEVELOPER) {
  31. p.getPacketSender().sendMessage("Dungeoneering isn't out yet.");
  32. return;
  33. }*/
  34. if(p.getMinigameAttributes().getDungeoneeringAttributes().getParty() == null) {
  35. DialogueManager.start(p, 111);
  36. return;
  37. }
  38. final DungeoneeringParty party = p.getMinigameAttributes().getDungeoneeringAttributes().getParty();
  39. if(party.hasEnteredDungeon())
  40. return;
  41. if(party.getDungeoneeringFloor() == null || party.getOwner() == null) {
  42. DialogueManager.start(p, 112);
  43. return;
  44. } else if(party.getComplexity() == -1) {
  45. DialogueManager.start(p, 113);
  46. return;
  47. }
  48. if(party.getOwner() != p) {
  49. p.getPacketSender().sendMessage("Only the party leader can start the dungeon.");
  50. return;
  51. }
  52. String plrCannotEnter = null;
  53. for(Player member : party.getPlayers()) {
  54. if(member != null) {
  55. member.getPacketSender().sendInterfaceRemoval();
  56. if(member.getSummoning().getFamiliar() != null) {
  57. member.getPacketSender().sendMessage("You must dismiss your familiar before being allowed to enter a dungeon.");
  58. p.getPacketSender().sendMessage(""+p.getUsername()+" has to dismiss their familiar before you can enter the dungeon.");
  59. return;
  60. }
  61. for(Item t : member.getEquipment().getItems()) {
  62. if(t != null && t.getId() > 0 && t.getId() != 15707) {
  63. plrCannotEnter = member.getUsername();
  64. }
  65. }
  66. for(Item t : member.getInventory().getItems()) {
  67. if(t != null && t.getId() > 0 && t.getId() != 15707) {
  68. plrCannotEnter = member.getUsername();
  69. }
  70. }
  71. if(plrCannotEnter != null) {
  72. p.getPacketSender().sendMessage("Your team cannot enter the dungeon because "+plrCannotEnter+" hasn't banked").sendMessage("all of their items.");
  73. return;
  74. }
  75. }
  76. }
  77. party.enteredDungeon(true);
  78. final int height = p.getIndex() * 4;
  79. final int amt = party.getPlayers().size() >= 2 ? 35000: 45000;
  80. for(Player member : party.getPlayers()) {
  81. if(member != null) {
  82. member.getPacketSender().sendInterfaceRemoval();
  83. member.getMinigameAttributes().getDungeoneeringAttributes().setDamageDealt(0);
  84. member.getMinigameAttributes().getDungeoneeringAttributes().setDeaths(0);
  85. member.setRegionInstance(null);
  86. member.getMovementQueue().reset();
  87. member.getClickDelay().reset();
  88. member.moveTo(new Position(party.getDungeoneeringFloor().getEntrance().getX(), party.getDungeoneeringFloor().getEntrance().getY(), height));
  89. member.getEquipment().resetItems().refreshItems();
  90. member.getInventory().resetItems().refreshItems();
  91. member.getInventory().add(18201, amt);
  92. ItemBinding.onDungeonEntrance(member);
  93. PrayerHandler.deactivateAll(member);
  94. CurseHandler.deactivateAll(member);
  95. for(Skill skill : Skill.values())
  96. member.getSkillManager().setCurrentLevel(skill, member.getSkillManager().getMaxLevel(skill));
  97. member.getSkillManager().stopSkilling();
  98. member.getPacketSender().sendClientRightClickRemoval();
  99. }
  100. }
  101. party.setDeaths(0);
  102. party.setKills(0);
  103. party.sendMessage("Welcome to Dungeoneering floor "+(party.getDungeoneeringFloor().ordinal() + 1)+", complexity level "+party.getComplexity()+".");
  104. party.sendFrame(37508, "Party deaths: 0");
  105. party.sendFrame(37509, "Party kills: 0");
  106. TaskManager.submit(new Task(1) {
  107. @Override
  108. public void execute() {
  109. setupFloor(party, height);
  110. stop();
  111. }
  112. });
  113. p.getInventory().add(new Item(17489));
  114. }
  115.  
  116. public static void leave(Player p, boolean resetTab, boolean leaveParty) {
  117. if(p.getMinigameAttributes().getDungeoneeringAttributes().getParty() != null) {
  118. p.getMinigameAttributes().getDungeoneeringAttributes().getParty().remove(p, resetTab, leaveParty);
  119. p.getInventory().resetItems().refreshItems();
  120. } else if(resetTab) {
  121. p.getInventory().resetItems().refreshItems();
  122. p.getPacketSender().sendTabInterface(GameSettings.QUESTS_TAB, 639);//
  123. p.getPacketSender().sendDungeoneeringTabIcon(false);
  124. p.getPacketSender().sendTab(GameSettings.QUESTS_TAB);
  125. }
  126. }
  127.  
  128. public static void setupFloor(DungeoneeringParty party, int height) {
  129. /*
  130. * Spawning npcs
  131. */
  132. NPC smuggler = new NPC(11226, new Position(party.getDungeoneeringFloor().getSmugglerPosition().getX(), party.getDungeoneeringFloor().getSmugglerPosition().getY(), height));
  133. World.register(smuggler);
  134. party.getNpcs().add(smuggler);
  135. for(NPC n : party.getDungeoneeringFloor().getNpcs()[party.getComplexity() - 1]) {
  136. NPC npc = new NPC(n.getId(), n.getPosition().copy().setZ(height));
  137. World.register(npc);
  138. party.getNpcs().add(npc);
  139. }
  140. /*
  141. * Spawning objects
  142. */
  143. for(GameObject obj : party.getDungeoneeringFloor().getObjects()) {
  144. CustomObjects.spawnGlobalObjectWithinDistance(new GameObject(obj.getId(), obj.getPosition().copy().setZ(height)));
  145. }
  146. }
  147.  
  148.  
  149. public static boolean doingDungeoneering(Player p) {
  150. return p.getMinigameAttributes().getDungeoneeringAttributes().getParty() != null && p.getMinigameAttributes().getDungeoneeringAttributes().getParty().hasEnteredDungeon();
  151. }
  152.  
  153. public static void handlePlayerDeath(Player player) {
  154. player.getMinigameAttributes().getDungeoneeringAttributes().incrementDeaths();
  155.  
  156. DungeoneeringParty party = player.getMinigameAttributes().getDungeoneeringAttributes().getParty();
  157. Position pos = party.getDungeoneeringFloor().getEntrance();
  158. player.moveTo(new Position(pos.getX(), pos.getY(), player.getPosition().getZ()));
  159. party.sendMessage("@red@"+player.getUsername()+" has died and been moved to the lobby.");
  160. party.setDeaths(party.getDeaths()+1);
  161. party.sendFrame(37508, "Party deaths: "+party.getDeaths());
  162. }
  163.  
  164. private static final Item[] misc = {new Item(555, 121), new Item(557, 87), new Item(554, 81), new Item(565, 63), new Item(5678), new Item(560, 97), new Item(861, 1), new Item(892, 127), new Item(18161, 2), new Item(18159, 2), new Item(139, 1)};
  165.  
  166. public static void handleNpcDeath(Player p, NPC n) {
  167. if(n.getPosition().getZ() == p.getPosition().getZ()) {
  168. DungeoneeringParty party = p.getMinigameAttributes().getDungeoneeringAttributes().getParty();
  169. if(!party.getNpcs().contains(n))
  170. return;
  171. party.getNpcs().remove(n);
  172. party.setKills(party.getKills()+1);
  173. boolean boss = n.getId() == 2060 || n.getId() == 8549 || n.getId() == 1382 || n.getId() == 9939;
  174. if(boss) {
  175. party.setKilledBoss(true);
  176. }
  177. party.sendFrame(37509, "Party kills: "+party.getKills());
  178. int random = Misc.getRandom(300);
  179. if(random >= 20 && random <= 45 || boss) {
  180. GroundItemManager.spawnGroundItem(p, new GroundItem(new Item(ItemBinding.getRandomBindableItem()), n.getPosition().copy(), "Dungeoneering", false, -1, false, -1));
  181. if(boss) {
  182. party.sendMessage("@red@The boss has been slain! Feel free to exit the dungeon via tha northern ladder.");
  183. }
  184. } else if(random >= 100 && random <= 150) {
  185. int amt = 3000 + Misc.getRandom(10000);
  186. GroundItemManager.spawnGroundItem(p, new GroundItem(new Item(18201, amt), n.getPosition().copy(), "Dungeoneering", false, -1, false, -1));
  187. } else if(random > 150 && random < 250)
  188. GroundItemManager.spawnGroundItem(p, new GroundItem(misc[Misc.getRandom(misc.length-1)], n.getPosition().copy(), "Dungeoneering", false, -1, false, -1));
  189. }
  190. }
  191.  
  192. public static final int FORM_PARTY_INTERFACE = 27224;
  193. public static final int PARTY_INTERFACE = 26224;
  194. public static final int DUNGEONEERING_GATESTONE_ID = 17489;
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement