StatusUpdate.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 java.util.ArrayList;
  21. import com.l2jserver.gameserver.model.L2Object;
  22. public final class StatusUpdate extends L2GameServerPacket
  23. {
  24. public static final int LEVEL = 0x01;
  25. public static final int EXP = 0x02;
  26. public static final int STR = 0x03;
  27. public static final int DEX = 0x04;
  28. public static final int CON = 0x05;
  29. public static final int INT = 0x06;
  30. public static final int WIT = 0x07;
  31. public static final int MEN = 0x08;
  32. public static final int CUR_HP = 0x09;
  33. public static final int MAX_HP = 0x0a;
  34. public static final int CUR_MP = 0x0b;
  35. public static final int MAX_MP = 0x0c;
  36. public static final int SP = 0x0d;
  37. public static final int CUR_LOAD = 0x0e;
  38. public static final int MAX_LOAD = 0x0f;
  39. public static final int P_ATK = 0x11;
  40. public static final int ATK_SPD = 0x12;
  41. public static final int P_DEF = 0x13;
  42. public static final int EVASION = 0x14;
  43. public static final int ACCURACY = 0x15;
  44. public static final int CRITICAL = 0x16;
  45. public static final int M_ATK = 0x17;
  46. public static final int CAST_SPD = 0x18;
  47. public static final int M_DEF = 0x19;
  48. public static final int PVP_FLAG = 0x1a;
  49. public static final int KARMA = 0x1b;
  50. public static final int CUR_CP = 0x21;
  51. public static final int MAX_CP = 0x22;
  52. private final int _objectId;
  53. private final ArrayList<Attribute> _attributes = new ArrayList<>();
  54. static class Attribute
  55. {
  56. /**
  57. * id values 09 - current health 0a - max health 0b - current mana 0c - max mana
  58. */
  59. public int id;
  60. public int value;
  61. Attribute(int pId, int pValue)
  62. {
  63. id = pId;
  64. value = pValue;
  65. }
  66. }
  67. /**
  68. * If you have access to object itself use {@link StatusUpdate#StatusUpdate(L2Object)}.
  69. * @param objectId
  70. */
  71. public StatusUpdate(int objectId)
  72. {
  73. _objectId = objectId;
  74. }
  75. /**
  76. * Create {@link StatusUpdate} packet for given {@link L2Object}.
  77. * @param object
  78. */
  79. public StatusUpdate(L2Object object)
  80. {
  81. _objectId = object.getObjectId();
  82. }
  83. public void addAttribute(int id, int level)
  84. {
  85. _attributes.add(new Attribute(id, level));
  86. }
  87. public boolean hasAttributes()
  88. {
  89. return !_attributes.isEmpty();
  90. }
  91. @Override
  92. protected final void writeImpl()
  93. {
  94. writeC(0x18);
  95. writeD(_objectId);
  96. writeD(_attributes.size());
  97. for (Attribute temp : _attributes)
  98. {
  99. writeD(temp.id);
  100. writeD(temp.value);
  101. }
  102. }
  103. }