This is a little tutorial on how to make map encounters by event, which can be used both in substitution or in parallel to the default system.
With this you can control how many enemies are per map, make more frequent enemies than others, concentrate them on regions, make them depend on switches or variables, make them unique (activate a switch after that disables it, or use a variable as a counter) or even make methods for the player to avoid them like a minimap or a radar, make encounters where you can't escape or something happens when you lose (or win), conditional encounters by equip, or by possessed item or whatever, etc.
With this you can also make encounters that follow the player so staying quiet is no longer a good option, and more complex things like that.
1. Define the events in the map
We create as many enemy events on the map as we want and wherever we want, and name them all "
ENCOUNTER". The event has "Touch player" as trigger and only has the battle as command, with the option to escape enabled. I think 10 at most for big maps should be enough.
You can optionally create a condition in the start of the event with this:
Code:
> Condition: $DEBUG && Input.press?(Input::CTRL)
>> Stop Event Process
> END
This way in Debug mode battles are disabled when you press CTRL, as default.
2. Place the events on the map
I posted two ways to do that
here, one using a very simple Pathfinding, and one using Areas instead.
We will do that on a common event. After the battle command on each ENCOUNTER event you can call it to place them after each battle, but the easier way is doing it only when you enter the map.
I recommend doing that with a Parallel Process that calls the common event and immediately after is erased temporarily. You could also use a script to call it directly on the entrance of any map instead.
Spoiler: Common Event Direct Call
Ruby:
class Game_Map
alias encounter_map_setup setup unless $@
def setup(map_id)
encounter_map_setup(map_id)
$game_temp.common_event_id = 1 # Common Event ID
end
end
Inside the Common Event we use these two Script calls which place every ENCOUNTER event. Note I used "rand_event_position" on the example, it would be "rand_event_area" if you use the Area option.
Code:
for event in $game_map.events.values
name = event.instance_eval("@event").name
if name == "ENCOUNTER"
ch = "@character_name = '051-Undead01'"
event.instance_eval(ch) if $DEBUG
event.instance_eval("@through = false")
rand_event_position(event.id)
end
end
Code:
for event in $game_map.events.values
name = event.instance_eval("@event").name
if name == "ENCOUNTER"
event.instance_eval("@through = false")
end
end
I also made it so in Debug mode you can see those invisible events as RTP ghosts instead. You can remove the "051-Undead01" line and the next one to disable that option.
That's it with the system, but I will also mention how to make a very simple radar as well.
3. Making a radar that detects near-by encounters
When used, the item will call another common event that will apply an animation on encounters that are near the player.
Code:
for event in $game_map.events.values
name = event.instance_eval("@event").name
if name == "ENCOUNTER"
dx = ($game_player.x - event.x).abs
dy = ($game_player.y - event.y).abs
d = Math.sqrt(dx ** 2 + dy ** 2)
if d < 5 # Range
event.animation_id = 1 # Animation ID
end
end
end