Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Update Encounter Percentage
- # Version: 1.0
- # Author: modern algebra (rmrk.net)
- # Date: April 29, 2010
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Description:
- #
- # This script allows you to dynamically alter the rate at which encounters
- # happen. It is useful particularly for making items or skills that can
- # reduce or increase the rate of encounters. What this script does is allow
- # you to specify a variable to control encounter rate, so you can use events
- # and common events to change the percentage of the default at which
- # encounters occur.
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Instructions:
- #
- # Paste this script into its own slot in the Script Editor (F11) above Main
- # but below Materials.
- #
- # To set up which variable you want to control Encounter Rate, go to line 38
- # and set UEP_CONTROL_VARIABLE_ID to the ID of the variable you want.
- #
- # The in-game value of the variable that you set will be the modified
- # percentage of encounters.
- # EX: If that variable is set to 100, then the encounter rate will not
- # change at all. If it's set to 50, then encounters will occur half as
- # frequently. If it's set to 200, then encounters will occur twice as
- # frequently. As a default measure, when that variable is set to 0, then it
- # will not alter encounter rate in any way. If you set the variable to
- # anything below 0 then no encounters will occur at all.
- #==============================================================================
- #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- # EDITABLE REGION
- #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- # The ID of the variable that controls how the encounter rate is updated
- UEP_CONTROL_VARIABLE_ID = 20
- #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- # END EDITABLE REGION
- #//////////////////////////////////////////////////////////////////////////////
- #==============================================================================
- # ** Game Variables
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased method - []=
- #==============================================================================
- class Game_Variables
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Set Variable
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malg_upep_setvar_7uj1 []= unless $@
- def []= (var_id, *args)
- old_val = self[var_id]
- malg_upep_setvar_7uj1 (var_id, *args)
- # Scale Encounter percentage if this is the control variable
- if var_id == UEP_CONTROL_VARIABLE_ID && old_val != self[var_id]
- $game_player.calc_encounter_percent (old_val)
- end
- end
- end
- #==============================================================================
- # ** Game Player
- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- # Summary of Changes:
- # aliased method - update_encounter, make_encounter_count
- # new method - calc_enc_percent
- #==============================================================================
- class Game_Player
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Make Encounter Count
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias modern_ueper_mkencnt_5fv1 make_encounter_count unless $@
- def make_encounter_count (*args)
- modern_ueper_mkencnt_5fv1 (*args)
- calc_encounter_percent
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Update Encounter
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- alias malg_uep_updenc_6yj2 update_encounter unless $@
- def update_encounter (*args)
- variable = $game_variables[UEP_CONTROL_VARIABLE_ID]
- return if variable.nil? || variable < 0
- malg_uep_updenc_6yj2 (*args) # Run Original Method
- end
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- # * Calculate Encounter Percentage
- #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- def calc_encounter_percent (old_mod = 100)
- variable = $game_variables[UEP_CONTROL_VARIABLE_ID]
- return if variable.nil? || variable < 0 || old_mod < 0
- old_mod = 100 if old_mod == 0
- variable = 100 if variable == 0
- @encounter_count = (@encounter_count*(old_mod.to_f / variable.to_f)).to_i
- end
- end
Add Comment
Please, Sign In to add comment