Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. /*
  2. * L2jFrozen Project - www.l2jfrozen.com
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2, or (at your option)
  7. * any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  17. * 02111-1307, USA.
  18. *
  19. * http://www.gnu.org/copyleft/gpl.html
  20. */
  21. package com.l2jfrozen.gameserver.network.serverpackets;
  22.  
  23. import com.l2jfrozen.gameserver.event.EventManager;
  24. import com.l2jfrozen.gameserver.datatables.AccessLevel;
  25. import com.l2jfrozen.gameserver.datatables.sql.AccessLevels;
  26. import com.l2jfrozen.gameserver.managers.CastleManager;
  27. import com.l2jfrozen.gameserver.managers.FortManager;
  28. import com.l2jfrozen.gameserver.model.L2Attackable;
  29. import com.l2jfrozen.gameserver.model.L2Character;
  30. import com.l2jfrozen.gameserver.model.L2SiegeClan;
  31. import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
  32. import com.l2jfrozen.gameserver.model.entity.event.CTF;
  33. import com.l2jfrozen.gameserver.model.entity.event.DM;
  34. import com.l2jfrozen.gameserver.model.entity.event.TvT;
  35. import com.l2jfrozen.gameserver.model.entity.siege.Castle;
  36. import com.l2jfrozen.gameserver.model.entity.siege.Fort;
  37. import com.l2jfrozen.gameserver.model.zone.type.L2MultiFunctionZone;
  38.  
  39. /**
  40. * sample 0b 952a1048 objectId 00000000 00000000 00000000 00000000 00000000 00000000 format dddddd rev 377 format ddddddd rev 417
  41. * @version $Revision: 1.3.3 $ $Date: 2009/04/29 00:46:18 $
  42. */
  43. public class Die extends L2GameServerPacket
  44. {
  45. private static final String _S__0B_DIE = "[S] 06 Die";
  46. private final int _charObjId;
  47. private final boolean _fake;
  48. private boolean _sweepable;
  49. private boolean _canTeleport;
  50. private AccessLevel _access = AccessLevels.getInstance()._userAccessLevel;
  51. private boolean _event;
  52. private com.l2jfrozen.gameserver.model.L2Clan _clan;
  53. L2Character _activeChar;
  54.  
  55. /**
  56. * @param cha
  57. */
  58. public Die(final L2Character cha)
  59. {
  60. _activeChar = cha;
  61. if (cha instanceof L2PcInstance)
  62. {
  63. final L2PcInstance player = (L2PcInstance) cha;
  64. _access = player.getAccessLevel();
  65. _clan = player.getClan();
  66. _event = EventManager.getInstance().isRegistered((L2PcInstance)cha);
  67. _canTeleport = !((TvT.is_started() && player._inEventTvT) || (DM.is_started() && player._inEventDM) || (CTF.is_started() && player._inEventCTF) || player.isInFunEvent() || player.isPendingRevive()|| (player.isInsideZone(L2Character.ZONE_MULTIFUNCTION) && L2MultiFunctionZone.revive));
  68. }
  69. _charObjId = cha.getObjectId();
  70. _fake = !cha.isDead();
  71. if (cha instanceof L2Attackable)
  72. {
  73. _sweepable = ((L2Attackable) cha).isSweepActive();
  74. }
  75.  
  76. }
  77.  
  78. @Override
  79. protected final void writeImpl()
  80. {
  81. if (_fake)
  82. return;
  83.  
  84. writeC(0x06);
  85.  
  86. writeD(_charObjId);
  87. // NOTE:
  88. // 6d 00 00 00 00 - to nearest village
  89. // 6d 01 00 00 00 - to hide away
  90. // 6d 02 00 00 00 - to castle
  91. // 6d 03 00 00 00 - to siege HQ
  92. // sweepable
  93. // 6d 04 00 00 00 - FIXED
  94.  
  95. if(_event) {
  96. writeD(0x00);
  97. writeD(0x00); // 6d 01 00 00 00 - to hide away
  98. writeD(0x00); // 6d 02 00 00 00 - to castle
  99. writeD(0x00);
  100. }
  101. else
  102. {
  103. writeD(_canTeleport ? 0x01 : 0); // 6d 00 00 00 00 - to nearest village
  104. if(_canTeleport && _clan != null)
  105. {
  106. L2SiegeClan siegeClan = null;
  107. Boolean isInDefense = false;
  108. Castle castle = CastleManager.getInstance().getCastle(_activeChar);
  109. Fort fort = FortManager.getInstance().getFort(_activeChar);
  110.  
  111. if(castle != null && castle.getSiege().getIsInProgress())
  112. {
  113. //siege in progress
  114. siegeClan = castle.getSiege().getAttackerClan(_clan);
  115. if(siegeClan == null && castle.getSiege().checkIsDefender(_clan))
  116. {
  117. isInDefense = true;
  118. }
  119. }
  120. else if(fort != null && fort.getSiege().getIsInProgress())
  121. {
  122. //siege in progress
  123. siegeClan = fort.getSiege().getAttackerClan(_clan);
  124. if(siegeClan == null && fort.getSiege().checkIsDefender(_clan))
  125. {
  126. isInDefense = true;
  127. }
  128. }
  129. writeD(_clan.getHasHideout() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away
  130. writeD(_clan.getHasCastle() > 0 || _clan.getHasFort() > 0 || isInDefense ? 0x01 : 0x00); // 6d 02 00 00 00 - to castle
  131. writeD(siegeClan != null && !isInDefense && siegeClan.getFlag().size() > 0 ? 0x01 : 0x00); // 6d 03 00 00 00 - to siege HQ
  132. {
  133. isInDefense = true;
  134. }
  135. }
  136. else
  137. {
  138. writeD(0x00); // 6d 01 00 00 00 - to hide away
  139. writeD(0x00); // 6d 02 00 00 00 - to castle
  140. writeD(0x00); // 6d 03 00 00 00 - to siege HQ
  141. }
  142. }
  143.  
  144. writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow)
  145. writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED
  146. }
  147.  
  148. /*
  149. * (non-Javadoc)
  150. * @see com.l2jfrozen.gameserver.serverpackets.ServerBasePacket#getType()
  151. */
  152. @Override
  153. public String getType()
  154. {
  155. return _S__0B_DIE;
  156. }
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement