Turn a region into a battle zone
make_encounter_zonePaint a map region, create its troop groups, and attach weighted encounter rows in one call, preventing broken or empty random encounters in RPG Maker MZ.
Instructions
Paint a region, make the troops, and attach the encounter rows in one call. A zone is three writes across two files (layer 5 of the map, then the map's encounter list) plus a Troops row per group, and the row shapes are exactly the ones that break a game when they are guessed: MZ reads regionSet unconditionally, so a row without that array throws inside Scene_Map on its first roll and freezes the map mid-walk, and a row without weight makes the weight sum NaN so that no row on the map ever rolls. A troop entry either names an existing troopId or lists enemies (ids, or {id, level?, x?, y?}), and the row is cloned from a real troop so its member shape matches what the editor writes. Region 0 means the whole map. The reply calls out any row whose region no cell carries, because that is the mistake that makes a zone feel empty rather than broken.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mapId | Yes | ||
| region | No | Paint the region on layer 5; omit to keep whatever is already painted | |
| troops | Yes | The battle groups that can appear here | |
| clearRegion | No | Erase this region id from the whole map first, so a re-run does not leave the old paint behind | |
| keepExisting | No | Add to the map's current encounter rows instead of replacing them | |
| encounterStep | No | Steps the player walks between encounter rolls on this map (default 20; MZ's new maps use 30) |