4. Stamina System & Hit Detection
Outcome: A data-driven stamina system where every attack type has its own stamina cost, consumed through a single reusable function, with delayed regen and real-time UI feedback — all connected through event dispatchers.
Intention: Combat needed resource consequences. A flat stamina bar where everything costs the same wouldn't create any real decision-making. Different attacks needed different costs so the player has to think about what they use and when.
Process: Built an Attack Profile struct that carries damage amount, socket names, hit sphere radius, and object types for each attack. Stamina costs live in a data map with 9 attack types — light attacks scale from 10 to 15, heavy attacks from 25 to 30, crossbow and dagger throw sit at 5, kickflip at 20. The ConsumeStamina function checks current stamina, deducts the cost, fires the UI update event, and starts a 1-second delay before regen kicks in. Hit detection is handled through animation notifies — a sphere trace fires between sword socket locations on active frames only, passing the Attack Profile data through to determine damage and hit object types.