Wiki source code of Combat System

Version 3.2 by Adam Janus on 2026/01/22 09:21

Hide last authors
Adam Janus 1.1 1 = **Combat System – Technical Design 0.3** =
2
3 == **1. Introduction** ==
4
5 The system revolves around player-crafted and player-wielded weapons. Weapons and enemies define **what** they do and **when** they do it.
6 A targeting mechanic inspired by **Mordhau** provides readable yet deep combat. It supports encounters with **multiple** enemies (not full hordes), maintaining clarity and intent.
7
8 === **1.1 Disclaimer** ===
9
10 Hereby document is not completed. Further development of the document requires validation by prototyping.
11
12 ----
13
14 == **2. Damage Delivery** ==
15
16 === **2.1 Targeting ** ===
17
18 Each enemy actor contains a reference component within  its class. Targeting is an automatic, 3 step process with the goal of selecting said reference component as current target.
19
20 1. **Visibility check: **To be considered a target, enemy reference point must be visible and not obstructed by any collider.
21 1. **Range check:** System verifies if enemy is at distance **<=** to **2*CurrentWeaponRange**
22 1. **Corsair proximity check: **Form previously filtered enemies system selects final one based on corsair proximity to reference component.  The parent of the selected component is set as the current target.
23
24 === **2.2 Types of attack and their selection** ===
25
26 Selection of Attack type is based on relative position to target reference component. Screen space around and divide it into 4 segments. Left, Right, top and Center+Bottom.
27
28
29 All of those attacks are based on animation. Each animation must guide the weapon through the center of the screen.
30
31 ==== **2.2.1 Directional attack ** ====
32
33 To define direction of attack, upon attack input, the system draws a **2D OnScreen Vector **originating at the center of the corsair. This vector ends at the center of the Reference component of the current target. 
34
35 [[image:1768909366379-510.png]]
36
37
38 This vector is translated into direction and rotation of attack animation. It is achieved by blending  2 out of 8 attack animations. [[image:1768909366379-927.png]]
39
40 //Note: each arrow represents one animation.//
41
Adam Janus 2.1 42 ==== **2.2.2 Stab Attack ** ====
Adam Janus 1.1 43
44 Stab attack follows the same principles as overhead attack.
45 \\//Note: Bottom-to-top animation is not stab animations, it's used only for blend purposes only. //
46
47 ----
48
49
50 === **2.3 Attack Phases** ===
51
52 Every attack consists of three phases (durations are defined per weapon):
53
54 * **Wind-Up** - First phase of attack, weapon is prepared for swing. Phase is triggered by input down.
55 * **Swing** — The actual striking phase. Animation of performing attack. Phase is triggered by input key release.
56 * **Recovery** — Last phase of attack, animation of retracting weapon into default position. Phase is triggered automatically. Serves a role of delay in between attacks.
57
58 If the player enters and holds the attack input, then the weapon is locked in the Wind-up phase. As the player moves the cursor Vector of attack remains  unchanged. If the player wants to change the Vector of attack, they must cancel the attack by entering respectable input or force the PC into another state that does not allow for performing the attack.
59
60 ----
61
62 === **2.4 Conditions for performing an attack & State machine** ===
63
64 In order to enter pc must:
65
66 * Be in respectable State; idle, walking or crouching
67 * Have sufficient stamina
68 * Wield Weapon Actor
69
70 **Wind-up phase**
71 If player successfully wind-up an attack, they enter a wind-up state. Once in windup state a player may walk and crouch but if PC enters any other state e.g. running, then entering state cancels Win-up. Wind-up state can be interrupted by any state.
72
73
74 **Swing phase**
75
76 During the Swing phase, only walking and crouching is possible. PC can’t enter any other state.
77
78
79 **Recovery phase **
80 During the Recovery phase, only walking and crouching is possible.PC can’t enter any other state.
81 \\//Note: Description above describes intended result, not expected code. //
82
83 ----
84
85
86 === **2.5 Movement Impact on Strikes** ===
87
88 Weapons are positioned relative to the PC’s camera transform. The player may move the camera at all times.
89 While the **animation **of the strike remains the same, its **world transform** updates with camera motion, preserving precise collision but allowing nuanced control.
90
91 ----
92
93 === **2.6 Time–Damage Curve** ===
94
95 **Time–Damage** is a **multiplier** defined by a curve:
96
97 * **X-axis:** normalized time of Swing phase (0–1). E.g. if swing lasts for 2.0 sec then at X = 0.2 swing is at 0.4 time.
98 * **Y-axis:** damage multiplier.
99 The curve **must match** the weapon’s animation timing and approximate blade velocity.
100
101 **Examples:**
102
103 * **Stab:** near-linear rise with a sharp falloff at the end (peak speed near impact).
104 \\[[image:1768909366380-652.png]]
105 * **Swing:** bell-shaped (≈ normal distribution) with a mid-swing peak.
106 \\[[image:1768909366380-304.png]]
107
108
109 **Important:** The curve is an **editable variable** per child of the weapon parent (per weapon instance/child class).
110
111 ----
112
113 == **3. Weapons Role in combat system** ==
114
115
116 === **3.1 Composition of weapon ** ===
117
118 Weapons are composed of Mesh and Damage Colliders. Mesh is a visual representation of weapon and diegetic reference point for players during combat. Collider's role is to define value and type of damage upon successful delivery. Lastly, the weapon holds respectable UX functionality.
119
120
121 ==== **3.1.1 Colliders Types and role ** ====
122
123 Each weapon has a set amount of colliders covering the entirety of the weapons mesh. Those colliders are divided into following categories holding special effect:
124
125 * **Cutting **- % bonus to damage against unarmored bone
126 * **Crushing **- % bonus to damage to armored bone durability
127 * **Piercing** - % bonus to armour penetration
128 * **Blunt **-  No special effect.
129
130 Each collider outside of special effects hold following variables:
131
132 * **Base Damage** - Base value used for calculating Delivered damage
133 * **Armor Penetration **-  Value of armour ignored upon successful damage delivery
134 * **On-hit effect **- effect applied on enemy at every hit, e.g. bleed, freeze, stun etc.
135
136 Weapons also have actor variable outside of colliders:
137
138 * **Weight **- mass of the weapon  in equipment
139 * **Range** - maximum reach of the attack (resemblance a distance between end of most distant form handle collider and pivot point.)
140 * **Handling **- It sets the duration of the wind-up and recovery phase.
141 * **Block cost **- Cost of raising guard and per tick cost of keeping guard up.
142 * **Attack cost **- Cost of performing an attack.
143
144 **Important: **All values of variables above will be described in balance sheets and instances of weapons. It’s a functionality that must be present in parent class.
145
146
147 ==== **3.1.3 Collider structure of weapon** ====
148
Adam Janus 3.2 149 The philosophy of overlaying colliders onto weapons mesh is very literal. All blades = Cutting colliders, Spikes = Piercing colliders, Heads =  Crushing collider, Lastly  all parts of weapon that are not lethal by design like: handles, guards and pommels shall be overlaid with blunt collider.
Adam Janus 1.1 150
151 [[image:1768909366380-349.png]]
152
153 **Red **- Cutting cloider
154 **Blue **- Smashing collider
155
156 **Green **- Piercing collider
157
Adam Janus 2.1 158 **Yellow **- Blunt collider 
Adam Janus 1.1 159
160
161 **Important: **Weapons meshes shall be designed with 1 singular endpoint.
162
163 === **3.1.4 Categories & types** ===
164
165 Weapons fall into three functional categories:
166
167 * **One-Handed** — usable alone or paired with an off-hand tool (e.g., sword + shield, nadziak + net).
168 * **Two-Handed** — require both hands, cannot be paired (e.g., war hammer, halberd).
169 * **Off-Hand** — supportive, tactical tools complementing one-handed weapons (e.g., shield, whip, net).
170
171 Further,  One and Two-Handed weapons are divided into  three types:
172
173 * **Hammers**
174 * **Swords**
175 * **Axes**
176
177 ----
178
179 == **4. Damage Avoidance** ==
180
181 Combat readability emphasizes **timing**. Each enemy attack is a **single primary vector**, encouraging deliberate responses.
182
183 The player has two defensive actions: **Blocking** and **Dodging**.
184 Blocking is **easier** to time but **more stamina-heavy** than dodging.
185
186 === **4.1 Blocking** ===
187
188 Blocking is a boolean state with a **wind-up** (like attacks):
189
190 * On input, **Block Wind-Up** starts  after delay
191 * **Stamina costs:** upfront activation **and** per-tick drain while blocking.
192 * Additional cost Upon blocked impact
193 * If stamina is insufficient, blocking **cannot** be initiated or is **interrupted**.
194
195 === **4.2 Dodging** ===
196
197 * (((
198 **Dodge:** briefly disables the PC’s hitbox and moves the PC along a vector adjacent to current movement.
199
200 * If stationary, only the hitbox disable applies (no displacement).
201 \\
202 )))
203
204 ----
205
Adam Janus 3.1 206 == **5. Armor System In context of combat system ** ==
Adam Janus 1.1 207
208 ===
Adam Janus 3.1 209 **5.1 Player Armor** ===
Adam Janus 1.1 210
211 Flat reduction model: damage received is reduced by the player’s current **Armor** value.
212
Adam Janus 3.1 213 === **5.2 Enemy Armor** ===
Adam Janus 1.1 214
215 Enemy bodies have  **Armored** and **Non-Armored** bones.
216 Armored bones store:
217
218 * **Armor Durability (HP):** reduced by each point of blocked damage; at 0 the zone becomes **non-armored**.
219 * **Armor Effectiveness:** flat reduction **before** penetration.
220
221 **Example:**
222
223 * Attack deals **10** damage with **2** armor penetration.
224 * Target: **Armor Effectiveness = 3**, **Durability = 15**.
225 * Effective reduction = 3 (Armor effectiveness) - 2 (armor penetration) = 1 (Final reduction value)
226 * Damage to health = 10 (base damage value) − 1 (Final reduction value)
227 ~= 9 (Value of delivered damage to enemy).
228 * Durability reduced by =  15 (base durability of Target/Damage receiver) - 1 (Final reduction value) = 15 ( post damage value of durability of Target/Damage receiver)
229
230 ----
231
232 == **6. Instance Editables** ==
233
234 === **6.1 Weapon Instance Editables** ===
235
236
237 |**Parameter Name**|**Type**|**Description**
238 |**Wind-Up Duration**|Float|Duration of the Wind-Up phase for this weapon instance. Each weapon defines its own timing.
239 |**Swing Duration**|Float|Duration of the Swing phase during which the attack deals damage. Defined per weapon.
240 |**Recovery Duration**|Float|Duration of the Recovery phase before another attack can start. Defined per weapon.
241 |**Time–Damage Curve**|CurveFloat|Damage multiplier curve sampled across normalized Swing time (0–1). Editable per weapon child class.
242 |**Range**|Float|Maximum reach of the weapon; defines attack distance and target validation distance (2× Range in targeting).
243 |**Weight**|Float|Mass of the weapon in equipment. Used by combat and inventory systems.
244 |**Handling**|Float|Defines Wind-Up and Recovery duration scaling (weapon handling characteristics).
245 |**Block Cost**|Float|Stamina cost for raising guard and per-tick cost of keeping guard up (per weapon instance).
246
247 ----
248
249 === **6.2 Weapon Collider Instance Editables** ===
250
251 //(Explicit collider-level variables described in section 3.1.1)//
252
253 |**Parameter Name**|**Type**|**Description**
254 |**Collider Type**|Enum (Cutting / Crushing / Piercing / Blunt)|Defines the damage specialization bonus and interaction with armor/bone types.
255 |**Base Damage**|Float|Core damage value used for calculating delivered damage.
256 |**Armor Penetration**|Float|Amount of armor ignored when this collider hits an armored bone.
257 |**On-Hit Effect**|Enum / Tag|Effect applied on every successful hit from this collider (bleed, freeze, stun, etc.).
258
259 ----
260
261 === **6.3 Blocking & Dodging Instance Editables** ===
262
263 |**Parameter Name**|**Type**|**Description**
264 |**Block Wind-Up Delay**|Float|Delay before block becomes active. //(Referenced as “after delay” in blocking description.)//
265 |**Block Activation Cost**|Float|Up-front stamina cost for initiating a block (per weapon).
266 |**Block Upkeep Cost**|Float|Per-tick stamina drain while blocking (per weapon).
267
268 ----