ServerObjectInfo.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 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 double _collisionHeight, _collisionRadius;
  30. private String _name;
  31. public ServerObjectInfo(L2Npc activeChar, L2Character actor)
  32. {
  33. _activeChar = activeChar;
  34. _idTemplate = _activeChar.getTemplate().idTemplate;
  35. _isAttackable = _activeChar.isAutoAttackable(actor);
  36. _collisionHeight = _activeChar.getCollisionHeight();
  37. _collisionRadius = _activeChar.getCollisionRadius();
  38. _x = _activeChar.getX();
  39. _y = _activeChar.getY();
  40. _z = _activeChar.getZ();
  41. _heading = _activeChar.getHeading();
  42. _name = _activeChar.getTemplate().serverSideName ? _activeChar.getTemplate().name : "";
  43. }
  44. /**
  45. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#writeImpl()
  46. */
  47. @Override
  48. protected final void writeImpl()
  49. {
  50. writeC(0x92);
  51. writeD(_activeChar.getObjectId());
  52. writeD(_idTemplate+1000000);
  53. writeS(_name); // name
  54. writeD(_isAttackable ? 1 : 0);
  55. writeD(_x);
  56. writeD(_y);
  57. writeD(_z);
  58. writeD(_heading);
  59. writeF(1.0); // movement multiplier
  60. writeF(1.0); // attack speed multiplier
  61. writeF(_collisionRadius);
  62. writeF(_collisionHeight);
  63. writeD((int) (_isAttackable ? _activeChar.getCurrentHp() : 0));
  64. writeD(_isAttackable ? _activeChar.getMaxHp() : 0);
  65. writeD(0x01); // object type
  66. writeD(0x00); // special effects
  67. }
  68. /**
  69. * @see com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket#getType()
  70. */
  71. @Override
  72. public String getType()
  73. {
  74. return _S__92_SERVEROBJECTINFO;
  75. }
  76. }