Wild Encounter System
The encounter system determines when and which wild monsters appear as the player explores the world. MCE supports multiple encounter methods, configurable probability tables, level ranges, and time-of-day encounters.
How Encounters Work
- The player walks on a tile that has encounter data.
- Each step, the system rolls against the encounter rate.
- If the roll succeeds, a monster is selected from the tile's encounter table based on weighted probability.
- A
BattleParametersobject is created with the selected monster's species, level, and form. - The
BattleLaunchertransitions to the battle scene.
WildEncountersSet
The WildEncountersSet ScriptableObject defines the encounter table for a given area:
Create one at: Assets > Create > OpenMon > Wild Encounters Set
Each entry in the set contains:
| Field | Description |
|---|---|
| Monster | Reference to the MonsterEntry ScriptableObject |
| Min Level | Minimum level the wild monster can be |
| Max Level | Maximum level the wild monster can be |
| Probability | Relative weight for this entry (higher = more common) |
The actual level is randomly chosen between Min and Max each time the encounter triggers.
Probability Calculation
Probabilities are relative weights, not percentages. The system sums all weights and calculates each entry's chance:
Chance = Entry Weight / Sum of All Weights
Example table:
| Monster | Weight | Actual Chance |
|---|---|---|
| Leafpup | 40 | 40/100 = 40% |
| Windling | 30 | 30/100 = 30% |
| Silkworm | 20 | 20/100 = 20% |
| Sparkbit | 10 | 10/100 = 10% |
Encounter Types
MCE supports different encounter methods via the EncounterType enum:
| Type | Trigger | Description |
|---|---|---|
| Walking | Walking through tall grass or caves | Standard overworld encounters |
| Surfing | Surfing on water tiles | Water-surface encounters |
| Fishing | Using the fishing rod on water | Rod-based encounters (Old Rod, Good Rod, Super Rod) |
| RockSmash | Using Rock Smash on a smashable rock | Rock-based encounters |
| Headbutt | Using Headbutt on a tree | Tree-based encounters |
Each WildEncountersSet can have encounters separated by type. Only encounters matching the current action (walking, surfing, fishing) are considered.
Setting Up Encounter Zones
Method 1: EncounterTile Component
- In your scene, create an empty GameObject in the map hierarchy.
- Add the
EncounterTilecomponent. - Assign a
WildEncountersSetto the Encounters field. - Position and size the encounter zone to cover the desired tiles.
Method 2: SceneInfo Default Encounters
Each scene's SceneInfo can have a default WildEncountersSet. Any walkable grass tile in the scene will use this encounter table unless overridden by a specific EncounterTile.
Method 3: Per-Tile Encounters
For fine-grained control, you can assign different encounter sets to different areas of the same map. Place multiple EncounterTile components covering different regions.
Encounter Rate
The encounter rate controls how frequently encounters trigger per step:
- Base Rate: Configured per encounter zone (typical range: 5-25%).
- Modifiers: Items (e.g., Repel reduces to 0%), abilities (e.g., Stench reduces rate), and items (e.g., Cleanse Tag).
- Step Counter: The system tracks steps since the last encounter. After many steps without an encounter, the rate increases slightly to prevent long dry spells.
Time-of-Day Encounters
Different monsters can appear at different times of day:
| Period | Hours |
|---|---|
| Morning | 06:00 - 11:59 |
| Day | 12:00 - 17:59 |
| Evening | 18:00 - 20:59 |
| Night | 21:00 - 05:59 |
Configure time-based encounters by creating separate WildEncountersSet assets for each time period and assigning them via the encounter zone's time-of-day configuration.
Form Encounters
Some species have forms that appear differently based on conditions. The EncounterFormCalculator determines which form a wild monster spawns in:
- Regional forms: Based on the map's region tag.
- Seasonal forms: Based on the in-game calendar.
- Random forms: Randomly selected from available forms.
Use the SingleFormEncounter component to force a specific form in an encounter entry.
Special Encounter Patterns
Fishing
Fishing encounters require the player to use a fishing rod item while facing a water tile:
- Create a
WildEncountersSetwithEncounterType.Fishingentries. - Assign it to the water area's encounter configuration.
- Different rod tiers (Old Rod, Good Rod, Super Rod) filter which entries are available.
Legendary / One-Time Encounters
For special encounters that should only happen once:
- Use a CommandGraph event instead of random encounters.
- The event checks a game variable (e.g.,
LegendaryDefeated) before triggering. - After the battle, set the variable to prevent re-encounters.
- This approach gives you full control over the encounter context (cutscenes, dialogue, terrain).
Horde Encounters
Multiple wild monsters at once:
- Configure the encounter entry with a horde flag.
- The battle spawns 3-5 monsters of the specified species.
- The player fights them one at a time or can target the group (with AOE moves, if supported).
Repels and Encounter Prevention
Players can use items to prevent encounters:
| Item | Effect | Duration |
|---|---|---|
| Repel | Prevents encounters with monsters below player's lead level | 100 steps |
| Super Repel | Same effect, longer duration | 200 steps |
| Max Repel | Same effect, longest duration | 250 steps |
Repels are implemented as a step counter. The encounter system checks the repel counter before rolling for encounters.
Encounter Utilities
The EncounterUtils class provides helper methods:
// Check if encounters are possible at the current tile
bool canEncounter = EncounterUtils.CanEncounterAt(position, encounterType);
// Get the encounter set for a position
WildEncountersSet set = EncounterUtils.GetEncounterSet(position, encounterType);
// Roll for an encounter (returns null if no encounter triggers)
WildEncounter encounter = EncounterUtils.RollEncounter(set);
Best Practices
- Balance encounter rates. Too high (>25%) feels annoying. Too low (<5%) makes the world feel empty. 8-15% is typical.
- Scale levels with progression. Route 1 should have level 2-5 monsters, not level 50.
- Vary encounter tables between maps. Each route should feel distinct.
- Include rare encounters. One 5% encounter entry per table gives players something to hunt for.
- Test time-of-day encounters. Players should not feel punished for playing at a specific time.
- Place Repels early. Players appreciate having encounter control before mid-game.