Exemplo n.º 1
0
  @Override
  protected final void writeImpl() {
    writeC(0x96);
    writeS(_activeChar.getName());
    writeD(_clan.getClanId());
    writeD(0x00);
    writeS(_clan.getName());
    writeS(_clan.getLeaderName());
    writeD(_clan.getCrestId()); // -> no, it's no longer used (nuocnam) fix by game
    writeD(_clan.getLevel());
    writeD(_clan.getCastleId());
    writeD(_clan.getHideoutId());
    writeD(_clan.getFortId());
    writeD(_clan.getRank());
    writeD(_clan.getReputationScore());
    writeD(0x00);
    writeD(0x00);

    writeD(_clan.getAllyId()); // c2
    writeS(_clan.getAllyName()); // c2
    writeD(_clan.getAllyCrestId()); // c2
    writeD(_clan.isAtWar() ? 1 : 0); // c3
    writeD(0x00); // T3 Unknown
    writeD(_clan.getMembers().length);

    for (L2ClanMember member : _clan.getMembers()) {
      if (member != null) {
        writeS(member.getName());
        writeD(member.getLevel());
        writeD(member.getClassId());
        writeD(member.getSex() ? 1 : 0);
        writeD(member.getRaceOrdinal());
        writeD(member.isOnline() ? member.getObjectId() : 0);
        writeD(member.getSponsor() != 0 ? 1 : 0);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * This method will set owner for Fort
   *
   * @param clan
   * @param updateClansReputation
   * @return
   */
  public boolean setOwner(L2Clan clan, boolean updateClansReputation) {
    if (clan == null) {
      _log.warning(getClass().getSimpleName() + ": Updating Fort owner with null clan!!!");
      return false;
    }

    final SystemMessage sm =
        SystemMessage.getSystemMessage(SystemMessageId.THE_FORTRESS_BATTLE_OF_S1_HAS_FINISHED);
    sm.addCastleId(getResidenceId());
    getSiege().announceToPlayer(sm);

    final L2Clan oldowner = getOwnerClan();
    if ((oldowner != null) && (clan != oldowner)) {
      // Remove points from old owner
      updateClansReputation(oldowner, true);
      try {
        L2PcInstance oldleader = oldowner.getLeader().getPlayerInstance();
        if (oldleader != null) {
          if (oldleader.getMountType() == MountType.WYVERN) {
            oldleader.dismount();
          }
        }
      } catch (Exception e) {
        _log.log(Level.WARNING, "Exception in setOwner: " + e.getMessage(), e);
      }
      removeOwner(true);
    }
    setFortState(0, 0); // initialize fort state

    // if clan already have castle, don't store him in fortress
    if (clan.getCastleId() > 0) {
      getSiege()
          .announceToPlayer(
              SystemMessage.getSystemMessage(
                  SystemMessageId.THE_REBEL_ARMY_RECAPTURED_THE_FORTRESS));
      return false;
    }

    // Give points to new owner
    if (updateClansReputation) {
      updateClansReputation(clan, false);
    }

    spawnSpecialEnvoys();
    // if clan have already fortress, remove it
    if (clan.getFortId() > 0) {
      FortManager.getInstance().getFortByOwner(clan).removeOwner(true);
    }

    setSupplyLvL(0);
    setOwnerClan(clan);
    updateOwnerInDB(); // Update in database
    saveFortVariables();

    if (getSiege().isInProgress()) {
      getSiege().endSiege();
    }

    for (L2PcInstance member : clan.getOnlineMembers(0)) {
      giveResidentialSkills(member);
      member.sendSkillList();
    }
    return true;
  }
Exemplo 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
  }