Package com.l2jfrozen.gameserver.model.entity.siege

Examples of com.l2jfrozen.gameserver.model.entity.siege.Castle


    {
      _log.warning("Living player [" + activeChar.getName() + "] called RestartPointPacket! Ban this player!");
      return;
    }
   
    Castle castle = CastleManager.getInstance().getCastle(activeChar.getX(), activeChar.getY(), activeChar.getZ());
    if (castle != null && castle.getSiege().getIsInProgress())
    {
      if (activeChar.getClan() != null && castle.getSiege().checkIsAttacker(activeChar.getClan()))
      {
        // Schedule respawn delay for attacker
        ThreadPoolManager.getInstance().scheduleGeneral(new DeathTask(activeChar), castle.getSiege().getAttackerRespawnDelay());
        activeChar.sendMessage("You will be re-spawned in " + castle.getSiege().getAttackerRespawnDelay() / 1000 + " seconds");
        return;
      }
    }
    // run immediately (no need to schedule)
    new DeathTask(activeChar).run();
View Full Code Here


        return;
      }
      try
      {
        Location loc = null;
        Castle castle = null;
        Fort fort = null;
       
        if (activeChar.isInJail())
        {
          _requestedPointType = 27;
        }
        else if (activeChar.isFestivalParticipant())
        {
          _requestedPointType = 4;
        }
       
        if (activeChar.isPhoenixBlessed())
          activeChar.stopPhoenixBlessing(null);
       
        switch (_requestedPointType)
        {
          case 1: // to clanhall
           
            if (activeChar.getClan() != null)
            {
             
              if (activeChar.getClan().getHasHideout() == 0)
              {
                // cheater
                activeChar.sendMessage("You may not use this respawn point!");
                Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " used respawn cheat.", IllegalPlayerAction.PUNISH_KICK);
                return;
              }
              loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClanHall);
             
              if (ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()) != null && ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP) != null)
              {
                activeChar.restoreExp(ClanHallManager.getInstance().getClanHallByOwner(activeChar.getClan()).getFunction(ClanHall.FUNC_RESTORE_EXP).getLvl());
              }
             
              break;       
            }
           
            loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
            break;
          case 2: // to castle
            Boolean isInDefense = false;
            castle = CastleManager.getInstance().getCastle(activeChar);
            fort = FortManager.getInstance().getFort(activeChar);
            MapRegionTable.TeleportWhereType teleportWhere = MapRegionTable.TeleportWhereType.Town;
           
            if (castle != null && castle.getSiege().getIsInProgress())
            {
              // siege in progress
              if (castle.getSiege().checkIsDefender(activeChar.getClan()))
              {
                isInDefense = true;
              }
            }
           
            if (fort != null && fort.getSiege().getIsInProgress())
            {
              // siege in progress
              if (fort.getSiege().checkIsDefender(activeChar.getClan()))
              {
                isInDefense = true;
              }
            }
           
            if (activeChar.getClan().getHasCastle() == 0 && activeChar.getClan().getHasFort() == 0 && !isInDefense)
            {
              // cheater
              activeChar.sendMessage("You may not use this respawn point!");
              Util.handleIllegalPlayerAction(activeChar, "Player " + activeChar.getName() + " used respawn cheat.", IllegalPlayerAction.PUNISH_KICK);
              return;
            }
           
            if (CastleManager.getInstance().getCastleByOwner(activeChar.getClan()) != null)
              teleportWhere = MapRegionTable.TeleportWhereType.Castle;
            else if (FortManager.getInstance().getFortByOwner(activeChar.getClan()) != null)
              teleportWhere = MapRegionTable.TeleportWhereType.Fortress;
           
            loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, teleportWhere);
            break;
         
          case 3: // to siege HQ
            L2SiegeClan siegeClan = null;
            castle = CastleManager.getInstance().getCastle(activeChar);
            fort = FortManager.getInstance().getFort(activeChar);
           
            if (castle != null && castle.getSiege().getIsInProgress())
            {
              siegeClan = castle.getSiege().getAttackerClan(activeChar.getClan());
            }
            else if (fort != null && fort.getSiege().getIsInProgress())
            {
              siegeClan = fort.getSiege().getAttackerClan(activeChar.getClan());
            }
View Full Code Here

    }

    if(!(target instanceof L2ManorManagerInstance))
      return;

    Castle castle = CastleManager.getInstance().getCastleById(_manorId);

    for(int i = 0; i < _count; i++)
    {
      int seedId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];
      int price = 0;
      int residual = 0;

      SeedProduction seed = castle.getSeed(seedId, CastleManorManager.PERIOD_CURRENT);
      price = seed.getPrice();
      residual = seed.getCanProduce();

      if(price <= 0)
        return;

      if(residual < count)
        return;

      totalPrice += count * price;

      L2Item template = ItemTable.getInstance().getTemplate(seedId);
      totalWeight += count * template.getWeight();
      if(!template.isStackable())
      {
        slots += count;
      }
      else if(player.getInventory().getItemByItemId(seedId) == null)
      {
        slots++;
      }
    }

    if(totalPrice > Integer.MAX_VALUE)
    {
      Util.handleIllegalPlayerAction(player, "Warning!! Character " + player.getName() + " of account " + player.getAccountName() + " tried to purchase over " + Integer.MAX_VALUE + " adena worth of goods.", Config.DEFAULT_PUNISH);
      return;
    }

    if(!player.getInventory().validateWeight(totalWeight))
    {
      sendPacket(new SystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
      return;
    }

    if(!player.getInventory().validateCapacity(slots))
    {
      sendPacket(new SystemMessage(SystemMessageId.SLOTS_FULL));
      return;
    }

    // Charge buyer
    if(totalPrice < 0 || !player.reduceAdena("Buy", (int) totalPrice, target, false))
    {
      sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
      return;
    }

    // Adding to treasury for Manor Castle
    castle.addToTreasuryNoTax((int) totalPrice);

    // Proceed the purchase
    InventoryUpdate playerIU = new InventoryUpdate();
    for(int i = 0; i < _count; i++)
    {
      int seedId = _items[i * 2 + 0];
      int count = _items[i * 2 + 1];

      if(count < 0)
      {
        count = 0;
      }

      // Update Castle Seeds Amount
      SeedProduction seed = castle.getSeed(seedId, CastleManorManager.PERIOD_CURRENT);
      seed.setCanProduce(seed.getCanProduce() - count);
      if(Config.ALT_MANOR_SAVE_ALL_ACTIONS)
      {
        CastleManager.getInstance().getCastleById(_manorId).updateSeed(seed.getId(), seed.getCanProduce(), CastleManorManager.PERIOD_CURRENT);
      }
View Full Code Here

    // Check if the player has a clan
    if(activeChar.getClan() == null)
      return;

    Castle castle = CastleManager.getInstance().getCastleById(_castleId);
    if(castle == null)
      return;

    // Check if leader of the clan who owns the castle?
    if(castle.getOwnerId() != activeChar.getClanId() || !activeChar.isClanLeader())
      return;

    L2Clan clan = ClanTable.getInstance().getClan(_clanId);
    if(clan == null)
      return;

    if(!castle.getSiege().getIsRegistrationOver())
    {
      if(_approved == 1)
      {
        if(castle.getSiege().checkIsDefenderWaiting(clan))
        {
          castle.getSiege().approveSiegeDefenderClan(_clanId);
        }
        else
          return;
      }
      else
      {
        if(castle.getSiege().checkIsDefenderWaiting(clan) || castle.getSiege().checkIsDefender(clan))
        {
          castle.getSiege().removeSiegeClan(_clanId);
        }
      }
    }

    //Update the defender list
View Full Code Here

          e.printStackTrace();
      }

      if(castleId > 0)
      {
        Castle castle = CastleManager.getInstance().getCastleById(castleId);
        castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
        castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
        castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
        castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);

        if(Config.ALT_MANOR_SAVE_ALL_ACTIONS)
        {
          castle.saveCropData();
          castle.saveSeedData();
        }

        activeChar.sendMessage("Manor data for " + castle.getName() + " was nulled");
      }
      else
      {
        for(Castle castle : CastleManager.getInstance().getCastles())
        {
          castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_CURRENT);
          castle.setCropProcure(new FastList<CropProcure>(), CastleManorManager.PERIOD_NEXT);
          castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_CURRENT);
          castle.setSeedProduction(new FastList<SeedProduction>(), CastleManorManager.PERIOD_NEXT);

          if(Config.ALT_MANOR_SAVE_ALL_ACTIONS)
          {
            castle.saveCropData();
            castle.saveSeedData();
          }
        }

        activeChar.sendMessage("Manor data was nulled");
      }
View Full Code Here

    L2Clan clan = activeChar.getClan();
    if (clan != null)
    {
      if (clan.getHasCastle() > 0)
      {
        Castle castle = CastleManager.getInstance().getCastleById(clan.getHasCastle());
        if ((castle != null) && (activeChar.getObjectId() == clan.getLeaderId()))
          Announcements.getInstance().announceToAll("Lord " + activeChar.getName() + " Ruler Of " + castle.getName() + " Castle is now Online!");
      }
    }
  }
View Full Code Here

  @Override
  protected void runImpl()
  {
    if(_castleId < 100)
    {
      Castle castle = CastleManager.getInstance().getCastleById(_castleId);

      if(castle == null)
        return;

      SiegeDefenderList sdl = new SiegeDefenderList(castle);
View Full Code Here

      // If in Monster Derby Track
      if(player.isInsideZone(L2Character.ZONE_MONSTERTRACK))
        return new Location(12661, 181687, -3560);

      Castle castle = null;
      Fort fort = null;
      ClanHall clanhall = null;

      if(player.getClan() != null)
      {
        // If teleport to clan hall
        if(teleportWhere == TeleportWhereType.ClanHall)
        {

          clanhall = ClanHallManager.getInstance().getClanHallByOwner(player.getClan());
          if(clanhall != null)
          {
            L2ClanHallZone zone = clanhall.getZone();
            if(zone != null)
              return zone.getSpawn();
          }
        }

        // If teleport to castle
        if(teleportWhere == TeleportWhereType.Castle)
        {
          castle = CastleManager.getInstance().getCastleByOwner(player.getClan());
        }

        // If teleport to fort
        if(teleportWhere == TeleportWhereType.Fortress)
        {
          fort = FortManager.getInstance().getFortByOwner(player.getClan());
        }

        // Check if player is on castle&fortress ground
        if(castle == null)
        {
          castle = CastleManager.getInstance().getCastle(player);
        }

        if(fort == null)
        {
          fort = FortManager.getInstance().getFort(player);
        }

        if(castle != null && castle.getCastleId() > 0)
        {
          // If Teleporting to castle or
          // If is on caslte with siege and player's clan is defender
          if(teleportWhere == TeleportWhereType.Castle || teleportWhere == TeleportWhereType.Castle && castle.getSiege().getIsInProgress() && castle.getSiege().getDefenderClan(player.getClan()) != null)
          {
            coord = castle.getZone().getSpawn();
            return new Location(coord[0], coord[1], coord[2]);
          }

          if(teleportWhere == TeleportWhereType.SiegeFlag && castle.getSiege().getIsInProgress())
          {
            // Check if player's clan is attacker
            List<L2NpcInstance> flags = castle.getSiege().getFlag(player.getClan());
            if(flags != null && !flags.isEmpty())
            {
              // Spawn to flag - Need more work to get player to the nearest flag
              L2NpcInstance flag = flags.get(0);
              return new Location(flag.getX(), flag.getY(), flag.getZ());
View Full Code Here

  @Override
  protected void runImpl()
  {
    if(_castleId < 100)
    {
      Castle castle = CastleManager.getInstance().getCastleById(_castleId);

      if(castle == null)
        return;

      SiegeAttackerList sal = new SiegeAttackerList(castle);
View Full Code Here

    };
    int castleIndex = castleidarray[townId];

    if(castleIndex > 0)
    {
      Castle castle = CastleManager.getInstance().getCastles().get(CastleManager.getInstance().getCastleIndex(castleIndex));
      if(castle != null)
        return castle.getSiege().getIsInProgress();
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.model.entity.siege.Castle

Copyright © 2018 www.massapicom. 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.