ServerObjectInfo.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 com.l2jserver.gameserver.network.serverpackets;
  16. import com.l2jserver.gameserver.model.actor.L2Character;
  17. import com.l2jserver.gameserver.model.actor.L2Npc;
  18. /**
  19. *
  20. * @author devScarlet & mrTJO
  21. */
  22. public final class ServerObjectInfo extends L2GameServerPacket
  23. {
  24. private static final String _S__92_SERVEROBJECTINFO = "[S] 92 ServerObjectInfo";
  25. private L2Npc _activeChar;
  26. private int _x, _y, _z, _heading;
  27. private int _idTemplate;
  28. private boolean _isAttackable;
  29. private int _collisionHeight, _collisionRadius;
  30. public ServerObjectInfo(L2Npc activeChar, L2Character actor)
  31. {
  32. _activeChar = activeChar;
  33. _idTemplate = _activeChar.getTemplate().idTemplate;
  34. _isAttackable = _activeChar.isAutoAttackable(actor);
  35. _collisionHeight = _activeChar.getCollisionHeight();
  36. _collisionRadius = _activeChar.getCollisionRadius();
  37. _x = _activeChar.getX();
  38. _y = _activeChar.getY();
  39. _z = _activeChar.getZ();
  40. _heading = _activeChar.getHeading();
  41. }
  42. /**
  43. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
  44. */
  45. @Override
  46. protected final void writeImpl()
  47. {
  48. writeC(0x92);
  49. writeD(_activeChar.getObjectId());
  50. writeD(_idTemplate+1000000);
  51. writeS(""); // name
  52. writeD(_isAttackable ? 1 : 0);
  53. writeD(_x);
  54. writeD(_y);
  55. writeD(_z);
  56. writeD(_heading);
  57. writeF(1.0); // movement multiplier
  58. writeF(1.0); // attack speed multiplier
  59. writeF(_collisionRadius);
  60. writeF(_collisionHeight);
  61. writeD((int) (_isAttackable ? _activeChar.getCurrentHp() : 0));
  62. writeD(_isAttackable ? _activeChar.getMaxHp() : 0);
  63. writeD(0x01); // object type
  64. writeD(0x00); // special effects
  65. }
  66. /**
  67. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
  68. */
  69. @Override
  70. public String getType()
  71. {
  72. return _S__92_SERVEROBJECTINFO;
  73. }
  74. }