Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.40 KB | None | 0 0
  1. package com.rs.game.npc.combat.impl;
  2.  
  3. import com.rs.game.Animation;
  4. import com.rs.game.Entity;
  5. import com.rs.game.ForceTalk;
  6. import com.rs.game.Graphics;
  7. import com.rs.game.npc.NPC;
  8. import com.rs.game.npc.NpcCombatDefs;
  9. import com.rs.game.npc.combat.CombatScript;
  10. import com.rs.game.npc.combat.NPCCombatDefinitions;
  11. import com.rs.game.player.Player;
  12. import com.rs.game.tasks.WorldTask;
  13. import com.rs.game.tasks.WorldTasksManager;
  14. import com.rs.utils.Utils;
  15. import com.rs.game.World;
  16.  
  17. public class CliffCombat extends CombatScript {
  18.  
  19. @Override
  20. public Object[] getKeys() {
  21. return new Object[] { 13635 };
  22. }
  23.  
  24. @Override
  25. public int attack(final NPC npc, final Entity target) {
  26. final NpcCombatDefs defs = npc.getCombatDefinitions();
  27.  
  28. int random = Utils.getRandom(4);
  29.  
  30. if (random == 0) {
  31. switch (Utils.getRandom(3)) {
  32. case 0:
  33. npc.setNextForceTalk(new ForceTalk("RAAAAAARRRRRRGGGGHHHH"));
  34. break;
  35.  
  36. case 1:
  37. npc.setNextForceTalk(new ForceTalk("You're going straight to hell!"));
  38. break;
  39.  
  40. case 2:
  41. String name = "";
  42. if (target instanceof Player)
  43. name = ((Player) target).getDisplayName();
  44. npc.setNextForceTalk(new ForceTalk("I'm going to crush you, " + name));
  45. break;
  46.  
  47. case 3:
  48. name = "";
  49. if (target instanceof Player)
  50. name = ((Player) target).getDisplayName();
  51. npc.setNextForceTalk(new ForceTalk("Die with pain, " + name));
  52. break;
  53. }
  54. }
  55.  
  56. random = Utils.getRandom(10);
  57.  
  58. if (random == 0) { // mage attack
  59. npc.setNextAnimation(new Animation(1932));
  60. npc.setNextForceTalk(new ForceTalk("Feel my wrath!!"));
  61. for (Entity t : npc.getPossibleTargets()) {
  62. if (!t.withinDistance(npc, 18))
  63. continue;
  64. ((Player) t).getPackets().sendSound(1927, 0, 2);
  65. int damage = getRandomMaxHit(npc, defs.getMaxHit(), NPCCombatDefinitions.MAGE, t);
  66. if (damage > 0) {
  67. delayHit(npc, 0, t, getMagicHit(npc, damage));
  68. t.setNextGraphics(new Graphics(3428));
  69. }
  70. }
  71. } else if (random == 2) { // Fire Blow
  72. npc.setNextAnimation(new Animation(1932));
  73. npc.setNextGraphics(new Graphics(1210));
  74. for (Entity t : npc.getPossibleTargets()) {
  75. delayHit(
  76. npc,
  77. 1,
  78. t,
  79. getMagicHit(
  80. npc,
  81. getRandomMaxHit(npc, 300,
  82. NPCCombatDefinitions.MAGE, t)));
  83. World.sendProjectile(npc, t, 1211, 41, 16, 41, 35, 16, 0);
  84. if (Utils.getRandom(4) == 0)
  85. t.getPoison().makePoisoned(168);
  86. }
  87. }else if (random == 1) { // True Power Attack
  88. WorldTasksManager.schedule(new WorldTask() {
  89. int loop = 0;
  90. @Override
  91. public void run() {
  92. if (loop == 0) {
  93. for (Entity t : npc.getPossibleTargets()) {
  94. if (!t.withinDistance(npc, 100))
  95. continue;
  96. ((Player) t).getPackets().sendSound(1929, 0, 2);
  97. }
  98. } else if (loop == 3) {
  99. npc.setNextAnimation(new Animation(1931));
  100. npc.setNextGraphics(new Graphics(2776));
  101. } else if (loop == 4) {
  102. for (Entity t : npc.getPossibleTargets()) {
  103. if (!t.withinDistance(npc, 100))
  104. continue;
  105. if (!isAtSafeArea((Player) t)) {
  106. ((Player) t).getPackets().sendSound(1936, 0, 2);
  107. ((Player) t).getPackets().sendCameraShake(3, 25, 50, 25, 50);
  108. if (Utils.random(100) < 2) { // 2% chance of 1 hitting
  109. delayHit(npc, 0, t, getRegularHit(npc, ((Player) t).getHitpoints()));
  110. } else {
  111. delayHit(npc, 0, t, getRegularHit(npc, 400 + Utils.random(100)));
  112. }
  113. } else {
  114. ((Player) t).getPackets().sendSound(1936, 0, 2);
  115. ((Player) t).getPackets().sendStopCameraShake();
  116. }
  117. }
  118. } else if (loop == 6) {
  119. for (Entity t : npc.getPossibleTargets()) {
  120. if (!t.withinDistance(npc, 100))
  121. continue;
  122. ((Player) t).getPackets().sendStopCameraShake();
  123. }
  124. stop();
  125. }
  126.  
  127. loop++;
  128. }
  129. }, 0, 1);
  130. return 20;
  131. } else {// melee attack
  132. npc.setNextAnimation(new Animation(defs.getAttackEmote()));
  133. delayHit(npc, 0, target, getMeleeHit(npc, getRandomMaxHit(npc, defs.getMaxHit(), NPCCombatDefinitions.MELEE, target)));
  134. }
  135.  
  136. return defs.getAttackDelay();
  137. }
  138.  
  139. public boolean isAtSafeArea(Player player) {
  140. if (player.getX() == 209 && player.getY() == 5385) {
  141. return true;
  142. }
  143. if (player.getX() == 209 && player.getY() == 5382) {
  144. return true;
  145. }
  146. if (player.getX() == 222 && player.getY() == 5385) {
  147. return true;
  148. }
  149. if (player.getX() == 222 && player.getY() == 5382) {
  150. return true;
  151. }
  152.  
  153. return false;
  154. }
  155. public void startTruePower(final NPC npc) {
  156. WorldTasksManager.schedule(new WorldTask() {
  157. int loop = 0;
  158. @Override
  159. public void run() {
  160. if (loop == 0) {
  161. for (Entity t : npc.getPossibleTargets()) {
  162. if (!t.withinDistance(npc, 18))
  163. continue;
  164. ((Player) t).getPackets().sendSound(1929, 2, 0);
  165. ((Player) t).getPackets().sendCameraShake(3, 25, 50, 25, 50);
  166. }
  167. } else if (loop == 3) {
  168. npc.setNextAnimation(new Animation(14412));
  169. npc.setNextGraphics(new Graphics(2776));
  170. for (Entity t : npc.getPossibleTargets()) {
  171. if (!t.withinDistance(npc, 18))
  172. continue;
  173. ((Player) t).getPackets().sendSound(1936, 2, 0);
  174. ((Player) t).getPackets().sendStopCameraShake();
  175. }
  176. } else if (loop == 5) {
  177. stop();
  178. }
  179.  
  180. loop++;
  181. }
  182. }, 0, 1);
  183. }
  184.  
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement