Skip to main content

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

  1. The player walks on a tile that has encounter data.
  2. Each step, the system rolls against the encounter rate.
  3. If the roll succeeds, a monster is selected from the tile's encounter table based on weighted probability.
  4. A BattleParameters object is created with the selected monster's species, level, and form.
  5. The BattleLauncher transitions 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:

FieldDescription
MonsterReference to the MonsterEntry ScriptableObject
Min LevelMinimum level the wild monster can be
Max LevelMaximum level the wild monster can be
ProbabilityRelative 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:

MonsterWeightActual Chance
Leafpup4040/100 = 40%
Windling3030/100 = 30%
Silkworm2020/100 = 20%
Sparkbit1010/100 = 10%

Encounter Types

MCE supports different encounter methods via the EncounterType enum:

TypeTriggerDescription
WalkingWalking through tall grass or cavesStandard overworld encounters
SurfingSurfing on water tilesWater-surface encounters
FishingUsing the fishing rod on waterRod-based encounters (Old Rod, Good Rod, Super Rod)
RockSmashUsing Rock Smash on a smashable rockRock-based encounters
HeadbuttUsing Headbutt on a treeTree-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

  1. In your scene, create an empty GameObject in the map hierarchy.
  2. Add the EncounterTile component.
  3. Assign a WildEncountersSet to the Encounters field.
  4. 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:

PeriodHours
Morning06:00 - 11:59
Day12:00 - 17:59
Evening18:00 - 20:59
Night21: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:

  1. Create a WildEncountersSet with EncounterType.Fishing entries.
  2. Assign it to the water area's encounter configuration.
  3. 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:

  1. Use a CommandGraph event instead of random encounters.
  2. The event checks a game variable (e.g., LegendaryDefeated) before triggering.
  3. After the battle, set the variable to prevent re-encounters.
  4. 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:

ItemEffectDuration
RepelPrevents encounters with monsters below player's lead level100 steps
Super RepelSame effect, longer duration200 steps
Max RepelSame effect, longest duration250 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

  1. Balance encounter rates. Too high (>25%) feels annoying. Too low (<5%) makes the world feel empty. 8-15% is typical.
  2. Scale levels with progression. Route 1 should have level 2-5 monsters, not level 50.
  3. Vary encounter tables between maps. Each route should feel distinct.
  4. Include rare encounters. One 5% encounter entry per table gives players something to hunt for.
  5. Test time-of-day encounters. Players should not feel punished for playing at a specific time.
  6. Place Repels early. Players appreciate having encounter control before mid-game.