Wersja 2.0 skryptu, dostosowana podobnie jak wersje na XP i VX. Zalecane dokładne testy:
#===================================================================
# Wymagania broni i pancerza [VXAce]
# by Ayene
# 08.01.2012 ver 2.0
# www.ultimateam.pl
#===================================================================
# Opis:
# Skrypt umożliwia ustawienie wymagań dla broni i pancerza.
# Na przykład ekwipowanie bohatera w topór dwuręczny byłoby możliwe
# dopiero po osiągnięciu konkretnego poziomu lub posiadaniu odpowiedniej
# statystyki.
#
# Instrukcja:
# By skorzystać ze skryptu w oknie 'Note' przy danym elemencie ekwipunku
# w Bazie Danych umieść tekst <wymagania LV, ATK, DEF, SPI, MDEF, AGI, LUCK>,
# gdzie:
# LV - wymagany poziom postaci (level)
# ATK - atak (attack)
# DEF - obrona (defence)
# SPI - wola (spirit)
# MDEF - obrona magiczna (magical defence)
# AGI - zręczność/zwinność (agility)
# LUCK - szczęście (luck)
#
# Przykład:
# Jeśli chcesz, by postać mogła ekwipować broń na poziomie 6, dodatkowo
# pod warunkiem, że ma 40 ataku i 70 obrony, to w oknie 'Note' tej broni
# należy wpisać:
# <wymagania 6, 40, 70, 0, 0, 0, 0>
#
# Natomiast, gdy bohater ma mieć tylko odpowiednią zręczność:
# <wymagania 0, 0, 0, 0, 0, 50, 0>
#
# Aby dodać wymóg posiadania umiejętności, wystarczy w oknie notek wpisać:
# <umiejetnosc_wymagana ID, ID, ...>
# gdzie ID to id umiejętności w Bazie Danych
#===================================================================
module AYENE
module ItemSpec
ITEM_SPEC = /<(?:WYMAGANIA|wymagania)\s*(\d+)\s*, \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+), \s*(\d+)>/i
WEAPON_TEXT = "By założyć tę broń musisz mieć:"
ARMOR_TEXT = "By założyć ten pancerz musisz mieć:"
ACC_TEXT = "By założyć ten przedmiot musisz mieć:"
PARAM_NAMES = ["Poziom", "Żywotność", "Mana", "Atak", "Obrona", "Wola", "Zwinność", "Umiejętności:"]
SKILL_SPEC = /<(?:UMIEJETNOSC_WYMAGANA|umiejetnosc_wymagana)[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i
SHOW_SKILL_REC = true # Czy wyświetlać, jakiej umiejętności brakuje?
end
end
module DataManager
#--------------------------------------------------------------------------
# alias method: load_database
#--------------------------------------------------------------------------
class << DataManager
alias aye_dataman_loaddata load_database
end
def self.load_database
aye_dataman_loaddata
for group in [$data_weapons, $data_armors]
for obj in group
next if obj.nil?
obj.item_spec_ini
end
end
end
end
#===================================================================
# RPG::BaseItem
#===================================================================
class RPG::EquipItem < RPG::BaseItem
attr_accessor :spec_params
def item_spec_ini
@spec_params = {}
(0..6).each{|i| @spec_params[i] = 0}
@spec_params[7] = []
self.note.split(/[\r\n]+/).each { |line|
case line
when AYENE::ItemSpec::ITEM_SPEC
@spec_params[0] = $1.to_i
@spec_params[1] = $2.to_i
@spec_params[2] = $3.to_i
@spec_params[3] = $4.to_i
@spec_params[4] = $5.to_i
@spec_params[5] = $6.to_i
@spec_params[6] = $7.to_i
end
}
self.note.split(/[\r\n]+/).each { |line|
case line
when AYENE::ItemSpec::SKILL_SPEC
$1.scan(/\d+/).each { |num|
skill_id = num.to_i
@spec_params[7].push(skill_id) if $data_skills[skill_id] != nil
}
end
}
end
end
#===================================================================
# RPG::Weapon
#===================================================================
class RPG::Weapon < RPG::EquipItem
def spec_text
return AYENE::ItemSpec::WEAPON_TEXT
end
end
#===================================================================
# RPG::Armor
#===================================================================
class RPG::Armor < RPG::EquipItem
def spec_text
case etype_id
when 4
return AYENE::ItemSpec::ACC_TEXT
else
return AYENE::ItemSpec::ARMOR_TEXT
end
end
end
#===================================================================
# Game_Actor
#===================================================================
class Game_Actor < Game_Battler
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_id == equip_slots[i] &&
equippable?(item) && item.performance >= 0 &&
equip_allowed?(item)
end
change_equip(i, items.max_by {|item| item.performance})
end
end
def equip_allowed?(item)
item.spec_params[7].each{|skill_id|
return false if !@skills.include?(skill_id)}
return true if (item.spec_params[0] <= level && item.spec_params[1] <= param(2) &&
item.spec_params[2] <= param(3) && item.spec_params[3] <= param(4) &&
item.spec_params[4] <= param(5) && item.spec_params[5] <= param(6) &&
item.spec_params[6] <= param(7))
return false
end
end
#===================================================================
# Game_Interpreter
#===================================================================
class Game_Interpreter
def check_change_equip(actor)
actor.equips.each_with_index do |item, i|
actor.change_equip(i, nil) if !item.nil? && !actor.equip_allowed?(item)
end
end
alias aye_command_315 command_315
def command_315
aye_command_315
iterate_actor_var(@params[0], @params[1]) do |actor|
check_change_equip(actor)
end
end
alias aye_command_316 command_316
def command_316
aye_command_316
iterate_actor_var(@params[0], @params[1]) do |actor|
check_change_equip(actor)
end
end
alias aye_command_317 command_317
def command_317
aye_command_317
iterate_actor_var(@params[0], @params[1]) do |actor|
check_change_equip(actor)
end
end
end
#===================================================================
# Window_Help
#===================================================================
class Window_Equip_Help < Window_Help
def initialize
super(1)
self.back_opacity = 255
self.z = 1000
end
def set_stats(item, data, actor, skill)
if skill.empty? or !AYENE::ItemSpec::SHOW_SKILL_REC
height = (data.size + 1) / 2 * line_height + line_height + 32
else
height = (data.size+1) / 2 * line_height + line_height * 2 + line_height * [skill.size, 7].min
end
self.y = 180 - height/2
self.height = height
contents.dispose
self.contents = Bitmap.new(contents_width, height - standard_padding * 2)
contents.font.color = crisis_color
draw_text(4, 0, contents_width, line_height, item.spec_text, 1)
x = 10
y = line_height
data.each_with_index{|array, i|
contents.font.color = system_color
draw_text(x+i%2*280, y+i/2*line_height, 240, line_height, AYENE::ItemSpec::PARAM_NAMES[array[0]].to_s, 0)
contents.font.color = normal_color
draw_text(x+120+i%2*280, y+i/2*line_height, 40, line_height, array[1].to_s, 2)
}
if !skill.empty? and AYENE::ItemSpec::SHOW_SKILL_REC
size = (data.size+1)/2*line_height
contents.font.color = system_color
draw_text(x, y+size, contents_width, line_height, AYENE::ItemSpec::PARAM_NAMES[7].to_s, 0)
contents.font.color = normal_color
skill.each_with_index{|id, i|
draw_text(x+140, y+size+line_height*i, contents_width, line_height, "- #{$data_skills[id].name}", 0)
}
end
end
end
#===================================================================
# Scene_Equip
#===================================================================
class Scene_Equip < Scene_MenuBase
alias aye_itspec_sceq_start start
alias aye_itspec_sceq_ter terminate
alias aye_itspec_sceq_update update
def start
@frame = 0
@spec_window = Window_Equip_Help.new
@spec_window.deactivate
@spec_window.hide
aye_itspec_sceq_start
end
def terminate
aye_itspec_sceq_ter
@spec_window.dispose
end
def update
@spec_window.update
if @spec_window.active
update_spec_selection
end
aye_itspec_sceq_update
end
def on_item_ok
item = @item_window.item
if item != nil and !@actor.equip_allowed?(item)
Sound.play_buzzer
data = []
item.spec_params.each {|type, value|
data.push([type, value]) if value > 0 if type < 7}
data.sort!{|a,b| a[0] <=> b[0]}
skill = item.spec_params[7]
@spec_window.set_stats(item, data, @actor, skill)
@spec_window.show
@spec_window.activate
@item_window.deactivate
else
Sound.play_equip
@actor.change_equip(@slot_window.index, item)
@slot_window.activate
@slot_window.refresh
@item_window.unselect
@item_window.refresh
end
end
def update_spec_selection
@frame < 200 ? @frame += 1 : @frame = 0
if @frame == 200 or Input.trigger?(Input::C) or Input.trigger?(Input::B)
@frame = 0
@spec_window.hide
@item_window.activate
@spec_window.deactivate
end
end
end