RelationChanged.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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.L2Playable;
  17. import com.l2jserver.gameserver.model.actor.L2Summon;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. *
  21. * @author Luca Baldi
  22. */
  23. public final class RelationChanged extends L2GameServerPacket
  24. {
  25. public static final int RELATION_PARTY1 = 0x00001; // party member
  26. public static final int RELATION_PARTY2 = 0x00002; // party member
  27. public static final int RELATION_PARTY3 = 0x00004; // party member
  28. public static final int RELATION_PARTY4 = 0x00008; // party member (for information, see L2PcInstance.getRelation())
  29. public static final int RELATION_PARTYLEADER = 0x00010; // true if is party leader
  30. public static final int RELATION_HAS_PARTY = 0x00020; // true if is in party
  31. public static final int RELATION_CLAN_MEMBER = 0x00040; // true if is in clan
  32. public static final int RELATION_LEADER = 0x00080; // true if is clan leader
  33. public static final int RELATION_INSIEGE = 0x00200; // true if in siege
  34. public static final int RELATION_ATTACKER = 0x00400; // true when attacker
  35. public static final int RELATION_ALLY = 0x00800; // blue siege icon, cannot have if red
  36. public static final int RELATION_ENEMY = 0x01000; // true when red icon, doesn't matter with blue
  37. public static final int RELATION_1SIDED_WAR = 0x08000; // single fist
  38. public static final int RELATION_MUTUAL_WAR = 0x04000; // double fist
  39. public static final int RELATION_TERRITORY_WAR= 0x80000; // show Territory War icon
  40. private static final String _S__CE_RELATIONCHANGED = "[S] ce RelationChanged";
  41. private int _objId, _relation, _autoAttackable, _karma, _pvpFlag;
  42. public RelationChanged(L2Playable activeChar, int relation, boolean autoattackable)
  43. {
  44. _objId = activeChar.getObjectId();
  45. _relation = relation;
  46. _autoAttackable = autoattackable ? 1 : 0;
  47. if (activeChar instanceof L2PcInstance)
  48. {
  49. _karma = ((L2PcInstance)activeChar).getKarma();
  50. _pvpFlag = ((L2PcInstance)activeChar).getPvpFlag();
  51. _invisible = ((L2PcInstance)activeChar).getAppearance().getInvisible();
  52. }
  53. else if (activeChar instanceof L2Summon)
  54. {
  55. _karma = ((L2Summon)activeChar).getOwner().getKarma();
  56. _pvpFlag = ((L2Summon)activeChar).getOwner().getPvpFlag();
  57. _invisible = ((L2Summon)activeChar).getOwner().getAppearance().getInvisible();
  58. }
  59. }
  60. /**
  61. * @see com.l2jserver.gameserver.serverpackets.ServerBasePacket#writeImpl()
  62. */
  63. @Override
  64. protected final void writeImpl()
  65. {
  66. writeC(0xce);
  67. writeD(1); // CT24 unknown
  68. writeD(_objId);
  69. writeD(_relation);
  70. writeD(_autoAttackable);
  71. writeD(_karma);
  72. writeD(_pvpFlag);
  73. }
  74. /**
  75. * @see com.l2jserver.gameserver.BasePacket#getType()
  76. */
  77. @Override
  78. public String getType()
  79. {
  80. return _S__CE_RELATIONCHANGED;
  81. }
  82. }