Project1
标题:
整合装备升级和装备拓展脚本时出现了错误
[打印本页]
作者:
月下枯柳
时间:
2011-1-13 19:18
标题:
整合装备升级和装备拓展脚本时出现了错误
我想整合沉影不器的装备升级系统和装备拓展系统,可是使用的时候出现了问题,说是脚本“装备升级”第229行出现了NoMethodError 还说说什么未定义的方法 "base_id"
这是两段代码
装备升级
#=============================================================================
# (测试)vx复杂装备系统之 装备升级功能 by 沉影不器
#-----------------------------------------------------------------------------
# 此版本侧重于捕捉bug,欢迎反馈.
#=============================================================================
# 参数设定如下
#=============================================================================
module Game_Equip
## 能力升级基数(倍数)
BaseAbility = 0.2
## 每级价格提高基数(倍数)
BasePrice = 0.3
## 是否保证成功
UpGrade_Absoluteness = false
## 每级成功率基数(百分比,用于逐级下降)
BaseSucceed = 0.8
## 最大等级
MaxLevel = 10
## 需金钱基数(与本身价格的倍数)
GoldNeed = 0.8
## 需物品id => 数量
ItemsNeed = {21=>1, 22=>2}
end
#=============================================================================
# 复杂装备模块
#=============================================================================
module Game_Equip
#--------------------------------------------------------------------------
# ● 处理价格
#--------------------------------------------------------------------------
def self.setup_price(item, price)
item.price = $base_weapons[item.base_id].price
item.price += [(item.price * BasePrice).round, 1].max
item.price += price
end
#--------------------------------------------------------------------------
# ● 升级是否成功?
#--------------------------------------------------------------------------
def self.upgradesucceed?(lv)
return true if UpGrade_Absoluteness
new_lv = lv.nil? ? 1 : lv + 1
return false if new_lv > MaxLevel
return BaseSucceed**new_lv > rand(0)
end
#--------------------------------------------------------------------------
# ● 装备重生
# equip: 装备
#--------------------------------------------------------------------------
def self.reini(equip)
return if equip.nil?
result = Marshal.load(Marshal.dump(equip))
result.base_id = equip.id
setup_price(result, 0)
case result
when RPG::Weapon
result.id = $data_weapons.size
##result.name += result.id.to_s
$data_weapons.push result
when RPG::Armor
result.id = $data_armors.size
##result.name += result.id.to_s
$data_armors.push result
end
return result
end
#--------------------------------------------------------------------------
# ● 直接指定装备等级
# equip: 装备
# lv: 等级
#--------------------------------------------------------------------------
def self.level(equip, lv)
equip.level = 1 if equip.level.nil?
n = lv - equip.level
## 等级更低时返回
return if n < 0
n.times{equip = self.upgrade(equip, true)}
return equip
end
#--------------------------------------------------------------------------
# ● 装备升级
# equip: 装备
#--------------------------------------------------------------------------
def self.upgrade(equip, abs = false)
return unless abs || upgradesucceed?(equip.level)
case equip
when RPG::Weapon
return if equip.level == MaxLevel
equip.level += 1
if equip.level == 2
equip.name.concat "(Lv.2)"
elsif equip.level > 2
equip.name.sub!(/\(Lv\.([0-9]+)\)/) {"(Lv.#{equip.level})"}
end
equip.atk += [(equip.atk * BaseAbility).round, 1].max
setup_price(equip, 0)
when RPG::Armor
return if equip.level == MaxLevel
equip.level += 1
if equip.level == 2
equip.name.concat "(Lv.2)"
elsif equip.level > 2
equip.name.sub!(/\(Lv\.([0-9]+)\)/) {"(Lv.#{equip.level})"}
end
equip.def += [(equip.def * BaseAbility).round, 1].max
setup_price(equip, 0)
end
return equip
end
end
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
module RPG
class BaseItem
def initialize
@id = 0
@name = ""
@icon_index = 0
@description = ""
@note = ""
@base_id = 0
@level = 1
end
attr_accessor :id
attr_accessor :name
attr_accessor :icon_index
attr_accessor :description
attr_accessor :note
attr_accessor :base_id
attr_accessor :level
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def setup(actor_id)
actor = $data_actors[actor_id]
@actor_id = actor_id
@name = actor.name
@character_name = actor.character_name
@character_index = actor.character_index
@face_name = actor.face_name
@face_index = actor.face_index
@class_id = actor.class_id
@weapon_id = actor.weapon_id
@armor1_id = actor.armor1_id
@armor2_id = actor.armor2_id
@armor3_id = actor.armor3_id
@armor4_id = actor.armor4_id
@level = actor.initial_level
@exp_list = Array.new(101)
make_exp_list
@exp = @exp_list[@level]
@skills = []
for i in self.class.learnings
learn_skill(i.skill_id) if i.level <= @level
end
clear_extra_values
recover_all
## 生成新装备id
reset_equip_id
end
#--------------------------------------------------------------------------
# ● 装备重设
#--------------------------------------------------------------------------
def reset_equip_id
if @weapon_id != 0
item = Game_Equip.reini($base_weapons[@weapon_id])
unless item.nil?
$data_weapons.push item
@weapon_id = item.id
end
end
if @armor1_id != 0
if two_swords_style####two_hands_legal?
item = Game_Equip.reini($base_weapons[@armor1_id])
unless item.nil?
$data_weapons.push item
@armor1_id = item.id
end
else
item = Game_Equip.reini($base_armors[@armor1_id])
unless item.nil?
$data_armors.push item
@armor1_id = item.id
end
end
end
if @armor2_id != 0
item = $base_armors[@armor2_id]
unless item.nil?
item = Game_Equip.reini(item)
$data_armors.push item
@armor2_id = item.id
end
end
if @armor3_id != 0
item = $base_armors[@armor3_id]
unless item.nil?
item = Game_Equip.reini(item)
$data_armors.push item
@armor3_id = item.id
end
end
if @armor4_id != 0
item = $base_armors[@armor4_id]
unless item.nil?
item = Game_Equip.reini(item)
$data_armors.push item
@armor4_id = item.id
end
end
end
#--------------------------------------------------------------------------
# ● 判断是否可以装备
# item : 物品
# base : 是否读取母版数据
#--------------------------------------------------------------------------
def equippable?(item, base = true)
id = base ? item.base_id : item.id
if item.is_a?(RPG::Weapon)
return self.class.weapon_set.include?(id)
elsif item.is_a?(RPG::Armor)
return false if two_swords_style and item.kind == 0
return self.class.armor_set.include?(id)
end
return false
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 判断持有的物品
# item : 物品
# include_equip : 包括装备品
#--------------------------------------------------------------------------
def has_item_by_base_id?(item, include_equip = false)
for i in items
return true if i.base_id == item.id
end
if include_equip
for actor in members
for e in actor.equips
return true if e.base_id == item.id
end
end
end
return false
end
#--------------------------------------------------------------------------
# ● 获得物品
# item : 物品
# n : 个数
#--------------------------------------------------------------------------
def gain_reini_item(item, n, include_equip = false)
if n < 0
lose_item(item, -n, include_equip = false)
else
case item
when RPG::Item
number = item_number(item)
@items[item.id] = [[number + n, 0].max, 99].min
when RPG::Weapon
for i in 0...n
w = Game_Equip.reini(item)
@weapons[w.id] = 1
end
when RPG::Armor
for i in 0...n
a = Game_Equip.reini(item)
@armors[a.id] = 1
end
end
end
end
#--------------------------------------------------------------------------
# ● 减少物品 (减少)
# item : 物品
# n : 个数
# include_equip : 包括装备品
#--------------------------------------------------------------------------
def lose_reini_item(item, n, include_equip = false)
number = item_number(item)
case item
when RPG::Item
@items[item.id] = [[number - n, 0].max, 99].min
when RPG::Weapon
@weapons[item.id] = [[number - n, 0].max, 99].min
when RPG::Armor
@armors[item.id] = [[number - n, 0].max, 99].min
end
n -= number
if include_equip and n > 0
for actor in members
while n > 0 and actor.equips.include?(item)
actor.discard_equip(item)
n -= 1
end
end
end
end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● 敌人角色名称后的文字表
#--------------------------------------------------------------------------
LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
'K','L','M','N','O','P','Q','R','S','T',
'U','V','W','X','Y','Z']
#--------------------------------------------------------------------------
# ● 生成掉落物品队列
#--------------------------------------------------------------------------
def make_drop_items
drop_items = []
for enemy in dead_members
for di in [enemy.drop_item1, enemy.drop_item2]
next if di.kind == 0
next if rand(di.denominator) != 0
if di.kind == 1
drop_items.push($data_items[di.item_id])
elsif di.kind == 2
drop_items.push($base_weapons[di.weapon_id])
elsif di.kind == 3
drop_items.push($base_armors[di.armor_id])
end
end
end
return drop_items
end
end
#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# ● 计算操作的值
# operation : 操作 (0:增加 1:减少)
# operand_type : 运算域类型 (0:常量 1:变量)
# operand : 运算域 (数值为变量 ID)
#--------------------------------------------------------------------------
def operate_value(operation, operand_type, operand)
if operand_type == 0
value = operand
else
value = $game_variables[operand]
end
if operation == 1
value = -value
end
return value
end
#--------------------------------------------------------------------------
# ● 条件分歧
#--------------------------------------------------------------------------
def command_111
result = false
case @params[0]
when 0 # 开关
result = ($game_switches[@params[1]] == (@params[2] == 0))
when 1 # 变量
value1 = $game_variables[@params[1]]
if @params[2] == 0
value2 = @params[3]
else
value2 = $game_variables[@params[3]]
end
case @params[4]
when 0 # 相等
result = (value1 == value2)
when 1 # 大于等于
result = (value1 >= value2)
when 2 # 小于等于
result = (value1 <= value2)
when 3 # 大于
result = (value1 > value2)
when 4 # 小于
result = (value1 < value2)
when 5 # 不等于
result = (value1 != value2)
end
when 2 # 自我开关
if @original_event_id > 0
key = [@map_id, @original_event_id, @params[1]]
if @params[2] == 0
result = ($game_self_switches[key] == true)
else
result = ($game_self_switches[key] != true)
end
end
when 3 # 计时器
if $game_system.timer_working
sec = $game_system.timer / Graphics.frame_rate
if @params[2] == 0
result = (sec >= @params[1])
else
result = (sec <= @params[1])
end
end
when 4 # 角色
actor = $game_actors[@params[1]]
if actor != nil
case @params[2]
when 0 # 是同伴
result = ($game_party.members.include?(actor))
when 1 # 姓名
result = (actor.name == @params[3])
when 2 # 特技
result = (actor.skill_learn?($data_skills[@params[3]]))
when 3 # 武器
## 判断是否符合母版id
actor.weapons.each do |weapon|
if weapon.base_id == @params[3]
result = true
break
end
end
when 4 # 防具
## 判断是否符合母版id
actor.armors.each do |armor|
if armor.base_id == @params[3]
result = true
break
end
end
when 5 # 状态
result = (actor.state?(@params[3]))
end
end
when 5 # 敌方角色
enemy = $game_troop.members[@params[1]]
if enemy != nil
case @params[2]
when 0 # 出现
result = (enemy.exist?)
when 1 # 状态
result = (enemy.state?(@params[3]))
end
end
when 6 # 角色
character = get_character(@params[1])
if character != nil
result = (character.direction == @params[2])
end
when 7 # 金钱
if @params[2] == 0
result = ($game_party.gold >= @params[1])
else
result = ($game_party.gold <= @params[1])
end
when 8 # 物品
result = $game_party.has_item?($data_items[@params[1]])
when 9 # 武器
result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
when 10 # 防具
result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
when 11 # 按钮
result = Input.press?(@params[1])
when 12 # 脚本
result = eval(@params[1])
when 13 # 交通工具
result = ($game_player.vehicle_type == @params[1])
end
@branch[@indent] = result # 将判断结果放置在缓存中
if @branch[@indent] == true
@branch.delete(@indent)
return true
end
return command_skip
end
#--------------------------------------------------------------------------
# ● 计算装备操作的值
# operand_type : 运算域类型 (0:常量 1:变量)
# operand : 运算域 (数值为变量 ID)
#--------------------------------------------------------------------------
def opera_equip_value(operation, operand_type, operand)
if operand_type == 0
value = operand
else
value = $game_variables[operand]
end
return value
end
#--------------------------------------------------------------------------
# ● 增减武器
#--------------------------------------------------------------------------
def command_127
value = operate_value(@params[1], @params[2], @params[3])
if @params[1] == 0
$game_party.gain_reini_item($base_weapons[@params[0]], value.abs, @params[4])
else
$game_party.lose_reini_item($base_weapons[@params[0]], value.abs, @params[4])
end
return true
end
#--------------------------------------------------------------------------
# ● 增减防具
#--------------------------------------------------------------------------
def command_128
value = operate_value(@params[1], @params[2], @params[3])
if @params[1] == 0
$game_party.gain_reini_item($base_armors[@params[0]], value.abs, @params[4])
else
$game_party.lose_reini_item($base_armors[@params[0]], value.abs, @params[4])
end
return true
end
#--------------------------------------------------------------------------
# ● 更改装备
#--------------------------------------------------------------------------
def command_319
actor = $game_actors[@params[0]]
if actor != nil
actor.change_equip_by_id(@params[1], @params[2])
end
return true
end
end
#==============================================================================
# ■ Window_ShopBuy
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@data = []
for goods_item in @shop_goods
case goods_item[0]
when 0
item = $base_items[goods_item[1]]
when 1
item = $base_weapons[goods_item[1]]
when 2
item = $base_armors[goods_item[1]]
end
if item != nil
@data.push(item)
end
end
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
end
#==============================================================================
# ■ Window_ShopStatus
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● 描绘角色现在装备的能力值变化
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_parameter_change(actor, x, y)
return if @item.is_a?(RPG::Item)
enabled = actor.equippable?(@item, false)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x, y, 200, WLH, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = weaker_weapon(actor)
elsif actor.two_swords_style and @item.kind == 0
item1 = nil
else
item1 = actor.equips[1 + @item.kind]
end
if enabled
if @item.is_a?(RPG::Weapon)
atk1 = item1 == nil ? 0 : item1.atk
atk2 = @item == nil ? 0 : @item.atk
change = atk2 - atk1
else
def1 = item1 == nil ? 0 : item1.def
def2 = @item == nil ? 0 : @item.def
change = def2 - def1
end
self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
end
draw_item_name(item1, x, y + WLH, enabled)
end
end
#==============================================================================
# ■ Window_ScrEquip
#==============================================================================
class Window_ScrEquip < Window_Selectable
attr_accessor :equip_only
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@column_max = 1
@equip_only = true
refresh
end
#--------------------------------------------------------------------------
# ● 取得物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 显示是否可以使用物品
# item : 物品
#--------------------------------------------------------------------------
def enable?(item)
return true
end
#--------------------------------------------------------------------------
# ● 列表中包含的物品
# item : 物品
#--------------------------------------------------------------------------
def include?(item)
return true if item == nil
if @equip_only
return false if item.is_a? RPG::Item
else
return false unless item.is_a? RPG::Item
end
return true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.index = 0
@data = []
for item in $game_party.items
next unless include?(item)
@data.push(item)
end
@data.push(nil) if include?(nil)
@item_max = @data.size
create_contents
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
self.contents.clear_rect(rect)
item = @data[index]
if item != nil
number = $game_party.item_number(item)
rect.width -= 4
draw_item_name(item, rect.x, rect.y)
self.contents.draw_text(rect, sprintf(":%2d", number), 2)
end
end
#--------------------------------------------------------------------------
# ● 更新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end
#==============================================================================
# ■ Window_DestEquip #equip add clear items
#==============================================================================
class Window_DestEquip < Window_Base
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :equip
attr_reader :items
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
# width : 窗口的宽
# height : 窗口的高
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
clear
end
#--------------------------------------------------------------------------
# ● 添加物品
#--------------------------------------------------------------------------
def add(item, n = 1)
$game_party.lose_item(item, n)
if @index == -1
@equip = item
else
number = @items[item].to_i
@items[item] = [[number + n, 0].max, 99].min
end
@index += 1
draw_item(item, n)
end
#--------------------------------------------------------------------------
# ● 清除物品
#--------------------------------------------------------------------------
def clear
@equip = nil
@items = {}
@index = -1
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0,0,self.contents.width-16,WLH,"请放入升级装备:")
self.contents.draw_text(0,WLH*2,self.contents.width-16,WLH,"请放入炼制物品:")
end
#--------------------------------------------------------------------------
# ● 归还物品
#--------------------------------------------------------------------------
def revert
$game_party.gain_item(@equip, 1)
@items.each{|i,n| $game_party.gain_item(i, n)}
clear
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(item, n)
rect = Rect.new(4,WLH+WLH*@index,self.contents.width-8, WLH)
rect.y += WLH if @index >0
##self.contents.clear_rect(rect)
if item != nil
##rect.width -= 4
draw_item_name(item, rect.x, rect.y)
self.contents.draw_text(rect, sprintf(":%2d", n), 2)
end
end
#--------------------------------------------------------------------------
# ● 更新帮助文本
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(item == nil ? "" : item.description)
end
end
#==============================================================================
# ■ Window_EquipNumber
#==============================================================================
class Window_EquipNumber < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
# x : 窗口的 X 坐标
# y : 窗口的 Y 坐标
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, 272, 304)
@item = nil
@max = 1
@number = 1
end
#--------------------------------------------------------------------------
# ● 设置物品、最大个数
#--------------------------------------------------------------------------
def set(item, max)
@item = item
@max = max
@number = 1
refresh
end
#--------------------------------------------------------------------------
# ● 设置输入个数
#--------------------------------------------------------------------------
def number
return @number
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
y = 96
self.contents.clear
draw_item_name(@item, 0, y)
self.contents.font.color = normal_color
self.contents.draw_text(212-32, y, 20, WLH, "×")
self.contents.draw_text(248-32, y, 20, WLH, @number, 2)
self.cursor_rect.set(244-32, y, 28, WLH)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if self.active
last_number = @number
if Input.repeat?(Input::RIGHT) and @number < @max
@number += 1
end
if Input.repeat?(Input::LEFT) and @number > 1
@number -= 1
end
if Input.repeat?(Input::UP) and @number < @max
@number = [@number + 10, @max].min
end
if Input.repeat?(Input::DOWN) and @number > 1
@number = [@number - 10, 1].max
end
if @number != last_number
Sound.play_cursor
refresh
end
end
end
end
#==============================================================================
# ■ Scene_UpEquip
#==============================================================================
class Scene_UpEquip < Scene_Base
include Game_Equip
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_menu_background
create_command_window
@help_window = Window_Help.new
@gold_window = Window_Gold.new(96+16, 56)
@gold_window.opacity = 0
@scr_window = Window_ScrEquip.new(0,112,272,304)
@scr_window.active = true
@scr_window.help_window = @help_window
@dest_window = Window_DestEquip.new(272,56,272,304+56)
@number_window = Window_EquipNumber.new(0, 112)
@number_window.active = false
@number_window.visible = false
@result_window = Window_Base.new(56,56,384,80)
@result_window.active = false
@result_window.visible = false
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_menu_background
dispose_command_window
@help_window.dispose
@gold_window.dispose
@scr_window.dispose
@dest_window.dispose
@number_window.dispose
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@command_window.update
@gold_window.update
@scr_window.update
@dest_window.update
@number_window.update
if @command_window.active
@scr_window.contents_opacity = 128
@command_window.contents_opacity = 255
update_command_selection
elsif @scr_window.active
@scr_window.contents_opacity = 255
@command_window.contents_opacity = 128
update_item_selection
elsif @number_window.active
update_number_input
elsif @result_window.active
update_result_window
end
end
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
s1 = "升级"
s2 = "退出"
@command_window = Window_Command.new(272, [s1, s2], 4, 0, 8)
@command_window.y = 56
@command_window.active = false
@command_window.contents_opacity = 128
end
#--------------------------------------------------------------------------
# ● 释放指令窗口
#--------------------------------------------------------------------------
def dispose_command_window
@command_window.dispose
end
#--------------------------------------------------------------------------
# ● 是否满足装备升级条件?
#--------------------------------------------------------------------------
def upgradeable?(equip)
return false if equip.nil?
if equip.is_a?(RPG::Weapon) || equip.is_a?(RPG::Armor) and equip.level.nil?
equip.level = 1
end
price = (equip.price * (GoldNeed ** equip.level)).round
return false if $game_party.gold < price
ItemsNeed.each do |id,n|
return false if @dest_window.items[$data_items[id]].nil?
return false if @dest_window.items[$data_items[id]] < n
end
## 扣钱
$game_party.lose_gold(price)
return true
end
#--------------------------------------------------------------------------
# ● 显示结果(包括处理金钱物品)
#--------------------------------------------------------------------------
def show_result
@result_window.active = true
@result_window.visible = true
###@scr_window.refresh
unless upgradeable?(@dest_window.equip)
@result_window.contents.clear
@result_window.contents.draw_text(0,0,352,24,"材料或金钱不足!", 1)
@result_window.contents.draw_text(0,24,352,24,"物品已自动归还.", 1)
@dest_window.revert
Sound.play_actor_collapse
## 直接返回
return
end
msg = Game_Equip.upgrade(@dest_window.equip)
case msg
when RPG::Weapon
s = "攻击力提升到(#{msg.atk})"
@result_window.contents.clear
@result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
@result_window.contents.draw_text(4, 24, 352-4, 24, s)
$game_party.gain_item(msg, 1)
Sound.play_shop
when RPG::Armor
s = "防御力提升到(#{msg.def})"
@result_window.contents.clear
@result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
@result_window.contents.draw_text(4, 24, 352-4, 24, s)
$game_party.gain_item(msg, 1)
Sound.play_shop
else
@result_window.contents.clear
@result_window.contents.draw_text(0,0,352,24,"升级失败, 物品已损坏!", 1)
Sound.play_actor_collapse
end
@dest_window.clear
end
#--------------------------------------------------------------------------
# ● 更新帮助文本
#--------------------------------------------------------------------------
def update_help(text)
@help_window.set_text(text)
end
#--------------------------------------------------------------------------
# ● 更新指令窗口
#--------------------------------------------------------------------------
def update_command_selection
case @command_window.index
when 0
update_help("确定键执行装备升级")
when 1
update_help("退出升级界面")
end
if Input.trigger?(Input::B)
## 重来
Sound.play_cancel
@scr_window.active = true
@command_window.active = false
elsif Input.trigger?(Input::C)
case @command_window.index
when 0 # 升级
Sound.play_decision
@command_window.active = false
@scr_window.active = false
######### 显示升级结果,归还物品
show_result
when 1 # 退出
Sound.play_decision
@dest_window.revert
$scene = Scene_Map.new
end
end
end
#--------------------------------------------------------------------------
# ● 更新选择物品
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@command_window.active = true
@scr_window.active = false
###@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @scr_window.item
number = $game_party.item_number(@item)
if @item == nil or number == 0
Sound.play_buzzer
else
Sound.play_decision
##### 传递物品给容器栏
if number > 1
@scr_window.active = false
@number_window.set(@item, number)
@number_window.active = true
@number_window.visible = true
else
Sound.play_shop
@dest_window.add(@scr_window.item, 1)
@scr_window.equip_only = false
@scr_window.refresh
end
end
end
end
#--------------------------------------------------------------------------
# ● 更新输入个数
#--------------------------------------------------------------------------
def update_number_input
if Input.trigger?(Input::B)
cancel_number_input
elsif Input.trigger?(Input::C)
decide_number_input
end
end
#--------------------------------------------------------------------------
# ● 更新结果窗体
#--------------------------------------------------------------------------
def update_result_window
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
Sound.play_decision
@scr_window.equip_only = true
@scr_window.refresh
@scr_window.active = true
@result_window.active = false
@result_window.visible = false
end
end
#--------------------------------------------------------------------------
# ● 取消输入个数
#--------------------------------------------------------------------------
def cancel_number_input
Sound.play_cancel
@number_window.active = false
@number_window.visible = false
@scr_window.active = true
@scr_window.visible = true
end
#--------------------------------------------------------------------------
# ● 确定输入个数
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
@dest_window.add(@item, @number_window.number)
@scr_window.equip_only = false
@scr_window.refresh
@scr_window.active = true
end
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● 写入存档数据
# file : 写入文件用对象 (已经打开)
#--------------------------------------------------------------------------
def write_save_data(file)
characters = []
for actor in $game_party.members
characters.push([actor.character_name, actor.character_index])
end
$game_system.save_count += 1
$game_system.version_id = $data_system.version_id
@last_bgm = RPG::BGM::last
@last_bgs = RPG::BGS::last
Marshal.dump(characters, file)
Marshal.dump(Graphics.frame_count, file)
Marshal.dump(@last_bgm, file)
Marshal.dump(@last_bgs, file)
Marshal.dump($game_system, file)
Marshal.dump($game_message, file)
Marshal.dump($game_switches, file)
Marshal.dump($game_variables, file)
Marshal.dump($game_self_switches, file)
Marshal.dump($game_actors, file)
Marshal.dump($game_party, file)
Marshal.dump($game_troop, file)
Marshal.dump($game_map, file)
Marshal.dump($game_player, file)
Marshal.dump($data_weapons, file)
Marshal.dump($data_armors, file)
end
#--------------------------------------------------------------------------
# ● 读取存档数据
# file : 读取文件用对象 (已经打开)
#--------------------------------------------------------------------------
def read_save_data(file)
characters = Marshal.load(file)
Graphics.frame_count = Marshal.load(file)
@last_bgm = Marshal.load(file)
@last_bgs = Marshal.load(file)
$game_system = Marshal.load(file)
$game_message = Marshal.load(file)
$game_switches = Marshal.load(file)
$game_variables = Marshal.load(file)
$game_self_switches = Marshal.load(file)
$game_actors = Marshal.load(file)
$game_party = Marshal.load(file)
$game_troop = Marshal.load(file)
$game_map = Marshal.load(file)
$game_player = Marshal.load(file)
$data_weapons = Marshal.load(file)
$data_armors = Marshal.load(file)
if $game_system.version_id != $data_system.version_id
$game_map.setup($game_map.map_id)
$game_player.center($game_player.x, $game_player.y)
end
end
end
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop < Scene_Base
#--------------------------------------------------------------------------
# ● 确定输入个数
#--------------------------------------------------------------------------
def decide_number_input
Sound.play_shop
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 购买
$game_party.lose_gold(@number_window.number * @item.price)
$game_party.gain_reini_item(@item, @number_window.number)
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
$game_party.gain_gold(@number_window.number * (@item.price / 2))
$game_party.lose_reini_item(@item, @number_window.number)
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
end
end
#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
#--------------------------------------------------------------------------
# ● 载入数据库
#--------------------------------------------------------------------------
def load_database
$data_actors = load_data("Data/Actors.rvdata")
$data_classes = load_data("Data/Classes.rvdata")
$data_skills = load_data("Data/Skills.rvdata")
$data_items = load_data("Data/Items.rvdata")
$base_weapons = load_data("Data/Weapons.rvdata")
$base_armors = load_data("Data/Armors.rvdata")
$data_enemies = load_data("Data/Enemies.rvdata")
$data_troops = load_data("Data/Troops.rvdata")
$data_states = load_data("Data/States.rvdata")
$data_animations = load_data("Data/Animations.rvdata")
$data_common_events = load_data("Data/CommonEvents.rvdata")
$data_system = load_data("Data/System.rvdata")
$data_areas = load_data("Data/Areas.rvdata")
$data_weapons = [nil]
$data_armors = [nil]
end
#--------------------------------------------------------------------------
# ● 载入战斗测试用的数据库
#--------------------------------------------------------------------------
def load_bt_database
$data_actors = load_data("Data/BT_Actors.rvdata")
$data_classes = load_data("Data/BT_Classes.rvdata")
$data_skills = load_data("Data/BT_Skills.rvdata")
$data_items = load_data("Data/BT_Items.rvdata")
$data_weapons = load_data("Data/BT_Weapons.rvdata")
$data_armors = load_data("Data/BT_Armors.rvdata")
$data_enemies = load_data("Data/BT_Enemies.rvdata")
$data_troops = load_data("Data/BT_Troops.rvdata")
$data_states = load_data("Data/BT_States.rvdata")
$data_animations = load_data("Data/BT_Animations.rvdata")
$data_common_events = load_data("Data/BT_CommonEvents.rvdata")
$data_system = load_data("Data/BT_System.rvdata")
$base_weapons = $data_weapons
$base_armors = $data_armors
end
end
复制代码
装备拓展
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ 装備拡張 - KGC_EquipExtension ◆ VX ◆
#_/ ◇ Last update : 2008/11/24 ◇
#_/----------------------------------------------------------------------------
#_/ 装備関連の機能を拡張します。
#_/============================================================================
#_/ 【メニュー】≪拡張装備画面≫ より下に導入してください。
#_/ 【スキル】≪パッシブスキル≫ より上に導入してください。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================
module KGC
module EquipExtension
# ◆ 拡張装備種別
# 先頭から順に 4, 5, 6, ... が割り当てられる。
EXTRA_EQUIP_KIND = ["足", "守护"]
# ◆ 装備箇所リスト
# 武器の後に、ここで指定した順番で並ぶ。
# ※ 装備箇所が最低一つないと、二刀流がバグる可能性があります。
# ** 装備種別一覧 **
# 0..盾 1..頭 2..身体 3..装飾品 4~..↑で定義
EQUIP_TYPE = [0, 1, 2, 4, 3, 5]
# ◆ EP (Equip Point) 制を使用する
# true : EP で装備品を制限。
# false : 通常の装備システム。
USE_EP_SYSTEM = true
# ◆ EP の名前
VOCAB_EP = "EP"
# ◆ EP の名前 (略)
VOCAB_EP_A = "E"
# ◆ ステータス画面に EP を表示する
SHOW_STATUS_EP = true
# ◆ 消費 EP 既定値
# 消費 EP が指定されていない装備品で使用。
DEFAULT_EP_COST = 1
# ◆ 消費 EP 0 は表示しない
HIDE_ZERO_EP_COST = true
# ◆ EP 上限
EP_MAX = 20
# ◆ EP 下限
EP_MIN = 10
# ◆ 最大 EP 算出式
# level..アクターのレベル
# 自動的に整数変換されるので、結果が小数になってもOK。
EP_CALC_EXP = "level * 0.3 + 4"
# ◆ アクター毎の最大 EP 算出式
PERSONAL_EP_CALC_EXP = []
# ここから下に、アクターごとの最大 EP を
# PERSONAL_EP_CALC_EXP[アクター ID] = "計算式"
# という書式で指定。
# 計算式は EP_CALC_EXP と同様の書式。
# 指定しなかったアクターは EP_CALC_EXP を使用。
# <例> ラルフだけ優遇
# PERSONAL_EP_CALC_EXP[1] = "level * 0.5 + 5"
# ◆ 消費 EP 値の色 (アイテム名の末尾に付く数値)
# 数値 : \C[n] と同じ色。
# Color : 指定した色。 ( Color.new(128, 255, 255) など )
EP_COST_COLOR = 23
# ◆ EP ゲージの開始色
EP_GAUGE_START_COLOR = 28
# ◆ EP ゲージの終了色
EP_GAUGE_END_COLOR = 29
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$imported = {} if $imported == nil
$imported["EquipExtension"] = true
module KGC::EquipExtension
# EP 制を使用しない場合の設定
unless USE_EP_SYSTEM
SHOW_STATUS_EP = false
HIDE_ZERO_EP_COST = true
end
# 正規表現
module Regexp
# ベースアイテム
module BaseItem
# 消費 EP
EP_COST = /<EP\s*(\d+)>/i
# 装備タイプ
EQUIP_TYPE = /<(?:EQUIP_TYPE|装備タイプ)\s*(\d+(?:\s*,\s*\d+)*)>/
end
# 防具
module Armor
# 装備種別
EQUIP_KIND = /<(?:EQUIP_KIND|装备类别)\s*(.+)>/i
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# □ KGC::Commands
#==============================================================================
module KGC
module Commands
module_function
#--------------------------------------------------------------------------
# ○ アクターの装備を修復
#--------------------------------------------------------------------------
def restore_equip
(1...$data_actors.size).each { |i|
actor = $game_actors[i]
actor.restore_equip
}
end
#--------------------------------------------------------------------------
# ○ アクターの装備タイプを設定
# actor_id : アクター ID
# equip_type : 装備タイプ
#--------------------------------------------------------------------------
def set_actor_equip_type(actor_id, equip_type = nil)
actor = $game_actors[actor_id]
return if actor == nil
actor.equip_type = equip_type
end
#--------------------------------------------------------------------------
# ○ アクターの MaxEP 補正値の取得
# actor_id : アクター ID
# variable_id : 取得した値を代入する変数の ID
#--------------------------------------------------------------------------
def get_actor_own_ep(actor_id, variable_id = 0)
value = $game_actors[actor_id].maxep_plus
$game_variables[variable_id] = value if variable_id > 0
return value
end
#--------------------------------------------------------------------------
# ○ アクターの MaxEP 補正値の変更
# actor_id : アクター ID
# value : MaxEP 補正値
#--------------------------------------------------------------------------
def set_actor_own_ep(actor_id, value)
$game_actors[actor_id].maxep_plus = value
end
#--------------------------------------------------------------------------
# ○ アクターの MaxEP 補正値の増加
# actor_id : アクター ID
# value : 増加量
#--------------------------------------------------------------------------
def gain_actor_ep(actor_id, value)
$game_actors[actor_id].maxep_plus += value
end
#--------------------------------------------------------------------------
# ○ アクターの装備を変更
# actor_id : アクター ID
# index : 装備部位 (0~)
# item_id : 武器 or 防具 ID (0 で解除)
# force_gain : 未所持なら取得 (true or false)
#--------------------------------------------------------------------------
def change_actor_equipment(actor_id, index, item_id, force_gain = false)
actor = $game_actors[actor_id]
return if actor == nil
item = (index == 0 ? $data_weapons[item_id] : $data_armors[item_id])
if actor.two_swords_style && index == 1
item = $data_weapons[item_id]
end
if force_gain && $game_party.item_number(item) == 0
$game_party.gain_item(item, 1)
end
actor.change_equip_by_id(index, item_id)
end
end
end
class Game_Interpreter
include KGC::Commands
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Vocab
#==============================================================================
module Vocab
# EP
def self.ep
return KGC::EquipExtension::VOCAB_EP
end
# EP (略)
def self.ep_a
return KGC::EquipExtension::VOCAB_EP_A
end
# 拡張防具欄
def self.extra_armor(index)
return KGC::EquipExtension::EXTRA_EQUIP_KIND[index]
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::BaseItem
#==============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# ○ 装備拡張のキャッシュを作成
#--------------------------------------------------------------------------
def create_equip_extension_cache
@__ep_cost = KGC::EquipExtension::DEFAULT_EP_COST
@__equip_type = []
self.note.each_line { |line|
case line
when KGC::EquipExtension::Regexp::BaseItem::EP_COST
# 消費 EP
@__ep_cost = $1.to_i
when KGC::EquipExtension::Regexp::BaseItem::EQUIP_TYPE
# 装備タイプ
@__equip_type = []
$1.scan(/\d+/) { |num|
@__equip_type << num.to_i
}
end
}
# EP 制を使用しない場合は消費 EP = 0
@__ep_cost = 0 unless KGC::EquipExtension::USE_EP_SYSTEM
end
#--------------------------------------------------------------------------
# ○ 消費 EP
#--------------------------------------------------------------------------
def ep_cost
create_equip_extension_cache if @__ep_cost == nil
return @__ep_cost
end
#--------------------------------------------------------------------------
# ○ 装備タイプ
#--------------------------------------------------------------------------
def equip_type
create_equip_extension_cache if @__equip_type == nil
return @__equip_type
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ RPG::Armor
#==============================================================================
class RPG::Armor < RPG::BaseItem
#--------------------------------------------------------------------------
# ○ 装備拡張のキャッシュを作成
#--------------------------------------------------------------------------
def create_equip_extension_cache
super
@__kind = -1
self.note.each_line { |line|
if line =~ KGC::EquipExtension::Regexp::Armor::EQUIP_KIND
# 装備種別
e_index = KGC::EquipExtension::EXTRA_EQUIP_KIND.index($1)
next if e_index == nil
@__kind = e_index + 4
end
}
end
unless $@
#--------------------------------------------------------------------------
# ○ 種別
#--------------------------------------------------------------------------
alias kind_KGC_EquipExtension kind
def kind
create_equip_extension_cache if @__kind == nil
return (@__kind == -1 ? kind_KGC_EquipExtension : @__kind)
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_writer :equip_type # 装備タイプ
attr_writer :maxep_plus # MaxEP 補正値
#--------------------------------------------------------------------------
# ● セットアップ
# actor_id : アクター ID
#--------------------------------------------------------------------------
alias setup_KGC_EquipExtension setup
def setup(actor_id)
actor = $data_actors[actor_id]
@extra_armor_id = []
setup_KGC_EquipExtension(actor_id)
@__last_equip_type = nil
restore_equip
end
#--------------------------------------------------------------------------
# ○ MaxEP 取得
#--------------------------------------------------------------------------
def maxep
calc_exp = KGC::EquipExtension::PERSONAL_EP_CALC_EXP[self.id]
if calc_exp == nil
calc_exp = KGC::EquipExtension::EP_CALC_EXP
end
n = Integer(eval(calc_exp)) + maxep_plus
return [[n, ep_limit].min, KGC::EquipExtension::EP_MIN].max
end
#--------------------------------------------------------------------------
# ○ EP 取得
#--------------------------------------------------------------------------
def ep
n = 0
equips.compact.each { |item| n += item.ep_cost }
return [maxep - n, 0].max
end
#--------------------------------------------------------------------------
# ○ EP 上限取得
#--------------------------------------------------------------------------
def ep_limit
return KGC::EquipExtension::EP_MAX
end
#--------------------------------------------------------------------------
# ○ MaxEP 補正値取得
#--------------------------------------------------------------------------
def maxep_plus
@maxep_plus = 0 if @maxep_plus == nil
return @maxep_plus
end
#--------------------------------------------------------------------------
# ○ 防具欄の取得
#--------------------------------------------------------------------------
def equip_type
if @equip_type.is_a?(Array)
return @equip_type
else
return KGC::EquipExtension::EQUIP_TYPE
end
end
#--------------------------------------------------------------------------
# ○ 防具欄の数
#--------------------------------------------------------------------------
def armor_number
return equip_type.size
end
#--------------------------------------------------------------------------
# ○ 拡張防具欄の数
#--------------------------------------------------------------------------
def extra_armor_number
return [armor_number - 4, 0].max
end
#--------------------------------------------------------------------------
# ○ 防具 ID リストの取得
#--------------------------------------------------------------------------
def extra_armor_id
@extra_armor_id = [] if @extra_armor_id == nil
return @extra_armor_id
end
#--------------------------------------------------------------------------
# ● 防具オブジェクトの配列取得
#--------------------------------------------------------------------------
alias armors_KGC_EquipExtension armors
def armors
result = armors_KGC_EquipExtension
# 5番目以降の防具を追加
extra_armor_number.times { |i|
armor_id = extra_armor_id[i]
result << (armor_id == nil ? nil : $data_armors[armor_id])
}
return result
end
#--------------------------------------------------------------------------
# ● 装備の変更 (オブジェクトで指定)
# equip_type : 装備部位
# item : 武器 or 防具 (nil なら装備解除)
# test : テストフラグ (戦闘テスト、または装備画面での一時装備)
#--------------------------------------------------------------------------
alias change_equip_KGC_EquipExtension change_equip
def change_equip(equip_type, item, test = false)
n = (item != nil ? $game_party.item_number(item) : 0)
change_equip_KGC_EquipExtension(equip_type, item, test)
# 拡張防具欄がある場合のみ
if extra_armor_number > 0 && (item == nil || n > 0)
item_id = item == nil ? 0 : item.id
case equip_type
when 5..armor_number # 拡張防具欄
@extra_armor_id = [] if @extra_armor_id == nil
@extra_armor_id[equip_type - 5] = item_id
end
end
restore_battle_skill if $imported["SkillCPSystem"]
end
#--------------------------------------------------------------------------
# ● 装備の破棄
# item : 破棄する武器 or 防具
# 武器/防具の増減で「装備品も含める」のとき使用する。
#--------------------------------------------------------------------------
alias discard_equip_KGC_EquipExtension discard_equip
def discard_equip(item)
last_armors = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
discard_equip_KGC_EquipExtension(item)
curr_armors = [@armor1_id, @armor2_id, @armor3_id, @armor4_id]
return unless item.is_a?(RPG::Armor) # 防具でない
return if last_armors != curr_armors # 既に破棄された
# 拡張防具欄を検索
extra_armor_number.times { |i|
if extra_armor_id[i] == item.id
@extra_armor_id[i] = 0
break
end
}
restore_battle_skill if $imported["SkillCPSystem"]
end
#--------------------------------------------------------------------------
# ● 職業 ID の変更
# class_id : 新しい職業 ID
#--------------------------------------------------------------------------
alias class_id_equal_KGC_EquipExtension class_id=
def class_id=(class_id)
class_id_equal_KGC_EquipExtension(class_id)
return if extra_armor_number == 0 # 拡張防具欄がない
# 装備できない拡張防具を外す
for i in 5..armor_number
change_equip(i, nil) unless equippable?(equips[i])
end
end
#--------------------------------------------------------------------------
# ○ EP 条件クリア判定
# equip_type : 装備部位
# item : 武器 or 防具
#--------------------------------------------------------------------------
def ep_condition_clear?(equip_type, item)
return true if item == nil # nil は解除なので OK
curr_item = equips[equip_type]
offset = (curr_item != nil ? curr_item.ep_cost : 0)
return false if self.ep < (item.ep_cost - offset) # EP 不足
return true
end
#--------------------------------------------------------------------------
# ○ 装備を修復
#--------------------------------------------------------------------------
def restore_equip
return if @__last_equip_type == equip_type
# 以前の装備品・パラメータを退避
last_equips = equips
last_hp = self.hp
last_mp = self.mp
if $imported["SkillCPSystem"]
last_battle_skill_ids = battle_skill_ids.clone
end
# 全装備解除
last_equips.each_index { |i| change_equip(i, nil) }
# 装備品・パラメータを復元
last_equips.compact.each { |item| equip_legal_slot(item) }
self.hp = last_hp
self.mp = last_mp
if $imported["SkillCPSystem"]
last_battle_skill_ids.each_with_index { |s, i| set_battle_skill(i, s) }
end
@__last_equip_type = equip_type.clone
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ○ 装備品を正しい箇所にセット
# item : 武器 or 防具
#--------------------------------------------------------------------------
def equip_legal_slot(item)
if item.is_a?(RPG::Weapon)
if @weapon_id == 0
# 武器 1
change_equip(0, item)
elsif two_swords_style && @armor1_id == 0
# 武器 2 (二刀流の場合)
change_equip(1, item)
end
elsif item.is_a?(RPG::Armor)
if !two_swords_style && item.kind == equip_type[0] && @armor1_id == 0
# 先頭の防具 (二刀流でない場合)
change_equip(1, item)
else
# 装備箇所リストを作成
list = [-1, @armor2_id, @armor3_id, @armor4_id]
list += extra_armor_id
# 正しい、かつ空いている箇所にセット
equip_type.each_with_index { |kind, i|
if kind == item.kind && list[i] == 0
change_equip(i + 1, item)
break
end
}
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ○ EP の文字色を取得
# actor : アクター
#--------------------------------------------------------------------------
def ep_color(actor)
return knockout_color if actor.maxep > 0 && actor.ep == 0
return normal_color
end
#--------------------------------------------------------------------------
# ○ EP ゲージの色 1 の取得
#--------------------------------------------------------------------------
def ep_gauge_color1
color = KGC::EquipExtension::EP_GAUGE_START_COLOR
return (color.is_a?(Integer) ? text_color(color) : color)
end
#--------------------------------------------------------------------------
# ○ EP ゲージの色 2 の取得
#--------------------------------------------------------------------------
def ep_gauge_color2
color = KGC::EquipExtension::EP_GAUGE_END_COLOR
return (color.is_a?(Integer) ? text_color(color) : color)
end
#--------------------------------------------------------------------------
# ○ EP の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 幅
#--------------------------------------------------------------------------
def draw_actor_ep(actor, x, y, width = 120)
draw_actor_ep_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, Vocab::ep_a)
self.contents.font.color = ep_color(actor)
xr = x + width
if width < 120
self.contents.draw_text(xr - 40, y, 40, WLH, actor.ep, 2)
else
self.contents.draw_text(xr - 90, y, 40, WLH, actor.ep, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 50, y, 10, WLH, "/", 2)
self.contents.draw_text(xr - 40, y, 40, WLH, actor.maxep, 2)
end
self.contents.font.color = normal_color
end
#--------------------------------------------------------------------------
# ○ EP ゲージの描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
# width : 幅
#--------------------------------------------------------------------------
def draw_actor_ep_gauge(actor, x, y, width = 120)
gw = width * actor.ep / [actor.maxep, 1].max
gc1 = ep_gauge_color1
gc2 = ep_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ○ 消費 EP の描画
# item : 武器 or 防具
# rect : 描画する領域
# enabled : 許可状態
#--------------------------------------------------------------------------
def draw_equipment_ep_cost(item, rect, enabled = true)
return if item == nil
# 消費 EP 0 を表示しない場合
return if KGC::EquipExtension::HIDE_ZERO_EP_COST && item.ep_cost == 0
color = KGC::EquipExtension::EP_COST_COLOR
self.contents.font.color = (color.is_a?(Integer) ?
text_color(color) : color)
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(rect, item.ep_cost, 2)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Equip
#==============================================================================
class Window_Equip < Window_Selectable
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@data = @actor.equips.clone
@item_max = [@data.size, @actor.armor_number + 1].min
create_contents
# 装備箇所を描画
self.contents.font.color = system_color
if @actor.two_swords_style
self.contents.draw_text(4, 0, 92, WLH, Vocab::weapon1)
self.contents.draw_text(4, WLH * 1, 92, WLH, Vocab::weapon2)
else
self.contents.draw_text(4, 0, 92, WLH, Vocab::weapon)
name = armor_slot_name(@actor.equip_type[0])
self.contents.draw_text(4, WLH * 1, 92, WLH, name)
end
for i in
[email protected]
_number
name = armor_slot_name(@actor.equip_type[i])
self.contents.draw_text(4, WLH * (i + 1), 92, WLH, name)
end
# 装備品を描画
rect = Rect.new(92, 0, self.width - 128, WLH)
@item_max.times { |i|
rect.y = WLH * i
draw_item_name(@data[i], rect.x, rect.y)
draw_equipment_ep_cost(@data[i], rect)
}
end
#--------------------------------------------------------------------------
# ○ 防具欄の名称を取得
# kind : 種別
#--------------------------------------------------------------------------
def armor_slot_name(kind)
case kind
when 0..3
return eval("Vocab.armor#{kind + 1}")
else
return Vocab.extra_armor(kind - 4)
end
end
unless $imported["ExtendedEquipScene"]
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ後ろに移動
#--------------------------------------------------------------------------
def cursor_pagedown
return if Input.repeat?(Input::R)
super
end
#--------------------------------------------------------------------------
# ● カーソルを 1 ページ前に移動
#--------------------------------------------------------------------------
def cursor_pageup
return if Input.repeat?(Input::L)
super
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
return unless self.active
if Input.repeat?(Input::RIGHT)
cursor_pagedown
elsif Input.repeat?(Input::LEFT)
cursor_pageup
end
end
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_EquipItem
#==============================================================================
class Window_EquipItem < Window_Item
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
@item_enabled = []
super
@data.each { |item| @item_enabled << enable?(item) }
end
#--------------------------------------------------------------------------
# ● アイテムをリストに含めるかどうか
# item : アイテム
#--------------------------------------------------------------------------
def include?(item)
return true if item == nil
if @equip_type == 0
return false unless item.is_a?(RPG::Weapon)
else
return false unless item.is_a?(RPG::Armor)
return false unless item.kind == @equip_type - 1
end
return @actor.equippable?(item)
end
#--------------------------------------------------------------------------
# ● アイテムを許可状態で表示するかどうか
# item : アイテム
#--------------------------------------------------------------------------
def enable?(item)
return false unless @actor.equippable?(item) # 装備不可
return false unless @actor.ep_condition_clear?(@equip_type, item) # EP 不足
return true
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
super(index)
rect = item_rect(index)
item = @data[index]
# 個数表示分の幅を削る
cw = self.contents.text_size(sprintf(":%2d", 0)).width
rect.width -= cw + 4
draw_equipment_ep_cost(item, rect, enable?(item))
end
#--------------------------------------------------------------------------
# ○ 簡易リフレッシュ
# equip_type : 装備部位
#--------------------------------------------------------------------------
def simple_refresh(equip_type)
# 一時的に装備部位を変更
last_equip_type = @equip_type
@equip_type = equip_type
@data.each_with_index { |item, i|
# 許可状態が変化した項目のみ再描画
if enable?(item) != @item_enabled[i]
draw_item(i)
@item_enabled[i] = enable?(item)
end
}
# 装備部位を戻す
@equip_type = last_equip_type
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_EquipStatus
#==============================================================================
class Window_EquipStatus < Window_Base
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
alias refresh_KGC_EquipExtension refresh
def refresh
refresh_KGC_EquipExtension
draw_actor_ep(@actor, 120, 0, 56) if KGC::EquipExtension::USE_EP_SYSTEM
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_Status
#==============================================================================
class Window_Status < Window_Base
if KGC::EquipExtension::SHOW_STATUS_EP
#--------------------------------------------------------------------------
# ● 基本情報の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
alias draw_basic_info_KGC_EquipExtension draw_basic_info
def draw_basic_info(x, y)
draw_basic_info_KGC_EquipExtension(x, y)
draw_actor_ep(@actor, x + 160, y + WLH * 4)
end
end
#--------------------------------------------------------------------------
# ● 装備品の描画
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_equipments(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, WLH, Vocab::equip)
item_number = [@actor.equips.size, @actor.armor_number + 1].min
item_number.times { |i|
draw_item_name(@actor.equips[i], x + 16, y + WLH * (i + 1))
}
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Window_ShopStatus
#==============================================================================
class Window_ShopStatus < Window_Base
#--------------------------------------------------------------------------
# ● アクターの現装備と能力値変化の描画
# actor : アクター
# x : 描画先 X 座標
# y : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_parameter_change(actor, x, y)
return if @item.is_a?(RPG::Item)
enabled = actor.equippable?(@item)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x, y, 200, WLH, actor.name)
if @item.is_a?(RPG::Weapon)
item1 = weaker_weapon(actor)
elsif actor.two_swords_style and @item.kind == 0
item1 = nil
else
index = actor.equip_type.index(@item.kind)
item1 = (index != nil ? actor.equips[1 + index] : nil)
end
if enabled
if @item.is_a?(RPG::Weapon)
atk1 = item1 == nil ? 0 : item1.atk
atk2 = @item == nil ? 0 : @item.atk
change = atk2 - atk1
else
def1 = item1 == nil ? 0 : item1.def
def2 = @item == nil ? 0 : @item.def
change = def2 - def1
end
self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
end
draw_item_name(item1, x, y + WLH, enabled)
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_Equip
#==============================================================================
class Scene_Equip < Scene_Base
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
EQUIP_TYPE_MAX = KGC::EquipExtension::EXTRA_EQUIP_KIND.size + 5
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# actor_index : アクターインデックス
# equip_index : 装備インデックス
#--------------------------------------------------------------------------
alias initialize_KGC_EquipExtension initialize
def initialize(actor_index = 0, equip_index = 0)
initialize_KGC_EquipExtension(actor_index, equip_index)
unit = ($imported["LargeParty"] ?
$game_party.all_members : $game_party.members)
actor = unit[actor_index]
@equip_index = [@equip_index, actor.armor_number].min
end
#--------------------------------------------------------------------------
# ● アイテムウィンドウの作成
#--------------------------------------------------------------------------
alias create_item_windows_KGC_EquipExtension create_item_windows
def create_item_windows
create_item_windows_KGC_EquipExtension
kind = equip_kind(@equip_index)
EQUIP_TYPE_MAX.times { |i|
@item_windows[i].visible = (kind == i)
}
end
#--------------------------------------------------------------------------
# ● アイテムウィンドウの更新
#--------------------------------------------------------------------------
def update_item_windows
kind = equip_kind(@equip_window.index)
for i in 0...EQUIP_TYPE_MAX
@item_windows[i].visible = (kind == i)
@item_windows[i].update
end
@item_window = @item_windows[kind]
@item_window.simple_refresh(@equip_window.index)
end
#--------------------------------------------------------------------------
# ○ 装備欄の種別を取得
# index : 装備欄インデックス
#--------------------------------------------------------------------------
def equip_kind(index)
if index == 0
return 0
else
return @actor.equip_type[index - 1] + 1
end
end
unless $imported["ExtendedEquipScene"]
#--------------------------------------------------------------------------
# ● ステータスウィンドウの更新
#--------------------------------------------------------------------------
def update_status_window
if @equip_window.active
@status_window.set_new_parameters(nil, nil, nil, nil)
elsif @item_window.active
temp_actor = Marshal.load(Marshal.dump(@actor))
temp_actor.change_equip(@equip_window.index, @item_window.item, true)
new_atk = temp_actor.atk
new_def = temp_actor.def
new_spi = temp_actor.spi
new_agi = temp_actor.agi
@status_window.set_new_parameters(new_atk, new_def, new_spi, new_agi)
end
@status_window.update
end
end
#--------------------------------------------------------------------------
# ● アイテム選択の更新
#--------------------------------------------------------------------------
alias update_item_selection_KGC_EquipExtension update_item_selection
def update_item_selection
if Input.trigger?(Input::C)
# 装備不可能な場合
index = @equip_window.index
item = @item_window.item
unless item == nil ||
(@actor.equippable?(item) && @actor.ep_condition_clear?(index, item))
Sound.play_buzzer
return
end
end
update_item_selection_KGC_EquipExtension
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# ● セーブデータの読み込み
# file : 読み込み用ファイルオブジェクト (オープン済み)
#--------------------------------------------------------------------------
alias read_save_data_KGC_EquipExtension read_save_data
def read_save_data(file)
read_save_data_KGC_EquipExtension(file)
KGC::Commands.restore_equip
Graphics.frame_reset
end
end
复制代码
QQ截图未命名.jpg
(24.39 KB, 下载次数: 19)
下载附件
保存到相册
2011-1-13 19:11 上传
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1