Improved impact rates
Version:1
By: gerkrt/gerrtunk
Introduction
This script completely revamps the classic impact rate calculations. Now you have
a full control of the random targets of the enemies.
You can set it now by:
-Positions in actor group
-Actor
-Classes
-Armors
-Weapons
You can also set a Max and a Base impact rate values, and add a inernal correction
to any actor that can be temporal or not and is setted via script call.
Finally it adds the option to use the default clasic values for actors postions, but
now you can set the rate value of rear, front and mid guard.
Screenshots
Not valid for this script.
Script
Get it here: http://usuarios.multimania.es/kisap/english_list.html
Instructions
Nothing special. Just insert it before main.
Authors notes
All my scripts are in development and im open to suggestions, critics, bugs, etc.
Version:1
By: gerkrt/gerrtunk
Introduction
This script completely revamps the classic impact rate calculations. Now you have
a full control of the random targets of the enemies.
You can set it now by:
-Positions in actor group
-Actor
-Classes
-Armors
-Weapons
You can also set a Max and a Base impact rate values, and add a inernal correction
to any actor that can be temporal or not and is setted via script call.
Finally it adds the option to use the default clasic values for actors postions, but
now you can set the rate value of rear, front and mid guard.
Screenshots
Not valid for this script.
Script
Get it here: http://usuarios.multimania.es/kisap/english_list.html
- #==============================================================================
- # Improved impact rate
- # By gerkrt/gerrtunk
- # Version: 1.0
- # License: MIT, credits
- # Date: 18/01/2010
- # IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
- # script check here: http://usuarios.multimania.es/kisap/english_list.html
- #==============================================================================
- =begin
- --------Introduction-----------
- This script completely revamps the classic impact rate calculations. Now you have
- a full control of the random targets of the enemies.
- You can set it now by:
- -Positions in actor group
- -Actor
- -Classes
- -Armors
- -Weapons
- You can also set a Max and a Base impact rate values, and add a inernal correction
- to any actor that can be temporal or not and is setted via script call.
- Finally it adds the option to use the default clasic values for actors postions, but
- now you can set the rate value of rear, front and mid guard.
- ----IMPACT RATE FOR POSITIONS-------
- Impact_rate['positions'][2] = 3
- Impact_rate['positions'][1] = 2
- Impact_rate['positions'][actor position] = rate
- ----IMPACT RATE FOR ACTORS-------
- Impact_rate['actors'][1] = 5
- Impact_rate['actors'][actor id] = rate
- ----IMPACT RATE FOR CLASSES-------
- Impact_rate['classes'][1] = 1
- Impact_rate['classes'][class id] = rate
- ----IMPACT RATE FOR WEAPONS-------
- Impact_rate['weapons'][1] = 1
- Impact_rate['weapons'][weapon id] = rate
- ----IMPACT RATE FOR ARMORS-------
- Impact_rate['armors'][1] = -1
- Impact_rate['armors'][armor id] = rate
- ----FIXED AND TEMPORAL CHANGUES(script calls)-----
- modify_impact_rate(actor, value): This will add to a internal variable that have each
- actor. That atribute is added when calculating its posibilities.
- Ex:
- modify_impact_rate(2, 4)
- This is adding 4 to the impact rate of the actor that have the id 2 in the database.
- The difference of this and the actors value is that the actors value cant be modified.
- modify_tmp_impact_rate(actor, value): This is like the other, but at the end of each
- combat, its reseted to 0. It can be used for special effects.
- Ex:
- modify_tmp_impact_rate(3, -4)
- This is adding -4 to the temporal impact rate of the actor that have the id 3 in the
- database. Note that in the two cases is valid to put negative numbers to compensate
- this.
- ----OTHER CONFIGURATIONS---------
- Impact_rate_max : This is used to create a max for the times the actors are put
- in the roulette. It can be interesting for someone thats lookig for tweaking the
- formula.
- Impact_rate_base : This is used to create a base value that will be added to all actors
- It can be interesting for someone thats lookig for tweaking theformula.
- Use_database_position : If not actived, it wont add the default impact rate of
- the database. If you set it to the word false, it will be desactived.
- You can set new values for the clasic options here:
- Front_guard_rate = 4
- Mid_guard_rate = 3
- Rear_guard_rate = 2
- ----HOW THE FORMULA WORKS-------
- Its an expansion of the classic one:
- Each active and valid actor is added to the list n times, where n is the sum of:
- Base rate
- Clasic database position(if active)
- All equipment rates
- Class rate
- Actor rate
- Actor base rate
- Actor temporal rate
- Then is checked if that is more than the Max n, if so, it sets n to that Max.
- So if all of them sum 15, and 15 is valid, it will add the actor 15 times to
- the roulette.
- The script does that for all the actors, and then try for a random slot of the
- roulette list.
- Note that any value of the script may have a negative value. Thats valid to
- for whatever you want, but, the minium of n is always 0.
- Finally, only the defined values will be added, so, if a position or class
- dont have any value for that, it will be ignored, like a default +0.
- =end
- module Wep
- # Dont touch this
- Impact_rate = {'positions' => [], 'actors' => [], 'classes' => [],'weapons' => [],'armors' => []}
- Impact_rate['positions'][0] = 0
- Impact_rate['positions'][2] = 3
- Impact_rate['positions'][1] = 2
- Impact_rate['positions'][3] = 1
- Impact_rate['weapons'][3] = 4
- Impact_rate['armors'][4] = -3
- Impact_rate['classes'][1] = 1
- Impact_rate['actors'][1] = 5
- Impact_rate_max = 20
- Impact_rate_base = 4
- Use_database_position = true
- Front_guard_rate = 4
- Mid_guard_rate = 3
- Rear_guard_rate = 2
- end
- #==============================================================================
- # ** Interpreter
- #------------------------------------------------------------------------------
- # added two impact rate methods to modify internal actor variables
- #==============================================================================
- class Interpreter
- #--------------------------------------------------------------------------
- # * Modifiy impact rate
- #--------------------------------------------------------------------------
- def modify_impact_rate(actor, val)
- $game_actors[actor].impact_rate_base += val
- end
- #--------------------------------------------------------------------------
- # * Modifiy temporal impact rate
- #--------------------------------------------------------------------------
- def modify_tmp_impact_rate(actor, val)
- $game_actors[actor].impact_rate_temp += val
- end
- end
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # moded the random target method
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # * Defined Random Selection of Target Actor
- # It allows you to define enemy random target based on combat positions,
- # actor, class, weapon, armor, and internal actor variables
- #--------------------------------------------------------------------------
- def random_target_actor(hp0 = false)
- # Initialize roulette
- roulette = []
- # Loop
- count = 0
- # Iterate in active actors
- for actor in @actors
- # If it fits the conditions
- if (not hp0 and actor.exist?) or (hp0 and actor.hp0?)
- # Create the total number
- n = Wep::Impact_rate_base + Wep::Impact_rate['positions'][count] + actor.impact_rate
- # Check if the use database position is active and apply it
- if Wep::Use_database_position
- # Get actor class [position]
- position = $data_classes[actor.class_id].position
- # Exchangue with defined values
- if position == 4
- position = Wep::Front_guard_rate
- elsif position == 3
- position = Wep::Mid_guard_rate
- else
- position = Wep::Rear_guard_rate
- end
- # Rest position values: Front guard: n = 4; Mid guard: n = 3; Rear guard: n = 2
- n -= position
- n = n.abs
- end
- # Check for n max size
- if n > Wep::Impact_rate_max
- n = Wep::Impact_rate_max
- end
- #p 'rand', n
- # Add actor to roulette n times
- n.times do
- roulette.push(actor)
- end
- end
- count+=1
- end
- # If roulette size is 0
- if roulette.size == 0
- return nil
- end
- # Spin the roulette, choose an actor
- return roulette[rand(roulette.size)]
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #------------------------------------------------------------------------------
- # modified battle end method
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # * Battle Ends
- # moded to reset impact rate temp variables
- #--------------------------------------------------------------------------
- alias wep_ib_battle_end battle_end
- def battle_end(result)
- # Reset all game party actors temporal impact rate
- $game_party.actors.each {|i|i.impact_rate_temp = 0 }
- wep_sb_battle_end(result)
- end
- end
- #==============================================================================
- # ** Game_Actor
- #------------------------------------------------------------------------------
- # added two variables in setup and general impact rate method
- #==============================================================================
- class Game_Actor
- attr_accessor :impact_rate_base
- attr_accessor :impact_rate_temp
- attr_accessor :impact_rate
- #--------------------------------------------------------------------------
- # * Setup
- # moded set internal variables
- #--------------------------------------------------------------------------
- alias ga_wep_ib_setup setup
- def setup(actor_id)
- ga_wep_ib_setup(actor_id)
- @impact_rate_base = 0
- @impact_rate_temp = 0
- end
- #--------------------------------------------------------------------------
- # * Impact Rate
- # sum all impact rates values
- #--------------------------------------------------------------------------
- def impact_rate
- n = 0
- n += $data_weapons[@weapon_id].impact_rate if @weapon_id != 0
- n += $data_armors[@armor1_id].impact_rate if @armor1_id != 0
- n += $data_armors[@armor2_id].impact_rate if @armor2_id != 0
- n += $data_armors[@armor3_id].impact_rate if @armor3_id != 0
- n += $data_armors[@armor4_id].impact_rate if @armor4_id != 0
- n += $data_classes[@class_id].impact_rate
- n += $data_actors[@actor_id].impact_rate
- n += @impact_rate_base
- n += @impact_rate_temp
- return n.to_i != 0 ? n.to_i: 1
- end
- end
- #==============================================================================
- # ¦ RPG::Actor
- # added impact rate support
- #==============================================================================
- class RPG::Actor
- attr_accessor :impact_rate
- #--------------------------------------------------------------------------
- # * Impact rate
- # moded to return the array values throught a internal method
- #--------------------------------------------------------------------------
- def impact_rate
- data = Wep::Impact_rate['actors']
- return data[@id] != nil ? data[@id] : 0
- end
- end
- #==============================================================================
- # ¦ RPG::Armor
- # added impact rate support
- #==============================================================================
- class RPG::Armor
- attr_accessor :impact_rate
- #--------------------------------------------------------------------------
- # * Impact rate
- # moded to return the array values throught a internal method
- #--------------------------------------------------------------------------
- def impact_rate
- data = Wep::Impact_rate['armors']
- return data[@id] != nil ? data[@id] : 0
- end
- end
- #==============================================================================
- # ¦ RPG::Class
- # added impact rate support
- #==============================================================================
- class RPG::Class
- attr_accessor :impact_rate
- #--------------------------------------------------------------------------
- # * Impact rate
- # moded to return the array values throught a internal method
- #--------------------------------------------------------------------------
- def impact_rate
- data = Wep::Impact_rate['classes']
- return data[@id] != nil ? data[@id] : 0
- end
- end
- #==============================================================================
- # ¦ RPG::Weapon
- # added impact rate support
- #==============================================================================
- class RPG::Weapon
- attr_accessor :impact_rate
- #--------------------------------------------------------------------------
- # * Impact rate
- # moded to return the array values throught a internal method
- #--------------------------------------------------------------------------
- def impact_rate
- data = Wep::Impact_rate['weapons']
- return data[@id] != nil ? data[@id] : 0
- end
- end
Expand to see the code.
Instructions
Nothing special. Just insert it before main.
Authors notes
All my scripts are in development and im open to suggestions, critics, bugs, etc.