- Joined
- Mar 24, 2012
- Messages
- 93
- Reaction score
- 16
- First Language
- English
- Primarily Uses
Enemy Encounter System
Written By Adon237
Much Thanks to HK!
Here for you I have details for an encounter system that can meet the following:
- Is easy to use
- Allows for different types of encounters
- Is easy to expand
- Respawns encounter events
PART 1:
• Go to the Common Events Tab
• Go to a new common event.
• Name it something similar to ***MONSTER DEFEAT*** There are no triggers.
• In the common event, simply put a SHOW ANIMATION command, which will serve as the animation that plays on the enemy event when it dies. It should be targetted on "This Event".
• Then add a Wait 90 Frames.
• Optional: Add an "After Battle Cleanup Event", to turn off any switches or other stuff you had activated in the battle.
You need nothing more here, do not worry.
PART 2:
• In another common event, name it ***RESPAWN FOES***, There are no triggers.
• In a Set Move Route command, do the following:
This Event (Skip)
$> Change Opacity: 0
$> Wait: 1 Frame(s)
$> Change Opacity: 55
$> Wait: 1 Frame(s)
$> Change Opacity: 155
$> Wait: 1 Frame(s)
$> Change Opacity: 255
• Then do a Self Switch command turning Self Switch A OFF.
Part 3:
• In your next and final common event, name it ***ESCAPED BATTLE***. There are no triggers.
• Next you must choose a variable you will use as your "Gold Lost" variable. This will be used to calculate how much gold you loose for escaping. Remember, if you do not want this, it is very easy to just clear this common event. (Though it is recommended that you keep the actual event in the same slot, just in case you add something else.)
• In a Control Variable command, set the "Gold Lost" variable to the party's gold amount.
• In a another Control Variable command, multiply the "Gold Lost" variable by the number of party members in your party.
• In a final control variable command, divide the "Gold Lost" variable by 24.
• In a Change Gold command, subtract the gold amount by the "Gold Lost" variable.
• In a message command, type in "You lost \v[Gold Lost Var ID] gold for escaping!".
If your "Gold Lost" variable has an ID of 1, you type in \v[1]. If it has an ID of 187, you type in \v[187].
• Next, In a Set Move Route command, do the following:
This Event (Skip)
$> Change Speed: 5
$> Move away from Player
$> Move away from Player
$> Chage Speed: 3
Comment: Above: Makes the enemy 'bounce' back two tiles away from the player, so you don't immediately re-encounter them upon escaping. Just add more "Move away from Player" commands if you want the enemy to move back further.
• In another Set Move Route command, do the following:
Player(Skip, Wait)
$>SE: "Blow1", 100, 100
$> Walking Animation OFF
$> 1 Step Backward
$> Walking Animation ON
Comment: Above: The SE play is optional, it is just an escape sound effect of any kind. The player also moves one step back for good measure.
Part 4:
• Now, the last part, the actual encounter! Now that you have created all of the CEs that the encounter event will use, you can start creating your own encounters!
• I provide TWO tutorials on how to create TWO different types of encounters, Passive and Aggressive encounters.
Tutorial: Passive Encounter
• Passive encounters are calm encounters that wander the map, not bothering you. Your presence doesn't disturb them, and they won't get violent unless you try to mess with them (aka pressing X/Enter on them.).• First, create an event on a map. Find a suitable graphic. I myself used a blue flame to represent these. You can check off whatever options are needed for your graphic, those aren't crucial to the process.
• Set the priority to Same as Characters. You don't want them below or above you unless you are really creative and have devised some pretty cool encounter. Triggers are an important detail that distinguishes some encounters from each other. Since this encounter is passive, set the trigger to Action Button. This will activate them only when the player tries to interact with them.
• In Autonomous Movement, set the type to Random, the speed to x2 Slower, and Frequency to Lowest.
• Next, in the event's first page, do a Control Variables command, choose a variable to be your Encounter Variable. I will refer to that variable as Variable X from this point forward.
• Under Operation, make sure it is at Set. Under Operand, set that to Random, 1 ~ 100. That will be used to randomly determine which monster troop you will encounter.
• Now, put a Play SE command. This should be like a surprised noise, but really it can be whatever you want.
• Next, do a Show Balloon Icon: This event, Exclamation, Wait command. (If using VX, then put a Wait Command for 35 frames) The player has to have some way of telling what is happening, so what is better than a noise and a balloon icon?
• Now, create a Conditional Branch. Make sure it is set to Variable, the specific variable Variable X, make it less than or equal to, and then choose constant. Set the constant to 50. Then, check the box that says "Set handling when conditions do not apply" or something like that. You will probably do this like 3 more times, so come back here to refer to it when needed.
• Inside the Conditional Branch, but in a Battle Processing command. Choose direct designation, and the monster troop you want to be encountered. Check the "Can Escape" option.
• In the Battle Processing command's Win condition, first put a Call Common Event command, and call the MONSTER DEFEAT common event that you set up earlier.
• After that, Turn that event's Self Switch A to ON.
• In the Escape condition, just call the ESCAPED BATTLE common event you set up.
• In the ELSE part of the Conditional Branch, make another Conditional branch with the same settings we had in the last one, except the constant which will be set to 70 this time. Repeat the steps above after the creation of the conditional branch, with a different monster troop.
• Repeat the above bullet point twice, except you set the constant to 90, and then 100. Once you have 4 conditional branches, you stop.
• Create a new page in the event. Do not set a graphic. On the page condition, set it to SELF SWITCH A, ON. The options, priority, and autonomous movement are irrelevant to this page. Set the trigger to Parallel Process.
• On the new page, Create two Wait commands, setting each to 999 frames. That seems obnoxious, but it is really appropriate. If you want them to respawn faster, I suggest removing one of the waits. You don't want them to automatically respawn, do you?
• Finally, add a Call Common Event command, the RESPAWN FOES common event.
At last, you have crafted a On-Map encounters system, and a passive encounter! Try it out! Remember that you will have to change the troops that are encountered when needed, but that is it! Then you copy-paste them in the locations you want on the map. Good job!
Tutorial: Aggressive Encounter
• Not much is different as far as event code goes in these than the Passive encounters.• Copy paste your Passive encounter event and open it up. (This will save time.)
• Change the graphic to something suitable. (I used a red flame)
• In Autonomous Movement, set the type to Custom. Then click the "Move Route..." button.
• Depending on what you want, you could either have Move at Random, Move toward player, or just Move toward player. Choose one.
• Set the Speed to x2 Faster, and Frequency to Higher(4).
• Finally, set the Trigger to Event Touch.
• These encounters will move towards you, and when they touch you an encounter will start.
• You can use a script like Yanfly's Event Chase Player to make it more authentic. Just simply put @change_range = 5 or something in the Custom movement along with how you want them to move when they haven't detected the player.
Here is a screenie of how passive encounters look like:
Stalker encounters are fairly easy to do.
1. Copy a passive encounter event.
2. Above the rest of the event code, add in a comment "<Move_With_Player>" (without the quotation marks)
3. Set the Trigger to Event Touch.
4. Add in the following script by BigEd: (below the materials section, it shouldn't cause much incompatibility with other scripts)
Code:
#==============================================================================# ** Game_Player#------------------------------------------------------------------------------# This class handles the player. It includes event starting determinants and# map scrolling functions. The instance of this class is referenced by# $game_player.#==============================================================================class Game_Player < Game_Character#--------------------------------------------------------------------------# * Alias Listing#--------------------------------------------------------------------------alias tds_event_move_with_player_game_player_increase_steps increase_steps#--------------------------------------------------------------------------# * Increase Steps#--------------------------------------------------------------------------def increase_steps(*args, &block)# Run Original Methodtds_event_move_with_player_game_player_increase_steps(*args, &block)# If Normal Walkif normal_walk?# Move Events that move with the player$game_map.events.values.select {|e| e.moving_with_player?}.each {|e| e.move_with_player}endendend#==============================================================================# ** Game_Event#------------------------------------------------------------------------------# This class handles events. Functions include event page switching via# condition determinants and running parallel process events. Used within the# Game_Map class.#==============================================================================class Game_Event < Game_Character#--------------------------------------------------------------------------# * Alias Listing#--------------------------------------------------------------------------alias tds_event_move_with_player_game_event_update_self_movement update_self_movementalias tds_event_move_with_player_game_event_clear_page_settings clear_page_settingsalias tds_event_move_with_player_game_event_setup_page_settings setup_page_settings#--------------------------------------------------------------------------# * Determine if Event should move along with player#--------------------------------------------------------------------------def moving_with_player? ; @move_with_player end#--------------------------------------------------------------------------# * Update During Autonomous Movement#--------------------------------------------------------------------------def update_self_movement(*args, &block)# Update Move With Player Movement if Moving with Playerreturn update_move_with_player_movement if moving_with_player?# Run Original Methodtds_event_move_with_player_game_event_update_self_movement(*args, &block)end#--------------------------------------------------------------------------# * Update Move With Player Movement#--------------------------------------------------------------------------def update_move_with_player_movement# Return if Moving orreturn if moving? or @move_with_player_steps <= 0# Decrease Move With Player Steps Counter@move_with_player_steps -= 1# If Move with Player Steps is 0 or lessif @move_with_player_steps <= 0# Set Move With Player Step Wait & Original Step Wait values@move_with_player_step_wait = @original_move_with_player_step_waitend# If Flag to match player speed is trueif @move_with_player_match_speed# Set Move Speed@move_speed = @move_with_player_speed# Adjust Move Speed by Match Offset@move_speed += @move_with_player_match_speed_offsetend# Move in the same direction as the player if mimicking movementreturn move_straight(@move_with_player_direction) if @move_with_player_mimic# Move in the Opposite Direction as the player if Reverse Mimic flag is truereturn move_straight(reverse_dir(@move_with_player_direction)) if @move_with_player_reverse_mimic# Move Type Casecase @move_typewhen 1; move_type_randomwhen 2; move_type_toward_playerwhen 3# Update Move Routeupdate_routine_move# Update Move Route if at Last Command (Prevents stop)update_routine_move if @move_route.list[@move_route_index].code == 0endend#--------------------------------------------------------------------------# * Update During Autonomous Movement#--------------------------------------------------------------------------def move_with_player# Return if Move With Player Step Wait is more than 0return @move_with_player_step_wait -= 1 if @move_with_player_step_wait > 0# Return if moving or Have Steps Remainingreturn if moving? or @move_with_player_steps > 0# Set Move With Player Steps@move_with_player_steps = @original_move_with_player_steps# Set Move with player Direction@move_with_player_direction = $game_player.direction# Set Move With Player Speed@move_with_player_speed = $game_player.real_move_speedend#--------------------------------------------------------------------------# * Clear Event Page Settings#--------------------------------------------------------------------------def clear_page_settings(*args, &block)# Run Original Methodtds_event_move_with_player_game_event_clear_page_settings(*args, &block)# Clear Move With Player Page Settingsclear_move_with_player_page_settingsend#--------------------------------------------------------------------------# * Clear Event Page Move with Player Settings#--------------------------------------------------------------------------def clear_move_with_player_page_settings# Move with Player Flag@move_with_player = false# # Move With Player Speed Match Flag & Offset@move_with_player_match_speed = false ; @move_with_player_match_speed_offset = 0# Move With Player Mimic Flags@move_with_player_mimic = false ; @move_with_player_reverse_mimic = false# Move With Player Step & Original Step values@move_with_player_steps = @original_move_with_player_steps = 0# Move With Player Step Wait & Original Step Wait values@move_with_player_step_wait = @original_move_with_player_step_wait = 0end#--------------------------------------------------------------------------# * Set Up Event Page Settings#--------------------------------------------------------------------------def setup_page_settings(*args, &block)# Run Original Methodtds_event_move_with_player_game_event_setup_page_settings(*args, &block)# Setup Page Move With Player Settingssetup_page_move_with_player_settingsend#--------------------------------------------------------------------------# * Set Up Event Page Move With Player Settings#--------------------------------------------------------------------------def setup_page_move_with_player_settings# Clear Move With Player Page Settingsclear_move_with_player_page_settings# Get All Page Comment Textcomment_text = @list.select {|c| [108, 408].include? (c.code)}.collect {|c| c.parameters}.join# Return if Comment Text is emptyreturn if comment_text.empty?# Set Move With Player Flag to true if Text Flag exist@move_with_player = true if comment_text =~ /<Move_With_Player>/i# Match Comment Text for Amount of Move Stepscomment_text[/<Move_With_Player_Steps: (\d+)>/i]@original_move_with_player_steps = $1.nil? ? 1 : $1.to_i# Set Move With Player Match Speed Flag to true if Text Flag exists@move_with_player_match_speed = true if comment_text =~ /<Match_Player_Speed>/i# Match Comment Text for Match Speed Offsetcomment_text[/<Match_Player_Speed_Offset: (-?\d+)>/i]@move_with_player_match_speed_offset = $1.nil? ? 0 : $1.to_i# Set Move with Player Mimic Flag to true if Text Flag exist@move_with_player_mimic = true if comment_text =~ /<Mimic_Player_Move>/i# Set Move with Player Reverse Mimic Flag to true if Text Flag exist@move_with_player_reverse_mimic = true if comment_text =~ /<Reverse_Mimic_Player_Move>/i# Match Comment Text for Step Wait Valuescomment_text[/<Player_Move_Step_Wait: (\d+)>/i]@move_with_player_step_wait = @original_move_with_player_step_wait = $1.nil? ? 0 : $1.to_iendend
Please note that there are other functions of that script that can be utilized by comment calls.
(Also please let me know if the script is improperly credited)
Other Potential Encounter Types:
• Stalking encounter (they make a move towards you every time you move)(think lufia)
• Evasive encounter (they run away from player, may have rare encounter)
• Curious encounter (a mix of passive and aggressive. they follow you, but you have to press X to battle)
• Aerial encounter (encounters that fly above the players head, experimental)
If you want a tutorial on how to do any of those, just ask! I have them in my game and am willing to share!
Last edited by a moderator:

