Advertisement
MarGaZeaS

Untitled

Oct 7th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. package margazeas.gold.gameserver.skills.l2skills;
  2.  
  3. import margazeas.gold.commons.data.StatSet;
  4.  
  5. import margazeas.gold.gameserver.data.xml.MapRegionData;
  6. import margazeas.gold.gameserver.data.xml.MapRegionData.TeleportType;
  7. import margazeas.gold.gameserver.enums.ZoneId;
  8. import margazeas.gold.gameserver.enums.items.ShotType;
  9. import margazeas.gold.gameserver.enums.skills.SkillType;
  10. import margazeas.gold.gameserver.model.WorldObject;
  11. import margazeas.gold.gameserver.model.actor.Creature;
  12. import margazeas.gold.gameserver.model.actor.Player;
  13. import margazeas.gold.gameserver.model.location.Location;
  14. import margazeas.gold.gameserver.skills.L2Skill;
  15.  
  16. public class L2SkillTeleport extends L2Skill
  17. {
  18. private final String _recallType;
  19. private final Location _loc;
  20.  
  21. public L2SkillTeleport(StatSet set)
  22. {
  23. super(set);
  24.  
  25. _recallType = set.getString("recallType", "");
  26. String coords = set.getString("teleCoords", null);
  27. if (coords != null)
  28. {
  29. String[] valuesSplit = coords.split(",");
  30. _loc = new Location(Integer.parseInt(valuesSplit[0]), Integer.parseInt(valuesSplit[1]), Integer.parseInt(valuesSplit[2]));
  31. }
  32. else
  33. _loc = null;
  34. }
  35.  
  36. @Override
  37. public void useSkill(Creature activeChar, WorldObject[] targets)
  38. {
  39. if (activeChar instanceof Player)
  40. {
  41. // Check invalid states.
  42. //if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode() || activeChar.isInsideZone(ZoneId.BOSS))
  43. if (activeChar.isAfraid() || ((Player) activeChar).isInOlympiadMode())
  44. return;
  45. }
  46.  
  47. boolean bsps = activeChar.isChargedShot(ShotType.BLESSED_SPIRITSHOT);
  48.  
  49. for (WorldObject obj : targets)
  50. {
  51. if (!(obj instanceof Creature))
  52. continue;
  53.  
  54. final Creature target = ((Creature) obj);
  55.  
  56. if (target instanceof Player)
  57. {
  58. Player targetChar = (Player) target;
  59.  
  60. // Check invalid states.
  61. if (targetChar.isFestivalParticipant() || targetChar.isInJail() || targetChar.isInDuel())
  62. continue;
  63.  
  64. if (targetChar != activeChar)
  65. {
  66. if (targetChar.isInOlympiadMode())
  67. continue;
  68.  
  69. if (targetChar.isInsideZone(ZoneId.BOSS))
  70. continue;
  71. }
  72. }
  73.  
  74. Location loc = null;
  75. if (getSkillType() == SkillType.TELEPORT)
  76. {
  77. if (_loc != null)
  78. {
  79. if (!(target instanceof Player) || !target.isFlying())
  80. loc = _loc;
  81. }
  82. }
  83. else
  84. {
  85. if (_recallType.equalsIgnoreCase("Castle"))
  86. loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.CASTLE);
  87. else if (_recallType.equalsIgnoreCase("ClanHall"))
  88. loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.CLAN_HALL);
  89. else
  90. loc = MapRegionData.getInstance().getLocationToTeleport(target, TeleportType.TOWN);
  91. }
  92.  
  93. if (loc != null)
  94. {
  95. if (target instanceof Player)
  96. ((Player) target).setIsIn7sDungeon(false);
  97.  
  98. target.teleportTo(loc, 20);
  99. }
  100. }
  101.  
  102. activeChar.setChargedShot(bsps ? ShotType.BLESSED_SPIRITSHOT : ShotType.SPIRITSHOT, isStaticReuse());
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement