Version: 1.1
by RPG Advocate
Not by DerVVulfman
Introduction
This script allows you to set up rectangular areas with different encounters like the map editor functionality of RPG Maker 2000 and 2003.
Screenshots
Meh... It's a map feature.
Demo
HERE ya go!
I drew some tiles surrounding my defined areas in the demo map, just so you can see where ya are.
Script
The script is in two components, a parallel map event and the RGSS script itself.
RM2K Defined Encounter Areas
Instructions
The 1st thing to look at is the 'Event' code:
This is a map event (set to parallel process) that checks every-so-often whether the player is in a defined area (defined in the script). When it checks, it fills a variable (I chose variable #1 [0001]) with the number of a defined rectangular area... or '0' if the hero is NOT in a defined area.
Quote:I created 2 rectangle areas in my demo, so the value it would return would be 0, 1 or 2... again, a '0' would mean the player is NOT in one of the two rectangle areas.
When that is done, it then goes through if conditions, one after the other. Each one does almost the same thing... it calls an RGSS script:
$game_map.enum_encounter_list = [ list of enemy troop ids ]
Quote:My first list that HOLDS troops is... = [1, 2]
This holds troop numbers 1 and 2 (ie Ghost*2 and Ghost*3 in the default setup).
And, that's all the map event does. Sees where the player is on the map, uses a user-defined variable to check what script-defined rectangle he/she's in (if any), and store a list of enemy encounters in a value ($game_map.enum_encounter_list).
The next thing to look at is the actual RGSS Script:
This script should be pasted above MAIN... or more importantly, above ANY script that messes with Scene_Map's update It's a complete rewrite... or more to the point, line 100 down to line 126 replaces the original random-encounter section of Scene_Map.
Where to edit in the script?: Sure... I'll tell ya.
Go to the bottom of the script... the get_world_map_area_id area.
Here, you define the rectangle(s) where the enemy troops are encountered, and copy ALL the defined areas into an array. As an example, consider this:
rect1 = [1, 1, 7, 7]
rect2 = [8, 8, 14, 14]
area_rects = [rect1, rect2]
The second rectangle starts at tile 8 across and 8 down. It TOO is 7 tiles high and 7 tiles wide (not 14!).
After designing the two rectangles (I coulda added more rectangles), I put 'em both in my area_rects array.
Now, the first rectangle (rect1) is checked every so often by the map 'event' (the 'event' instructions above), and if the player is in THIS rectangle, the number 1 is returned. Likewise, if the player is found to be within the area defined in the second rectangle (rect2), the number 2 is returned (value based on it's order in area_rects).
Now, the next section to edit... if need be... is at the bottom of the script.
$game_variables[1] = area
$game_variables[23] = area
That's pretty much it. The script section creates the rectangle areas (only) and tells us which variable we're gonna use in the conditional branches in the map event above.
FAQ
This script was posted at http://www.phylomortis.com, but had a minor glitch that the 'example' image file (that showed how to set encounters) was missing.
Compatibility
As the CENTRAL portion of this script is a rewrite of Scene_Map's Update routine, any script that rewrites this portion will have problems. IF you're using a script that ALIASes Scene_Map, I recommend pasting this ABOVE that script.
Credits and Thanks
Obviously to RPG Advocate for returning this system to RMXP.
Author's Notes
Sorry, I ain't the author... just the guy who figured it out. :D