Advertisement
Guest User

Untitled

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