StatusUpdate.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 java.util.ArrayList;
  17. /**
  18. *
  19. * 01 // Packet Identifier <BR>
  20. * c6 37 50 40 // ObjectId <BR><BR>
  21. *
  22. * 01 00 // Number of Attribute Trame of the Packet <BR><BR>
  23. *
  24. * c6 37 50 40 // Attribute Identifier : 01-Level, 02-Experience, 03-STR, 04-DEX, 05-CON, 06-INT, 07-WIT, 08-MEN, 09-Current HP, 0a, Max HP...<BR>
  25. * cd 09 00 00 // Attribute Value <BR>
  26. *
  27. * format d d(dd)
  28. *
  29. * @version $Revision: 1.3.2.1.2.5 $ $Date: 2005/03/27 15:29:39 $
  30. */
  31. public final class StatusUpdate extends L2GameServerPacket
  32. {
  33. private static final String _S__1A_STATUSUPDATE = "[S] 18 StatusUpdate";
  34. public static final int LEVEL = 0x01;
  35. public static final int EXP = 0x02;
  36. public static final int STR = 0x03;
  37. public static final int DEX = 0x04;
  38. public static final int CON = 0x05;
  39. public static final int INT = 0x06;
  40. public static final int WIT = 0x07;
  41. public static final int MEN = 0x08;
  42. public static final int CUR_HP = 0x09;
  43. public static final int MAX_HP = 0x0a;
  44. public static final int CUR_MP = 0x0b;
  45. public static final int MAX_MP = 0x0c;
  46. public static final int SP = 0x0d;
  47. public static final int CUR_LOAD = 0x0e;
  48. public static final int MAX_LOAD = 0x0f;
  49. public static final int P_ATK = 0x11;
  50. public static final int ATK_SPD = 0x12;
  51. public static final int P_DEF = 0x13;
  52. public static final int EVASION = 0x14;
  53. public static final int ACCURACY = 0x15;
  54. public static final int CRITICAL = 0x16;
  55. public static final int M_ATK = 0x17;
  56. public static final int CAST_SPD = 0x18;
  57. public static final int M_DEF = 0x19;
  58. public static final int PVP_FLAG = 0x1a;
  59. public static final int KARMA = 0x1b;
  60. public static final int CUR_CP = 0x21;
  61. public static final int MAX_CP = 0x22;
  62. private int _objectId;
  63. private ArrayList<Attribute> _attributes;
  64. class Attribute
  65. {
  66. /** id values
  67. * 09 - current health
  68. * 0a - max health
  69. * 0b - current mana
  70. * 0c - max mana
  71. *
  72. */
  73. public int id;
  74. public int value;
  75. Attribute(int pId, int pValue)
  76. {
  77. id = pId;
  78. value = pValue;
  79. }
  80. }
  81. public StatusUpdate(int objectId)
  82. {
  83. _attributes = new ArrayList<Attribute>();
  84. _objectId = objectId;
  85. }
  86. public void addAttribute(int id, int level)
  87. {
  88. _attributes.add(new Attribute(id, level));
  89. }
  90. @Override
  91. protected final void writeImpl()
  92. {
  93. writeC(0x18);
  94. writeD(_objectId);
  95. writeD(_attributes.size());
  96. for (Attribute temp: _attributes)
  97. {
  98. writeD(temp.id);
  99. writeD(temp.value);
  100. }
  101. }
  102. /* (non-Javadoc)
  103. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#getType()
  104. */
  105. @Override
  106. public String getType()
  107. {
  108. return _S__1A_STATUSUPDATE;
  109. }
  110. }