Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- Flips Actor Equip Restrictions
- v1.0
- Hey guys and girls ;D
- this is one of my first usefull (I hope so) scripts on VX-Ace.
- This script helps you to restrict certain armors and weapons for actors.
- I know it could be done over the Equip Types but why to set up for a
- single Axe a new Equiptype because only 1 actor is using it?
- Not needed anymore with this script!
- Set a notetag in the equipment which should be restricted for certain actors
- and it will work (:
- How to use it?
- Write in the notetag of a weapon or armor:
- <restrict_actor: x>
- or
- <restrict_actor: x,x>
- As an example:
- if you want that the weapon with the ID 1 won't be available for the actor with
- the ID 5 then do this: <restrict_actor: 5>
- if actor 5, 7, 10 and 12 shouldn't be able to use the weapon then set it up like
- this: <restrict_actor: 5,7,10,12>
- I hope you understand what I mean (:
- Credits goes to:
- FlipelyFlip for creating the Equip Restrictions
- MephistoX for the NoteTag Reading Scriptpart I used
- =end
- #=============================================================================
- # ONLY EDIT IF YOU KNOW WHAT YOU DO!!
- #=============================================================================
- module RPG
- class Weapon
- def actor_restrict
- NoteReader.get_data(note, 'restrict_actor')
- end
- end
- class Armor
- def actor_restrict
- NoteReader.get_data(note, 'restrict_actor')
- end
- end
- end
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # ● 装備可能判定
- #--------------------------------------------------------------------------
- def equippable?(item)
- return false unless item.is_a?(RPG::EquipItem)
- return false if equip_type_sealed?(item.etype_id)
- return false if item.is_a?(RPG::Weapon) and w_act_check(item.id).include?(actor.id)
- return false if item.is_a?(RPG::Armor) and a_act_check(item.id).include?(actor.id)
- return equip_wtype_ok?(item.wtype_id) if item.is_a?(RPG::Weapon)
- return equip_atype_ok?(item.atype_id) if item.is_a?(RPG::Armor)
- return false
- end
- #--------------------------------------------------------------------------
- # ● checks if actor can equip the weapon
- #--------------------------------------------------------------------------
- def w_act_check(item)
- a = 0
- acties = []
- for weaponry in $data_weapons[item].actor_restrict
- a += 1
- acties[a] = weaponry
- end
- end
- #--------------------------------------------------------------------------
- # ● checks if actor can equip the armor
- #--------------------------------------------------------------------------
- def a_act_check(item)
- a = 0
- acties = []
- for armory in $data_armors[item].actor_restrict
- a += 1
- acties[a] = armory
- end
- end
- end
- #==============================================================================
- # ■ Module NoteReader # Author: MephistoX
- #------------------------------------------------------------------------------
- # Description:
- # ------------
- # Read and Retrieve Information from notes based on a identifier
- # It will return 'string' type data, but also incldues some defined returners
- # to return data in type like symbols, strings, arrays, etc to make easy to
- # read the data after.
- #==============================================================================
- module NoteReader
- #-------------------------------------------------------------------------
- # Name : Get Parameter
- # Info : Returns a String with a parameter
- # Author : MephistoX
- # Call Info : note to read, parameter
- #-------------------------------------------------------------------------
- def self.get_parameter(note, parameter)
- # Get data to process
- dc_data = note.downcase.split("\r\n")
- data = note.split("\r\n")
- # Set Result
- result = nil
- # Pass Through each data line
- # If Line Text include parameter
- dc_data.each_index do |i|
- next if dc_data[i].start_with?('#')
- # If Line Text include parameter
- if dc_data[i].include?(parameter.downcase)
- # Set Result as second element of line separated by ':'
- result = data[i].split(':')[1]
- # Break Loop
- break
- end
- end
- # Return Result to Sym if Transform
- return result
- end
- #-------------------------------------------------------------------------
- # Name : Get Data
- # Info : Get Checked and Proccessed data
- # Author : MephistoX
- # Call Info : text, parameter to search and type
- #-------------------------------------------------------------------------
- def self.get_data(text, parameter)
- # Set String
- string = get_parameter(text, parameter)
- # Set Result and Proccess it
- result = process_result(string)
- # Return Result
- result
- end
- #-------------------------------------------------------------------------
- # Name : Proccess Result
- # Info : Proccess the result string and transform into the data
- # Author : MephistoX
- # Call Info : string & type
- #-------------------------------------------------------------------------
- def self.process_result(string)
- # Return nil if no string
- return nil if string.nil?
- # Delete string whitespaces
- r_string = string.strip
- # Return Array of Symbols if type is sarray
- return to_array(r_string)
- end
- #-------------------------------------------------------------------------
- # Name : To Array
- # Info : Transform string into an array with symbols
- # Author : MephistoX
- # Call Info : String, transform type (:sym or :int)
- #-------------------------------------------------------------------------
- def self.to_array(string)
- # Set Empty Array
- array = []
- # Get Items
- sitems = string.strip.split(',')
- # Pass Through each item
- sitems.each do |item|
- # Push String into integer if transform type is to integer
- array << item.to_i
- end
- # Return Array
- array
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement