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
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:
Start state, 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.AttackMachineZones or DefenseMachineZones).
- Server sends:
CastleSiegeMachineUseResult to the operator and their viewport.
CastleSiegeMachineRegionNotify to all units within 6 tiles of the impact point.
- After a short delay, apply damage to all
IAttackable units 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
IAttackable objects within 3 tiles of impact via IAttackable.ReceiveHitAsync.
3. Machine Interface — NPC Talk Handler
When a player talks to a machine NPC:
- Validate:
Start state, player side matches machine type, no other operator.
- Set player as the machine's operator.
- Send
CastleSiegeMachineInterface packet 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
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
CastleSiegeMachineNPC class.Startstate.Requirements
1. Machine Use Flow
Startstate, player is the machine's operator, correct side (attacker→attack machine, defender→defense machine), machine not on cooldown.CastleSiegeConfiguration.AttackMachineZonesorDefenseMachineZones).CastleSiegeMachineUseResultto the operator and their viewport.CastleSiegeMachineRegionNotifyto all units within 6 tiles of the impact point.IAttackableunits within 3 tiles of the impact point.2. Machine Use Action — New file:
GameLogic/CastleSiege/Actions/CastleSiegeMachineUseAction.csValidation:
Start.Effect:
IAttackableobjects within 3 tiles of impact viaIAttackable.ReceiveHitAsync.3. Machine Interface — NPC Talk Handler
When a player talks to a machine NPC:
Startstate, player side matches machine type, no other operator.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:
Defense Zones:
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
GameLogic/CastleSiege/Actions/CastleSiegeMachineUseAction.csGameServer/MessageHandler/CastleSiege/CastleSiegeMachineUseHandlerPlugIn.csGameLogic/Views/CastleSiege/ICastleSiegeMachineUseResultPlugIn.csGameLogic/Views/CastleSiege/ICastleSiegeMachineRegionNotifyPlugIn.csGameLogic/Views/CastleSiege/ICastleSiegeMachineInterfacePlugIn.csGameServer/RemoteView/CastleSiege/CastleSiegeMachineUseResultPlugIn.csGameServer/RemoteView/CastleSiege/CastleSiegeMachineRegionNotifyPlugIn.csGameServer/RemoteView/CastleSiege/CastleSiegeMachineInterfacePlugIn.csAcceptance Criteria
Startstate.