Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. package l2d.game.model.instances.custom;
  2.  
  3. import java.util.concurrent.ScheduledFuture;
  4. import l2d.Config;
  5. import l2d.ext.scripts.Functions;
  6. import l2d.game.ThreadPoolManager;
  7. import l2d.game.ai.CtrlIntention;
  8. import l2d.game.ai.L2CharacterAI;
  9. import l2d.game.instancemanager.HellboundManager;
  10. import l2d.game.model.L2Character;
  11. import l2d.game.model.L2DropData;
  12. import l2d.game.model.L2Player;
  13. import l2d.game.model.L2Spawn;
  14. import l2d.game.model.L2World;
  15. import l2d.game.model.base.Experience;
  16. import l2d.game.model.instances.L2NpcInstance;
  17. import l2d.game.templates.L2NpcTemplate;
  18. import l2d.util.Util;
  19.  
  20. public class L2RabInstance extends L2HellboundNpcInstance
  21. {
  22. private ScheduledFuture<?> FallowTask;
  23. private static L2Player spasitel;
  24. private static final L2DropData[] DROPS = { new L2DropData(1876, 1, 2, 1000000.0D, 1), new L2DropData(1885, 3, 4, 1000000.0D, 1), new L2DropData(9628, 5, 10, 1000000.0D, 1) };
  25.  
  26. public L2RabInstance(int objectId, L2NpcTemplate template)
  27. {
  28. super(objectId, template);
  29. }
  30.  
  31. public void doDie(L2Character killer)
  32. {
  33. HellboundManager.getInstance().addPoints(-10L);
  34. }
  35.  
  36. public void showChatWindow(L2Player player, int val)
  37. {
  38. int hLevel = HellboundManager.getInstance().getLevel();
  39. String filename = "";
  40. String path = "data/html/hellbound/rab/";
  41. if (hLevel < 5)
  42. filename = "data/html/hellbound/rab/" + getNpcId() + "-no.htm";
  43. else if (hLevel >= 5) {
  44. filename = "data/html/hellbound/rab/" + getNpcId() + ".htm";
  45. }
  46. super.showChatWindow(player, filename);
  47. }
  48.  
  49. public void onBypassFeedback(L2Player p, String command)
  50. {
  51. if (command.equalsIgnoreCase("fallowme"))
  52. {
  53. setSpasitel(p);
  54. startFallowTask();
  55. }
  56. super.onBypassFeedback(p, command);
  57. }
  58.  
  59. public void startFallowTask()
  60. {
  61. if (this.FallowTask != null) {
  62. stopFallowTask();
  63. }
  64. if (getSpasitel() != null)
  65. this.FallowTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Fallow(null), 10L, 1000L);
  66. }
  67.  
  68. public void stopFallowTask()
  69. {
  70. if (this.FallowTask != null)
  71. this.FallowTask.cancel(false);
  72. this.FallowTask = null;
  73. }
  74.  
  75. public void setSpasitel(L2Player p)
  76. {
  77. spasitel = p;
  78. }
  79.  
  80. public L2Player getSpasitel()
  81. {
  82. return spasitel;
  83. }
  84.  
  85. public void setIsSpasen()
  86. {
  87. stopFallowTask();
  88. stopMove();
  89.  
  90. if (getSpasitel() != null)
  91. {
  92. double chancemod = Experience.penaltyModifier(calculateLevelDiffForDrop(getSpasitel().getLevel()), 9.0D);
  93.  
  94. L2DropData d = DROPS[l2d.util.Rnd.get(0, DROPS.length)];
  95. if (d != null) {
  96. dropItem(getSpasitel(), d.getItemId(), Util.rollDrop(d.getMinDrop(), d.getMaxDrop(), d.getChance() * chancemod * Config.RATE_DROP_ITEMS * getSpasitel().getRateItems(), true));
  97. }
  98. }
  99. Functions.npcSay(this, "Thank you for saving me! Here is a small gift.");
  100. HellboundManager.getInstance().addPoints(10L);
  101. decayMe();
  102. getSpawn().respawnNpc(this);
  103. }
  104.  
  105. private void checkInRadius(int id)
  106. {
  107. L2NpcInstance Pillar = L2World.findNpcByNpcId(id);
  108. if (getRealDistance3D(Pillar) <= 200.0D)
  109. setIsSpasen();
  110. }
  111.  
  112. private class Fallow implements Runnable {
  113. private Fallow() {
  114. }
  115.  
  116. public void run() {
  117. L2RabInstance.this.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, L2RabInstance.this.getSpasitel(), Integer.valueOf(200));
  118. L2RabInstance.this.checkInRadius(18506);
  119. }
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement