RelationChanged.java 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_CLAN_MATE = 0x00100; // true if is in same clan
  34. public static final int RELATION_INSIEGE = 0x00200; // true if in siege
  35. public static final int RELATION_ATTACKER = 0x00400; // true when attacker
  36. public static final int RELATION_ALLY = 0x00800; // blue siege icon, cannot have if red
  37. public static final int RELATION_ENEMY = 0x01000; // true when red icon, doesn't matter with blue
  38. public static final int RELATION_1SIDED_WAR = 0x08000; // single fist
  39. public static final int RELATION_MUTUAL_WAR = 0x04000; // double fist
  40. public static final int RELATION_ALLY_MEMBER = 0x10000; // clan is in alliance
  41. public static final int RELATION_TERRITORY_WAR= 0x80000; // show Territory War icon
  42. private static final String _S__CE_RELATIONCHANGED = "[S] ce RelationChanged";
  43. private int _objId, _relation, _autoAttackable, _karma, _pvpFlag;
  44. public RelationChanged(L2Playable activeChar, int relation, boolean autoattackable)
  45. {
  46. _objId = activeChar.getObjectId();
  47. _relation = relation;
  48. _autoAttackable = autoattackable ? 1 : 0;
  49. if (activeChar instanceof L2PcInstance)
  50. {
  51. _karma = ((L2PcInstance)activeChar).getKarma();
  52. _pvpFlag = ((L2PcInstance)activeChar).getPvpFlag();
  53. _invisible = ((L2PcInstance)activeChar).getAppearance().getInvisible();
  54. }
  55. else if (activeChar instanceof L2Summon)
  56. {
  57. _karma = ((L2Summon)activeChar).getOwner().getKarma();
  58. _pvpFlag = ((L2Summon)activeChar).getOwner().getPvpFlag();
  59. _invisible = ((L2Summon)activeChar).getOwner().getAppearance().getInvisible();
  60. }
  61. }
  62. /**
  63. * @see com.l2jserver.util.network.BaseSendablePacket.ServerBasePacket#writeImpl()
  64. */
  65. @Override
  66. protected final void writeImpl()
  67. {
  68. writeC(0xce);
  69. writeD(1); // CT24 unknown
  70. writeD(_objId);
  71. writeD(_relation);
  72. writeD(_autoAttackable);
  73. writeD(_karma);
  74. writeD(_pvpFlag);
  75. }
  76. /**
  77. * @see com.l2jserver.gameserver.BasePacket#getType()
  78. */
  79. @Override
  80. public String getType()
  81. {
  82. return _S__CE_RELATIONCHANGED;
  83. }
  84. }