Skip to main content

Overview

The Siege system manages castle siege warfare in L2J Mobius Chronicle 4. It coordinates siege registration, tower spawning, siege timing, clan participation, and siege-related game mechanics. Key Classes:
  • org.l2jmobius.gameserver.managers.SiegeManager - Siege configuration and coordination (singleton)
  • org.l2jmobius.gameserver.managers.CastleManager - Castle ownership and management (singleton)
  • org.l2jmobius.gameserver.model.siege.Siege - Individual siege instance logic
  • org.l2jmobius.gameserver.model.siege.Castle - Castle data and ownership

SiegeManager

Location: org.l2jmobius.gameserver.managers.SiegeManager

Singleton Pattern

SiegeManager siegeManager = SiegeManager.getInstance();
Initialized on server startup, loads configuration from ./config/Siege.ini.

Configuration Properties

_siegeCycle
int
Siege cycle duration in weeks (default: 2).
public int getSiegeCycle()
_attackerMaxClans
int
Maximum number of attacking clans (default: 500).
public int getAttackerMaxClans()
_defenderMaxClans
int
Maximum number of defending clans (default: 500).
public int getDefenderMaxClans()
_attackerRespawnDelay
int
Respawn delay for attackers in milliseconds (default: 0).
public int getAttackerRespawnDelay()
_siegeLength
int
Siege duration in minutes (default: 120).
public int getSiegeLength()
_siegeClanMinLevel
int
Minimum clan level to participate (default: 4).
public int getSiegeClanMinLevel()
_flagMaxCount
int
Maximum number of flags per clan (default: 1).
public int getFlagMaxCount()
_bloodAllianceReward
int
Blood Alliance items rewarded for successful defense (default: 0).
public int getBloodAllianceReward()

Key Methods

Registration Validation

checkIsRegistered
boolean
Checks if a clan is registered or owns a castle.
public boolean checkIsRegistered(Clan clan, int castleid)
Parameters:
  • clan - The clan to check
  • castleid - The castle ID
Returns: true if clan owns castle or is registered for siegeQueries database table siege_clans for registration status.

Siege Lookup

getSiege
Siege
Gets the active siege at specified coordinates.
public Siege getSiege(int x, int y, int z)
public Siege getSiege(WorldObject activeObject)
public Siege getSiege(ILocational loc)
Returns: Siege instance if location is in siege zone, null otherwiseIterates through all castles checking if coordinates fall within siege zones.
getSieges
List<Siege>
Gets all siege instances.
public List<Siege> getSieges()
Returns: List of all castle sieges (one per castle)

Tower Management

getControlTowers
List<TowerSpawn>
Gets control tower spawn locations for a castle.
public List<TowerSpawn> getControlTowers(int castleId)
Returns: List of control tower spawn definitionsControl towers are defensive structures that must be destroyed by attackers.
getFlameTowers
List<TowerSpawn>
Gets flame tower spawn locations for a castle.
public List<TowerSpawn> getFlameTowers(int castleId)
Returns: List of flame tower spawn definitions with associated zone listsFlame towers can be upgraded and provide defensive bonuses.

Siege Skills

addSiegeSkills
void
Grants siege-related skills to a player.
public void addSiegeSkills(Player character)
Skills granted based on:
  • Player noble status (character.isNoble())
  • Castle ownership (character.getClan().getCastleId() > 0)
Uses SkillData.getInstance().getSiegeSkills() to retrieve appropriate skills.
removeSiegeSkills
void
Removes siege skills from a player.
public void removeSiegeSkills(Player character)
Called when player leaves siege zone or siege ends.

Tower Configuration

Towers are loaded from ./config/Siege.ini using the format:
# Control Towers
GludioControlTower1 = x,y,z,npcId
GludioControlTower2 = x,y,z,npcId

# Flame Towers
GludioFlameTower1 = x,y,z,npcId,zoneId1,zoneId2...
TowerSpawn Structure:
public class TowerSpawn {
    private final int _npcId;
    private final Location _location;
    private final List<Integer> _zoneList; // For flame towers
    private int _upgradeLevel; // Flame tower upgrade level
}

CastleManager

Location: org.l2jmobius.gameserver.managers.CastleManager

Singleton Pattern

CastleManager castleManager = CastleManager.getInstance();

Castle Lookup Methods

getCastleById
Castle
Retrieves a castle by its ID.
public Castle getCastleById(int castleId)
Castle IDs:
  • 1: Gludio
  • 2: Dion
  • 3: Giran
  • 4: Oren
  • 5: Aden
  • 6: Innadril
  • 7: Goddard
  • 8: Rune
  • 9: Schuttgart
getCastle
Castle
Gets castle by location or name.
public Castle getCastle(int x, int y, int z)
public Castle getCastle(WorldObject activeObject)
public Castle getCastle(String name)
Returns: Castle instance or null if not found
getCastleByOwner
Castle
Finds castle owned by a specific clan.
public Castle getCastleByOwner(Clan clan)
Returns: Castle instance or null if clan owns no castle
getCastles
List<Castle>
Gets all castles in the game.
public List<Castle> getCastles()
Returns: Thread-safe list of all castle instances (9 total)

Castle Index Operations

getCastleIndex
int
Gets the array index of a castle.
public int getCastleIndex(int castleId)
public int getCastleIndex(int x, int y, int z)
public int getCastleIndex(WorldObject activeObject)
Returns: Index (0-8) or -1 if not found
findNearestCastleIndex
int
Finds nearest castle to an object.
public int findNearestCastleIndex(WorldObject obj)
public int findNearestCastleIndex(WorldObject obj, long maxDistanceValue)
Returns: Index of nearest castle or -1

