Skip to main content

Set Up Your First Battle

This guide shows you how to configure an encounter zone, trigger a wild battle, and understand the battle flow. By the end, you will have a working battle that you can test in the editor.

Prerequisites

  • MCE is installed and the setup wizard has been completed.
  • You have at least one monster in your database (the included 151 or one you created).
  • You have a scene with a player character and a grid-based tilemap.

Step 1: Create an Encounter Zone

Wild battles are triggered by encounter tiles on your tilemap. Here is how to set one up:

  1. In your scene hierarchy, select the tilemap layer where you want encounters (typically a "Grass" or "TallGrass" layer).
  2. Create a new empty GameObject as a child of your grid: Right-click > Create Empty, name it GrassEncounters.
  3. Add the EncounterTile component to this GameObject.
  4. Position it on the tiles where encounters should happen using the tile-based coordinates.

Alternatively, you can paint encounter zones directly on a dedicated tilemap layer using MCE's encounter tile types.

Step 2: Configure the Encounter Table

The EncounterTile component references a WildEncountersSet ScriptableObject. Create one:

  1. Assets > Create > OpenMon > Wild Encounters Set
  2. Name it something descriptive, like Route1_GrassEncounters.
  3. Open the ScriptableObject and configure the encounters:
FieldDescription
MonsterThe MonsterEntry SO for the species that can appear
Min LevelMinimum level of the wild monster
Max LevelMaximum level of the wild monster
ProbabilityEncounter weight (higher = more common)
Encounter TypeWhen this encounter can trigger (Walking, Surfing, Fishing, etc.)

Add multiple entries to create variety. For example:

MonsterLevel RangeProbability
Flameleon3-540
Leaflet3-540
Sparkit4-620
  1. Assign this WildEncountersSet to your EncounterTile component's Encounters field.

Step 3: Set Up the Battle Scene

MCE uses a dedicated battle scene that loads additively when a battle starts. You need:

  1. A BattleLauncher component in your overworld scene. This is typically on a persistent manager GameObject. If you used the setup wizard, this should already exist.
  2. A Battle Scene configured in your build settings. The default battle scene is included with MCE.

The BattleLauncher handles the transition:

  • Fades the screen.
  • Loads the battle scene additively.
  • Instantiates the BattleManager with the correct parameters.
  • Returns to the overworld when the battle ends.

BattleManager Components

The BattleManager is the heart of the battle system. In the battle scene, you will find a GameObject with the BattleManager component, which uses a modular architecture with these key modules:

ModulePurpose
BattlersModuleManages battler instances on both sides
HealthModuleHP tracking, fainting, healing
MovesModuleMove execution, PP tracking, type effectiveness
ItemsModuleIn-battle item usage
CaptureModuleWild monster capture mechanics
AIModuleEnemy decision-making
AnimationModuleBattle animations and visual effects
AudioModuleBattle music and sound effects
StatusesModuleStatus conditions (burn, poison, sleep, etc.)
BattlerStatsModuleStat stages and modifications
BattlerSwitchModuleSwitching between party members
RostersModuleParty management during battle
ScenariosModuleBattle type configuration (wild, trainer, etc.)
MegaModuleMega Evolution activation
CharactersModuleTrainer sprite display

You do not need to configure these individually. The BattleManager wires everything together automatically via Zenject dependency injection.

Step 4: Configure the BattleStateMachine

The BattleStateMachine drives the battle flow:

Start → Introduction → Turn Selection → Action Execution →
→ Check Fainted → Replace Fainted → Turn End →
→ [loop back to Turn Selection or] → Battle End → Results

The state machine is pre-configured in the battle scene prefab. Each state handles transitions automatically based on battle conditions.

Step 5: Test the Battle

  1. Make sure your overworld scene has:

    • A PlayerCharacter with a roster containing at least one monster.
    • An EncounterTile with a configured WildEncountersSet.
    • A BattleLauncher on a manager GameObject.
  2. Press Play in the editor.

  3. Walk your character into the encounter zone.

  4. After a few steps (determined by the encounter rate), a battle will trigger.

Quick Testing

To test battles immediately without walking around, you can:

  1. Set the encounter rate to 100% on your EncounterTile.
  2. Or use the BattleLauncher component directly and call its launch method from a test script.

Understanding the Battle Flow

When a battle starts, this is what happens under the hood:

  1. BattleLauncher receives an encounter trigger from the EncounterTile.
  2. A BattleParameters object is created with the wild monster's data.
  3. The battle scene loads additively.
  4. BattleManager initializes all modules.
  5. BattleStateMachine enters the Introduction state (shows the wild monster, plays cry).
  6. The player is presented with action choices: Fight, Bag, Monster, Run.
  7. Actions execute in speed order.
  8. The loop continues until one side faints or the player runs/captures.
  9. BattleResultParameters are sent back to the overworld (exp gained, items used, monster caught, etc.).
  10. The battle scene unloads and the overworld resumes.

Battle Types

MCE supports several battle types out of the box:

TypeDescription
WildSingle wild monster encounter, can capture
TrainerNPC trainer battle, cannot capture, rewards money on win
DoubleTwo vs two battle format
ScriptedStory battles with special conditions

The battle type is determined by the BattleType enum passed in BattleParameters.

Listening to Battle Events (DLL Users)

If you are using Lite, Basic, or Pro tier (no source code), you can still respond to battle events through the SDK:

using OpenMon.MCE.SDK;

public class MyBattleTracker : MonoBehaviour
{
[Inject] private IBattleSystem battleSystem;

private void OnEnable()
{
battleSystem.OnBattleStarted += HandleBattleStarted;
battleSystem.OnBattleEnded += HandleBattleEnded;
}

private void OnDisable()
{
battleSystem.OnBattleStarted -= HandleBattleStarted;
battleSystem.OnBattleEnded -= HandleBattleEnded;
}

private void HandleBattleStarted()
{
Debug.Log("A battle has started!");
}

private void HandleBattleEnded(bool playerWon)
{
Debug.Log($"Battle ended. Player won: {playerWon}");
}
}

See the Public API Guide for more on extending MCE without source code.

Troubleshooting

IssueSolution
Battle does not triggerCheck that the EncounterTile has a valid WildEncountersSet assigned
Black screen after encounterVerify the battle scene is in your Build Settings scene list
Monster appears at level 0Ensure Min Level and Max Level are set in the encounter table
No battle musicCheck that BattleManagerAudioModule has audio clips assigned
Crashes on battle startRun MCE > Tools > Asset Validation to check for missing database references

Next Steps