@Override
 public boolean doDie(L2Character killer) {
   if (!super.doDie(killer)) return false;
   if (_siege != null && _clan != null) {
     L2SiegeClan sc = _siege.getAttackerClan(_clan);
     if (sc != null) sc.removeFlag(this);
   } else if (_clan != null) TerritoryWarManager.getInstance().removeClanFlag(_clan);
   return true;
 }
  public L2SiegeFlagInstance(
      L2PcInstance player,
      int objectId,
      L2NpcTemplate template,
      boolean advanced,
      boolean outPost) {
    super(objectId, template);
    setInstanceType(InstanceType.L2SiegeFlagInstance);

    if (TerritoryWarManager.getInstance().isTWInProgress()) {
      _clan = player.getClan();
      _player = player;
      _canTalk = false;
      if (_clan == null) deleteMe();
      if (outPost) {
        _isAdvanced = false;
        setIsInvul(true);
      } else {
        _isAdvanced = advanced;
        setIsInvul(false);
      }
      getStatus();
      return;
    }
    _clan = player.getClan();
    _player = player;
    _canTalk = true;
    _siege = SiegeManager.getInstance().getSiege(_player.getX(), _player.getY(), _player.getZ());
    if (_siege == null)
      _siege =
          FortSiegeManager.getInstance().getSiege(_player.getX(), _player.getY(), _player.getZ());
    if (_siege == null) _siege = CHSiegeManager.getInstance().getSiege(player);
    if (_clan == null || _siege == null) {
      throw new NullPointerException(getClass().getSimpleName() + ": Initialization failed.");
    }

    L2SiegeClan sc = _siege.getAttackerClan(_clan);
    if (sc == null)
      throw new NullPointerException(getClass().getSimpleName() + ": Cannot find siege clan.");

    sc.addFlag(this);
    _isAdvanced = advanced;
    getStatus();
    setIsInvul(false);
  }
Ejemplo n.º 3
0
  @Override
  protected final void writeImpl() {
    writeC(0x00);
    writeD(_charObjId);
    writeD(_canTeleport ? 0x01 : 0);
    if (_canTeleport && (_clan != null) && !_isJailed) {
      boolean isInCastleDefense = false;
      boolean isInFortDefense = false;

      L2SiegeClan siegeClan = null;
      Castle castle = CastleManager.getInstance().getCastle(_activeChar);
      Fort fort = FortManager.getInstance().getFort(_activeChar);
      SiegableHall hall = CHSiegeManager.getInstance().getNearbyClanHall(_activeChar);
      if ((castle != null) && castle.getSiege().getIsInProgress()) {
        // siege in progress
        siegeClan = castle.getSiege().getAttackerClan(_clan);
        if ((siegeClan == null) && castle.getSiege().checkIsDefender(_clan)) {
          isInCastleDefense = true;
        }
      } else if ((fort != null) && fort.getSiege().getIsInProgress()) {
        // siege in progress
        siegeClan = fort.getSiege().getAttackerClan(_clan);
        if ((siegeClan == null) && fort.getSiege().checkIsDefender(_clan)) {
          isInFortDefense = true;
        }
      }

      writeD(_clan.getHideoutId() > 0 ? 0x01 : 0x00); // 6d 01 00 00 00 - to hide away
      writeD(
          (_clan.getCastleId() > 0) || isInCastleDefense
              ? 0x01
              : 0x00); // 6d 02 00 00 00 - to castle
      writeD(
          (TerritoryWarManager.getInstance().getFlagForClan(_clan) != null)
                  || ((siegeClan != null)
                      && !isInCastleDefense
                      && !isInFortDefense
                      && !siegeClan.getFlag().isEmpty())
                  || ((hall != null) && hall.getSiege().checkIsAttacker(_clan))
              ? 0x01
              : 0x00); // 6d 03 00 00 00 - to siege HQ
      writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow)
      writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED
      writeD(
          (_clan.getFortId() > 0) || isInFortDefense ? 0x01 : 0x00); // 6d 05 00 00 00 - to fortress
    } else {
      writeD(0x00); // 6d 01 00 00 00 - to hide away
      writeD(0x00); // 6d 02 00 00 00 - to castle
      writeD(0x00); // 6d 03 00 00 00 - to siege HQ
      writeD(_sweepable ? 0x01 : 0x00); // sweepable (blue glow)
      writeD(_access.allowFixedRes() ? 0x01 : 0x00); // 6d 04 00 00 00 - to FIXED
      writeD(0x00); // 6d 05 00 00 00 - to fortress
    }
    // TODO: protocol 152
    // @formatter:off
    /*
     * writeC(0); //show die animation
     * writeD(0); //agathion ress button
     * writeD(0); //additional free space
     */
    // @formatter:on
  }
Ejemplo n.º 4
0
  @Override
  protected final void writeImpl() {
    writeC(0xcb);
    writeD(_castle.getResidenceId());
    writeD(0x00); // Unknown
    writeD(0x01); // Unknown
    writeD(0x00); // Unknown

    final int size =
        _castle.getSiege().getDefenderWaitingClans().size()
            + _castle.getSiege().getDefenderClans().size()
            + (_castle.getOwner() != null ? 1 : 0);

    writeD(size);
    writeD(size);

    // Add owners
    final L2Clan ownerClan = _castle.getOwner();
    if (ownerClan != null) {
      writeD(ownerClan.getId());
      writeS(ownerClan.getName());
      writeS(ownerClan.getLeaderName());
      writeD(ownerClan.getCrestId());
      writeD(0x00); // signed time (seconds) (not storated by L2J)
      writeD(SiegeClanType.OWNER.ordinal());
      writeD(ownerClan.getAllyId());
      writeS(ownerClan.getAllyName());
      writeS(""); // AllyLeaderName
      writeD(ownerClan.getAllyCrestId());
    }

    // List of confirmed defenders
    for (L2SiegeClan siegeClan : _castle.getSiege().getDefenderClans()) {
      final L2Clan defendingClan = ClanTable.getInstance().getClan(siegeClan.getClanId());
      if ((defendingClan == null) || (defendingClan == _castle.getOwner())) {
        continue;
      }

      writeD(defendingClan.getId());
      writeS(defendingClan.getName());
      writeS(defendingClan.getLeaderName());
      writeD(defendingClan.getCrestId());
      writeD(0x00); // signed time (seconds) (not storated by L2J)
      writeD(SiegeClanType.DEFENDER.ordinal());
      writeD(defendingClan.getAllyId());
      writeS(defendingClan.getAllyName());
      writeS(""); // AllyLeaderName
      writeD(defendingClan.getAllyCrestId());
    }

    // List of not confirmed defenders
    for (L2SiegeClan siegeClan : _castle.getSiege().getDefenderWaitingClans()) {
      final L2Clan defendingClan = ClanTable.getInstance().getClan(siegeClan.getClanId());
      if (defendingClan == null) {
        continue;
      }

      writeD(defendingClan.getId());
      writeS(defendingClan.getName());
      writeS(defendingClan.getLeaderName());
      writeD(defendingClan.getCrestId());
      writeD(0x00); // signed time (seconds) (not storated by L2J)
      writeD(SiegeClanType.DEFENDER_PENDING.ordinal());
      writeD(defendingClan.getAllyId());
      writeS(defendingClan.getAllyName());
      writeS(""); // AllyLeaderName
      writeD(defendingClan.getAllyCrestId());
    }
  }