adiktuzmiko

Equip Extension v1.10

Mar 5th, 2014
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.76 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  
  4.  Equip Extension v1.10
  5.  by AdiktuzMiko
  6.  --- Date Created: 03/05/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.  equip and unequip of weapons/armors
  16.  
  17.  These can be used for:
  18.  
  19.  actors/classes/weapons/armors
  20.  
  21.  Actors - affects all equip/unequip by the actor
  22.  Classes - affects all equip/unequip by the actor that uses that class
  23.  Weapons/Armors - affects all actors that equips/unequips the item
  24.  
  25.  ==============================================================================
  26.  Set-Up
  27.  ==============================================================================
  28.  
  29.  Just put this script into a blank slot above main but below materials
  30.  (see compatibility section) and start tagging and making your own formulas
  31.  
  32.  ==============================================================================
  33.  Method flow
  34.  ==============================================================================
  35.  
  36.  This is the normal flow of the custom methods based on the default set-up
  37.  
  38.  Item Unequip
  39.  Actor Unequip
  40.  Class Unequip
  41.  Item Equip
  42.  Actor Equip
  43.  Class Equip
  44.  
  45.  ==============================================================================
  46.  Tags
  47.  ==============================================================================
  48.  
  49.  -------------------------------------------------------------------
  50.  For equip
  51.  -------------------------------------------------------------------
  52.  <start_equip_ext>
  53.    formula
  54.  <end_equip_ext>
  55.  
  56.  -------------------------------------------------------------------
  57.  For unequip
  58.  -------------------------------------------------------------------
  59.  <start_unequip_ext>
  60.    formula
  61.  <end_unequip_ext>
  62.  
  63.  Use self to denote the actor that equips/unequips
  64.  
  65.  ==============================================================================
  66.  Compatibility
  67.  ==============================================================================
  68.  
  69.  This script aliases Game_Actor's change_equip and setup methods
  70.  So put it below any script that overwrites those
  71.  
  72.  ==============================================================================
  73.  Terms and Conditions
  74.  ==============================================================================
  75.  
  76.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  77.  
  78.  ==============================================================================
  79. =end
  80.  
  81. # ==============================================================================
  82. # DO NOT EDIT BELOW THIS LINE
  83. # ==============================================================================
  84.  
  85. module ADIK
  86.   module EQUIP_EXTENSION
  87.     EQUIP = /<start_equip_ext>(.*)<end_equip_ext>/m
  88.     UNEQUIP = /<start_unequip_ext>(.*)<end_unequip_ext>/m
  89.   end
  90. end
  91.  
  92. class RPG::BaseItem
  93.  
  94.  def load_equip_extension_formula
  95.     @equip_extension_formula = ""
  96.     if self.note =~ ADIK::EQUIP_EXTENSION::EQUIP
  97.       @equip_extension_formula = $1.to_s
  98.     end
  99.     return @equip_extension_formula
  100.   end
  101.  
  102.   def equip_extension_formula
  103.     return @equip_extension_formula.nil? ? load_equip_extension_formula : @equip_extension_formula
  104.   end
  105.  
  106.   def load_unequip_extension_formula
  107.     @unequip_extension_formula = ""
  108.     if self.note =~ ADIK::EQUIP_EXTENSION::UNEQUIP
  109.       @unequip_extension_formula = $1.to_s
  110.     end
  111.     return @unequip_extension_formula
  112.   end
  113.  
  114.   def unequip_extension_formula
  115.     return @unequip_extension_formula.nil? ? load_unequip_extension_formula : @unequip_extension_formula
  116.   end
  117.  
  118. end
  119.  
  120. class Game_Actor
  121.  
  122.   alias change_equip_extension change_equip
  123.   def change_equip(slot_id, item)
  124.     unless equips[slot_id].nil?
  125.       eval(equips[slot_id].unequip_extension_formula)
  126.         eval(self.actor.unequip_extension_formula)
  127.       eval(self.class.unequip_extension_formula)
  128.     end
  129.     change_equip_extension(slot_id, item)
  130.     unless item.nil?
  131.       eval(item.equip_extension_formula)
  132.       eval(self.actor.equip_extension_formula)
  133.       eval(self.class.equip_extension_formula)   
  134.     end
  135.   end
  136.  
  137.   alias setup_adik_extension setup
  138.   def setup(actor_id)
  139.     setup_adik_extension(actor_id)
  140.     actor.equips.each_with_index do |item_id, i|
  141.       etype_id = index_to_etype_id(i)
  142.       item = etype_id == 0 ? $data_weapons[item_id] : $data_armors[item_id]
  143.       unless item.nil?
  144.         eval(item.equip_extension_formula)
  145.         eval(self.actor.equip_extension_formula)
  146.         eval(self.class.equip_extension_formula)     
  147.       end
  148.     end
  149.     refresh
  150.   end
  151.  
  152. end
Advertisement
Add Comment
Please, Sign In to add comment