Monstrum Arcana - Turn Based Battle
Created by Tristan O'Donnell and Luke Ninh
Role: Lead Solo Programmer, Producer
Monstrum Arcana
Monstrum Arcana is a turn based battle simulator which pits you against an intense battle against enemy monsters.
When you start the game you are given a random party of 6, and you have gameplay choices to attack, select items, and swap monsters. Try and survive endless waves of monsters in a turn based battle format inspired by games like Pokemon and Fossil Fighters.
The current project build includes:
-
Full Battle System with complex move calculations, AI systems, input systems, game slot systems, inventory, sbility, and status systems.
-
10 different types of monsters, each with different moves, types, abilities and stats.
-
8 different consumable items for your party
-
7 monster status effects
-
29 distinct moves with different diverse move effects
-
4 types with strengths and weaknesses.
-
UI systems for monster slots, party, input selectors for moves, items, party
-
UI Text scroller to view gameplay history in real time.
Play Here: MonstrumArcanaTurnBasedBattle
Check out the Github Project Repository: TurnBasedBattle on Github
Big thanks to Luke Ninh for designing all monster game design, including monster narrative designs, move names, stat values, types, and items.
Project Retrospective
Favorite Contributions
I programmed the entire project, and I would love to talk about every single system I created, but I wanted to highlight four, the Battle System, AI Selector, Move Calculator, and UI Text Scroller. Click each title below to jump to their section!
Changes/Challenges
-
There are some remaining bugs that will cause an issue with transitioning to a new round. I wanted to jump to a new project, and the game was running well many playthroughs so not sure where these bugs are!!
-
Project Scale: The original scale I had was too large and I wanted to move onto a new project, so systems I knew I could implement but did not provide additional learning opportunities like an Exp System were cut.
-
Static Meshes: This was my first time using static meshes in Unreal so I accepted that some things would not be perfect. The snake keeps spawning in the wrong spot no matter what I did :(
-
Player Controller, HUD, and Game Mode: Had to understand how Unreal likes to handle the Game Mode system.
-
Game Slot System vs. Struct Arrays: I realized part way through this project that my Game Slot BP may have been unnecessary and that I could have manipulated structs directly, but I was already over half way done at that point.
-
Death Checking and Party Status: This caused many problems with debugging and although I fixed things eventually, I feel like the game slot to struct system I had was making checking the party and Death more complex than necessary.
Working With My Designer
-
Game Design Collaboration: I worked closely with the designer to build a system that took his monster stats, types, names, and move ideas.
-
Ease of Use: I built systems allowing easy input and management of design data without programming knowledge, so he could go into Unreal and populate required data he had on his end.
Battle System
Overview
-
The Battle System contains the core gameplay loop, managing combat flow through different turn phase events. I split responsibilities into different phases to help organization. Core Responsibilities:
-
Game Loop & State Management: Tracks turns, determines outcomes, and controls battle phases.
-
Turn Management: Determines active player, handles cooldowns, and processes stat updates. Turn order is influenced by speed of game slots.
-
Phase Management: Includes phases like StartTurn, MoveOrder, Attack, DeathCheck, and EndTurn.
-
Event Dispatchers: Utilized by the input system to send the correct input information to the battle system. Dispatchers are also used to communicate monster ability effects.
-
Game Slots: Stores monster states (stats, abilities) for player and AI, handling actions, damage, and status changes.
System Initialization
-
During setup, the system ensures all components are ready for the gameplay loop:
-
UI Setup: Connects UI elements to game logic.
-
Ability Manager: Binds event dispatchers for handling actions.
-
Selectors: Links Move, Item, and Party Selectors for player input.
-
Game Slots: Initializes player/AI slots with monster stats and movesets.
-
AI Setup: Loads AI monsters.
-
Start Round: Transitions from setup to active gameplay.
Turn Phases
-
StartTurn Phase:
-
Prepares the new turn, updating status effects and enabling input for player.
-
Input Phase:
-
Player/AI selects actions (Attack, Swap, or Item) using the Action Enum.
-
CurrentActionSwitch:
-
Processes selected actions:
-
Attack: Executes move logic and effects.
-
Swap: Switches to another monster.
-
Item: Activates item effects.
Combat Flow
-
Move Order Phase:
-
Determines action sequence based on speed stats.
-
Attack Phase:
-
Calculates damage, status effects, and critical hits using the Move Calculator.
-
Applies effects to targets (e.g., damage, stat changes, status conditions).
-
Death Check Phase:
-
Verifies if monsters’ health reaches 0, triggering death handling and checks for remaining party members.
End Turn & Game Loop
-
End Turn:
-
Wraps up turn logic, applies ongoing effects (e.g., poison), and checks for deaths.
-
Game Loop:
-
Repeats phases until one party loses all monsters.
-
Triggers round transitions or game over depending on the outcome.
-
Round Transition:
-
New rounds begin with fresh opponents if the player wins.
-
A game-over screen appears if the player loses.
AI Selector
Overview
The AI Selector system empowers AI-controlled monsters to make strategic, informed decisions during combat. By utilizing a combination of calculation and evaluation functions, the AI Selector determines optimal actions, such as attacking, swapping monsters, or taking other strategic steps.
Key Features
Function Types:
The AI Selector Blueprint is divided into two categories:
-
Calculation Functions:
Perform evaluations like type advantages and scoring moves or swaps. Can be used independently or integrated into evaluation functions. -
Evaluate Functions:
Consolidate calculation results to decide AI actions, including evaluating move choice, switch options, and actions.
Core Functionality
Core Functionality
-
Type Advantage Move Calculation
Input: Attacking and defending monsters' Game Instance Structures.
Process: Evaluates all moves, determines type effectiveness, and scores based on effectiveness and damage.
Output: Highest-value move score. -
Type Advantage Swap Calculation
Input: Current monster and swap candidates.
Process: Compares type advantages, health, stats, buffs, and debuffs.
Output: Swap decision score. -
Evaluate Functions
-
Evaluate Action: Identifies highest-value action from the score map, using tie-breakers.
-
Evaluate Move Choice: Selects optimal move based on Type Advantage Move Calculation and Evaluate Action.
-
Evaluate Switch Options: Chooses best monster to swap to using Type Advantage Swap Calculation and Evaluate Action.
-
Evaluate Turn Decision
The Evaluate Turn Decision function synthesizes all calculation and evaluation results to make the final decision for the AI-controlled monster.
Decision Flow:
-
Check Type Advantage:
-
Uses Type Advantage Swap Calculation to determine if the current monster has a favorable type advantage to remain in combat.
-
-
Evaluate Swap:
-
If the total switch score exceeds the minimum threshold and at least two party members are alive:
-
The AI evaluates potential swaps.
-
If a swap is selected, the AI Slot’s action is set to Swap.
-
-
-
Evaluate Move Choice:
-
If no swap is required, the system evaluates the best move using Evaluate Move Choice.
-
If a move is selected, the AI Slot’s action is set to Attack.
-
Design Benefits
-
Strategic AI Behavior:
AI simulates player-like behavior, making decisions based on type matchups, move effectiveness, and battle context. -
Modularity and Scalability:
Modular functions allow easy updates and expansion without disrupting existing systems. -
Robust Swap Logic:
Evaluates type advantages, health, and strategy for intelligent swaps. -
Dynamic Adaptation:
Adjusts scores each turn to respond to changing battle conditions, like weakened monsters. -
Flexible Scoring System:
Scores based on type effectiveness, move power, health, risk, and AI playstyle (e.g., aggressive or defensive).
Move Calculator
Overview
The Move Calculator is a modular system designed to process move effects during combat. It takes input data, performs calculations, and outputs results in a standardized format to ensure compatibility with other game systems.
Inputs:
-
Game Slot Variables: Relevant game state variables for move calculations.
Move Struct: Defines the move's attributes.
Calculations
-
STAB (Same Type Attack Bonus): Based on the attacking monster's type.
Effectiveness: Based on the interaction between the move’s type and the target’s type(s).
Ability Checks: Applies modifiers based on abilities or conditions.
Move Categories and Handling: -
Moves are categorized using an Enum (MoveCategory), including Physical, Special, Stat Change, Status, and Healing.
A For Each Loop iterates through the categories, and a Switch Statement processes each category, calling the appropriate Handle Function for the specific move category.
Output:
All results are compiled into a Move Calculation Struct, containing: -
Damage values
Stat changes
Applied status effects
Healing amounts
Other relevant data
Design Benefits
-
Modularity:
Allows easy mixing and matching of move effects through enums and handle functions. Supports moves with multiple effects, such as damage, status infliction, and stat boosts simultaneously. -
Extensibility:
New move categories can be added by introducing a new Enum entry and defining its handle function, with no need to refactor existing systems. -
Reusability:
The Move Calculation Struct ensures consistent data handling across combat systems, providing a robust foundation for diverse gameplay mechanics.
UI Text Scroller System
Overview
The UI Text Scroller displays a history of gameplay messages in a scrollable interface, enhancing player immersion and aiding debugging.
Key Features
-
Scroll Box Integration: Displays a chronological history of gameplay events. Players can scroll through messages by turn.
-
Dynamic Text Generation: GenerateBattleText creates and formats all in-game messages. Messages are modular and customizable with specific inputs.
-
Text Templates: Uses an enum (TextTemplate) to standardize message formats, including types like "Attack Used," "Item Used," and "Monster Summoned."
-
Reusable Functions: GenerateBattleText is used throughout the game to display text with various inputs.
-
Workflow: GenerateBattleText takes inputs such as text template and data (e.g., move name, damage value). A switch statement processes the TextTemplate enum to determine the message format, and text nodes inject the inputs into the template.
-
Text Creation Functions: Routes messages through CreateTextBox for standard messages or CreateRedText for warnings/errors or special cases.
-
Text Display: Formatted text is added to the scroll box in the UI Text Scroller widget, which adjusts to accommodate the new message.
Design Details
-
GenerateBattleText Function:
-
Inputs: TextTemplate enum and additional parameters (e.g., monster name, damage).
-
Logic: Switches on TextTemplate to format the message.
-
Outputs: A dynamically generated string ready for display.
Design Benefits
-
Modularity: Centralized text generation for easy updates and consistent messaging.
-
Scalability: Simple to add or modify templates.
-
Dynamic & Immersive: Real-time gameplay messages enhance immersion and clarity.