class Array
def data
@data.to_s
end
end
module Options
#
#
#
#RANK 0 1 2 3 4 5 6 7 8 9 #特性
f = [[ 0, 3, 10, 15, 30, 40, 70, 90,150,190], #白/无
[ 10, 11, 15, 20, 33, 43, 72, 92,152,192], #绿
[ 30, 31, 33, 35, 40, 50, 77, 97,156,196], #蓝
[ 70, 71, 73, 74, 79, 81, 90,110,167,207], #紫
[150,151,153,154,158,161,169,174,190,230]] #橙
a = Table.new(10,5)
10.times{|x| 5.times{|y| a[x,y] = f[y][x] }}
#<=以上内容请不要修改=======================================================>
S初始评价 = a
S使用耐久 = false
S每级强化评价 = 1
S宝石评价_白 = 1
S宝石评价_绿 = 2
S宝石评价_蓝 = 4
S宝石评价_紫 = 8
S宝石评价_橙 = 16
S品质_白 = 0
S品质_绿 = 10
S品质_蓝 = 30
S品质_紫 = 70
S品质_橙 = 150
S品质掉率_绿 = 0 #315
S品质掉率_蓝 = 0 #63
S品质掉率_紫 = 0 #9
S品质掉率_橙 = 100000 #1
S嵌孔掉率_1 = 315
S嵌孔掉率_2 = 100
S嵌孔掉率_3 = 63
S嵌孔掉率_4 = 18
S嵌孔掉率_5 = 4
#<=以下内容请不要修改=======================================================>
def self.dataA
S初始评价
end
def self.dataB
S每级强化评价
end
def self.dataC
[S品质_白, S品质_绿, S品质_蓝, S品质_紫, S品质_橙]
end
def self.dataD
[S品质掉率_橙, S品质掉率_紫, S品质掉率_蓝, S品质掉率_绿]
end
def self.dataE
[S嵌孔掉率_5, S嵌孔掉率_4, S嵌孔掉率_3, S嵌孔掉率_2, S嵌孔掉率_1]
end
def self.dataF
[S宝石评价_白, S宝石评价_绿, S宝石评价_蓝, S宝石评价_紫, S宝石评价_橙]
end
def self.cf(a, b)
self.dataA[a, b]
end
def self.lf(e=0)
self.dataD.each_with_index do |r, i|
return 4-i if (r * ( r ** -0.05 + 0.4 ) ** e).to_i >= rand(1000)
end
return 0
end
def self.qf(e=0)
self.dataE.each_with_index do |r, i|
return 5-i if (r * ( r ** -0.05 + 0.4 ) ** e).to_i >= rand(1000)
end
return 0
end
end
module RPG
class BaseItem
def is_maho?
note.include?("<前缀>")
end
def is_item?
self.is_a?(RPG::Item) && is_gem?
end
def is_gem?
note.include?("<宝石>")
end
def rank
lv = note[/<品质\s*(.*)>/, 1].to_s
["白","绿","蓝","紫","橙", ""].index(lv) % 5 #"白","绿","蓝","紫","橙", "" %5
end
def rank_lv
note[/<RANK\s*(\d*)>/, 1].to_i
end
def features
@features + features_note
end
def kind_id
self.class.to_s + self.id.to_s
end
def features_note
note.scan(/<特性 (.*) (.*)>/).inject([]) do |r, i|
case i[0]
when "吸收"
r.push RPG::BaseItem::Feature.new(22,10,(i[1].to_i)/100.0)
end
end
end
end
end
module Vocab
def self.xparam(id)
["命中率","回避率","会心率","会心回避率","魔法回避率","魔法反射率","反击率","HP再生率","MP再生率","TP再生率","生命吸收"][id]
end
def self.sparam(id)
["受到攻击的几率","防御效果率","恢复效果率","药物知识","MP消费率","TP消耗率","物理伤害率","魔法伤害率","针板伤害率","经验获得率"][id]
end
def self.zparam(id)
["遇敌机率减半","随机遇敌无效","偷袭无效","先发攻击率提升","获得2倍现金","物品获得机率翻倍"][id]
end
def self.elements(id)
$data_system.elements[id]
end
def self.weapon_types(id)
$data_system.weapon_types[id]
end
def self.armor_types(id)
$data_system.armor_types[id]
end
end
module DataManager
def self.create_game_objects
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_timer = Game_Timer.new
$game_message = Game_Message.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$game_items = Game_Items.new
end
def self.make_save_contents
contents = {}
contents[:system] = $game_system
contents[:timer] = $game_timer
contents[:message] = $game_message
contents[:switches] = $game_switches
contents[:variables] = $game_variables
contents[:self_switches] = $game_self_switches
contents[:actors] = $game_actors
contents[:party] = $game_party
contents[:troop] = $game_troop
contents[:map] = $game_map
contents[:player] = $game_player
contents[:items] = $game_items
contents
end
def self.extract_save_contents(contents)
$game_system = contents[:system]
$game_timer = contents[:timer]
$game_message = contents[:message]
$game_switches = contents[:switches]
$game_variables = contents[:variables]
$game_self_switches = contents[:self_switches]
$game_actors = contents[:actors]
$game_party = contents[:party]
$game_troop = contents[:troop]
$game_map = contents[:map]
$game_player = contents[:player]
$game_items = contents[:items]
end
end
module BattleManager
def self.gain_drop_items
$game_troop.make_drop_items.each do |item|
$game_party.add_item(item, 1, true)
$game_message.add(sprintf(Vocab::ObtainItem, item.name))
end
wait_for_message
end
end
class Game_Items < Array
def idForNewItem(item, rand=false)
if item.is_a?(RPG::Item) || item.is_gem?
item = Game_UsableItem.new(item)
else
item = Game_EquipItem.new(item, rand)
end
self.push item
return self.size - 1
end
def items
self.collect {|item| item.is_item? }
end
def gems
self.collect {|item| item.is_gem? }
end
def weapons
self.collect {|item| item.is_weapon? }
end
def armors
self.collect {|item| item.is_armor? }
end
end
class Game_BaoItem
def initialize(id = nil)
@id = id
end
def add_item(id)
@id = id
end
def unadd_item
@id = nil
end
def name
item ? item.name : "空插槽"
end
def rank
item ? item.rank : 0
end
def features
item.features if item
end
def item
$game_items[@id] if @id
end
end
class Game_Item
def initialize(item)
@item = item
@id = $game_items.size
end
def is_a?(kind); item.is_a?(kind); end
def is_item?; item.is_a?(RPG::Item) || is_gem?; end
def is_gem?; item.is_gem?; end
def is_weapon?; item.is_a?(RPG::Weapon) && !is_gem?; end
def is_armor?; item.is_a?(RPG::Armor); end
def is_equip?; is_weapon? || is_armor?; end
def item
@item
end
def id
@id
end
def id=(id)
@id = id
end
def rank
item.rank
end
def item_id
item.id
end
def kind_id
item.class.to_s + item.id.to_s
end
def note
item.note
end
def price
item.price
end
def icon_index
item.icon_index
end
def description
item.description
end
def features
item.features
end
end
class Game_UsableItem < Game_Item
def initialize(item)
super(item)
@number = 0
end
def number
@number
end
def number=(n)
@number = n
end
def performance
Options.dataC[item.rank]
end
def name; item.name; end #物品名
def itype_id; item.itype_id; end #贵重品值
def scope; item.scope; end #使用范围
def occasion; item.occasion; end #使用时刻
def effects; item.effects; end #使用效果
def damage; item.damage; end #使用伤害
def repeats; item.repeats; end #连续回数
def success_rate; item.success_rate; end #成功率
def tp_gain; item.tp_gain; end #获得TP
def animation_id; item.animation_id; end #动画编号
def speed; item.speed; end #速度補正
def key_item?; itype_id == 2; end #贵重品判定
def consumable; item.consumable; end #消耗判定
def for_opponent?; [1, 2, 3, 4, 5, 6].include?(scope); end
def for_friend?; [7, 8, 9, 10, 11].include?(scope); end
def for_dead_friend?; [9, 10].include?(scope); end
def for_user?; scope == 11; end
def for_one?; [1, 3, 7, 9, 11].include?(scope); end
def for_random?; [3, 4, 5, 6].include?(scope); end
def number_of_targets; for_random? ? scope - 2 : 0; end
def for_all?; [2, 8, 10].include?(scope); end
def need_selection?; [1, 7, 9].include?(scope); end
def battle_ok?; [0, 1].include?(occasion); end
def menu_ok?; [0, 2].include?(occasion); end
def certain?; @hit_type == 0; end #技能用?
def physical?; @hit_type == 1; end #技能用?
def magical?; @hit_type == 2; end #技能用?
end
class Game_EquipItem < Game_Item
def initialize(item, rand = true)
super(item)
@lv = rand ? make_lv : 0
@params = make_params(rand)
@prefix = 0
@prefix_lv = 0
@dongshu = []
make_prefix if rand
make_dongshu if rand
make_naijiu(rand)
end
def dongshu
@dongshu
end
def wtype_id; item.wtype_id; end #武器类型
def atype_id; item.atype_id; end #防具类型
def etype_id; item.etype_id; end #装备部位
def animation_id; item.animation_id; end
def lv; @lv; end
def naijiu; @naijiu; end
def naijiu_max; @naijiu_max; end
def lv_up
@lv += 1
end
def make_naijiu(rand)
@naijiu_max = 100
@naijiu = rand ? rand(51)+50 : @naijiu_max
end
def make_dongshu
n = Options.qf(0)
n.times{add_ds}
end
def add_ds
@dongshu.push Game_BaoItem.new
end
def make_lv
u = 0
max_lv = 5 + 0 #提高0 可提高强化等级
max_le = 200 + 0 #提高0 可提高强化概率
max_lv.times{
return u if rand(max_le) < 100
u += 1
}
u
end
def make_params(rand)
return item.params unless rand
item.params.collect do |param|
num = ([(param).abs, 1].max**-0.5*param).truncate
ts = param - num + rand(num*2+1)
ts == 0 ? param : ts
end
end
def make_prefix
@prefix_lv = Options.lf(0)
return if @prefix_lv == 0
items = pzqz(@prefix_lv)
@prefix = items[rand(items.size)].id
end
def features
base_features + ds_features
end
def base_features
item.features + prefix_item_features
end
def ds_features
result = []
@dongshu.each {|item|
if item.item
features = item.features
if is_armor?
data = $data_armors.compact.find {|i| i.name == item.name }
features = data.features if data
end
result += features
end
}
result
end
def prefix_item_features
@prefix > 0 ? prefix_item.features : []
end
def prefix_item
equip = $data_weapons[@prefix]
if is_armor?
data = $data_armors.compact.find {|i| i.name == equip.name }
equip = data if data
end
equip
end
def allqz
$data_weapons.select {|item| item ? item.is_maho? : false}
end
def pzqz(n)
n = 5 #TEST
allqz.select{|item| item.rank == n}
end
def ds
prefix_item.description if @prefix > 0
end
def name
tn = ""
tn = tn + prefix_item.name + "的" if @prefix > 0
tn += item.name
tn += (@lv == 0 ? "" : sprintf("%+d", @lv))
tn
end
def price
all_lv_price = (@lv * @lv + @lv)*(50+base_performance*2)/2
super + all_lv_price + 2 ** @prefix_lv * 1000
end
def params
r = 0.0
@params.each_with_index do |e, i|
if e > 0
case i
when 0
r += 0.8
when 1
r += 0.9
else
r += 1
end
end
end
#g = @params.inject(0) {|r, i| i > 0 ? r + 1 : r }
r = (r == 0 ? 0 : r ** -0.6 / 2.0)
8.times.collect do |i|
pa = @params[i]
case i
when 0
(pa + @lv * pa * [pa.abs, 1].max ** -0.5 * r * (pa < 0 ? 0.2 : 2)).round
when 1
(pa + @lv * pa * [pa.abs, 1].max ** -0.5 * r * (pa < 0 ? 0.12 : 1.2)).round
else
(pa + @lv * pa * [pa.abs, 1].max ** -0.5 * r * (pa < 0 ? 0.1 : 1)).round
end
end
#@params.collect do |param|
#end
end
def rank
case performance
when 0...10 ; 0
when 10...30 ; 1
when 30...70 ; 2
when 70...150 ; 3
when 150...310 ; 4
when 310...999 ; 5
end
end
def dakongg
2 ** dongshu.size * (100+base_performance*10)
end
def lv_price
(@lv + 1) * (100+base_performance)
end
def base_performance
Options.cf(item.rank_lv, @prefix_lv)
end
def ds_performance
@dongshu.inject(0) {|r, i| r + Options.dataF[i.rank] }
end
def performance
@lv + base_performance + ds_performance
end
end
class Game_Party < Game_Unit
def initialize
super
@gold = 0
@steps = 0
@last_item = Game_BaseItem.new
@menu_actor_id = 0
@target_actor_id = 0
@actors = []
@items = []
end
def consume_item(item)
lose_item(item.id, 1) if item.is_a?(RPG::Item) && item.consumable
end
def item_number(item)
return unless item
n = 0
all_items.each do |i|
if i.kind_id == item.kind_id
n += i.is_item? ? i.number : 1
end
end
n
end
def setup_battle_test_items
$data_items.each do |item|
add_item(item, max_item_number(item)) if item && !item.name.empty?
end
end
def has_item?(item, include_equip = false)
return true if item_number(item) > 0
#return include_equip ? members_equip_include?(item) : false
end
def members_equip_include?(item)
msgbox "判定队伍成员是否装备着指定物品"
members.any? {|actor| actor.equips.any?{|it|it.item_id == item.item_id }}
end
def add_item(item, amount, rand = true)
return unless item
return if amount == 0
return unadd_item(item, amount) if amount < 0
if item.class == RPG::Item
gain_item($game_items.idForNewItem(item), amount)
else
amount.times{ gain_item($game_items.idForNewItem(item, rand)) }
end
$game_map.need_refresh = true
end
def unadd_item(item, amount)
amount.abs.times do
all_items.each do |i|
if i.kind_id == item.kind_id
lose_item(i.id, 1)
break
end
end
end
$game_map.need_refresh = true
end
def add_shopitem(item, number)
if item.is_item?
$game_items.push item
gain_item($game_items.size-1, number)
else
id = item.item_id
item = item.is_weapon? ? $data_weapons[id] : $data_armors[id]
add_item(item, number, false)
end
end
def gain_item(id, n=1)
return unless id
if $game_items[id].is_item?
items.each do |item|
if $game_items[id].kind_id == item.kind_id
maxn = [item.number + n, 99].min - item.number
n -= maxn
item.number += maxn
end
end
if n > 0
$game_items[id].number = n
@items.push(id)
end
else
@items.push(id)
end
all_items_sort
end
def lose_item(id, n=1)
return unless id
if $game_items[id].is_item?
items.reverse_each do |item|
if $game_items[id].kind_id == item.kind_id
maxn = [item.number, n].min
item.number -= maxn
n -= maxn
@items.delete(item.id) if item.number == 0
end
end
else
@items.delete(id)
end
end
def all_items_sort
@items.sort!{|a, b|$game_items[a].item_id - $game_items[b].item_id}
end
def items
@items.collect {|id| $game_items[id] }.select {|item| item.is_item? }
end
def gems
@items.collect {|id| $game_items[id] }.select {|item| item.is_gem? }
end
def weapons
@items.collect {|id| $game_items[id] }.select {|item| item.is_weapon? }
end
def armors
@items.collect {|id| $game_items[id] }.select {|item| item.is_armor? }
end
end
class Game_Battler < Game_BattlerBase
def make_damage_value(user, item)
value = item.damage.eval(user, self, $game_variables)
value *= item_element_rate(user, item)
value *= pdr if item.physical?
value *= mdr if item.magical?
value *= rec if item.damage.recover?
value = apply_critical(value) if @result.critical
value = apply_variance(value, item.damage.variance)
value = apply_guard(value)
@result.make_damage(value.to_i, user, item)
end
end
class Game_Actor < Game_Battler
def init_equips(equips)
@equips = Array.new(equip_slots.size)
equips.each_with_index do |item_id, i|
next if item_id == 0
etype_id = equip_slots[i]
item = etype_id == 0 ? $data_weapons[item_id] : $data_armors[item_id]
@equips[i] = $game_items.idForNewItem(item, false)
end
refresh
end
def param_rate(param_id)
features_sum_pi(FEATURE_PARAM, param_id)
end
def sparam(sparam_id)
features_sum_pi(FEATURE_SPARAM, sparam_id)
end
def features_sum_pi(code, id)
r_features_pi(code, id) * r_features_sum(code, id)
end
def r_features_pi(code, id)
rsum_features_with_id(code, id).inject(1.0) {|r, ft| r += (ft.value-1) }
end
def r_features_sum(code, id)
rpi_features_with_id(code, id).inject(1.0) {|r, ft| r *= ft.value }
end
def rsum_features_with_id(code, id)
rsum_all_features.select {|ft| ft.code == code && ft.data_id == id }
end
def rpi_features_with_id(code, id)
rpi_all_features.select {|ft| ft.code == code && ft.data_id == id }
end
def rsum_all_features
rsum_feature_objects.inject([]) {|r, obj| r + obj.features }
end
def rpi_all_features
rpi_feature_objects.inject([]) {|r, obj| r + obj.features }
end
def rsum_feature_objects
[actor] + [self.class] + equips.compact
end
def rpi_feature_objects
states
end
def equip_slots
return [0,0,2,3,4,4] if dual_wield?
return [0,1,2,3,4,4]
end
def weapons
@equips.select {|i| i ? $game_items[i].is_weapon? : false }.collect {|i| $game_items[i] }
end
def armors
@equips.select {|i| i ? $game_items[i].is_armor? : false }.collect {|i| $game_items[i] }
end
def equips
@equips.collect {|i| i ? $game_items[i] : nil }
end
def equip_change_ok?(slot_id)
return true
return false if equip_type_fixed?(equip_slots[slot_id])
return false if equip_type_sealed?(equip_slots[slot_id])
return true
end
def release_unequippable_items(item_gain = true)
equips.each_with_index do |item, i|
next if item
if !equippable?(item) || item.etype_id != equip_slots[i]
trade_item_with_party(nil, @equips[i]) if item_gain
end
end
end
def clear_equipments
equip_slots.size.times do |i|
change_equip(i, nil) if equip_change_ok?(i)
end
end
def change_equip(slot_id, item)
return unless trade_item_with_party(item, equips[slot_id])
return if item && equip_slots[slot_id] != item.etype_id
@equips[slot_id] = item ? item.id : nil
refresh
end
def force_change_equip(slot_id, item)
@equips[slot_id] = item ? item.id : nil
release_unequippable_items(false)
refresh
end
def trade_item_with_party(new_item, old_item)
return false if new_item && !$game_party.has_item?(new_item)
$game_party.gain_item(old_item ? old_item.id : nil)
$game_party.lose_item(new_item ? new_item.id : nil)
return true
end
def change_equip_by_id(slot_id, item_id)
msgbox "变更装备(用 ID 指定)"
if equip_slots[slot_id] == 0
change_equip(slot_id, item_id)
else
change_equip(slot_id, item_id)
end
end
end
class Game_Action
def clear
@item = nil
@target_index = -1
@value = 0
end
def set_skill(skill_id)
@item = $data_skills[skill_id]
self
end
def set_item(item)
@item = item
self
end
def item
@item
end
end
class Game_ActionResult
def make_damage(value, user, item)
@critical = false if value == 0
@hp_damage = value if item.damage.to_hp?
@mp_damage = value if item.damage.to_mp?
@mp_damage = [@battler.mp, @mp_damage].min
@hp_drain = make_drain_hp(user, item)
@mp_drain = @mp_damage if item.damage.drain?
@hp_drain = [@battler.hp, @hp_drain].min
@success = true if item.damage.to_hp? || @mp_damage != 0
end
def make_drain_hp(user, item)
hp_damage = (@hp_damage * @battler.element_rate(2)).to_i
return hp_damage if item.damage.drain?
return (hp_damage * [user.xparam(10), 1].min).to_i if user.xparam(10) > 0
return 0
end
alias celica_hp_damage_text hp_damage_text
def hp_damage_text
celica_hp_damage_text
if @hp_damage > 0
fmt = @battler.actor? ? Vocab::ActorDamage : Vocab::EnemyDamage
sprintf(fmt, @battler.name, @hp_damage)
elsif @hp_damage < 0
fmt = @battler.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
sprintf(fmt, @battler.name, Vocab::hp, -hp_damage)
else
fmt = @battler.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
sprintf(fmt, @battler.name)
end
end
def hp_drain_text
fmt = @battler.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
sprintf("吸收了%s点%s", @hp_drain, Vocab::hp)
end
end
class Game_Interpreter
def command_126
value = operate_value(@params[1], @params[2], @params[3])
$game_party.add_item($data_items[@params[0]], value)
end
def command_127
value = operate_value(@params[1], @params[2], @params[3])
$game_party.add_item($data_weapons[@params[0]], value, true)
end
def command_128
value = operate_value(@params[1], @params[2], @params[3])
$game_party.add_item($data_armors[@params[0]], value, true)
end
def 开启强化画面
SceneManager.call(Scene_MakeEquip)
end
end
class Window_Base < Window
def draw_item_name(item, x, y, enabled = true, width = 300)
return unless item
draw_icon(item.icon_index, x, y, enabled)
change_color(performance_color(item), enabled)
draw_text(x + 24, y, width, line_height, item.name)
end
def performance_color(item)
return text_color(0) if item.is_a?(RPG::Skill)
pf = item.performance
if pf < 10
performance_rank(0)
elsif pf < 30
performance_rank(1)
elsif pf < 70
performance_rank(2)
elsif pf < 150
performance_rank(3)
elsif pf < 310
performance_rank(4)
else
performance_rank(5)
end
end
def performance_rank(n)
#白 绿 蓝 紫 橙 粉
text_color([ 0,28, 9,30,20,27][n])
end
end
class Window_Selectable < Window_Base
def active=(active)
super
update_cursor
call_update_help
call_update_equiphelp
end
def index=(index)
@index = index
update_cursor
call_update_help
call_update_equiphelp
end
def call_update_equiphelp
update_equiphelp if active && @equiphelp_window
end
def update_equiphelp
@equiphelp_window.clear
end
def drx
x + index % col_max * (item_width + spacing) + item_width / 4
end
def dry
y + index / col_max * item_height + item_height - oy
end
def equiphelp_window=(equiphelp_window)
@equiphelp_window = equiphelp_window
call_update_equiphelp
end
end
class Window_EquipHelp < Window_Base
def initialize
super(0,0,200,600)
self.opacity = 0
end
def standard_padding
return 0
end
def item
@item
end
def set_item(window, item)
@item = item
@window = window
refresh
end
def clear
contents.clear
end
def refresh
clear
return unless item
@dy = 0
draw_start #描画上外框
draw_name #描画物品名
if item.is_equip?
draw_equip_kind #描画装备类型
draw_equip_attack_type #描画武器攻击类型
draw_equip_params #描画装备能力值
draw_equip_features #描画装备特性
draw_equip_dongshu #描画装备插槽
draw_description #描画说明
elsif item.is_gem?
draw_gem_type #描画宝石类型
draw_gem_features #描画宝石特性
else
draw_item_type #描画物品类型
draw_item_effects #描画物品使用效果
end
draw_price #描画售格
draw_end #描画下外框
move_coordinate #移动坐标
end
def draw_start
pf_color = performance_color(item)
contents.fill_rect(2,0,200-4,600,pf_color)
contents.fill_rect(0,2,200,600-4,pf_color)
contents.fill_rect(2+2,2,200-4-4,600-4,Color.new(0,0,64,160))
contents.fill_rect(2,2+2,200-4,600-4-4,Color.new(0,0,64,160))
end
def draw_name
contents.font.size = 16
contents.font.name = "宋体"
contents.font.bold = true
contents.font.color = performance_color(item)
contents.draw_text(6,6+@dy*16,200+8,16,item.name,0)
contents.font.size = 15
contents.font.name = "黑体"
contents.font.bold = false
contents.font.color = text_color(0)
@dy += 1
end
def draw_description
if item.ds
if item.ds != ""
contents.font.color = text_color(21)
contents.draw_text(6, 6+@dy*16, 200, 16, item.ds)
contents.font.color = text_color(0)
@dy += 1
end
end
end
def draw_price
str = item.price == 0 ? "无法出售" : "售价:#{item.price / 2}"
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
def draw_gem_type
contents.draw_text(6, 6+@dy*16, 200, 16, "宝石", 0)
@dy += 1
end
def draw_gem_features
item2 = $data_armors.compact.find {|t| t.name == item.name }
contents.font.color = text_color(25)
if item2
contents.draw_text(6, 6+@dy*16, 200, 16, "镶嵌武器")
else
contents.draw_text(6, 6+@dy*16, 200, 16, "镶嵌通用")
end
@dy += 1
item.features.each do |ft|
str = feature_text(ft)
next unless str
contents.font.color = text_color(24)
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
if item2
contents.font.color = text_color(25)
contents.draw_text(6, 6+@dy*16, 200, 16, "镶嵌防具")
@dy += 1
item2.features.each do |ft|
str = feature_text(ft)
next unless str
contents.font.color = text_color(24)
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
end
contents.font.color = text_color(0)
end
def draw_item_type
str = item.consumable ? "消耗品" : "非消耗品"
contents.draw_text(6, 6+@dy*16, 200, 16, str, 0)
@dy += 1
end
def draw_item_effects
contents.font.color = text_color(24)
item.effects.each do |ft|
str = "特性显示未定义"
case ft.code
when 11
str = "回复#{ft.value2.to_i}点#{Vocab::hp}" if ft.value2 != 0
str = "回复#{(ft.value1*100).to_i.to_s}%#{Vocab::hp}" if ft.value1 != 0
when 12
str = "回复#{ft.value2.to_i}点#{Vocab::mp}" if ft.value2 != 0
str = "回复#{(ft.value1*100).to_i.to_s}%#{Vocab::mp}" if ft.value1 != 0
when 13
str = "回复#{ft.value2.to_i}点#{Vocab::tp}" if ft.value2 != 0
str = "回复#{(ft.value1*100).to_i.to_s}%#{Vocab::tp}" if ft.value1 != 0
when 21
str = "附加 #{$data_states[ft.data_id].name}"
when 22
str = "解除 #{$data_states[ft.data_id].name}"
when 31
when 32
when 33
when 34
when 41
when 42
str = "#{Vocab::param(ft.data_id)}永久增加#{ft.value1.to_i}点"
when 43
str = "永久习得 #{$data_skills[ft.data_id].name}"
when 44
next
end
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
contents.font.color = text_color(0)
end
def draw_equip_kind
if item.is_a?(RPG::Armor)
strA = Vocab::etype(item.etype_id)
strB = Vocab::armor_types(item.atype_id)
else
bo = (item.features.select{|ft| ft.code == 54 }).any?{|ft| ft.data_id == 1}
strA = bo ? "双手" : "单手"
strB = Vocab::weapon_types(item.wtype_id)
end
contents.draw_text(6, 6+@dy*16, 200, 16, strA, 0)
contents.draw_text(6, 6+@dy*16, 200-12, 16, strB, 2)
@dy += 1
end
def draw_equip_attack_type
str = ""
(item.features.select{|ft| ft.code == 31 }).each do |ft|
ts = Vocab::elements(ft.data_id)
str += (ts + " ") unless str.include?(ts)
end
if str != ""
contents.font.color = text_color(24)
contents.draw_text(6, 6+@dy*16, 200, 16, str)
contents.font.color = text_color(0)
@dy += 1
end
end
def draw_equip_params
item.params.each_with_index do |param, index|
if param != 0
str = sprintf("%+d #{Vocab::param(index)}",param)
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
end
end
def draw_equip_features
contents.font.color = text_color(24)
item.base_features.each do |ft|
next if ft.code == 31
str = feature_text(ft)
next unless str
contents.draw_text(6, 6+@dy*16, 200, 16, str)
@dy += 1
end
contents.font.color = text_color(0)
end
def draw_equip_dongshu
item.dongshu.each do |i|
rect1 = Rect.new(6+1, 6+@dy*16+1, 14, 14)
rect2 = Rect.new(120, 96, 8, 8)
contents.stretch_blt(rect1, windowskin, rect2, 128)
if i.item
color = performance_color(i.item)
contents.font.color = color
bitmap = Cache.system("Iconset")
rect2 = Rect.new(i.item.icon_index % 16 * 24, i.item.icon_index / 16 * 24, 24, 24)
contents.stretch_blt(rect1, bitmap, rect2)
else
contents.font.color = text_color(0)
contents.font.color.alpha = 160
end
contents.draw_text(6+16, 6+@dy*16, 200, 16, i.name)
@dy += 1
if i.item
if item.is_armor?
data = $data_armors.compact.find {|t| t.name == i.name }
i = data if data
end
contents.font.color = text_color(24)
i.features.each do |ft|
next if ft.code == 31
str = feature_text(ft)
#next unless str
contents.draw_text(6+16, 6+@dy*16, 200, 16, str)
@dy += 1
end
end
end
contents.font.color = text_color(0)
end
def draw_end
pf_color = performance_color(item)
contents.clear_rect(0,10+@dy*16,200,600)
contents.fill_rect(0,8+@dy*16,200,2,pf_color)
contents.fill_rect(4,8+@dy*16,200-8,2,Color.new(0,0,64,160))
contents.fill_rect(2,10+@dy*16,200-4,2,pf_color)
end
def move_coordinate
self.x = @window.drx
self.y = @window.dry
endy = self.y + 12+@dy*16 - @window.y
self.y -= [endy - @window.height + 6, 0].max
self.y = [self.y, 0].max
end
def feature_text(ft)
str = "特性显示未定义"
case ft.code
when 11
str = (ft.value*100).to_i.to_s + "%" + Vocab::elements(ft.data_id) + "有效度"
when 12
str = (ft.value*100).to_i.to_s + "%" + Vocab::param(ft.data_id) + "弱化有效度"
when 13
str = (ft.value*100).to_i.to_s + "%" + $data_states[ft.data_id].name + "有效度"
when 14
str = $data_states[ft.data_id].name + "状态无效化"
when 21
#str = (ft.value*100).to_i.to_s + "% " + Vocab::param(ft.data_id)
str = sprintf("%+d%%#{Vocab::param(ft.data_id)}", (ft.value*100-100).to_i)
when 22
return if ft.value == 0
str = sprintf("%+d%%#{Vocab::xparam(ft.data_id)}", (ft.value*100).to_i)
when 23
#str = (ft.value*100).to_i.to_s + "% " + Vocab::sparam(ft.data_id)
str = sprintf("%+d%%#{Vocab::xparam(ft.data_id)}", (ft.value*100-100).to_i)
when 31
str = "攻击属性附加 " + Vocab::elements(ft.data_id)
when 32
str = "+" + (ft.value*100).to_i.to_s + "%附加" + $data_states[ft.data_id].name + "状态"
when 33
str = sprintf("%+d 攻击速度", ft.value.to_i)
when 34
str = sprintf("%+d 攻击回数", ft.value.to_i)
when 41
when 42
when 43
str = "习得#{$data_skills[ft.data_id].name}"
when 44
str = "禁用#{$data_skills[ft.data_id].name}"
when 51
when 52
when 53
when 54
when 55
when 61
str = sprintf("%+d 行动回数", ft.value.to_i)
when 62
when 63
when 64
str = Vocab.zparam(ft.data_id)
end
end
end
class Window_ItemList < Window_Selectable
def include?(item)
return unless item
case @category
when :item
item.is_gem? || (item.is_item? && !item.key_item?)
when :weapon
item.is_weapon?
when :armor
item.is_armor?
when :key_item
!item.is_gem? && item.is_item? && item.key_item?
else
false
end
end
def draw_item(index)
item = @data[index]
if item
rect = item_rect(index)
rect.width -= 4
draw_item_name(item, rect.x, rect.y)#, enable?(item))
draw_item_number(rect, item)
end
end
def draw_item_number(rect, item)
#draw_text(rect, sprintf(":%2d", item.number), 2) if item.is_allitem?
draw_text(rect, sprintf(":%2d", item.number), 2) if item.is_item?
end
def update_equiphelp
@equiphelp_window.set_item(self, item)
end
end
class Window_EquipStatus < Window_Base
def visible_line_number
return 8
end
end
class Window_EquipSlot < Window_Selectable
def visible_line_number
6
end
def drx
super + 92
end
def update_equiphelp
@equiphelp_window.set_item(self, item)
end
end
class Window_EquipItem < Window_ItemList
def include?(item)
return true if item == nil
return false unless item.is_equip?
return false if @slot_id < 0
return false if item.etype_id != @actor.equip_slots[@slot_id]
return @actor.equippable?(item)
end
end
class Window_ShopBuy < Window_Selectable
def window_width
return 400
end
def make_item_list
@data = []
@price = {}
@shop_goods.each do |goods|
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
if item.is_a?(RPG::Item) || item.is_gem?
item = Game_UsableItem.new(item)
else
item = Game_EquipItem.new(item, false)
end
@data.push(item)
@price[item] = goods[2] == 0 ? item.price : goods[3]
end
end
end
def enable?(item)
item && price(item) <= @money
end
def update_equiphelp
@equiphelp_window.set_item(self, item)
end
end
class Window_ShopNumber < Window_Selectable
def window_width
return 400
end
def dry
y + item_y + line_height
end
def update_equiphelp
@equiphelp_window.set_item(self, @item)
end
def figures
return 3
end
end
class Window_ShopStatus < Window_Base
def refresh
contents.clear
draw_possession(4, 0)
return unless @item
draw_equip_info(4, line_height * 2) if @item.is_equip?
end
end
class Window_BattleLog < Window_Selectable
def display_hp_damage(target, item)
return if target.result.hp_damage == 0 && item && !item.damage.to_hp?
if target.result.hp_damage > 0
target.perform_damage_effect
end
Sound.play_recovery if target.result.hp_damage < 0
add_text(target.result.hp_damage_text)
wait
if target.result.hp_drain > 0
add_text(target.result.hp_drain_text)
wait
end
end
end
class Window_MakeCommand < Window_HorzCommand
def initialize(window_width)
@window_width = window_width
super(0, 0)
end
def window_width
@window_width
end
def col_max
return 4
end
def make_command_list
add_command("强化装备", :a)
add_command("镶嵌装备", :b)
add_command("合成装备", :c, false)
add_command("离开", :cancel)
end
def current_item_enabled?
index == 2 ? false : true
end
end
class Window_MakeA_ItemLise < Window_ItemList
def initialize(x, y, width, height)
super(x, y, width, height)
end
def col_max
return 1
end
def current_item_enabled?
return false unless item
item.lv_price <= $game_party.gold
end
def make_item_list
@data = $game_party.equip_items
end
def status_window=(status_window)
@status_window = status_window
call_update_help
end
def update_help
super
@help_window.set_item(item) if @help_window
@status_window.item = item if @status_window
end
def update_equiphelp
@equiphelp_window.set_item(self, item)
end
end
class Window_MakeA_Ok < Window_Command
def initialize
super(Graphics.width/2-60, Graphics.height/2)
self.hide.deactivate
end
def window_width
120
end
def col_max
return 1
end
def alignment
return 1
end
def make_command_list
add_command("强化", :ok)
add_command("取消", :cancel)
end
end
class Window_MakeA_Status < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
@item = nil
@page_index = 0
refresh
end
def refresh
contents.clear
return unless @item
draw_A(4, 0)
draw_B(4, 0)
draw_C(4, 0)
end
def item=(item)
@item = item
refresh
end
def draw_A(x, y)
change_color(system_color)
draw_text(x, line_height*(y+0), 300, 24, "强化费用")
change_color(normal_color)
draw_text(x, line_height*(y+1), 300, 24, @item.lv_price, 2)
end
def draw_B(x, y)
change_color(system_color)
draw_text(x, line_height*(y+2), 300, 24, "强化材料")
end
def draw_C(x, y)
change_color(system_color)
draw_text(x, line_height*(y+6), 300, 24, "属性变化")
end
end
class Window_MakeB_ItemLise < Window_ItemList
def initialize(x, y, width, height)
super(x, y, width, height)
end
def col_max
return 1
end
def current_item_enabled?
true
end
def make_item_list(syt)
if syt == "A"
@data = $game_party.equip_items
else
@data = $game_party.gems
end
@data.push(nil)
end
def status_window=(status_window)
@status_window = status_window
call_update_help
end
def update_help
super
@help_window.set_item(item) if @help_window
@status_window.item = item if @status_window
end
def refresh(syt)
make_item_list(syt)
create_contents
draw_all_items
select(0)
end
def clear
@data = []
select(-1)
create_contents
draw_all_items
end
def update_equiphelp
@equiphelp_window.set_item(self, item)
end
end
class Window_MakeB_Ok < Window_Selectable
def initialize(x, y, width, height)
super(x, y, width, height)
self.hide.deactivate
@item = nil
end
def window_width
end
def item_max
item ? 1 + [item.dongshu.size+1, 5].min : 1
end
def refresh
contents.clear
change_color(system_color)
y = 0
draw_text(4, y, 92, line_height, "装备")
if item
draw_item_name(item, 64, 0)
item.dongshu.each{|d|
y += 1
change_color(system_color)
draw_text(4, y*line_height, 92, line_height, "插槽")
change_color(normal_color)
draw_item_name(d.item, 64, y*line_height)
#dest_rect = Rect.new(64, (1+i)*line_height+4, 240, 16)
#src_bitmap = self.windowskin
#src_rect = Rect.new(120,96+8,8,8)
#contents.stretch_blt(dest_rect, src_bitmap, src_rect, 128)
#change_color(normal_color)
#draw_text(64, (1+i)*line_height, 240, line_height, "不可更改",1)
#draw_text(64, (1+i)*line_height, 92, line_height, d.name)
}
if item.dongshu.size < 5
y += 1
change_color(system_color)
draw_text(4, y*line_height, 92, line_height, "打孔")
change_color(normal_color)
draw_text(64+24, y*line_height, 240, line_height, "花费: #{item.dakongg}")
end
y += 2
gold = 50 + item.base_performance * 5
change_color(normal_color)
draw_text(0, y*line_height, 240, line_height, "镶嵌宝石花费: #{gold}")
y += 1
draw_text(0, y*line_height, 240, line_height, "取出宝石花费: #{gold*2}")
else
change_color(normal_color, false)
draw_text(64, 0,142, line_height, "请选择一件装备")
end
end
def item
@item
end
def item=(item)
@item = item
refresh
end
def kind
index == 0 ? 0 : index == item_max-1 && item.dongshu.size != 5 ? 2 : 1
end
def eq_gem(ritem)
if eitem && ritem
return if eitem.kind_id == ritem.kind_id
end
gold = 50 + item.base_performance * 5
if ritem
if eitem
$game_party.gain_item(eitem.id)
$game_party.lose_gold(gold * 2)
end
item.dongshu[index-1].add_item(ritem.id)
$game_party.lose_gold(50 + item.base_performance * 5)
$game_party.lose_item(ritem.id)
else
if eitem
$game_party.lose_gold(gold * 2)
$game_party.gain_item(eitem.id)
item.dongshu[index-1].unadd_item
end
end
refresh
end
def add_ds
$game_party.lose_gold(item.dakongg)
item.add_ds
refresh
end
def current_item_enabled?
case kind
when 0
true
when 1
50 + item.base_performance * 5 <= $game_party.gold
when 2
item.dakongg <= $game_party.gold
end
end
def eitem
case kind
when 0
item
when 1
item.dongshu[index-1].item if item
end
end
def update_equiphelp
@equiphelp_window.set_item(self, eitem)
end
end
class Window_MakeB_Status < Window_Base
def initialize(x, y, width, height)
super(x, y, width, height)
@item = nil
@page_index = 0
refresh
end
def refresh
contents.clear
return unless @item
#draw_A(4, 0)
end
def item=(item)
@item = item
#refresh
end
def draw_A(x, y)
@item.dongshu.each_with_index{|item,index|
contents.fill_rect(x+1,line_height * (y+5+index)+1,22,22, Color.new(128,128,128))
}
end
end
=begin
合成解释
1.种类保留
├不同部位的合成 => 合成失败,获得材料
└同部位的合成 => 保留高等级的一件,特性按以下方式计算
└有配方的情况按配方,特性按以下方式计算
2.特性保留
├强化等级 => 高强化等级 + 低强化等级的高强化等级的一半每1
│ max = [a.lv, b.lv].max
│ min = [a.lv, b.lv].min
│ lv = max + (min/(max/2)).ceil
│
├前缀 => 相加, 超2个的情况随机保留最大等级2个
└嵌孔数 => 保留嵌孔少的一个
└宝石 => 随机保留最大等级
=end
class Scene_MenuBase < Scene_Base
def create_help_window
@help_window = Window_Help.new
@help_window.viewport = @viewport
end
def create_equiphelp_window
@equiphelp_window = Window_EquipHelp.new
@equiphelp_window.viewport = @viewport
@equiphelp_window.z += 1000
end
end
class Scene_Item < Scene_ItemBase
def start
super
create_help_window
create_equiphelp_window
create_category_window
create_item_window
end
def create_category_window
@category_window = Window_ItemCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.equiphelp_window = @equiphelp_window
@category_window.y = @help_window.height
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
def create_item_window
wy = @category_window.y + @category_window.height
wh = Graphics.height - wy
@item_window = Window_ItemList.new(0, wy, Graphics.width, wh)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.equiphelp_window = @equiphelp_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@category_window.item_window = @item_window
end
end
class Scene_Equip < Scene_MenuBase
def start
super
create_help_window
create_equiphelp_window
create_status_window
create_command_window
create_slot_window
create_item_window
end
def create_command_window
wx = @status_window.width
wy = @help_window.height
ww = Graphics.width - @status_window.width
@command_window = Window_EquipCommand.new(wx, wy, ww)
@command_window.viewport = @viewport
@command_window.help_window = @help_window
@command_window.equiphelp_window = @equiphelp_window
@command_window.set_handler(:equip, method(:command_equip))
@command_window.set_handler(:optimize, method(:command_optimize))
@command_window.set_handler(:clear, method(:command_clear))
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:pagedown, method(:next_actor))
@command_window.set_handler(:pageup, method(:prev_actor))
end
def create_item_window
wx = 0
wy = @slot_window.y + @slot_window.height
ww = Graphics.width
wh = Graphics.height - wy
@item_window = Window_EquipItem.new(wx, wy, ww, wh)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.equiphelp_window = @equiphelp_window
@item_window.status_window = @status_window
@item_window.actor = @actor
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:on_item_cancel))
@slot_window.item_window = @item_window
end
def create_slot_window
wx = @status_window.width
wy = @command_window.y + @command_window.height
ww = Graphics.width - @status_window.width
@slot_window = Window_EquipSlot.new(wx, wy, ww)
@slot_window.viewport = @viewport
@slot_window.help_window = @help_window
@slot_window.equiphelp_window = @equiphelp_window
@slot_window.status_window = @status_window
@slot_window.actor = @actor
@slot_window.set_handler(:ok, method(:on_slot_ok))
@slot_window.set_handler(:cancel, method(:on_slot_cancel))
end
end
class Scene_MakeEquip < Scene_MenuBase
def start
super
create_help_window
create_equiphelp_window
create_gold_window
create_command_window
create_dummy_window
create_A_window
create_B_window
end
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.viewport = @viewport
@gold_window.x = Graphics.width - @gold_window.width
@gold_window.y = @help_window.height
end
def create_command_window
@command_window = Window_MakeCommand.new(@gold_window.x)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.equiphelp_window = @equiphelp_window
@command_window.set_handler(:a, method(:command_A))
@command_window.set_handler(:b, method(:command_B))
@command_window.set_handler(:c, method(:command_C))
@command_window.set_handler(:cancel, method(:return_scene))
end
def create_dummy_window
wy = @command_window.y + @command_window.height
wh = Graphics.height - wy
@dummy_window = Window_Base.new(0, wy, Graphics.width, wh)
@dummy_window.viewport = @viewport
end
def create_A_window
@makeA_status_window = Window_MakeA_Status.new(400, 120, 400, 480)
@makeA_status_window.viewport = @viewport
@makeA_status_window.hide
@makeA_itemlist_window = Window_MakeA_ItemLise.new(0, 120, 400, 480)
@makeA_itemlist_window.viewport = @viewport
@makeA_itemlist_window.help_window = @help_window
@makeA_itemlist_window.equiphelp_window = @equiphelp_window
@makeA_itemlist_window.status_window = @makeA_status_window
@makeA_itemlist_window.hide
@makeA_itemlist_window.set_handler(:ok, method(:on_A_ok))
@makeA_itemlist_window.set_handler(:cancel, method(:on_A_cancel))
@makeA_ok_window = Window_MakeA_Ok.new
@makeA_ok_window.viewport = @viewport
@makeA_ok_window.set_handler(:ok, method(:on_A_ok_ok))
@makeA_ok_window.set_handler(:cancel, method(:on_A_ok_cancel))
end
def create_B_window
@makeB_status_window = Window_MakeB_Status.new(800, 120, 400, 480)
@makeB_status_window.viewport = @viewport
@makeB_status_window.hide
@makeB_itemlist_window = Window_MakeB_ItemLise.new(400, 120, 400, 480)
@makeB_itemlist_window.viewport = @viewport
@makeB_itemlist_window.help_window = @help_window
@makeB_itemlist_window.equiphelp_window = @equiphelp_window
@makeB_itemlist_window.status_window = @makeB_status_window
@makeB_itemlist_window.hide
@makeB_itemlist_window.set_handler(:ok, method(:on_B_ok))
@makeB_itemlist_window.set_handler(:cancel, method(:on_B_cancel))
@makeB_ok_window = Window_MakeB_Ok.new(0, 120, 400, 480)
@makeB_ok_window.viewport = @viewport
@makeB_ok_window.equiphelp_window = @equiphelp_window
@makeB_ok_window.set_handler(:ok, method(:on_B_ok_ok))
@makeB_ok_window.set_handler(:cancel, method(:on_B_ok_cancel))
end
def command_A
@dummy_window.hide
@makeA_itemlist_window.show.activate
@makeA_itemlist_window.refresh
@makeA_itemlist_window.select(0)
@makeA_status_window.show
end
def command_B
@dummy_window.hide
@makeB_itemlist_window.show
#@makeB_itemlist_window.refresh
#@makeA_itemlist_window.select(0)
#@makeB_status_window.show
@makeB_ok_window.show.activate
@makeB_ok_window.refresh
@makeB_ok_window.select(0)
end
def command_C
@dummy_window.hide
@category_window.show.activate
@sell_window.show
@sell_window.unselect
@sell_window.refresh
end
def on_A_ok
@item = @makeA_itemlist_window.item
@makeA_itemlist_window.deactivate
@makeA_ok_window.show.activate
end
def on_A_cancel
@command_window.activate
@dummy_window.show
@makeA_itemlist_window.hide
@makeA_status_window.hide
@makeA_status_window.item = nil
@help_window.clear
@equiphelp_window.clear
end
def on_A_ok_ok
$game_party.lose_gold(@item.lv_price)
@item.lv_up
@makeA_itemlist_window.activate
@makeA_itemlist_window.refresh
@makeA_ok_window.hide
@gold_window.refresh
end
def on_A_ok_cancel
@makeA_itemlist_window.activate
@makeA_ok_window.hide
end
def on_B_ok
case @makeB_ok_window.kind
when 0
@makeB_ok_window.item = @makeB_itemlist_window.item
when 1
@makeB_ok_window.eq_gem(@makeB_itemlist_window.item)
@gold_window.refresh
when 2
end
on_B_cancel
end
def on_B_cancel
@makeB_ok_window.activate
@makeB_itemlist_window.clear
@help_window.clear
#@equiphelp_window.clear
end
def on_B_ok_ok
case @makeB_ok_window.kind
when 0
@makeB_ok_window.deactivate
@makeB_itemlist_window.activate
@makeB_itemlist_window.refresh("A")
when 1
@makeB_ok_window.deactivate
@makeB_itemlist_window.activate
@makeB_itemlist_window.refresh("B")
when 2
@makeB_ok_window.add_ds
@makeB_ok_window.activate
end
@gold_window.refresh
end
def on_B_ok_cancel
@command_window.activate
@dummy_window.show
@makeB_ok_window.item = nil
@makeB_ok_window.hide
@makeB_itemlist_window.hide
@help_window.clear
#@equiphelp_window.clear
end
def money
@gold_window.value
end
def currency_unit
@gold_window.currency_unit
end
def buying_price
@buy_window.price(@item)
end
def selling_price
@item.price / 2
end
end
class Scene_Shop < Scene_MenuBase
def start
super
create_help_window
create_equiphelp_window
create_gold_window
create_command_window
create_dummy_window
create_number_window
create_status_window
create_buy_window
create_category_window
create_sell_window
end
def create_command_window
@command_window = Window_ShopCommand.new(@gold_window.x, @purchase_only)
@command_window.viewport = @viewport
@command_window.y = @help_window.height
@command_window.equiphelp_window = @equiphelp_window
@command_window.set_handler(:buy, method(:command_buy))
@command_window.set_handler(:sell, method(:command_sell))
@command_window.set_handler(:cancel, method(:return_scene))
end
def create_number_window
wy = @dummy_window.y
wh = @dummy_window.height
@number_window = Window_ShopNumber.new(0, wy, wh)
@number_window.viewport = @viewport
@number_window.equiphelp_window = @equiphelp_window
@number_window.hide
@number_window.set_handler(:ok, method(:on_number_ok))
@number_window.set_handler(:cancel, method(:on_number_cancel))
end
def create_buy_window
wy = @dummy_window.y
wh = @dummy_window.height
@buy_window = Window_ShopBuy.new(0, wy, wh, @goods)
@buy_window.viewport = @viewport
@buy_window.help_window = @help_window
@buy_window.equiphelp_window = @equiphelp_window
@buy_window.status_window = @status_window
@buy_window.hide
@buy_window.set_handler(:ok, method(:on_buy_ok))
@buy_window.set_handler(:cancel, method(:on_buy_cancel))
end
def create_category_window
@category_window = Window_ItemCategory.new
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.equiphelp_window = @equiphelp_window
@category_window.y = @dummy_window.y
@category_window.hide.deactivate
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:on_category_cancel))
end
def create_sell_window
wy = @category_window.y + @category_window.height
wh = Graphics.height - wy
@sell_window = Window_ShopSell.new(0, wy, Graphics.width, wh)
@sell_window.viewport = @viewport
@sell_window.help_window = @help_window
@sell_window.equiphelp_window = @equiphelp_window
@sell_window.hide
@sell_window.set_handler(:ok, method(:on_sell_ok))
@sell_window.set_handler(:cancel, method(:on_sell_cancel))
@category_window.item_window = @sell_window
end
def del_on_buy_cancel
@command_window.activate
@dummy_window.show
@buy_window.hide
@status_window.hide
@status_window.item = nil
@help_window.clear
@equiphelp_window.clear
end
def del_on_sell_cancel
@sell_window.unselect
@category_window.activate
@status_window.item = nil
@help_window.clear
@equiphelp_window.clear
end
def do_buy(number)
$game_party.lose_gold(number * buying_price)
$game_party.add_shopitem(@item, number)
end
def do_sell(number)
$game_party.gain_gold(number * selling_price)
$game_party.lose_item(@item.id, number)
end
def max_buy
buying_price == 0 ? 99 : [99, money / buying_price].min
end
def max_sell
@item.is_item? ? $game_party.item_number(@item) : 1
end
end
class Scene_Battle < Scene_Base
def on_item_ok
@item = @item_window.item
BattleManager.actor.input.set_item(@item)
if !@item.need_selection?
@item_window.hide
next_command
elsif @item.for_opponent?
select_enemy_selection
else
select_actor_selection
end
$game_party.last_item.object = @item
end
end