ATBTT - Experiments - HoMM-Style Combat #3
Implementing Heroes of Might and Magic Combat Mechanics
Introduction to Combat Mechanics
- The video focuses on creating a combat system inspired by the game "Heroes of Might and Magic" within the ATBT framework.
- Previous videos established stack mechanics where units reduce in number when attacked, leading to unit death upon reaching zero.
Damage Calculation Based on Stack Size
- The presenter plans to modify the move attack ability to incorporate damage scaling based on stack size.
- A new function called
get stack damageis introduced, which calculates damage by multiplying the unit's base damage with its current stack size.
- This function is designed as a pure function for simplicity, avoiding unnecessary complexity in casting.
Implementation Steps
- The implementation involves modifying how damage is calculated during an attack, ensuring it references the newly created
get stack damagefunction.
- The presenter emphasizes keeping code simple while assuming that all units will be of a specific type for this game design.
Testing Damage Scaling
- After setting up the new ability, testing reveals that larger stacks deal significantly more damage compared to smaller ones.
- Adjustments are made to ensure that units with fewer stacks do less damage, confirming that the mechanic works as intended.
Adding Random Damage Variation
- To enhance gameplay realism, random damage values are introduced instead of fixed numbers for attacks.
- A range (e.g., 30 to 60 damage points) is implemented using a vector data structure for flexibility in defining minimum and maximum values.
Addressing Random Damage Issues
- The presenter notes potential issues with uniformity in randomization across multiple units within a single stack affecting overall gameplay experience.
- Caution is advised regarding discrepancies between health calculations if different random values are used inconsistently across functions.
Counterattack Mechanic Development
- The next feature discussed is implementing counterattacks after an initial attack occurs within combat interactions.
- Logic is added so that after one unit attacks another, the target can retaliate immediately without causing infinite loops in code execution.
Finalizing Counterattack Logic
- Adjustments ensure that counterattacks utilize their own calculated stack-based damages rather than mirroring initial attack values.
Error Handling and Validity Checks
- An error handling mechanism checks if a target unit still exists before allowing further actions post-attacks; this prevents accessing invalid or dead units from causing crashes or errors.
Enhancing Visual Presentation and Gameplay Experience
- Modifications are made to camera angles and grid sizes for better visual representation during combat scenarios.
Conclusion of Tutorial Series
- The series wraps up with reflections on what was covered regarding combat mechanics, UI adjustments, and overall gameplay enhancements.
Turn any video into a summary like this
YouTube links, meetings, lectures. With transcripts, search, and chat.




