Package l2p.gameserver.serverpackets

Source Code of l2p.gameserver.serverpackets.Die

package l2p.gameserver.serverpackets;

import l2p.gameserver.instancemanager.SiegeManager;
import l2p.gameserver.model.L2Character;
import l2p.gameserver.model.L2Clan;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.entity.siege.Siege;
import l2p.gameserver.model.entity.siege.SiegeClan;
import l2p.gameserver.model.entity.siege.territory.TerritorySiege;
import l2p.gameserver.model.instances.L2MonsterInstance;

public class Die extends L2GameServerPacket
{
  private int _chaId;
  private boolean _fake;
  private boolean _sweepable;
  private int _access;
  private L2Clan _clan;
  private L2Character _cha;
  private int to_hideaway, to_castle, to_siege_HQ, to_fortress;
  private boolean isEvent;

  public Die(L2Character cha)
  {
    _cha = cha;
    if(cha.isPlayer())
    {
      L2Player player = (L2Player) cha;
      isEvent = player.isEvent();
      _access = player.getPlayerAccess().ResurectFixed ? 0x01 : 0x00;
      _clan = player.getClan();
    }
    _chaId = cha.getObjectId();
    _fake = !cha.isDead();
    if(cha.isMonster())
    {
      _sweepable = ((L2MonsterInstance) cha).isSweepActive();
    }
    if(_clan != null)
    {
      SiegeClan siegeClan = null;
      Siege siege = SiegeManager.getSiege(_cha, true);
      if(siege != null)
      {
        siegeClan = siege.getAttackerClan(_clan);
      }
      if(TerritorySiege.checkIfInZone(_cha))
      {
        siegeClan = TerritorySiege.getSiegeClan(_clan);
      }
      to_hideaway = _clan.getHasHideout() > 0 ? 0x01 : 0x00;
      to_castle = _clan.getHasCastle() > 0 ? 0x01 : 0x00;
      to_siege_HQ = siegeClan != null && siegeClan.getHeadquarter() != null ? 0x01 : 0x00;
      to_fortress = _clan.getHasFortress() > 0 ? 0x01 : 0x00;
    }
    else
    {
      to_hideaway = 0;
      to_castle = 0;
      to_siege_HQ = 0;
      to_fortress = 0;
    }
  }

  @Override
  protected final void writeImpl()
  {
    if(_fake)
    {
      return;
    }
    writeC(0x00);
    writeD(_chaId);
    writeD(isEvent ? 0x00 : 0x01); // to nearest village
    writeD(isEvent ? 0x00 : to_hideaway); // to hide away
    writeD(isEvent ? 0x00 : to_castle); // to castle
    writeD(isEvent ? 0x00 : to_siege_HQ); // to siege HQ
    writeD(_sweepable ? 0x01 : 0x00); // sweepable  (blue glow)
    writeD(isEvent ? 0x00 : _access); // FIXED
    writeD(isEvent ? 0x00 : to_fortress); // fortress
    if(getClient().getRevision() >= 152) // cd dx[d]
    {
      writeC(0); //show die animation
      writeD(0); //agathion ress button
      writeD(0); //additional free space
    }
  }
}
TOP

Related Classes of l2p.gameserver.serverpackets.Die

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.