Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Unique Equipment
- # -- Author : Dekita
- # -- Version : 1.0
- # -- Level : N/A
- # -- Requires : $D13x - CORE
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:UniEquip] = true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # o1/o4/2o13 - Update for release,(v1.0)
- # 23/o2/2o13 - Started, Finished,
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # This script is what makes every item unique, without this the Equipment
- # part of the $D13x system would be FULL of errors, faults and glitches !!
- # This script has 0 customisation options.
- #
- # NOTE :
- # I HIGHLY Reccommend you to NOT have any actor wearing any equipment at
- # the beggining of the game, if needbe, create all items after starting the game
- # and add them to the actor via script calls.
- # This will likley avoid glitches with multiple save files and potential errors.
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- # Place Below $D13x Core Script.
- # Place Above ALL Other $D13x Equipment Related Scripts.
- #
- #===============================================================================
- # ☆ Script Calls
- #-------------------------------------------------------------------------------
- # make_weapon(id)
- # This script call will create a cloned weapon and add it to the party.
- #
- # make_armor(id)
- # This script call will create a cloned armor and add it to the party
- #
- # actor_has_weapon?(actor_id, weapon id)
- # This script call will check if actor_id has weapon_id equipped
- # it will return true if yes and false if no, should be used for things like
- # conditional branch checks as the default checks wont work.
- #
- # actor_has_armor?(actor_id, armor id)
- # Same as above but for armors
- #
- # party_has_weapon?(weapon id)
- # party_has_armor?(armor_id)
- # Similar to the above script calls but checks if the item exists within the
- # party, ie includes inventory.
- #
- # change_eqp_to_this(actor_id, slot_id, item_id)
- # use the following script call to change an actors equipment to a specific
- # item. (if the party has the item)
- #
- # $game_actors[ID].has_any_equip?
- # will return true if actor ID is wearing at least 1 piece of equipment.
- # retusn false otherwise.
- #
- #===============================================================================#
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- module Weapons
- #===============================================================================
- ID=[]
- Data = load_data("Data/Weapons.rvdata2")
- Data.size.times{|i|ID[i]={:teir_chances=>[]}}
- end
- #===============================================================================
- module Armors
- #===============================================================================
- ID=[]
- Data = load_data("Data/Armors.rvdata2")
- Data.size.times{|i|ID[i]={:teir_chances=>[]}}
- end
- #===============================================================================
- module Cloning_101 # A.K.A ~ Cloning for Dummies
- #===============================================================================
- #---------------------------------------------------------------------------
- # Initializes cloning process
- #---------------------------------------------------------------------------
- def self.start_clone(type, id, set_teir = nil, need_ret = false)
- case type
- when :weapon
- vi = $data_weapons ; vii = $deki_weaps ; mod = Weapons
- when :armor
- vi = $data_armors ; vii = $deki_armrs ; mod = Armors
- end
- new = make_clone(vi,vii,id)
- teir = get_random_teir(mod, id, new, set_teir)
- new = get_unique_stats(new, mod, vi, id, teir)
- vi.push(new) ; vii.push(new)
- item = vi[new.id]
- new.uni_feats.sort_by!{|i| i[1] }
- $game_party.gain_item(item, 1)
- if $D13x[:Equip_Durability]
- new.durability = (new.max_durability/2).to_f
- end
- return new if need_ret
- end
- #---------------------------------------------------------------------------
- # removes clone from database
- #---------------------------------------------------------------------------
- def self.delete_clone(type, id, inc_equip = false)
- case type
- when :weapon then vi = $data_weapons ; vii = $deki_weaps
- when :armor then vi = $data_armors ; vii = $deki_armrs
- end
- return if vi[id] == nil
- $game_party.gain_item(vi[id], -1, inc_equip)
- end
- #---------------------------------------------------------------------------
- # Create complete clone
- #---------------------------------------------------------------------------
- def self.make_clone(vi,vii, id)
- new = vi[id].clone
- new.features = vi[id].features.clone
- vi[id].instance_variables.each do |var|
- val = vi[id].instance_variable_get(var).is_a?(Numeric) ?
- vi[id].instance_variable_get(var) :
- vi[id].instance_variable_get(var) == nil ? nil :
- vi[id].instance_variable_get(var) == true ? true :
- vi[id].instance_variable_get(var) == false ? false :
- vi[id].instance_variable_get(var).clone
- new.instance_variable_set(var, val)
- end
- new.params = vi[id].params.clone
- new.id = vi.size
- return new
- end
- #---------------------------------------------------------------------------
- # get teir
- #---------------------------------------------------------------------------
- def self.get_random_teir(mod, id, new, set_teir)
- return 0 unless $D13x[:Equip_Randomize]
- end
- #---------------------------------------------------------------------------
- # Make item unique
- #---------------------------------------------------------------------------
- def self.get_unique_stats(new, mod, vi, id, teir)
- return new unless $D13x[:Equip_Randomize]
- return new if mod == nil
- end
- end # end Cloning_101
- #===============================================================================
- module DataManager
- #===============================================================================
- #---------------------------------------------------------------------------
- # Alias List
- #---------------------------------------------------------------------------
- class << self
- alias :cgo_unique_items :create_game_objects
- alias :msc_unique_items :make_save_contents
- alias :esc_unique_items :extract_save_contents
- end
- #---------------------------------------------------------------------------
- # Create Game Objects (alias)
- #---------------------------------------------------------------------------
- def self.create_game_objects
- cgo_unique_items
- $deki_weaps = []
- $deki_armrs = []
- end
- #---------------------------------------------------------------------------
- # make save contents (alias)
- #---------------------------------------------------------------------------
- def self.make_save_contents
- contents = msc_unique_items
- contents[:deki_weaps] = $deki_weaps
- contents[:deki_armrs] = $deki_armrs
- contents
- end
- #---------------------------------------------------------------------------
- # extract save contents (alias)
- #---------------------------------------------------------------------------
- def self.extract_save_contents(contents)
- esc_unique_items(contents)
- get_unique_contents(contents)
- end
- #---------------------------------------------------------------------------
- # Get Unique Contents
- #---------------------------------------------------------------------------
- def self.get_unique_contents(conts)
- $deki_weaps = conts[:deki_weaps]
- $deki_weaps.each do |w|
- next unless w != nil
- $data_weapons << w
- end
- $deki_armrs = conts[:deki_armrs]
- $deki_armrs.each do |a|
- next unless a != nil
- $data_armors << a
- end
- end
- end # DataManager
- #===============================================================================
- class RPG::EquipItem < RPG::BaseItem
- #===============================================================================
- #---------------------------------------------------------------------------
- # Pi Variables
- #---------------------------------------------------------------------------
- attr_accessor :uni_feats
- attr_accessor :teir
- #---------------------------------------------------------------------------
- # load unique shit
- #---------------------------------------------------------------------------
- def load_dekita_core
- super
- load_unique_equip
- end
- #---------------------------------------------------------------------------
- # load unique shit
- #---------------------------------------------------------------------------
- def load_unique_equip
- @uni_feats = []
- @teir = 0
- end
- end # RPG::EquipItem
- #===============================================================================
- class Game_Actor < Game_Battler
- #===============================================================================
- #--------------------------------------------------------------------------
- # Change Equipment ( overwrite )
- # slot_id = Equipment slot ID && item_id = Weapons/armor ID
- #--------------------------------------------------------------------------
- def change_equip_by_id(slot_id, item_id)
- item = nil
- if equip_slots[slot_id] == 0
- $game_party.weapons.each do |weap|
- item = weap if weap.database_id == item_id && item == nil
- end
- else
- $game_party.armors.each do |arms|
- item = arms if arms.database_id == item_id && item == nil
- end
- change_equip(slot_id, item) if item != nil
- end
- end
- #--------------------------------------------------------------------------
- # Actor Is Wearing Any Equipment ?
- #--------------------------------------------------------------------------
- def has_any_equip?
- equips.each {|e| return true if e != nil}
- return false
- end
- end
- #===============================================================================
- class Game_Interpreter
- #===============================================================================
- #--------------------------------------------------------------------------
- # Change Weapons (overwrite)
- #--------------------------------------------------------------------------
- def command_127
- value = operate_value(@params[1], @params[2], @params[3])
- if value > 0
- value.times do
- @params[0] = Cloning_101.start_clone(:weapon,@params[0],0,true).id
- end
- elsif value < 0
- $game_party.weapons.each do |weap|
- break if value >= 0
- if weap.database_id == @params[0]
- Cloning_101.delete_clone(:weapon, weap.id, @params[4])
- value += 1
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # Change Armor (overwrite)
- #--------------------------------------------------------------------------
- def command_128
- value = operate_value(@params[1], @params[2], @params[3])
- if value > 0
- value.times do
- @params[0] = Cloning_101.start_clone(:armor,@params[0],0,true).id
- end
- elsif value < 0
- $game_party.armors.each do |arm|
- break if value >= 0
- if arm.database_id == @params[0]
- Cloning_101.delete_clone(:armor, arm.id, @params[4])
- value += 1
- end
- end
- end
- end
- #---------------------------------------------------------------------------
- # Creates A Cloned Weapon
- #---------------------------------------------------------------------------
- def make_weapon(id, teir = nil)
- return if id == ( nil || 0 )
- id = Cloning_101.start_clone(:weapon, id, teir, true).id
- make_popup(:weapon,id,1) if $D13x[:Item_Pops]
- end
- #---------------------------------------------------------------------------
- # Creates A Cloned Armor
- #---------------------------------------------------------------------------
- def make_armor(id, teir = nil)
- return if id == ( nil || 0 )
- id = Cloning_101.start_clone(:armor, id, teir, true).id
- make_popup(:armor,id,1) if $D13x[:Item_Pops]
- end
- #---------------------------------------------------------------------------
- # Checks if actor has weapon equipped
- #---------------------------------------------------------------------------
- def actor_has_weapon?(aid, wid)
- bool = false
- $game_actors[aid].weapons.each do |wep|
- bool = true if $data_weapons[wep.id].database_id == wid
- end
- return bool
- end
- #---------------------------------------------------------------------------
- # Checks if actor has armor equipped
- #---------------------------------------------------------------------------
- def actor_has_armor?(aid, wid)
- bool = false
- $game_actors[aid].armors.each do |wep|
- bool = true if $data_armors[wep.id].database_id == wid
- end
- return bool
- end
- #---------------------------------------------------------------------------
- # Checks if party has weapon
- #---------------------------------------------------------------------------
- def party_has_weapon?(wid)
- bool = false
- $game_party.weapons.each do |wep|
- bool = true if $data_weapons[wep.id].database_id == wid
- end
- return bool
- end
- #---------------------------------------------------------------------------
- # Checks if party has armor
- #---------------------------------------------------------------------------
- def party_has_armor?(wid)
- bool = false
- $game_party.armors.each do |wep|
- bool = true if $data_armors[wep.id].database_id == wid
- end
- return bool
- end
- #---------------------------------------------------------------------------
- # Changes an actors equipment to X with X teir
- #---------------------------------------------------------------------------
- def change_eqp_to_this(actor_id, slot_id, item_id, teir = 0)
- return if actor_id == (nil || 0)
- $game_actors[actor_id].change_equip_by_id_and_teir(slot_id, item_id, teir)
- end
- end
- #===============================================================================
- module BattleManager
- #===============================================================================
- #--------------------------------------------------------------------------
- # Dropped Item Acquisition and Display
- #--------------------------------------------------------------------------
- def self.gain_drop_items
- $game_troop.make_drop_items.each do |item|
- if item.is_a?(RPG::Item)
- $game_party.gain_item(item, 1)
- else
- type = item.is_a?(RPG::Weapon) ? :weapon : :armor
- item = Cloning_101.start_clone(type,item.id,nil,true)
- end
- $game_message.add(sprintf(Vocab::ObtainItem, item.name))
- end
- wait_for_message
- end
- end # end Battle Manager
- #===============================================================================
- class Scene_Shop < Scene_MenuBase
- #===============================================================================
- #--------------------------------------------------------------------------
- # Execute Purchase
- #--------------------------------------------------------------------------
- def do_buy(number)
- $game_party.lose_gold(number * buying_price)
- if @item.is_a?(RPG::EquipItem)
- number.times do
- Cloning_101.start_clone(:weapon,@item.id, 0) if @item.is_a?(RPG::Weapon)
- Cloning_101.start_clone(:armor, @item.id, 0) if @item.is_a?(RPG::Armor)
- end
- else
- $game_party.gain_item(@item, number)
- end
- end
- #--------------------------------------------------------------------------
- # Execute Sale
- #--------------------------------------------------------------------------
- def do_sell(number)
- $game_party.gain_gold(number * selling_price)
- if @item.is_a?(RPG::EquipItem)
- Cloning_101.delete_clone(:weapon,@item.id) if @item.is_a?(RPG::Weapon)
- Cloning_101.delete_clone(:armor, @item.id) if @item.is_a?(RPG::Armor)
- else
- $game_party.lose_item(@item, number)
- end
- end
- end # end Scene_Shop
- end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement