#=============================================================================== # # Yanfly Engine RD - Variable Controlled Encounters # Last Date Updated: 2009.04.20 # Level: Normal # # I got tired of terrible encounter rates when you would set the average rate # to roughly "30" steps and every 4 steps, the game would enter a battle so I # made this to augment the rate battles would appear and to give me more control # over them. The control that's given are the number of times the steps are # rolled before making an average, the minimum number of steps that are free of # battle, the percentage rate of the encounters that is free of battle, and if # used, an event variable to modify the encounter rate. # # In addition to that, I've recreated a system similar to the Pokemon Repel item # which gets rid of encounters so long as the Repel item isn't spent. Note that # this isn't anything too special, but it's something extra to stick into this # script. Repel is bound to an event variable so that the player doesn't have to # throw in extra coding to modify the Repel value. Just modify it through the # event editor. Simple as that. # # Also, for the opposite of Repel, there is a lure variable. Although rather # than initiating a battle every step, lure will cut down the encounter count # by a certain amount, which can be controlled from within the game. # #=============================================================================== # Instructions #=============================================================================== # # By default, the variables are as follows: # # THE_STEPS_VARIABLE = Variable 61 = Bonus steps added upon encounter. This # adds a control to the randomization. # STEPS_REMAINING_VAR = Variable 62 = Steps remaining before battle. This can be # calculated with or without the repel # variable. Used for debugging purposes. # REPEL_VARIABLE = Variable 63 = Used like it is in Pokemon. How many steps # does the player get free of battles. # LURE_VARIABLE = Variable 64 = Used similar to the Repel variable. It # lowers the encounter countdown which uses # the following two variables to modify. # LURE_DIV_VAR = Variable 65 = Divides the encounter countdown by this # amount. Ignored if it's equal to zero. # LURE_SUB_VAR = Variable 66 = Subtracts the encounter countdown by # this amount. Make it negative to raise the # countdown timer if you want to do that # instead for whatever reason. # # Change the variables in the event editor to alter the encounter rates in your # game. They will internally affect the game through external means. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.04.20 - Bug fix. # o 2009.04.11 - Started script. #=============================================================================== # # Compatibility # - Alias: Scene_Map, update_encounter # - Overwrites: Game_Player, make_encounter_count, update_encounter # #=============================================================================== $imported = {} if $imported == nil $imported["VariableControlledEncounters"] = true module YE module EVENT module VARIABLE # These are modifiers for the default encounter countdown reduction. # Bush values are at the center of an autotile and not necessarily inside # something that looks like a bush. Well, now you can modify it. BUSH_REDUCTION = 1 NORM_REDUCTION = 1 # The number of times the encounter steps are rolled. This means that if # it's set to 3, the encounter rate would be rolled three times and would # take the average of that. # Note: Setting this value to 0 will make your computer explode. STEPS_ROLLED = 4 # This is the minimum amount of steps the player would have free of # encounters after a battle. MINIMUM_STEPS_FREE = 10 # This is a percent of the map's encounter rate that the player would # get free after a battle. A value of 10 would be 10% of the rate. A # map with 30 steps an encounter rate would get an additional 3 steps # free of encounters. PERCENT_RATE_FREE = 20 # If this is set to true, it will designate an event variable to modify # the encounter rate. The encounter rate would be added by however much # the variable equals. The variable can be set to a negative value to # raise the encounter rate if needed. USE_STEPS_VARIABLE = true # Needs to be set to true for next to work. THE_STEPS_VARIABLE = 61 # Number of steps modified to encounter. # For debugging purposes, you can use this variable to keep track of how # many steps are remaining before a battle will ensue. STEPS_REMAINING_VAR = 62 TOTAL_WITH_REPEL = false # Set this to true to total it with Repel. # This is the Repel Variable. If this value is above zero, it will not # allow the encounter countdown to drop by even one step. REPEL_VARIABLE = 63 # This is the Lure Variable and the variables that modify the encounter # rate. The DIV_VAR divides the encounter countdown by its value while # the SUB_VAR subtracts it by its value. LURE_VARIABLE = 64 # This is the variable representing the steps. LURE_DIV_VAR = 65 # This is the variable dividing the countdown. LURE_SUB_VAR = 66 # This is the variable subtracting the steps. end # module VARIABLE end # module EVENT end # module YE #=============================================================================== # Editting anything past this point may potentially result in causing computer # damage, incontinence, explosion of user's head, coma, death, and/or halitosis. # Therefore, edit at your own risk. #=============================================================================== #=============================================================================== # Game Player #=============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # make_encounter_count #-------------------------------------------------------------------------- def make_encounter_count if $game_map.map_id != 0 n = $game_map.encounter_step @encounter_count = 0 for i in 0..YE::EVENT::VARIABLE::STEPS_ROLLED @encounter_count += rand(n) end @encounter_count /= YE::EVENT::VARIABLE::STEPS_ROLLED @encounter_count += 1 @encounter_count += YE::EVENT::VARIABLE::MINIMUM_STEPS_FREE @encounter_count += n * YE::EVENT::VARIABLE::PERCENT_RATE_FREE / 100 if YE::EVENT::VARIABLE::USE_STEPS_VARIABLE @encounter_count += $game_variables[YE::EVENT::VARIABLE::THE_STEPS_VARIABLE] end @encounter_count = 1 if @encounter_count < 1 end end #-------------------------------------------------------------------------- # Update Encounter #-------------------------------------------------------------------------- def update_encounter # Check for Repel if $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] > 0 $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] -= 1 $game_temp.common_event_id = 40 if $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] == 1 end return if $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] > 0 # The default stuff return if $TEST and Input.press?(Input::CTRL) return if in_vehicle? if $game_map.bush?(@x, @y) @encounter_count -= YE::EVENT::VARIABLE::BUSH_REDUCTION else @encounter_count -= YE::EVENT::VARIABLE::NORM_REDUCTION end # Check for Lure if $game_variables[YE::EVENT::VARIABLE::LURE_VARIABLE] > 0 $game_variables[YE::EVENT::VARIABLE::LURE_VARIABLE] -= 1 @encounter_count /= $game_variables[YE::EVENT::VARIABLE::LURE_DIV_VAR] if $game_variables[YE::EVENT::VARIABLE::LURE_DIV_VAR] != 0 @encounter_count -= $game_variables[YE::EVENT::VARIABLE::LURE_SUB_VAR] $game_temp.common_event_id = 40 if $game_variables[YE::EVENT::VARIABLE::LURE_VARIABLE] == 1 end # Update the Encounter Variable if @encounter_count != nil $game_variables[YE::EVENT::VARIABLE::STEPS_REMAINING_VAR] = @encounter_count $game_variables[YE::EVENT::VARIABLE::STEPS_REMAINING_VAR] += $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] if YE::EVENT::VARIABLE::TOTAL_WITH_REPEL end end end #=============================================================================== # Scene Map #=============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # Update Encounter #-------------------------------------------------------------------------- alias modifier_update_encounter update_encounter unless $@ def update_encounter return if $game_variables[YE::EVENT::VARIABLE::REPEL_VARIABLE] > 0 modifier_update_encounter end end #=============================================================================== # # END OF FILE # #===============================================================================