Tax & Economic Management

validateTaxes
void
Validates and adjusts castle tax rates based on Seven Signs.
public void validateTaxes(int sealStrifeOwner)
Tax Limits:
  • Dusk wins: Max 5%
  • Dawn wins: Max 25%
  • No winner: Max 15%
Automatically reduces any castle tax exceeding the maximum.

Circlet Management

Castle Circlets: Special items for castle owners
getCircletByCastleId
int
Gets circlet item ID for a castle.
public int getCircletByCastleId(int castleId)
Circlet Item IDs:
private static final int[] _castleCirclets = {
    0,     // No castle
    6838,  // Gludio
    6835,  // Dion
    6839,  // Giran
    6837,  // Oren
    6840,  // Aden
    6834,  // Innadril
    6836,  // Goddard
    8182,  // Rune
    8183   // Schuttgart
};
removeCirclet
void
Removes circlets from clan members.
public void removeCirclet(Clan clan, int castleId)
public void removeCirclet(ClanMember member, int castleId)
Called when castle ownership changes. Handles both online and offline players.

Siege Date Tracking

registerSiegeDate
void
Registers a siege date for a castle.
public void registerSiegeDate(int castleId, long siegeDate)
Prevents multiple sieges from occurring simultaneously.
getSiegeDates
int
Counts how many sieges scheduled near a date.
public int getSiegeDates(long siegeDate)
Returns: Count of sieges within 1 second of specified date

Instance Management

loadInstances
void
Loads castle instances from database.
public void loadInstances()
Queries castle table and creates Castle objects.
activateInstances
void
Activates all castle instances.
public void activateInstances()
Called during server initialization.

Usage Examples

Check Siege Registration

Player player = ...;
Clan clan = player.getClan();
int castleId = 1; // Gludio

SiegeManager siegeManager = SiegeManager.getInstance();

if (siegeManager.checkIsRegistered(clan, castleId)) {
    player.sendMessage("Your clan is registered for the siege!");
} else {
    player.sendMessage("Your clan is not registered.");
}

Find Active Siege

Player player = ...;
SiegeManager siegeManager = SiegeManager.getInstance();

Siege siege = siegeManager.getSiege(player);
if (siege != null && siege.isInProgress()) {
    player.sendMessage("You are in an active siege zone!");
    
    // Grant siege skills
    siegeManager.addSiegeSkills(player);
}

Get Castle by Location

Player player = ...;
CastleManager castleManager = CastleManager.getInstance();

Castle castle = castleManager.getCastle(player);
if (castle != null) {
    player.sendMessage("You are in " + castle.getName() + " territory");
    player.sendMessage("Tax rate: " + castle.getTaxPercent() + "%");
    
    Clan owner = castle.getOwner();
    if (owner != null) {
        player.sendMessage("Owned by: " + owner.getName());
    }
}

List All Sieges

SiegeManager siegeManager = SiegeManager.getInstance();
List<Siege> sieges = siegeManager.getSieges();

for (Siege siege : sieges) {
    Castle castle = siege.getCastle();
    System.out.println(castle.getName() + " - Next siege: " + siege.getSiegeDate());
    System.out.println("  Attackers: " + siege.getAttackerClans().size());
    System.out.println("  Defenders: " + siege.getDefenderClans().size());
}

Spawn Siege Towers

int castleId = 1; // Gludio
SiegeManager siegeManager = SiegeManager.getInstance();

// Get control towers
List<TowerSpawn> controlTowers = siegeManager.getControlTowers(castleId);
for (TowerSpawn tower : controlTowers) {
    // Spawn tower NPC at location
    Spawn spawn = new Spawn(tower.getNpcId());
    spawn.setXYZ(tower.getLocation());
    spawn.init();
}

// Get flame towers
List<TowerSpawn> flameTowers = siegeManager.getFlameTowers(castleId);
for (TowerSpawn tower : flameTowers) {
    // Spawn upgraded flame tower
    int upgradeLevel = tower.getUpgradeLevel();
    // Apply upgrade bonuses...
}

Validate Taxes After Seven Signs

import org.l2jmobius.gameserver.model.sevensigns.SevenSigns;

CastleManager castleManager = CastleManager.getInstance();
int winner = SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE);

// Adjust max tax rates based on Seven Signs winner
castleManager.validateTaxes(winner);
  • Siege (org.l2jmobius.gameserver.model.siege.Siege) - Individual siege instance
  • Castle (org.l2jmobius.gameserver.model.siege.Castle) - Castle data model
  • SiegeGuardManager - Manages siege guard NPCs
  • MercTicketManager - Handles mercenary tickets
  • CHSiegeManager - Clan hall siege management
  • TerritoryWarManager - Territory war system

Configuration

Siege configuration is loaded from ./config/Siege.ini:
# Siege Settings
SiegeCycle = 2
SiegeLength = 120
AttackerMaxClans = 500
DefenderMaxClans = 500
AttackerRespawn = 0
SiegeClanMinLevel = 4
MaxFlags = 1
BloodAllianceReward = 1

# Tower Definitions
GludioControlTower1 = -18237,109591,-2488,13002
# ... more towers

Source Reference

  • Source: java/org/l2jmobius/gameserver/managers/SiegeManager.java:47
  • Source: java/org/l2jmobius/gameserver/managers/CastleManager.java:44

Build docs developers (and LLMs) love