Skip to content

Castle Siege Warfare Machines #727

@sven-n

Description

@sven-n

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

  1. Player interacts with a machine NPC → server opens the machine interface.
  2. Player selects a target zone (1–4) and sends fire request.
  3. Server validates: Start state, player is the machine's operator, correct side (attacker→attack machine, defender→defense machine), machine not on cooldown.
  4. Server computes random target coordinates within the zone rectangle (from CastleSiegeConfiguration.AttackMachineZones or DefenseMachineZones).
  5. Server sends:
    • CastleSiegeMachineUseResult to the operator and their viewport.
    • CastleSiegeMachineRegionNotify to all units within 6 tiles of the impact point.
  6. 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

  • 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 Start state.
  • Machines have a cooldown between firings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions