ServerObjectInfo.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.serverpackets;
  20. import com.l2jserver.gameserver.model.actor.L2Character;
  21. import com.l2jserver.gameserver.model.actor.L2Npc;
  22. /**
  23. * @author devScarlet, mrTJO
  24. */
  25. public final class ServerObjectInfo extends L2GameServerPacket
  26. {
  27. private final L2Npc _activeChar;
  28. private final int _x, _y, _z, _heading;
  29. private final int _idTemplate;
  30. private final boolean _isAttackable;
  31. private final double _collisionHeight, _collisionRadius;
  32. private final String _name;
  33. public ServerObjectInfo(L2Npc activeChar, L2Character actor)
  34. {
  35. _activeChar = activeChar;
  36. _idTemplate = _activeChar.getTemplate().getDisplayId();
  37. _isAttackable = _activeChar.isAutoAttackable(actor);
  38. _collisionHeight = _activeChar.getCollisionHeight();
  39. _collisionRadius = _activeChar.getCollisionRadius();
  40. _x = _activeChar.getX();
  41. _y = _activeChar.getY();
  42. _z = _activeChar.getZ();
  43. _heading = _activeChar.getHeading();
  44. _name = _activeChar.getTemplate().isUsingServerSideName() ? _activeChar.getTemplate().getName() : "";
  45. }
  46. @Override
  47. protected final void writeImpl()
  48. {
  49. writeC(0x92);
  50. writeD(_activeChar.getObjectId());
  51. writeD(_idTemplate + 1000000);
  52. writeS(_name); // name
  53. writeD(_isAttackable ? 1 : 0);
  54. writeD(_x);
  55. writeD(_y);
  56. writeD(_z);
  57. writeD(_heading);
  58. writeF(1.0); // movement multiplier
  59. writeF(1.0); // attack speed multiplier
  60. writeF(_collisionRadius);
  61. writeF(_collisionHeight);
  62. writeD((int) (_isAttackable ? _activeChar.getCurrentHp() : 0));
  63. writeD(_isAttackable ? _activeChar.getMaxHp() : 0);
  64. writeD(0x01); // object type
  65. writeD(0x00); // special effects
  66. }
  67. }