adiktuzmiko

State Extension v1.00

Mar 5th, 2014
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.07 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  
  4.  State Extension v1.00
  5.  by AdiktuzMiko
  6.  --- Date Created: 03/06/2014
  7.  --- Last Date Updated: 03/06/2014
  8.  --- Level: Easy
  9.  
  10.  ==============================================================================
  11.  Overview
  12.  ==============================================================================
  13.  
  14.  This script provides the ability to run RGSS3 methods/formulas during the
  15.  adding and removing of states
  16.  
  17.  These can be used for:
  18.  
  19.  actors/classes/weapons/armors/states/enemies
  20.  
  21.  Actors - affects all state application/removal on the actor
  22.  Classes - affects all state application/removal on the class
  23.  Weapons/Armors - affects all state application/removal on the actor that is
  24.                   equipped with the item
  25.  Enemies - affects all state application/removal on the enemy
  26.  States - affects all state application/removal of the state
  27.  
  28.  ==============================================================================
  29.  Set-Up
  30.  ==============================================================================
  31.  
  32.  Just put this script into a blank slot above main but below materials
  33.  (see compatibility section) and start tagging and making your own formulas
  34.  
  35.  ==============================================================================
  36.  Method flow
  37.  ==============================================================================
  38.  
  39.  This is the normal flow of the custom methods based on the default set-up
  40.  
  41.  State
  42.  Actor
  43.  Class
  44.  Equips
  45.  Enemiy
  46.  
  47.  ==============================================================================
  48.  Tags
  49.  ==============================================================================
  50.  
  51.  -------------------------------------------------------------------
  52.  For apply
  53.  -------------------------------------------------------------------
  54.  <start_state_ext>
  55.    formula
  56.  <end_state_ext>
  57.  
  58.  -------------------------------------------------------------------
  59.  For removal
  60.  -------------------------------------------------------------------
  61.  <start_unstate_ext>
  62.    formula
  63.  <end_unstate_ext>
  64.  
  65.  Use self to denote the actor/enemy that in which the state is applied/removed
  66.  Use state_id to denote the ID of the state being applied/removed
  67.  
  68.  ==============================================================================
  69.  Compatibility
  70.  ==============================================================================
  71.  
  72.  This script aliases Game_Battlers's add_new_state and remove_state methods
  73.  So put it below any script that overwrites those
  74.  
  75.  ==============================================================================
  76.  Terms and Conditions
  77.  ==============================================================================
  78.  
  79.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  80.  
  81.  ==============================================================================
  82. =end
  83.  
  84. # ==============================================================================
  85. # DO NOT EDIT BELOW THIS LINE
  86. # ==============================================================================
  87.  
  88. module ADIK
  89.   module STATE_EXTENSION
  90.     STATE = /<start_state_ext>(.*)<end_state_ext>/m
  91.     UNSTATE = /<start_unstate_ext>(.*)<end_unstate_ext>/m
  92.   end
  93. end
  94.  
  95. class RPG::BaseItem
  96.  
  97.  def load_state_extension_formula
  98.     @state_extension_formula = ""
  99.     if self.note =~ ADIK::STATE_EXTENSION::STATE
  100.       @state_extension_formula = $1.to_s
  101.     end
  102.     return @state_extension_formula
  103.   end
  104.  
  105.   def state_extension_formula
  106.     return @state_extension_formula.nil? ? load_state_extension_formula : @state_extension_formula
  107.   end
  108.  
  109.   def load_unstate_extension_formula
  110.     @unstate_extension_formula = ""
  111.     if self.note =~ ADIK::STATE_EXTENSION::UNSTATE
  112.       @unstate_extension_formula = $1.to_s
  113.     end
  114.     return @unstate_extension_formula
  115.   end
  116.  
  117.   def unstate_extension_formula
  118.     return @unstate_extension_formula.nil? ? load_unstate_extension_formula : @unstate_extension_formula
  119.   end
  120.  
  121. end
  122.  
  123. class Game_Battler
  124.  
  125.   alias add_new_state_extension add_new_state
  126.   def add_new_state(state_id)
  127.     add_new_state_extension(state_id)
  128.     eval($data_states[state_id].state_extension_formula)
  129.     if self.actor?
  130.       eval(self.actor.state_extension_formula)
  131.       eval(self.class.state_extension_formula)
  132.       self.equips.each do |equip|
  133.         next if equip.nil?
  134.         eval(equip.state_extension_formula)
  135.       end
  136.     else
  137.       eval(self.enemy.state_extension_formula)
  138.     end
  139.     refresh
  140.   end
  141.  
  142.   alias remove_state_extension remove_state
  143.   def remove_state(state_id)
  144.     return unless state?(state_id)
  145.     remove_state_extension(state_id)
  146.     eval($data_states[state_id].unstate_extension_formula)
  147.     if self.actor?
  148.       eval(self.actor.unstate_extension_formula)
  149.       eval(self.class.unstate_extension_formula)
  150.       self.equips.each do |equip|
  151.         next if equip.nil?
  152.         eval(equip.unstate_extension_formula)
  153.       end
  154.     else
  155.       eval(self.enemy.unstate_extension_formula)
  156.     end
  157.     refresh
  158.   end
  159.  
  160. end
Advertisement
Add Comment
Please, Sign In to add comment