EffectBlink.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.skills.effects;
  16. import net.sf.l2j.Config;
  17. import net.sf.l2j.gameserver.GeoData;
  18. import net.sf.l2j.gameserver.model.L2Effect;
  19. import net.sf.l2j.gameserver.model.Location;
  20. import net.sf.l2j.gameserver.serverpackets.FlyToLocation;
  21. import net.sf.l2j.gameserver.serverpackets.ValidateLocation;
  22. import net.sf.l2j.gameserver.serverpackets.FlyToLocation.FlyType;
  23. import net.sf.l2j.gameserver.skills.Env;
  24. import net.sf.l2j.gameserver.util.Util;
  25. public class EffectBlink extends L2Effect
  26. {
  27. private int x, y, z;
  28. public EffectBlink(Env env, EffectTemplate template)
  29. {
  30. super(env, template);
  31. }
  32. @Override
  33. public EffectType getEffectType()
  34. {
  35. return EffectType.BUFF;
  36. }
  37. @Override
  38. public void onStart()
  39. {
  40. int _radius = getSkill().getFlyRadius();
  41. double angle = Util.convertHeadingToDegree(getEffected().getHeading());
  42. double radian = Math.toRadians(angle);
  43. int x1 = (int) (Math.sin(radian) * _radius);
  44. int y1 = (int) (Math.cos(radian) * _radius);
  45. x = getEffected().getX() - x1;
  46. y = getEffected().getY() - y1;
  47. z = getEffected().getZ();
  48. if (Config.GEODATA > 0)
  49. {
  50. Location destiny = GeoData.getInstance().moveCheck(getEffected().getX(), getEffected().getY(), getEffected().getZ(), x, y, z);
  51. x = destiny.getX();
  52. y = destiny.getY();
  53. z = destiny.getZ();
  54. }
  55. getEffected().broadcastPacket(new FlyToLocation(getEffected(), x, y, z, FlyType.DUMMY));
  56. getEffected().abortAttack();
  57. getEffected().abortCast();
  58. }
  59. @Override
  60. public void onExit()
  61. {
  62. // maybe is need force set X,Y,Z
  63. getEffected().setXYZ(x, y, z);
  64. getEffected().broadcastPacket(new ValidateLocation(getEffected()));
  65. }
  66. @Override
  67. public boolean onActionTime()
  68. {
  69. return false;
  70. }
  71. }