adiktuzmiko

Custom Equip Requirement V1.01

Aug 30th, 2014
688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.57 KB | None | 0 0
  1. =begin
  2.  ==============================================================================
  3.  
  4.  Custom Equip Conditions v1.01
  5.  by AdiktuzMiko
  6.  --- Date Created: 08/29/2014
  7.  --- Last Date Updated: 09/03/2014
  8.  --- Level: Easy
  9.  
  10.  ==============================================================================
  11.  Overview
  12.  ==============================================================================
  13.  
  14.  This script provides the ability to use RGSS3 methods/formulas as custom
  15.  requirements for equipping an item. Use it with the default RGSS3 scripts
  16.  or couple it with custom scripts (like custom stat systems) for more
  17.  custom requirement possibilities.
  18.  
  19.  The actor must be able to equip the item under normal conditions (equip types)
  20.  before the custom requirement is even checked.
  21.  
  22.  ==============================================================================
  23.  Set-Up
  24.  ==============================================================================
  25.  
  26.  Just put this script into a blank slot above main but below materials
  27.  (see compatibility section) and start tagging and making your own formulas
  28.  
  29.  ==============================================================================
  30.  Tags
  31.  ==============================================================================
  32.  
  33.  <start_custom_req>
  34.    formula
  35.  <end_custom_req>
  36.  
  37.  Use the variable "actor" to denote the actor being checked
  38.  
  39.  Example: The item is only equippable if the actor's level is greater
  40.  than 5
  41.  
  42.  <start_custom_req>
  43.    actor.level > 5
  44.  <end_custom_req>
  45.  
  46.  ==============================================================================
  47.  Compatibility
  48.  ==============================================================================
  49.  
  50.  This script aliases Game_Battler's equippable? method
  51.  
  52.  ==============================================================================
  53.  Terms and Conditions
  54.  ==============================================================================
  55.  
  56.  View it here: http://lescripts.wordpress.com/terms-and-conditions/
  57.  
  58.  ==============================================================================
  59. =end
  60.  
  61. module ADIK
  62.   module CUSTOM_EQUIP_REQUIREMENTS
  63.     #the tag to use for setting custom requirements
  64.     #modify if needed (i.e. conflict with another script)
  65.     TAG = /<start_custom_req>(.*)<end_custom_req>/m
  66.   end
  67. end
  68.  
  69. # ==============================================================================
  70. # DO NOT EDIT BELOW THIS LINE
  71. # ==============================================================================
  72.  
  73. class RPG::BaseItem
  74.  
  75.   #attribute for the custom equip requirement
  76.   attr_reader :custom_equip_requirement
  77.  
  78.   #reads the requirements if the item has the tag on the database
  79.   def get_custom_equip_requirement
  80.     @custom_equip_requirement = ""
  81.     if self.note =~ ADIK::CUSTOM_EQUIP_REQUIREMENTS::TAG
  82.       @custom_equip_requirement = $1.to_s
  83.     end
  84.   end
  85.  
  86.   #processes any custom requirement to determine
  87.   #if the item is equippable
  88.   def custom_requirement_process(actor)
  89.     #sets the data if it doesn't exist
  90.     get_custom_equip_requirement if @custom_equip_requirement.nil?
  91.     #if there is no custom requirement, then all's good to go
  92.     return true if @custom_equip_requirement == ""
  93.     #evaluates the custom requirement
  94.     return eval(@custom_equip_requirement)
  95.   end
  96.  
  97. end
  98.  
  99. class Game_BattlerBase
  100.  
  101.   #Checks first if the item is equippable by normal settings
  102.   alias equippable_adik? equippable?
  103.   def equippable?(item)
  104.     return false unless equippable_adik?(item)
  105.     return item.custom_requirement_process(self)
  106.   end
  107.  
  108. end
Advertisement
Add Comment
Please, Sign In to add comment