-
Notifications
You must be signed in to change notification settings - Fork 485
Castle Siege Warfare Machines #727
Copy link
Copy link
Open
Labels
Description
Summary
Implement the siege warfare machines (attack machines for attackers, defense machines for defenders) that allow players to fire area-of-effect damage at predefined target zones during battle.
Prerequisites
- Castle Siege NPCs (Gates, Statues, Crown, Switches, Levers) #725 (NPCs) — for
CastleSiegeMachineNPC class. - Castle Siege Guild Selection & Participant Tracking #724 (Guild Selection) — for join side awareness.
- Castle Siege State Machine #722 (State Machine) — for
Startstate.
Requirements
1. Machine Use Flow
- Player interacts with a machine NPC → server opens the machine interface.
- Player selects a target zone (1–4) and sends fire request.
- Server validates:
Startstate, player is the machine's operator, correct side (attacker→attack machine, defender→defense machine), machine not on cooldown. - Server computes random target coordinates within the zone rectangle (from
CastleSiegeConfiguration.AttackMachineZonesorDefenseMachineZones). - Server sends:
CastleSiegeMachineUseResultto the operator and their viewport.CastleSiegeMachineRegionNotifyto all units within 6 tiles of the impact point.
- After a short delay, apply damage to all
IAttackableunits within 3 tiles of the impact point.
2. Machine Use Action — New file: GameLogic/CastleSiege/Actions/CastleSiegeMachineUseAction.cs
Validation:
- Current state is
Start. - Player is the current operator of the machine (set on NPC interaction).
- Player's join side matches the machine type (attack side → attack machine, defense → defense machine).
- Target zone is valid (1–4, subtract 1 for 0-based index).
- Machine is not on cooldown.
Effect:
- Select random (X, Y) within the target zone rectangle.
- Set machine on cooldown.
- Send visual notification to nearby players.
- Schedule damage application (after a brief delay, e.g., 1–2 seconds).
- Apply damage to all
IAttackableobjects within 3 tiles of impact viaIAttackable.ReceiveHitAsync.
3. Machine Interface — NPC Talk Handler
When a player talks to a machine NPC:
- Validate:
Startstate, player side matches machine type, no other operator. - Set player as the machine's operator.
- Send
CastleSiegeMachineInterfacepacket to open the UI.
4. Target Zone Coordinates
From the C++ reference, predefined as hex values. Convert to decimal and store in CastleSiegeConfiguration.AttackMachineZones / DefenseMachineZones:
Attack Zones:
| Zone | X1 | Y1 | X2 | Y2 |
|---|---|---|---|---|
| 0 | 62 | 103 | 72 | 112 |
| 1 | 88 | 104 | 124 | 111 |
| 2 | 116 | 105 | 124 | 112 |
| 3 | 73 | 86 | 105 | 103 |
Defense Zones:
| Zone | X1 | Y1 | X2 | Y2 |
|---|---|---|---|---|
| 0 | 61 | 88 | 93 | 108 |
| 1 | 92 | 89 | 127 | 111 |
| 2 | 84 | 52 | 102 | 66 |
| 3 | 84 | 52 | 102 | 66 |
5. Message Handlers — New files in GameServer/MessageHandler/CastleSiege/
CastleSiegeMachineUseHandlerPlugIn— handles machine fire request.CastleSiegeMachineDamageHandlerPlugIn— handles damage callback (if client-driven).
6. View Interfaces & Remote Views
ICastleSiegeMachineUseResultPlugIn— sends fire result with impact coordinates.ICastleSiegeMachineRegionNotifyPlugIn— sends AoE visual to nearby players.ICastleSiegeMachineInterfacePlugIn— sends machine interface open packet.
Files to Create
| File | Description |
|---|---|
GameLogic/CastleSiege/Actions/CastleSiegeMachineUseAction.cs |
Machine fire logic |
GameServer/MessageHandler/CastleSiege/CastleSiegeMachineUseHandlerPlugIn.cs |
Packet handler |
GameLogic/Views/CastleSiege/ICastleSiegeMachineUseResultPlugIn.cs |
View interface |
GameLogic/Views/CastleSiege/ICastleSiegeMachineRegionNotifyPlugIn.cs |
View interface |
GameLogic/Views/CastleSiege/ICastleSiegeMachineInterfacePlugIn.cs |
View interface |
GameServer/RemoteView/CastleSiege/CastleSiegeMachineUseResultPlugIn.cs |
Remote view |
GameServer/RemoteView/CastleSiege/CastleSiegeMachineRegionNotifyPlugIn.cs |
Remote view |
GameServer/RemoteView/CastleSiege/CastleSiegeMachineInterfacePlugIn.cs |
Remote view |
Acceptance Criteria
- Only the correct side can use a machine (attacker→attack, defender→defense).
- Machine fire targets a random point within the selected zone.
- AoE damage hits all attackable units within 3 tiles of the impact point.
- Visual notification is sent to players within 6 tiles.
- Machines are only usable during the
Startstate. - Machines have a cooldown between firings.
Reactions are currently unavailable