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 logicorg.l2jmobius.gameserver.model.siege.Castle- Castle data and ownership
SiegeManager
Location:org.l2jmobius.gameserver.managers.SiegeManager
Singleton Pattern
./config/Siege.ini.
Configuration Properties
Siege cycle duration in weeks (default: 2).
Maximum number of attacking clans (default: 500).
Maximum number of defending clans (default: 500).
Respawn delay for attackers in milliseconds (default: 0).
Siege duration in minutes (default: 120).
Minimum clan level to participate (default: 4).
Maximum number of flags per clan (default: 1).
Blood Alliance items rewarded for successful defense (default: 0).
Key Methods
Registration Validation
Checks if a clan is registered or owns a castle.Parameters:
clan- The clan to checkcastleid- The castle ID
true if clan owns castle or is registered for siegeQueries database table siege_clans for registration status.Siege Lookup
Gets the active siege at specified coordinates.Returns: Siege instance if location is in siege zone,
null otherwiseIterates through all castles checking if coordinates fall within siege zones.Gets all siege instances.Returns: List of all castle sieges (one per castle)
Tower Management
Gets control tower spawn locations for a castle.Returns: List of control tower spawn definitionsControl towers are defensive structures that must be destroyed by attackers.
Gets flame tower spawn locations for a castle.Returns: List of flame tower spawn definitions with associated zone listsFlame towers can be upgraded and provide defensive bonuses.
Siege Skills
Grants siege-related skills to a player.Skills granted based on:
- Player noble status (
character.isNoble()) - Castle ownership (
character.getClan().getCastleId() > 0)
SkillData.getInstance().getSiegeSkills() to retrieve appropriate skills.Removes siege skills from a player.Called when player leaves siege zone or siege ends.
Tower Configuration
Towers are loaded from./config/Siege.ini using the format:
CastleManager
Location:org.l2jmobius.gameserver.managers.CastleManager
Singleton Pattern
Castle Lookup Methods
Retrieves a castle by its ID.Castle IDs:
- 1: Gludio
- 2: Dion
- 3: Giran
- 4: Oren
- 5: Aden
- 6: Innadril
- 7: Goddard
- 8: Rune
- 9: Schuttgart
Gets castle by location or name.Returns: Castle instance or
null if not foundFinds castle owned by a specific clan.Returns: Castle instance or
null if clan owns no castleGets all castles in the game.Returns: Thread-safe list of all castle instances (9 total)
Castle Index Operations
Gets the array index of a castle.Returns: Index (0-8) or -1 if not found
Finds nearest castle to an object.Returns: Index of nearest castle or -1
Tax & Economic Management
Validates and adjusts castle tax rates based on Seven Signs.Tax Limits:
- Dusk wins: Max 5%
- Dawn wins: Max 25%
- No winner: Max 15%
Circlet Management
Castle Circlets: Special items for castle ownersGets circlet item ID for a castle.Circlet Item IDs:
Removes circlets from clan members.Called when castle ownership changes. Handles both online and offline players.
Siege Date Tracking
Registers a siege date for a castle.Prevents multiple sieges from occurring simultaneously.
Counts how many sieges scheduled near a date.Returns: Count of sieges within 1 second of specified date
Instance Management
Loads castle instances from database.Queries
castle table and creates Castle objects.Activates all castle instances.Called during server initialization.
Usage Examples
Check Siege Registration
Find Active Siege
Get Castle by Location
List All Sieges
Spawn Siege Towers
Validate Taxes After Seven Signs
Related Systems
- 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:
Source Reference
- Source:
java/org/l2jmobius/gameserver/managers/SiegeManager.java:47 - Source:
java/org/l2jmobius/gameserver/managers/CastleManager.java:44