Advertisement
Guest User

Jump(Mr.Anonymous)

a guest
Aug 30th, 2012
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  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.network.clientpackets;
  16.  
  17. import java.nio.BufferUnderflowException;
  18.  
  19. import net.sf.l2j.Config;
  20. import net.sf.l2j.gameserver.GeoData;
  21. import net.sf.l2j.gameserver.ai.CtrlIntention;
  22. import net.sf.l2j.gameserver.model.L2CharPosition;
  23. import net.sf.l2j.gameserver.model.Location;
  24. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  25. import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  26. import net.sf.l2j.gameserver.network.serverpackets.FlyToLocation;
  27. import net.sf.l2j.gameserver.network.serverpackets.StopMove;
  28. import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  29. import net.sf.l2j.gameserver.network.serverpackets.FlyToLocation.FlyType;
  30. import net.sf.l2j.gameserver.util.Util;
  31.  
  32. public class MoveBackwardToLocation extends L2GameClientPacket
  33. {
  34. // cdddddd
  35. private int _targetX;
  36. private int _targetY;
  37. private int _targetZ;
  38. private int _originX;
  39. private int _originY;
  40. private int _originZ;
  41. private int _moveMovement;
  42.  
  43. // For geodata
  44. private int _curX;
  45. private int _curY;
  46. @SuppressWarnings("unused")
  47. private int _curZ;
  48.  
  49. @Override
  50. protected void readImpl()
  51. {
  52. _targetX = readD();
  53. _targetY = readD();
  54. _targetZ = readD();
  55. _originX = readD();
  56. _originY = readD();
  57. _originZ = readD();
  58.  
  59. try
  60. {
  61. _moveMovement = readD(); // is 0 if cursor keys are used 1 if mouse is used
  62. }
  63. catch (BufferUnderflowException e)
  64. {
  65. if (Config.L2WALKER_PROTECTION)
  66. {
  67. L2PcInstance activeChar = getClient().getActiveChar();
  68. Util.handleIllegalPlayerAction(activeChar, activeChar.getName() + " is trying to use L2Walker.", Config.DEFAULT_PUNISH);
  69. }
  70. }
  71. }
  72.  
  73. @Override
  74. protected void runImpl()
  75. {
  76. final L2PcInstance activeChar = getClient().getActiveChar();
  77. if (activeChar == null)
  78. return;
  79.  
  80. if (_targetX == _originX && _targetY == _originY && _targetZ == _originZ)
  81. {
  82. activeChar.sendPacket(new StopMove(activeChar));
  83. return;
  84. }
  85.  
  86. // Correcting targetZ from floor level to head level
  87. _targetZ += activeChar.getTemplate().getCollisionHeight();
  88.  
  89. _curX = activeChar.getX();
  90. _curY = activeChar.getY();
  91. _curZ = activeChar.getZ();
  92.  
  93. if (activeChar.getTeleMode() > 0)
  94. {
  95. if (activeChar.getTeleMode() == 1)
  96. activeChar.setTeleMode(0);
  97.  
  98. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  99. activeChar.teleToLocation(_targetX, _targetY, _targetZ, false);
  100. return;
  101. }
  102. if (_moveMovement == 0 && Config.GEODATA < 1) // cursor movement without geodata is disabled
  103. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  104.  
  105. else
  106. {
  107. double dx = _targetX - _curX;
  108. double dy = _targetY - _curY;
  109.  
  110. // Can't move if character is confused, or trying to move a huge distance
  111. if (activeChar.isOutOfControl() || ((dx * dx + dy * dy) > 98010000)) // 9900*9900
  112. {
  113. activeChar.sendPacket(ActionFailed.STATIC_PACKET);
  114. return;
  115. }
  116. +final boolean CanJump = Config.CAN_JUMP;
  117.  
  118. + if(CanJump)
  119. +Phda(activeChar,_targetX, _targetY, _targetZ);
  120. +else
  121. +activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(_targetX, _targetY, _targetZ, 0));
  122. }
  123. }
  124.  
  125. + public void Phda(L2PcInstance activeChar,int x,int y, int z)
  126. + {
  127. + final boolean EnableGeodata = Config.GEODATA > 0;
  128. + Location l = new Location(x, y, z);
  129. +
  130. + if (EnableGeodata)
  131. + l = GeoData.getInstance().moveCheck(activeChar.getX(), activeChar.getY(), activeChar.getZ(), x, y, z);
  132. +
  133. + activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
  134. + activeChar.broadcastPacket(new FlyToLocation(activeChar, l.getX(), l.getY(), l.getZ(), FlyType.THROW_UP));
  135. + activeChar.abortAttack();
  136. + activeChar.abortCast();
  137. + activeChar.setXYZ(l.getX(), l.getY(), l.getZ());
  138. + activeChar.broadcastPacket(new ValidateLocation(activeChar));
  139. + }
  140. }
  141.  
  142. Config.java
  143.  
  144. +public static boolean CAN_JUMP;
  145. +CAN_JUMP = Boolean.parseBoolean(Anonymous.getProperty("CanJump", "True"));
  146.  
  147. config properties
  148.  
  149. #Custom jump By Mr.Anonymous
  150. CanJump = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement