Advertisement
FlipelyFlip

Flips Actor Equip Restriction v1.1

Jul 5th, 2012
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2.                             Flips Equip Restrictions
  3.                                      v1.1
  4.  
  5. Hey guys and girls ;D
  6.  
  7. this is one of my first usefull (I hope so) scripts on VX-Ace.
  8. This script helps you to restrict certain armors and weapons for actors.
  9. I know it could be done over the Equip Types but why to set up for a
  10. single Axe a new Equiptype because only 1 actor is using it?
  11. Not needed anymore with this script!
  12.  
  13. Set a notetag in the equipment which should be restricted for certain actors
  14. and it will work (:
  15.  
  16. How to use it?
  17. Write in the notetag of a weapon or armor:
  18.  
  19. <restrict_actor: x>
  20.  
  21. or
  22.  
  23. <restrict_actor: x,x>
  24.  
  25. As an example:
  26.  
  27. if you want that the weapon with the ID 1 won't be available for the actor with
  28. the ID 5 then do this: <restrict_actor: 5>
  29. if actor 5, 7, 10 and 12 shouldn't be able to use the weapon then set it up like
  30. this: <restrict_actor: 5,7,10,12>
  31.  
  32. I hope you understand what I mean (:
  33.  
  34. Version History:
  35.  
  36. v1.1
  37. - fixed a huge bug, which would cause an error if the actor has some equipments
  38.   equiped from beginning.
  39.  
  40. v1.0
  41. - Got this Script to work :D
  42. - Allows to restrict certain actors certain weapons from their equipment type
  43.  
  44. Credits goes to:
  45.  
  46. FlipelyFlip for creating the Equip Restrictions
  47. MephistoX for the NoteTag Reading Scriptpart I used
  48.  
  49. =end
  50.  
  51. #=============================================================================
  52. # ONLY EDIT IF YOU KNOW WHAT YOU DO!!
  53. #=============================================================================
  54. module RPG
  55.   class Weapon
  56.     def actor_restrict
  57.       NoteReader.get_data(note, 'restrict_actor')
  58.     end
  59.   end
  60.   class Armor
  61.     def actor_restrict
  62.       NoteReader.get_data(note, 'restrict_actor')
  63.     end
  64.   end
  65. end
  66.  
  67. #==============================================================================
  68. # ■ Window_EquipItem
  69. #------------------------------------------------------------------------------
  70. #  装備画面で、装備変更の候補となるアイテムの一覧を表示するウィンドウです。
  71. #==============================================================================
  72.  
  73. class Window_EquipItem < Window_ItemList
  74.   #--------------------------------------------------------------------------
  75.   # ● アイテムをリストに含めるかどうか
  76.   #--------------------------------------------------------------------------
  77.   def include?(item)
  78.     return true if item == nil
  79.     return false unless item.is_a?(RPG::EquipItem)
  80.     return false if @slot_id < 0
  81.     return false if item.etype_id != @actor.equip_slots[@slot_id]
  82.     return @actor.equippable?(item)
  83.     return false if item.is_a?(RPG::Weapon) and w_act_check(item.id).include?(actor.id)
  84.     return false if item.is_a?(RPG::Armor) and a_act_check(item.id).include?(actor.id)
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● checks if actor can equip the weapon
  88.   #--------------------------------------------------------------------------
  89.   def w_act_check(item)
  90.     a = 0
  91.     acties = []
  92.     for weaponry in $data_weapons[item].actor_restrict
  93.       a += 1
  94.       acties[a] = weaponry
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● checks if actor can equip the armor
  99.   #--------------------------------------------------------------------------
  100.   def a_act_check(item)
  101.     a = 0
  102.     acties = []
  103.     for armory in $data_armors[item].actor_restrict
  104.       a += 1
  105.       acties[a] = armory
  106.     end
  107.   end
  108. end
  109.  
  110. #==============================================================================
  111. # ■ Module NoteReader                                                                      # Author: MephistoX
  112. #------------------------------------------------------------------------------
  113. # Description:
  114. # ------------
  115. # Read and Retrieve Information from notes based on a identifier
  116. # It will return 'string' type data, but also incldues some defined returners
  117. # to return data in type like symbols, strings, arrays, etc to make easy to
  118. # read the data after.
  119. #==============================================================================
  120.  
  121. module NoteReader
  122.   #-------------------------------------------------------------------------
  123.   #   Name        : Get Parameter
  124.   #   Info        : Returns a String with a parameter
  125.   #   Author    : MephistoX
  126.   #   Call Info : note to read, parameter
  127.   #-------------------------------------------------------------------------
  128.   def self.get_parameter(note, parameter)
  129.         # Get data to process
  130.         dc_data = note.downcase.split("\r\n")
  131.         data    = note.split("\r\n")
  132.         # Set Result
  133.         result = nil
  134.         # Pass Through each data line
  135.         # If Line Text include parameter
  136.         dc_data.each_index do |i|
  137.           next if dc_data[i].start_with?('#')
  138.           # If Line Text include parameter
  139.           if dc_data[i].include?(parameter.downcase)
  140.                 # Set Result as second element of line separated by ':'
  141.                 result = data[i].split(':')[1]
  142.                 # Break Loop
  143.                 break
  144.           end
  145.         end
  146.         # Return Result to Sym if Transform
  147.         return result
  148.   end
  149.   #-------------------------------------------------------------------------
  150.   #   Name        : Get Data
  151.   #   Info        : Get Checked and Proccessed data
  152.   #   Author    : MephistoX
  153.   #   Call Info : text, parameter to search and type
  154.   #-------------------------------------------------------------------------
  155.   def self.get_data(text, parameter)
  156.         # Set String
  157.         string = get_parameter(text, parameter)
  158.         # Set Result and Proccess it
  159.         result = process_result(string)
  160.         # Return Result
  161.         result
  162.   end
  163.   #-------------------------------------------------------------------------
  164.   #   Name        : Proccess Result
  165.   #   Info        : Proccess the result string and transform into the data
  166.   #   Author    : MephistoX
  167.   #   Call Info : string & type
  168.   #-------------------------------------------------------------------------
  169.   def self.process_result(string)
  170.         # Return nil if no string
  171.         return nil if string.nil?
  172.         # Delete string whitespaces
  173.         r_string = string.strip
  174.         # Return Array of Symbols if type is sarray
  175.         return to_array(r_string)
  176.   end
  177.   #-------------------------------------------------------------------------
  178.   #   Name        : To Array
  179.   #   Info        : Transform string into an array with symbols
  180.   #   Author    : MephistoX
  181.   #   Call Info : String, transform type (:sym or :int)
  182.   #-------------------------------------------------------------------------
  183.   def self.to_array(string)
  184.         # Set Empty Array
  185.         array = []
  186.         # Get Items
  187.         sitems = string.strip.split(',')
  188.         # Pass Through each item
  189.         sitems.each do |item|
  190.           # Push String into integer if transform type is to integer
  191.           array << item.to_i
  192.         end
  193.         # Return Array
  194.         array
  195.   end
  196. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement