Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###############################################################################
- # SES: MultiSlot
- # v1.0
- # 4.14.2012
- # Compatibility: VXAce/RGSS3
- # Author: Enelvon
- #===============================================================================
- # Terms of Use:
- #
- # This script may be used for free in any game, whether it's commercial or not.
- # The only requirement is that I be credited in some visible manner. You may not
- # claim this script as your own work. You are free to modify this script, but
- # may not redistribute it except for in a thread that I have started that relates
- # to it in some way.
- #===============================================================================
- # Changelog:
- # 4.14.2012: v1.0 - Script written.
- #===============================================================================
- # This script implements more equipment slots for actors. You can have as many
- # as you would like, and pieces of equipment can go into more than one type of
- # slot.
- #===============================================================================
- # Required Scripts: Enelvon Script Core v1.0 or higher
- # Known Incompatibilities: None, though it contains some redefinitions so some
- # may occur if this script is below another script that aliases the same
- # method, or if it is above another script that redefines that method. A full
- # list of redefinition is included at the bottom of my comments.
- #===============================================================================
- # Installation: Place below Materials and the Enelvon Script Core and above all
- # other custom scripts (just to be safe).
- #===============================================================================
- # Instructions:
- #
- # ***Constants for SES::MultiSlot***
- #
- # Actorslots - this is a hash consisting of actor IDs and an associated array of
- # equipment slot IDs, in the order that you desire for them to appear.
- #
- # EquipSlot - this is the RegExp to set the slot ID for a piece of equipment.
- # You can include more than one of these to allow a piece of equipment to
- # fit into more than one slot. Make sure to set the Equip Type of the
- # equipment in the Database to Accessory if you don't want it to also fit
- # into the Database type selection. There is more on this in the next section.
- #
- # Seal - this is the RegExp that allows you to seal new equipment types, as per
- # the Feature. There is more on this in the next section.
- #
- # Fix - this is the RegExp that allows you to fix an equipment slot and make it
- # unchangeable, as per the Feature. There is more on this in the next section.
- #
- # Equips - this is the RegExp that allows you to set an actor's default equipment
- # for new slots. There is more on this in the next section.
- #
- # ***Methods for SES::MultiSlot***
- #
- # self.terms(etype_id)
- # This is the method that tells the game what the names of equipment slots are.
- # Add in additional when statements for the new slots that you add.
- #
- # ***Additional: Equipment Tags***
- #
- # You can customize this script for each piece of equipment in your game by adding
- # tags in their Notes boxes. These are the tags available in this script:
- #
- # <Equip: !Slot!>
- # Place this in a Notes box to allow an item to be placed in an equip slot.
- # You can include more than one of these per item.
- # Replacements:
- # !Slot! with the slot ID that you want the item to be placed in.
- #
- # <Seal: !Slot!>
- # Place this in a Notes box to cause the item to seal an equip slot, exactly
- # like the Feature. You can include more than one of these per item.
- # Replacements:
- # !Slot! with the slot ID that you want the item to seal.
- #
- # <Fix: !Slot!>
- # Place this in a Notes box to cause the item to fix an equip slot, exactly
- # like the Feature. You can include more than one of these per item.
- # Replacements:
- # !Slot! with the slot ID that you want the item to fix.
- #
- # ***Additional: Actor Tags***
- #
- # You can customize this script for each actor in your game by adding tags in
- # their Notes boxes. These are the tags available in this script:
- #
- # <Equip: !Slot!, !Equip!>
- # Place this in a Notes box to select the default equipment to be placed in
- # a slot.
- # Replacements:
- # !Slot! with the slot ID that you want the item to be placed in.
- # !Equip! with the ID of the equipment that you want to be placed in the slot.
- #
- # <Seal: !Slot!>
- # Place this in a Notes box to seal an actor's equip slot, exactly like the
- # Feature. You can include more than one of these per actor.
- # Replacements:
- # !Slot! with the slot ID that you want to be sealed.
- #
- # <Fix: !Slot!>
- # Place this in a Notes box to fix an actor's equip slot, exactly like the
- # Feature. You can include more than one of these per actor.
- # Replacements:
- # !Slot! with the slot ID that you want to be fixed.
- #
- # ***Additional: Class Tags***
- #
- # You can customize this script for each class in your game by adding tags in
- # their Notes boxes. These are the tags available in this script:
- #
- # <Seal: !Slot!>
- # Place this in a Notes box to cause the class to seal an actor's equip slot,
- # exactly like the Feature. You can include more than one of these per class.
- # Replacements:
- # !Slot! with the slot ID that you want to be sealed.
- #
- # <Fix: !Slot!>
- # Place this in a Notes box to cause the class to fix an actor's equip slot,
- # exactly like the Feature. You can include more than one of these per class.
- # Replacements:
- # !Slot! with the slot ID that you want to be fixed.
- #
- #===============================================================================
- # Aliases:
- #
- # These are the methods that are aliased by this script. This information is
- # included for the purpose of pinpointing compatibility errors between scripts.
- #
- # ***class Game_BaseItem***
- #
- # object
- #
- # ***class Game_Actor***
- #
- # setup(actor_id)
- #
- #===============================================================================
- # Redefinitions:
- #
- # These are the methods that are redefined by this script. This information is
- # included for the purpose of pinpointing compatibility errors between scripts.
- #
- # ***module Vocab***
- #
- # self.etype(etype_id)
- #
- # ***class Game_Actor***
- #
- # release_unequippable_items(item_gain = true)
- # optimize_equipments
- # equip_slots
- # change_equip(slot_id, item)
- #
- # ***class Window_EquipSlot***
- #
- # refresh
- #
- # ***class Window_EquipItem***
- #
- # include?
- #
- ################################################################################
- module SES
- module MultiSlot
- Actorslots = {
- # Actor ID => Array of Equip Slots. Do not include 0 (weapon) unless you
- # want more than one weapon slot.
- 1 => [1,2,3,5,6,4,4],
- }
- # Default array of Equip Slots for Actor IDs that aren't listed in Actorslots.
- Actorslots.default = [1,2,3,5,6,4,4]
- # RegExp for an item's equipment slot type. You can include more than one.
- EquipSlot = /^<Equip: ([\d]+)>/i
- # RegExp for sealing an equipment slot when a certain item is equipped.
- Seal = /^<Seal: ([\d]+)>/i
- # RegExp for fixing an equipment slot when a certain item is equipped.
- Fix = /^<Fix: ([\d]+)>/i
- # RegExp for an Actor's default equipment for extra slots.
- Equips = /^<Equip: ([\d]+), ([\d]+)>/i
- def self.terms(etype_id) # Method that defines slot names. Edit this for
- case etype_id # any slots that you add.
- when 0..4
- $data_system.terms.etypes[etype_id]
- when 5 # when Slot ID
- return "Legs" # return "Slot Name"
- when 6
- return "Shoes"
- end
- end
- end
- end
- $imported = {} if $imported.nil?
- $imported["SES - MultiSlot"] = true
- class RPG::Actor < RPG::BaseItem
- alias en_ms_a_sn en_scan_notes
- def en_scan_notes(tags = [])
- oldequips = @equips.clone
- @equips = []
- SES::MultiSlot::Actorslots[@id].size.times do
- @equips.push(0)
- end
- ns = [0] + SES::MultiSlot::Actorslots[@id]
- for i in 0..oldequips.size-1
- e = ns.index(i)
- @equips[e] = oldequips[i] if !e.nil?
- end
- tags.push([SES::MultiSlot::Equips, "@equips[$1.to_i] = $2.to_i"])
- tags.push([SES::MultiSlot::Seal, "seal = RPG::BaseItem::Feature.new(54, $1.to_i); @features.push(seal)"])
- tags.push([SES::MultiSlot::Fix, "fix = RPG::BaseItem::Feature.new(53, $1.to_i); @features.push(fix)"])
- en_ms_a_sn(tags)
- end
- end
- class RPG::Class
- alias en_ms_c_sn en_scan_notes
- def en_scan_notes(tags = [])
- tags.push([SES::MultiSlot::Seal, "seal = RPG::BaseItem::Feature.new(54, $1.to_i); @features.push(seal)"])
- tags.push([SES::MultiSlot::Fix, "fix = RPG::BaseItem::Feature.new(53, $1.to_i); @features.push(fix)"])
- en_ms_c_sn(tags)
- end
- end
- class RPG::EquipItem < RPG::BaseItem
- alias en_ms_e_sn en_scan_notes
- def en_scan_notes(tags = [])
- @etype_ids = []
- @etype_ids.push(@etype_id) unless @etype_id == 1
- tags.push([SES::MultiSlot::EquipSlot, "@etype_ids.push($1.to_i)"])
- tags.push([SES::MultiSlot::Seal, "seal = RPG::BaseItem::Feature.new(54, $1.to_i); @features.push(seal)"])
- tags.push([SES::MultiSlot::Fix, "fix = RPG::BaseItem::Feature.new(53, $1.to_i); @features.push(fix)"])
- en_ms_e_sn(tags)
- end
- def etype_ids
- en_scan_notes if @etype_ids.nil?
- return @etype_ids
- end
- end
- module Vocab
- def self.etype(etype_id)
- return SES::MultiSlot.terms(etype_id)
- end
- end
- class Game_BaseItem
- alias en_ms_gbi_o object
- def object
- return if @item_id.nil?
- en_ms_gbi_o
- end
- end
- class Game_Actor < Game_Battler
- alias en_ms_a_s setup
- def setup(actor_id)
- @actor_id = actor_id
- actor.en_scan_notes
- en_ms_a_s(actor_id)
- end
- def release_unequippable_items(item_gain = true)
- loop do
- last_equips = equips.dup
- @equips.each_with_index do |item, i|
- if !equippable?(item.object) || !item.object.etype_ids.include?(equip_slots[i])
- trade_item_with_party(nil, item.object) if item_gain
- item.object = nil
- end
- end
- return if equips == last_equips
- end
- end
- def optimize_equipments
- clear_equipments
- equip_slots.size.times do |i|
- next if !equip_change_ok?(i)
- items = $game_party.equip_items.select do |item|
- item.etype_ids.include?(equip_slots[i]) &&
- equippable?(item) && item.performance >= 0
- end
- change_equip(i, items.max_by do |item| item.performance end)
- end
- end
- def equip_slots
- equiptypes = SES::MultiSlot::Actorslots[@actor_id]
- if dual_wield?
- equiptypes.delete_at(1) if equiptypes[1] == 1
- equiptypes.delete_at(0) if equiptypes[0] == 0
- return [0,0] + equiptypes
- else
- return [0] + equiptypes
- return equiptypes
- end
- end
- def change_equip(slot_id, item)
- return unless trade_item_with_party(item, equips[slot_id])
- return if item && !item.etype_ids.include?(equip_slots[slot_id])
- @equips[slot_id].object = item
- refresh
- end
- end
- class Window_EquipSlot < Window_Selectable
- def refresh
- self.contents.clear
- return unless @actor
- create_contents
- rect = Rect.new(92, 0, self.width - 128, 24)
- @actor.equip_slots.each_with_index do |s, i|
- name = Vocab.etype(s); self.contents.draw_text(4, 24 * i, 92, 24, name)
- end
- item_max.times do |i| rect.y = 24 * i; draw_item_name(@actor.equips[i], rect.x, rect.y) end
- end
- end
- class Window_EquipItem < Window_ItemList
- def include?(item)
- return true if item == nil
- return false unless item.is_a?(RPG::EquipItem)
- return false if @slot_id < 0
- return false if !item.etype_ids.include?(@actor.equip_slots[@slot_id])
- return @actor.equippable?(item)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment