armark1ng

Untitled

Sep 4th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. package com.rs.game.npc.vorago;
  2.  
  3. import java.util.List;
  4.  
  5. import com.rs.game.Animation;
  6. import com.rs.game.Entity;
  7. import com.rs.game.World;
  8. import com.rs.game.WorldTile;
  9. import com.rs.game.npc.NPC;
  10. import com.rs.game.npc.combat.NPCCombatDefinitions;
  11. import com.rs.game.npc.familiar.Familiar;
  12. import com.rs.game.player.Player;
  13. import com.rs.game.tasks.WorldTask;
  14. import com.rs.game.tasks.WorldTasksManager;
  15. import com.rs.utils.Utils;
  16.  
  17. @SuppressWarnings("serial")
  18. public class Vitalis extends NPC {
  19.  
  20. private transient Vorago vorago;
  21.  
  22. public Vitalis(int id, WorldTile tile, int mapAreaNameHash, boolean canBeAttackFromOutOfArea, Vorago vorago) {
  23. super(id, tile, mapAreaNameHash, canBeAttackFromOutOfArea);
  24. this.vorago = vorago;
  25. setForceFollowClose(true);
  26. setIntelligentRouteFinder(true);
  27. }
  28.  
  29. @Override
  30. public boolean isBoundImmune() {
  31. return true;
  32. }
  33.  
  34. @Override
  35. public boolean canWalkNPC(int toX, int toY) {
  36. int size = getSize();
  37. for (int regionId : getMapRegionsIds()) {
  38. List<Integer> npcIndexes = World.getRegion(regionId).getNPCsIndexes();
  39. if (npcIndexes != null/* && npcIndexes.size() < 100 */) {
  40. for (int npcIndex : npcIndexes) {
  41. NPC target = World.getNPCs().get(npcIndex);
  42. if (target == null || target == this || target.isDead() || target.hasFinished()
  43. || target.getPlane() != getPlane() || target instanceof Familiar
  44. || target instanceof Vorago)
  45. continue;
  46. int targetSize = target.getSize();
  47. // npc is under this target so skip checking it
  48. if (Utils.colides(this, target))
  49. continue;
  50. WorldTile tile = new WorldTile(target);
  51. // has to be checked aswell, cuz other one assumes npc will
  52. // manage to move no matter what
  53. if (Utils.colides(toX, toY, size, tile.getX(), tile.getY(), targetSize))
  54. return false;
  55. if (target.getNextWalkDirection() != -1) {
  56. tile.moveLocation(Utils.DIRECTION_DELTA_X[target.getNextWalkDirection()],
  57. Utils.DIRECTION_DELTA_Y[target.getNextWalkDirection()], 0);
  58. if (target.getNextRunDirection() != -1)
  59. tile.moveLocation(Utils.DIRECTION_DELTA_X[target.getNextRunDirection()],
  60. Utils.DIRECTION_DELTA_Y[target.getNextRunDirection()], 0);
  61. // target is at x,y
  62. if (Utils.colides(toX, toY, size, tile.getX(), tile.getY(), targetSize))
  63. return false;
  64. }
  65. }
  66. }
  67. }
  68. return true;
  69. }
  70.  
  71. @Override
  72. public boolean isPoisonImmune() {
  73. return true;
  74. }
  75.  
  76. @Override
  77. public void sendDeath(Entity source) {
  78. final NPCCombatDefinitions defs = getCombatDefinitions();
  79. resetWalkSteps();
  80. getCombat().removeTarget();
  81. setNextAnimation(null);
  82. if (!isDead())
  83. setHitpoints(0);
  84. final int deathDelay = defs.getDeathDelay() - (getId() == 50 ? 2 : 1);
  85. Vitalis thisNPC = this;
  86. WorldTasksManager.schedule(new WorldTask() {
  87. int loop;
  88.  
  89. @Override
  90. public void run() {
  91. if (loop == 0) {
  92. setNextAnimation(new Animation(defs.getDeathEmote()));
  93. } else if (loop >= deathDelay) {
  94. if (source != null && (source instanceof Player))
  95. ((Player) source).getControlerManager().processNPCDeath(thisNPC);
  96. vorago.sendVitalisDeath(thisNPC);
  97. reset();
  98. finish();
  99. stop();
  100. }
  101. loop++;
  102. }
  103. }, 0, 1);
  104. }
  105.  
  106. public Vorago getVorago() {
  107. return vorago;
  108. }
  109. }
Add Comment
Please, Sign In to add comment