Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Z_Systems
- module SceneEquipX
- #==========================================================================#
- # Multiple Equip Feature : For Redefining Equipment! #
- # To disable this feature, set 'EQUIPS = ORIGINAL' #
- #==========================================================================#
- USE_MULTI_EQUIP_SYSTEM = false
- ORIGINAL = [ # Default types. Do not edit unless you know what this does.
- :weapon, :shield, :helm, :armor, :acces]
- EQUIPS = [
- :weapon, # Must be Weapon
- :shield, # Must be replaced if Weapon is two handed
- :helm,
- :back,
- :armor,
- :acces,
- :acces
- ] # DO NOT REMOVE
- REPLACE = {
- # Condition, New Vocab, New Symbol
- :weapon => ['actor.two_swords_style', 'Vocab::weapon1', :weapon],
- :shield => ['actor.two_swords_style', 'Vocab::weapon2', :weapon]
- }
- EQUIP_DATA = {
- # Condition for Equip, Vocab
- :weapon => ['check_type(0) and noregexp', 'Vocab::weapon'],
- :shield => ['check_type(1) and noregexp', 'Vocab::armor1'],
- :helm => ['check_type(2) and noregexp', 'Vocab::armor2'],
- :armor => ['check_type(3) and noregexp', 'Vocab::armor3'],
- :acces => ['check_type(4) and noregexp', 'Vocab::armor4'],
- :back => ['regexp("BACK")', '"Back"']
- }
- # Scripts for above's 'Condition for Equip' ONLY!!! (All returns bool values)
- # check_type(i) => checks item's kind to original index
- # regexp(string) => checks for <equip_type: string>
- # noregexp => checks to see if <equip_type: > does not exist.
- #==========================================================================#
- # Slot and Gem Feature : Set SLOT_MAX to 0 to Disable! #
- #==========================================================================#
- #~ USE_SLOT_SYSTEM = false # NOT YET INSTALLED
- #~ SLOT_VOCAB = "Slot"
- #~ SLOT_MAX = 2 #Number from 0..2 ONLY! Future versions may include more.
- #========#======================#====#================================#========#
- #--------# #----# DO NOT EDIT PAST THIS POINT!!! #--------#
- #--------# End of Customization #----# Editing will cause death by #--------#
- #--------# #----# brain asplosions. #--------#
- #========#======================#====#================================#========#
- unless USE_MULTI_EQUIP_SYSTEM
- EQUIPS = ORIGINAL
- REPLACE = {
- ORIGINAL[0] => ['actor.two_swords_style', 'Vocab::weapon1', ORIGINAL[0]],
- ORIGINAL[1] => ['actor.two_swords_style', 'Vocab::weapon2', ORIGINAL[0]]}
- EQUIP_DATA = {}
- for i in 0..4
- EQUIP_DATA[ORIGINAL[i]] = (['check_type('+i.to_s+')'])
- if i == 0
- EQUIP_DATA[ORIGINAL[i]][1] = 'Vocab::weapon'
- else
- EQUIP_DATA[ORIGINAL[i]][1] = 'Vocab::armor'+i.to_s
- end
- end
- end
- end
- end
- $zsys ||= {}
- $zsys['SceneEquipX'] = true
- module Z
- def self.active_actor
- return $scene.active_actor
- end
- end
- class Scene_Base
- def active_actor
- return @actor
- end
- end
- module Z::SceneEquipX
- include Z_Systems::SceneEquipX
- def self.symbol_index(i)
- symbol = EQUIPS[i]
- unless REPLACE[symbol].nil?
- actor = Z::active_actor
- actor ||= $actor
- if eval(REPLACE[symbol][0])
- symbol = REPLACE[symbol][2]
- end
- end
- return symbol
- end
- def self.vocab_index(i)
- symbol = EQUIPS[i]
- vocab = eval(EQUIP_DATA[symbol][1])
- unless REPLACE[symbol].nil?
- actor = Z::active_actor
- actor ||= $actor
- if eval(REPLACE[symbol][0])
- vocab = eval(REPLACE[symbol][1])
- end
- end
- return vocab
- end
- def self.check_type(i, item)
- if i == 0
- return (item.is_a?(RPG::Weapon))
- else
- return item.kind == i - 1
- end
- end
- def self.noregexp(item)
- item.note.scan(/<equip_type:[ ](.*)>/i){
- return (false)
- }
- return true
- end
- def self.regexp(string, item)
- item.note.scan(/<equip_type:[ ](.*)>/i){|nstring|
- return (string.upcase == nstring[0].upcase)
- }
- return false
- end
- def self.original_equipment(actor)
- return [$data_weapons[actor.weapon_id],
- $data_armors[actor.armor1_id],
- $data_armors[actor.armor2_id],
- $data_armors[actor.armor3_id],
- $data_armors[actor.armor4_id]]
- end
- end
- class RPG::BaseItem
- include Z_Systems::SceneEquipX
- def symbol
- for sym in EQUIPS.compact
- if eval(EQUIP_DATA[sym][0])
- return sym
- end
- end
- print "Error, symbol not found for #{self.name}"
- end
- def check_type(i)
- return Z::SceneEquipX::check_type(i, self)
- end
- def regexp(string)
- return Z::SceneEquipX::regexp(string, self)
- end
- def noregexp
- return Z::SceneEquipX::noregexp(self)
- end
- end
- class Window_Rect < Window_Selectable
- alias seqx_init initialize
- def initialize(x, y, width, height)
- seqx_init(x, y, width, height)
- self.opacity = 0
- end
- end
- class Scene_Equip < Scene_Base
- include Z_Systems::SceneEquipX
- EQUIP_TYPE_MAX = EQUIPS.size
- def update_status_window
- if @equip_window.active
- @status_window.set_new_parameters(nil, nil, nil, nil)
- elsif @item_window.active
- temp_actor = @actor.clone
- equip = @actor.equip_at_slot(@equip_window.index)
- if equip.nil?
- @status_window.set_new_parameters(nil, nil, nil, nil)
- else
- new_atk = @actor.atk - equip.atk
- new_def = @actor.def - equip.def
- new_spi = @actor.spi - equip.spi
- new_agi = @actor.agi - equip.agi
- if !@item_window.item.nil? and @item_window.active
- new_atk += @item_window.item.atk
- new_def += @item_window.item.def
- new_spi += @item_window.item.spi
- new_agi += @item_window.item.agi
- end
- @status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
- end
- end
- @status_window.update
- end
- def update_equip_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::R)
- Sound.play_cursor
- next_actor
- elsif Input.trigger?(Input::L)
- Sound.play_cursor
- prev_actor
- elsif Input.trigger?(Input::C)
- if @actor.fix_equipment
- Sound.play_buzzer
- else
- Sound.play_decision
- @equip_window.active = false
- @item_window.active = true
- @item_window.index = 0
- update_status_window
- end
- end
- end
- def update_item_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- elsif Input.trigger?(Input::C)
- Sound.play_equip
- @actor.change_equip(@equip_window.index, @item_window.item)
- @equip_window.active = true
- @item_window.active = false
- @item_window.index = -1
- @equip_window.refresh
- for item_window in @item_windows
- item_window.refresh
- end
- update_status_window
- end
- end
- def update_item_windows
- for i in 0...EQUIP_TYPE_MAX
- @item_windows[i].visible = (@equip_window.index == i)
- @item_windows[i].update
- end
- @item_window = @item_windows[@equip_window.index]
- update_status_window
- end
- def update_equip_window
- @equip_window.update
- update_status_window
- end
- end
- class Window_Equip < Window_Selectable
- include Z_Systems::SceneEquipX
- def refresh
- self.contents.clear
- @data = []
- for item in @actor.equips do @data.push(item) end
- @item_max = EQUIPS.size
- create_contents
- self.contents.font.color = system_color
- for i in 0...EQUIPS.size
- self.contents.draw_text(4, WLH*i, 92, WLH, Z::SceneEquipX::vocab_index(i))
- end
- for i in 0...EQUIPS.size
- draw_item_name(@data[i], 92, WLH * i)
- end
- end
- end
- class Window_EquipItem < Window_Item
- def initialize(x, y, width, height, actor, equip_type)
- @actor = actor
- @equip_type = equip_type
- super(x, y, width, height)
- end
- def include?(item)
- return true if item == nil
- return false unless @actor.equippable?(item)
- return (item.symbol == Z::SceneEquipX::symbol_index(@equip_type))
- end
- end
- class Game_Actor < Game_Battler
- include Z_Systems::SceneEquipX
- alias seqx_setup setup
- def setup(actor_id)
- seqx_setup(actor_id)
- @equips_id = []
- $actor = self
- for i in 0...EQUIPS.size
- @equips_id.push(0)
- for equip in Z::SceneEquipX::original_equipment(self)
- next if equip.nil?
- if equip.symbol == Z::SceneEquipX::symbol_index(i)
- @equips_id[i] = equip.id
- break
- end
- end
- end
- end
- def weapons
- result = []
- for i in 0...EQUIPS.size
- item = $data_weapons[@equips_id[i]]
- next if Z::SceneEquipX::symbol_index(i) != ORIGINAL[0]
- result.push(item)
- end
- return result
- end
- def armors
- result = []
- for i in 0...EQUIPS.size
- item = $data_armors[@equips_id[i]]
- next if Z::SceneEquipX::symbol_index(i) == ORIGINAL[0]
- if item.nil?
- result.push(nil)
- next
- end
- result.push(item) if (Z::SceneEquipX::symbol_index(i) == item.symbol)
- end
- return result
- end
- def atk_animation_id
- if weapons.size > 1
- return weapons[0].animation_id if weapons[0] != nil
- return weapons[1] == nil ? 1 : 0
- else
- return weapons[0] == nil ? 1 : weapons[0].animation_id
- end
- end
- def atk_animation_id2
- if weapons.size > 1
- return weapons[1] == nil ? 0 : weapons[1].animation_id
- else
- return 0
- end
- end
- def change_equip_by_id(equip_type, item_id, test = false)
- if Z::SceneEquipX::symbol_index(equip_type) == ORIGINAL[0]
- change_equip(equip_type, $data_weapons[item_id], test)
- else
- change_equip(equip_type, $data_armors[item_id], test)
- end
- end
- def change_equip(equip_type, item, test = false)
- unless test
- last_item = equip_at_slot(equip_type)
- return if $game_party.item_number(item) == 0 if item != nil
- $game_party.gain_item(last_item, 1)
- $game_party.lose_item(item, 1)
- end
- item_id = item == nil ? 0 : item.id
- @equips_id[equip_type] = item_id
- end
- def equip_at_slot(i)
- id = @equips_id[i]
- if Z::SceneEquipX::symbol_index(i) == ORIGINAL[0]
- item = $data_weapons[id]
- else
- item = $data_armors[id]
- end
- end
- def discard_equip(item)
- for i in 0...EQUIPS.size
- if (@equips_id[i] == item.id and
- item.symbol == Z::SceneEquipX::symbol_index(i))
- @equips_id[i] = 0
- break
- end
- end
- end
- def two_hands_legal?
- if weapons[0] != nil and weapons[0].two_handed
- return false if @equips_id[1] != 0
- end
- if weapons[1] != nil and weapons[1].two_handed
- return false if @equips_id[0] != 0
- end
- return true
- end
- def class_id=(class_id)
- @class_id = class_id
- for i in 0..EQUIPS.size
- change_equip(i, nil) unless equippable?(equips[i])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement