#==============================================================================
# ■ SEP 插件公共核心 v1.1 by SailCat
#------------------------------------------------------------------------------
# 方法:本脚本插入Scene_Debug(默认脚本)之后使用,需为自定义脚本的第一项
# 依赖:无(需要RGSS1 默认完整引擎)
# 版本:v1.1 (Build 171218)
# 效果:
# 1. 作为其他(几乎是所有)SEP插件脚本的必要依赖项
# 2. RGSS1 引擎中,各项固化的游戏用语统一设定文字内容
# 3. RGSS1 引擎中,各项固化的游戏数值统一设定数值限制
# 4. RGSS1 引擎中,原游戏内部类的机能扩充和优化
# 5. RGSS1 引擎中,已知的bug修正
# a) 装备自动状态错误卸除 bug
# b) 失明状态下物理技能恒Miss bug
# c) 回复技能,被攻击力增幅时威力反而减小 bug
# d) 威力为0,攻击力增幅不为0的技能,伤害值显示的 bug
# e) 事件脚本执行结果为false时,有时卡死的 bug
# f) 提升最大HP/SP后重新初始化角色,角色的当前HP和SP比最大值高的 bug
# 6. 为了后续插件的便利,将攻击改为执行0号特技(注意并不是$data_skills[0])
# 7. 独立开关可以当作独立变量来使用(在事件和插件脚本中)
# 8. 引入类似VA的Scene_Base 模块,用以简化场景的开发,并重写所有原引擎场景
# 9. 调试模式下以及商店中可以按Ctrl/Alt/Shift键来快速变化数值
# 配置:全部游戏用语、全部上限值、以及引擎扩充的设定值
# 冲突:无,和RGSS1 默认引擎100%兼容,按正确位置插入的情况下不会引起任何冲突
# 说明:
# 1. 单独植入此插件,且不修改任何配置项的情况下,游戏表现与默认引擎无差别
# 2. 如果修改了帧率,一定要打开平滑模式,否则显示可能有问题,切记
#==============================================================================
#==============================================================================
# ■ SailCat's 插件公用
#==============================================================================
module SailCat
$sailcat_import = {}
#--------------------------------------------------------------------------
# ● 脚本配置区
#--------------------------------------------------------------------------
module Core_Config
#--------------------------------------------------------------------------
# ● 上限设定,除最后三项外均可完全开放(设置为nil即无上限)
#--------------------------------------------------------------------------
GOLD_MAX = 9999999 # 金钱持有上限
STEPS_MAX = 9999999 # 步数积累上限
VAR_MAX = 99999999 # 变量取值上限
ITEM_MAX = 99 # 道具持有上限
MAXHP_MAX_BATTLER = 999999 # 最大HP值上限(通用)
MAXHP_MAX_ACTOR = 9999 # 最大HP值上限(角色)
MAXSP_MAX = 9999 # 最大SP值上限
STR_MAX = 999 # 力量值的上限
DEX_MAX = 999 # 灵巧值的上限
AGI_MAX = 999 # 速度值的上限
INT_MAX = 999 # 魔力值的上限
EXP_MAX = 9999999 # 经验值的上限
DATA_MAX = 999 # 数据库条数上限
SWITCH_MAX = 5000 # 开关数目上限
VARIABLE_MAX = 5000 # 变量数目上限
#--------------------------------------------------------------------------
# ● 用语设定
#--------------------------------------------------------------------------
VOCAB_EXP = "EXP" # 经验值 用语
VOCAB_EXP_A = "E" # 经验值 用语 简写
VOCAB_LEVEL = "LEVEL" # 等级 用语
VOCAB_LEVEL_A = "Lv" # 等级 用语 简写
VOCAB_NEXT_LEVEL = "NEXT" # 下一级经验 用语
VOCAB_STATE_EMPTY = "[正常]" # 空状态 用语
VOCAB_PLAYTIME = "游戏时间" # 游戏时间 用语
VOCAB_STEPS = "步数" # 步数 用语
VOCAB_HOLD_NUMBER = "所持数" # 所持数 用语
VOCAB_FILE = "文件" # 文件 用语
VOCAB_EQUIPMENT = "装备" # 装备 用语(注:状态窗口的装备用语)
VOCAB_MISS = "Miss" # 未击中 用语
VOCAB_CRITICAL = "CRITICAL" # 会心 用语
VOCAB_LEVEL_UP = "LEVEL UP!" # 升级 用语
VOCAB_BUY = "买" # 买 用语
VOCAB_SELL = "卖" # 卖 用语
VOCAB_CANCEL = "取消" # 取消 用语
VOCAB_FIGHT = "战斗" # 战斗 用语
VOCAB_ESCAPE = "逃跑" # 逃跑 用语
VOCAB_NEW_GAME = "新" # 新游戏 用语
VOCAB_CONTINUE = "继" # 继续 用语
VOCAB_QUIT = "退" # 退出 用语
VOCAB_STATUS = "状态" # 状态 用语
VOCAB_SAVE = "存档" # 存档 用语
VOCAB_END_GAME = "结束游戏" # 结束游戏 用语
VOCAB_TO_TITLE = "返回标题画面" # 返回标题画面 用语
VOCAB_OK = "确定" # 确定 用语
#--------------------------------------------------------------------------
# ● 引擎设定
#--------------------------------------------------------------------------
SHADOW_DIRECTION = 0 # 文字阴影方向(1-9),设为0关闭阴影
SHADOW_OPACITY = 170 # 文字阴影的默认不透明度
FONT_SIZE_DEFAULT = 22 # 字体默认大小
BLUR_RADIUS = 1 # 模糊位图的半径(1-4)
MOSAIC_SIZE = 8 # 马赛克位图的色块大小(1-32)
SCREEN_W = 640 # 屏幕分辨率的宽度
SCREEN_H = 480 # 屏幕分辨率的高度
FRAME_RATE = 60 # 游戏运行的帧率
INTERPRETER_RATE = 20 # 事件解释器的帧率
START_TRANSPARENT = false # 游戏开始时角色透明
#--------------------------------------------------------------------------
# ● 配置检查,请勿更改
#--------------------------------------------------------------------------
unless FRAME_RATE % INTERPRETER_RATE == 0
raise "游戏帧率需为事件解释器帧率的倍数"
else
FRAME_SKIP = FRAME_RATE / INTERPRETER_RATE
end
end
#--------------------------------------------------------------------------
# ● 植入
#--------------------------------------------------------------------------
$sailcat_import[:CoreEngine] = 1.0
end
#==============================================================================
# ■ Vocab
#------------------------------------------------------------------------------
# 所有用语的整合模块。
#==============================================================================
module Vocab
include SailCat::Core_Config
class << self
#--------------------------------------------------------------------------
# ● 导入数据库用语
#--------------------------------------------------------------------------
[:gold, :hp, :sp, :str, :dex, :agi, :int, :atk, :pdef, :mdef,
:weapon, :armor1, :armor2, :armor3, :armor4,
:attack, :skill, :guard, :item, :equip].each do |sym|
self.send :define_method, sym do; $data_system.words.send(sym); end
end
#--------------------------------------------------------------------------
# ● 增补用语
#--------------------------------------------------------------------------
SailCat::Core_Config.constants.each do |name|
if name[0..5] == "VOCAB_"
sym = name.sub("VOCAB_") {""}.downcase.to_sym
self.send :define_method, sym do; const_get(name); end
end
end
end
end
#==============================================================================
# ■ Enumerable
#------------------------------------------------------------------------------
# 可枚举模块的增强功能。
#==============================================================================
module Enumerable
#--------------------------------------------------------------------------
# ● 求和
#--------------------------------------------------------------------------
def sum
if block_given?
inject(0) {|n, i| n + yield(i)}
else
inject(0) {|n, i| n + (i || 0)}
end
end
#--------------------------------------------------------------------------
# ● 求积
#--------------------------------------------------------------------------
def product
if block_given?
inject(1) {|n, i| n * yield(i)}
else
include?(0) ? 0 : inject(1) {|n, i| n * (i || 1)}
end
end
#--------------------------------------------------------------------------
# ● 按值取大小
#--------------------------------------------------------------------------
def min_by; block_given? ? min {|a, b| yield(a) <=> yield(b)} : min; end
def max_by; block_given? ? max {|a, b| yield(a) <=> yield(b)} : max; end
end
#==============================================================================
# ■ NilClass
#------------------------------------------------------------------------------
# 空值的增强功能。
#==============================================================================
class NilClass
#--------------------------------------------------------------------------
# ● 取反,总是返回自身
#--------------------------------------------------------------------------
def -@; self; end
end
#==============================================================================
# ■ Array
#------------------------------------------------------------------------------
# 数组的增强功能。
#==============================================================================
class Array
#--------------------------------------------------------------------------
# ● 洗牌
#--------------------------------------------------------------------------
def shuffle
self.clone.shuffle!
end
#--------------------------------------------------------------------------
# ● 破坏性洗牌
#--------------------------------------------------------------------------
def shuffle!
(size - 1).times do |i|
j = i + rand(size - i)
t = self[j]
self[j] = self[i]
self[i] = t
end
end
end
#==============================================================================
# ■ Numeric
#------------------------------------------------------------------------------
# 数值的增强功能。
#==============================================================================
class Numeric
#--------------------------------------------------------------------------
# ● 数值上下限定
# min : 最小值
# max : 最大值
#--------------------------------------------------------------------------
def limit(min, max)
return self if min.nil? and max.nil?
return [self, min].max if max.nil?
return [self, max].min if min.nil?
if min > max
min += max; max = min - max; min -= max
end
[[self, min].max, max].min
end
#--------------------------------------------------------------------------
# ● 数值分散
# args : 分散度(0-1),可用两个参数的分数表示
#--------------------------------------------------------------------------
def variance(*args)
return self if abs == 0
var = (args[0].to_f / (args[1] || 1)).limit(0.0, 1.0)
return self if var == 0.0
amp = [(abs * var).round, 1].max
self + rand(amp + 1) + rand(amp + 1) - amp
end
#--------------------------------------------------------------------------
# ● 数值混合
# other : 被混合的另一个数
# args : 混合度(0-1),可用两个参数的分数表示
#--------------------------------------------------------------------------
def blend(other, *args)
var = (args[0].to_f / (args[1] || 1)).limit(0.0, 1.0)
return self if var == 0.0
return other if var == 1.0
n = self * var + other * (1 - var)
self.is_a?(Fixnum) && other.is_a?(Fixnum) ? n.round : n
end
end
#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
# 位图的增强功能,植入部分RGSS2的功能。
#==============================================================================
class Bitmap
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_dispose)
alias sailcat_sepcore_dispose dispose
alias sailcat_sepcore_draw_text draw_text
end
#--------------------------------------------------------------------------
# ● 获得描绘缓存
#--------------------------------------------------------------------------
def buffer
@buffer ||= Bitmap.new(width, height)
end
#--------------------------------------------------------------------------
# ● 清除缓存
#--------------------------------------------------------------------------
def clear_buffer
self.buffer.clear
end
#--------------------------------------------------------------------------
# ● 复制当前位图到缓存
#--------------------------------------------------------------------------
def clone_to_buffer
self.buffer.blt(0, 0, self, rect)
self.buffer
end
#--------------------------------------------------------------------------
# ● 复制缓存到当前位图
#--------------------------------------------------------------------------
def clone_from_buffer
self.blt(0, 0, self.buffer, rect)
self
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
sailcat_sepcore_dispose
@buffer.dispose if @buffer
end
#--------------------------------------------------------------------------
# ● 灰度效果
#--------------------------------------------------------------------------
def to_grayscale
for i in 0...width
for j in 0...height
color = get_pixel(i, j)
next if color.alpha == 0
gray = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11
self.buffer.set_pixel(i, j, Color.new(gray, gray, gray, color.alpha))
end
end
buffer
end
#--------------------------------------------------------------------------
# ● 马赛克效果
#--------------------------------------------------------------------------
def mosaic(*args)
case args.size
when 0
rect = self.rect
msize = 8
when 1
rect = self.rect
msize = args[1]
when 2
rect = args[0]
msize = args[1]
when 5
rect = Rect.new(args[0], args[1], rect[2], rect[3])
msize = args[4]
else
raise ArgumentError
end
msize = (msize || MOSAIC_SIZE).limit(1, 32)
msize = [msize, [rect.width, rect.height].max / 8].min
return clone_to_buffer if msize == 1
if rect == self.rect
start_x = -rand(msize)
start_y = -rand(msize)
clear_buffer
else
start_x = rect.x
start_y = rect.y
clone_to_buffer
end
start_x.step(rect.width - 1, msize) do |i|
start_y.step(rect.height - 1, msize) do |j|
center_x = (i + msize / 2).limit(0, rect.width - 1)
center_y = (j + msize / 2).limit(0, rect,height - 1)
buffer.fill_rect(i, j, [msize, rect.width - i].min,
[msize, rect.height - j].min, get_pixel(center_x, center_y))
end
end
buffer
end
#--------------------------------------------------------------------------
# ● 模糊效果
#--------------------------------------------------------------------------
def blur(r = BLUR_RADIUS)
r = (r || BLUR_RADIUS).limit(1, 4)
clear_buffer
diameter = 1 + r * 2
for i in 0...diameter
for j in 0...diameter
distance = Math.hypot(r - i, r - j)
str = [(128 * (r - distance + 1) / (r + 1)).round, 0].max
self.buffer.blt(i - r, j - r, @buffer, rect, str)
end
end
buffer
end
#--------------------------------------------------------------------------
# ● 更改色调
#--------------------------------------------------------------------------
def tone_change(*args)
case args.size
when 1
tone = args[0]
when 3
tone = Tone.new(args[0], args[1], args[2], 0)
when 4
tone = Tone.new(*args)
else
raise ArgumentError
end
return clone_to_buffer if tone == Tone.new(0, 0, 0, 0)
return to_grayscale if tone == Tone.new(0, 0, 0, 255)
grayscale = (255.0 - tone.gray) / 255
for i in 0...width
for j in 0...height
color = get_pixel(i, j)
next if color.alpha == 0
n = [color.red, color.green, color.blue]
gray = n[0] * 0.3 + n[1] * 0.59 + n[2] * 0.11 if tone.gray > 0
[:red, :green, :blue].each_with_index do |sym, k|
n[k] = [[n[k] + tone.send(sym), 0].max, 255].min
n[k] = n[k].blend(gray, grayscale) if tone.gray > 0
end
self.buffer.set_pixel(i, j, Color.new(n[0], n[1], n[2], color.alpha))
end
end
buffer
end
#--------------------------------------------------------------------------
# ● 上述功能的破坏性操作
#--------------------------------------------------------------------------
def to_grayscale!; to_grayscale; clone_from_buffer; end
def mosaic!(*args); mosaic(*args); clone_from_buffer; end
def blur!(r = 2); blur(r); clone_from_buffer; end
def tone_change!(tone); tone_change(tone); clone_from_buffer; end
#--------------------------------------------------------------------------
# ● 渐变填充位图
# args : 绘制参数,写法同RGSS2
# 参数1:x, y, width, height, color1, color2[, vertical]
# 参数2:rect, color1, color2[, vertical]
#--------------------------------------------------------------------------
def gradient_fill_rect(*args)
case args[0]
when Numeric
x, y, width, height, color1, color2, vertical = args
when Rect
rect, color1, color2, vertical = args
x = args[0].x
y = args[0].y
width = args[0].width
height = args[0].height
end
color = color1.clone
increment = vertical ? height : width
step_r = (color2.red - color1.red) / increment
step_g = (color2.green - color1.green) / increment
step_b = (color2.blue - color1.blue) / increment
step_a = (color2.alpha - color1.alpha) / increment
increment.times do |i|
if vertical
fill_rect(x, y + i, width, 1, color)
else
fill_rect(x + i, y, 1, height, color)
end
color.set(color.red + step_r, color.green + step_g,
color.blue + step_b, color.alpha + step_a)
end
end
#--------------------------------------------------------------------------
# ● 清除位图
# args : 参数,写法同RGSS2
# 参数1:x, y, width, height
# 参数2:rect
#--------------------------------------------------------------------------
def clear_rect(*args)
case args.size
when 1
fill_rect(args[0], Color.new(0, 0, 0, 0))
when 4
fill_rect(args[0], args[1], args[2], args[3], Color.new(0, 0, 0, 0))
else
raise ArgumentError
end
end
#--------------------------------------------------------------------------
# ● 绘制带有阴影或描边的文字
# args : 参数,写法同RGSS2
# 参数1:x, y, width, height, str[, align[, shadow_direction[, color]]]
# 参数2:rect, str[, align[, shadow_direction[, color]]]
# shadow_direction : 阴影的方向(0/1/3/5/7/9),0取消,1/3/7/9四角,5描边
# color : 阴影的颜色,不透明度会自动调整
#--------------------------------------------------------------------------
def draw_text(*args)
case args[0]
when Numeric
x, y, width, height, text, align, shadow_direction, shadow_color = args
align ||= 0
shadow_direction ||= SHADOW_DIRECTION
shadow_color ||= Color.new(0, 0, 0)
shadow_color.alpha = font.color.alpha * SHADOW_OPACITY / 255
when Rect
rect, text, align, shadow_direction, shadow_color = args
x = args[0].x
y = args[0].y
width = args[0].width
height = args[0].height
align ||= 0
shadow_direction ||= SHADOW_DIRECTION
shadow_color ||= Color.new(0, 0, 0)
shadow_color.alpha = font.color.alpha * SHADOW_OPACITY / 255
end
text = text.to_s unless text.is_a?(String)
color_temp = font.color.clone
if shadow_direction != 0
font.color = shadow_color
if shadow_direction == 5
buffer_rect = Rect.new(0, 0, width, height)
clear_buffer
buffer.font = font.clone
buffer.font.color = shadow_color
buffer.sailcat_sepcore_draw_text(buffer_rect, text, align)
blt(x - 1,y - 1, buffer, buffer_rect)
blt(x - 1,y + 1, buffer, buffer_rect)
blt(x + 1,y - 1, buffer, buffer_rect)
blt(x + 1,y + 1, buffer, buffer_rect)
else
a = shadow_direction % 6 == 1 ? -1 : 1
b = shadow_direction / 6 == 1 ? -1 : 1
sailcat_sepcore_draw_text(x + a, y + b, width, height, text, align)
end
font.color = color_temp
end
sailcat_sepcore_draw_text(x, y, width, height, text, align)
end
end
#==============================================================================
# ■ Color
#==============================================================================
class Color
#--------------------------------------------------------------------------
# ● 从 HTML 代码获得颜色
# string : HTML颜色字符串,为#RRGGBB或#RRGGBBAA形式
#--------------------------------------------------------------------------
def self.html(string)
raise ArgumentError unless string.size != 7 or string.size != 9
red = string[1..2].to_i(16)
green = string[3..4].to_i(16)
blue = string[5..6].to_i(16)
alpha = string[7..8] == "" ? 255 : string[7..8].to_i(16)
new(red, green, blue, alpha)
end
#--------------------------------------------------------------------------
# ● 从 ARGB 值获得颜色
# value : 用以表示ARGB颜色值的整数
#--------------------------------------------------------------------------
def self.argb(value)
alpha = (value & 4278190080 != 0) ? (value & 4278190080) >> 24 : 255
red = (value & 16711680) >> 16
green = (value & 65280) >> 8
blue = value & 255
new(red, green, blue, alpha)
end
end
#==============================================================================
# ■ Rect
#==============================================================================
class Rect
#--------------------------------------------------------------------------
# ● 矩形的扩张
# ox : 水平扩张度
# oy : 垂直扩张度
#--------------------------------------------------------------------------
def inflate(ox, oy)
ox = [ox, -width / 2].max
oy = [oy, -height / 2].max
set(x - ox, y - oy, width + ox * 2, height + oy * 2)
self
end
#--------------------------------------------------------------------------
# ● 矩形的偏移
# ox : 水平偏移量
# oy : 垂直偏移量
#--------------------------------------------------------------------------
def offset(ox, oy)
set(x + ox, y + oy, width, height)
self
end
#--------------------------------------------------------------------------
# ● 矩形的四边定义(只读属性)
#--------------------------------------------------------------------------
def left; x; end # 左边
def right; x + width; end # 右边
def top; y; end # 上边
def bottom; y + height; end # 下边
end
#==============================================================================
# ■ RPG::Sprite
#==============================================================================
module RPG
class Sprite
S = SailCat::Core_Config::FRAME_SKIP
def damage(value, critical)
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, Vocab.critical, 1)
bitmap.draw_text(+1, -1, 160, 20, Vocab.critical, 1)
bitmap.draw_text(-1, +1, 160, 20, Vocab.critical, 1)
bitmap.draw_text(+1, +1, 160, 20, Vocab.critical, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, Vocab.critical, 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
if @_damage_duration > 0
@_damage_duration -= 1
case @_damage_duration
when 38..39
@_damage_sprite.y -= 4
when 36..37
@_damage_sprite.y -= 2
when 34..35
@_damage_sprite.y += 2
when 28..33
@_damage_sprite.y += 4
end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
if @_damage_duration == 0
dispose_damage
end
end
if @_animation != nil and (Graphics.frame_count % S == 0)
@_animation_duration -= 1
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % S == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
def animation_process_timing(timing, hit)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
case timing.flash_scope
when 1
self.flash(timing.flash_color, timing.flash_duration * S)
when 2
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * S)
end
when 3
self.flash(nil, timing.flash_duration * S)
end
end
end
end
end
#==============================================================================
# ■ Game_Switches
#==============================================================================
class Game_Switches
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 获取开关
# switch_id : 开关 ID
#--------------------------------------------------------------------------
def [](switch_id)
switch_id <= SWITCH_MAX ? (@data[switch_id] || false) : false
end
#--------------------------------------------------------------------------
# ● 设置开关
# switch_id : 开关 ID
# value : ON (true) / OFF (false)
#--------------------------------------------------------------------------
def []=(switch_id, value)
@data[switch_id] = value if switch_id <= SWITCH_MAX
end
end
#==============================================================================
# ■ Game_Variables
#==============================================================================
class Game_Variables
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 获取变量
# variable_id : 变量 ID
#--------------------------------------------------------------------------
def [](variable_id)
variable_id <= VARIABLE_MAX ? (@data[variable_id] || 0) : 0
end
#--------------------------------------------------------------------------
# ● 设置变量
# variable_id : 变量 ID
# value : 变量的值
#--------------------------------------------------------------------------
def []=(variable_id, value)
@data[variable_id] = value if variable_id <= VARIABLE_MAX
end
end
#==============================================================================
# ■ Game_SelfSwitches
#==============================================================================
class Game_SelfSwitches
#--------------------------------------------------------------------------
# ● 获取独立开关
# key : 键
#--------------------------------------------------------------------------
def [](key)
return @data[key] || false
end
end
#==============================================================================
# ■ Game_Battler
#==============================================================================
class Game_Battler
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_initialize)
alias sailcat_sepcore_initialize initialize
end
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
sailcat_sepcore_initialize
post_initialize
end
#--------------------------------------------------------------------------
# ● 后续处理内容
#--------------------------------------------------------------------------
def post_initialize
end
#--------------------------------------------------------------------------
# ● 获取 MaxHP
#--------------------------------------------------------------------------
def maxhp
n = (base_maxhp + @maxhp_plus).limit(1, MAXHP_MAX_BATTLER)
n *= @states.product {|i| $data_states[i].maxhp_rate / 100.0}
Integer(n).limit(1, MAXHP_MAX_BATTLER)
end
#--------------------------------------------------------------------------
# ● 获取 MaxSP
#--------------------------------------------------------------------------
def maxsp
n = (base_maxsp + @maxsp_plus).limit(0, MAXSP_MAX)
n *= @states.product {|i| $data_states[i].maxsp_rate / 100.0}
Integer(n).limit(0, MAXSP_MAX)
end
#--------------------------------------------------------------------------
# ● 获取力量
#--------------------------------------------------------------------------
def str
n = (base_str + @str_plus).limit(1, STR_MAX)
n *= @states.product {|i| $data_states[i].str_rate / 100.0}
Integer(n).limit(1, STR_MAX)
end
#--------------------------------------------------------------------------
# ● 获取灵巧
#--------------------------------------------------------------------------
def dex
n = (base_dex + @dex_plus).limit(1, STR_MAX)
n *= @states.product {|i| $data_states[i].dex_rate / 100.0}
Integer(n).limit(1, DEX_MAX)
end
#--------------------------------------------------------------------------
# ● 获取速度
#--------------------------------------------------------------------------
def agi
n = (base_agi + @agi_plus).limit(1, AGI_MAX)
n *= @states.product {|i| $data_states[i].agi_rate / 100.0}
Integer(n).limit(1, AGI_MAX)
end
#--------------------------------------------------------------------------
# ● 获取魔力
#--------------------------------------------------------------------------
def int
n = (base_int + @int_plus).limit(1, INT_MAX)
n *= @states.product {|i| $data_states[i].int_rate / 100.0}
Integer(n).limit(1, INT_MAX)
end
#--------------------------------------------------------------------------
# ● 设置 MaxHP
# maxhp : 新的 MaxHP
#--------------------------------------------------------------------------
def maxhp=(maxhp)
@maxhp_plus += maxhp - self.maxhp
@maxhp_plus = @maxhp_plus.limit(-MAXHP_MAX_BATTLER, MAXHP_MAX_BATTLER)
@hp = [@hp, self.maxhp].min
end
#--------------------------------------------------------------------------
# ● 设置 MaxSP
# maxsp : 新的 MaxSP
#--------------------------------------------------------------------------
def maxsp=(maxsp)
@maxsp_plus += maxsp - self.maxsp
@maxsp_plus = @maxsp_plus.limit(-MAXSP_MAX, MAXSP_MAX)
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# ● 设置力量
# str : 新的力量
#--------------------------------------------------------------------------
def str=(str)
@str_plus += str - self.str
@str_plus = @str_plus.limit(-STR_MAX, STR_MAX)
end
#--------------------------------------------------------------------------
# ● 设置灵巧
# dex : 新的灵巧
#--------------------------------------------------------------------------
def dex=(dex)
@dex_plus += dex - self.dex
@dex_plus = @dex_plus.limit(-DEX_MAX, DEX_MAX)
end
#--------------------------------------------------------------------------
# ● 设置速度
# agi : 新的速度
#--------------------------------------------------------------------------
def agi=(agi)
@agi_plus += agi - self.agi
@agi_plus = @agi_plus.limit(-AGI_MAX, AGI_MAX)
end
#--------------------------------------------------------------------------
# ● 设置魔力
# int : 新的魔力
#--------------------------------------------------------------------------
def int=(int)
@int_plus += int - self.int
@int_plus = @int_plus.limit(-INT_MAX, INT_MAX)
end
#--------------------------------------------------------------------------
# ● HP和SP的比例
#--------------------------------------------------------------------------
def hp_rate; self.hp.to_f / self.maxhp; end
def sp_rate; self.maxsp == 0 ? 1.0 : self.sp.to_f / self.maxsp; end
#--------------------------------------------------------------------------
# ● 预设的RGSS基本默认值,用于计算通常攻击伤害
#--------------------------------------------------------------------------
def variance; 15; end # 分散度
def atk_f; 100; end # 攻击力F
def pdef_f; 100; end # 防御力F
def mdef_f; 0; end # 魔防力F
def str_f; 100; end # 力量F
def dex_f; 0; end # 灵巧F
def agi_f; 0; end # 速度F
def int_f; 0; end # 魔力F
def eva_f; 100; end # 回避F
def common_event_id;0; end # 公共事件ID
#--------------------------------------------------------------------------
# ● 预设的RGSS战斗系统的其他系数默认值
#--------------------------------------------------------------------------
def critical_rate; 4; end # 基础会心率
def eva_rate; 8; end # 基础回避率
def critical_fold; 200; end # 基础会心倍率
def guarding_fold; 200; end # 基础防御倍率
def damage_rate; 20; end # 基础伤害倍率
def pdef_rate; 50; end # 物防力折算率
def mdef_rate; 50; end # 魔防力折算率
def slip_rate; 10; end # 连续伤害倍率
def slip_variance; 15; end # 连续伤害分散
#--------------------------------------------------------------------------
# ● 战斗者的阵营判定
#--------------------------------------------------------------------------
def actor?; self.is_a?(Game_Actor); end # 角色判定
def enemy?; self.is_a?(Game_Enemy); end # 敌人判定
def friendly?(other); self.actor? ^ other.enemy?; end # 友好判定
def hostile?(other); not friendly?(other); end # 敌对判定
#--------------------------------------------------------------------------
# ● 用于攻击动作的零号特技
#--------------------------------------------------------------------------
def attack_skill
skill = RPG::Skill.new
skill.id = 0
skill.scope = 1
skill.animation1_id = self.animation1_id
skill.animation2_id = self.animation2_id
skill.common_event_id = self.common_event_id
skill.atk_f = self.atk_f
skill.eva_f = self.eva_f
skill.str_f = self.str_f
skill.dex_f = self.dex_f
skill.agi_f = self.agi_f
skill.int_f = self.int_f
skill.hit = 100
skill.pdef_f = self.pdef_f
skill.mdef_f = self.mdef_f
skill.variance = self.variance
skill.element_set = self.element_set
skill.plus_state_set = self.plus_state_set
skill.minus_state_set = self.minus_state_set
skill
end
#--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 攻击准备
pre_attack(attacker)
# 应用零号特技效果
perform_skill(attacker, attacker.attack_skill)
# 攻击收尾
post_attack(attacker)
return true
end
#--------------------------------------------------------------------------
# ● 攻击准备
#--------------------------------------------------------------------------
def pre_attack(attacker)
# 清除会心一击标志
self.critical = false
end
#--------------------------------------------------------------------------
# ● 攻击收尾
#--------------------------------------------------------------------------
def post_attack(attacker)
end
#--------------------------------------------------------------------------
# ● 应用特技效果
# user : 特技的使用者 (battler)
# skill : 特技
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# 特技判定
return false unless skill_can_apply?(user, skill) or skill.id == 0
# 有效标志
@effective = false
# 特技准备
pre_skill(user, skill)
# 特技动作
perform_skill(user, skill)
# 特技收尾
post_skill(user, skill)
return @effective
end
#--------------------------------------------------------------------------
# ● 特技应用判定
#--------------------------------------------------------------------------
def skill_can_apply?(user, skill)
# 特技的效果范围不符的情况下
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
# 判定失败
return false
end
# 判定成功
return true
end
#--------------------------------------------------------------------------
# ● 特技准备
#--------------------------------------------------------------------------
def pre_skill(user, skill)
# 清除会心一击标志
self.critical = false
# 公共事件 ID 是有效的情况下,设置为有效标志
@effective |= skill.common_event_id > 0
end
#--------------------------------------------------------------------------
# ● 特技动作
#--------------------------------------------------------------------------
def perform_skill(user, skill)
# 命中判定
if judge_skill_hit(user, skill)
# 计算伤害
calculate_skill_damage(user, skill)
# 应用击中效果
apply_hit(user, skill)
else
# 应用未击中效果
apply_miss(user, skill)
end
end
#--------------------------------------------------------------------------
# ● 特技收尾
#--------------------------------------------------------------------------
def post_skill(user, skill)
end
#--------------------------------------------------------------------------
# ● 特技命中判定
#--------------------------------------------------------------------------
def judge_skill_hit(user, skill)
judge_skill_hit1(user, skill) and judge_skill_hit2(user, skill)
end
#--------------------------------------------------------------------------
# ● 第一命中判定
#--------------------------------------------------------------------------
def judge_skill_hit1(user, skill)
hit = skill.hit
hit = hit * user.hit / 100 if skill.atk_f > 0
@effective |= hit < 100
rand(100) < hit
end
#--------------------------------------------------------------------------
# ● 第二命中判定
#--------------------------------------------------------------------------
def judge_skill_hit2(user, skill)
if skill_can_heal?(user, skill) or cant_evade?
hit = 100
else
eva = self.eva_rate * self.agi / user.dex + self.eva
hit = 100 - eva * skill.eva_f / 100
end
@effective |= hit < 100
rand(100) < hit
end
#--------------------------------------------------------------------------
# ● 技能回复判定
#--------------------------------------------------------------------------
def skill_can_heal?(user, skill)
a = (skill.id == 0 ? user.atk : skill.power) <=> 0
a * elements_correct(skill.element_set) < 0
end
#--------------------------------------------------------------------------
# ● 计算伤害
#--------------------------------------------------------------------------
def calculate_skill_damage(user, skill)
# 计算基本威力
calculate_basic(user, skill)
# 计算倍率
calculate_rate(user, skill)
# 计算伤害修正
calculate_modifier(user, skill)
end
#--------------------------------------------------------------------------
# ● 计算基本威力
#--------------------------------------------------------------------------
def calculate_basic(user, skill)
# 技能的威力
calculate_basic_atk(user, skill)
# 技能对象的防御力
calculate_basic_def(user, skill)
end
#--------------------------------------------------------------------------
# ● 攻击者的攻击力
#--------------------------------------------------------------------------
def calculate_basic_atk(user, skill)
self.damage = skill.power
if self.damage >= 0
self.damage += user.atk * skill.atk_f / 100
else
self.damage -= user.atk * skill.atk_f / 100
end
end
#--------------------------------------------------------------------------
# ● 对象的防御力
#--------------------------------------------------------------------------
def calculate_basic_def(user, skill)
if self.damage > 0
self.damage -= self.pdef * skill.pdef_f * self.pdef_rate / 10000
self.damage -= self.mdef * skill.mdef_f * self.mdef_rate / 10000
self.damage = [self.damage, 0].max
end
end
#--------------------------------------------------------------------------
# ● 计算伤害倍率
#--------------------------------------------------------------------------
def calculate_rate(user, skill)
rate = self.damage_rate
rate += user.str * skill.str_f / 100
rate += user.dex * skill.dex_f / 100
rate += user.agi * skill.agi_f / 100
rate += user.int * skill.int_f / 100
self.damage = self.damage * rate / self.damage_rate
end
#--------------------------------------------------------------------------
# ● 计算伤害修正
#--------------------------------------------------------------------------
def calculate_modifier(user, skill)
# 计算属性修正
calculate_element(skill.element_set)
# 计算会心修正
calculate_critical(user, skill)
# 计算防御修正
calculate_guarding(user, skill)
# 计算分散修正
calculate_variance(skill.variance)
end
#--------------------------------------------------------------------------
# ● 计算属性修正
#--------------------------------------------------------------------------
def calculate_element(element_set)
case self.damage
when Numeric
self.damage = self.damage * elements_correct(element_set) / 100
when Array
self.damage.each_index do |i|
self.damage[i] = self.damage[i] * elements_correct(element_set) / 100
end
end
end
#--------------------------------------------------------------------------
# ● 计算会心修正
#--------------------------------------------------------------------------
def calculate_critical(user, skill)
if self.damage > 0 and judge_critical(user, skill)
self.damage = self.damage * user.critical_fold / 100
self.critical = true
end
end
#--------------------------------------------------------------------------
# ● 计算防御修正
#--------------------------------------------------------------------------
def calculate_guarding(user, skill)
if self.damage > 0 and self.guarding?
self.damage = self.damage * 100 / self.guarding_fold
end
end
#--------------------------------------------------------------------------
# ● 计算分散修正
#--------------------------------------------------------------------------
def calculate_variance(variance)
case self.damage
when Numeric
self.damage = self.damage.variance(variance, 100)
when Array
self.damage.each_index do |i|
self.damage[i] = self.damage[i].variance(variance, 100)
end
end
end
#--------------------------------------------------------------------------
# ● 会心一击判定
#--------------------------------------------------------------------------
def judge_critical(user, skill)
rand(100) < (skill.id == 0 ? user.critical_rate * user.dex / self.agi : 0)
end
#--------------------------------------------------------------------------
# ● 应用击中结果
#--------------------------------------------------------------------------
def apply_hit(user, skill)
# 状态冲击解除
if skill.id == 0 or skill.atk_f > 0
remove_states_shock
@effective = true
end
# HP 的伤害计算
last_hp = self.hp
self.hp -= self.damage
@effective |= last_hp != self.hp
# 状态变化
@states_changed = false
@effective |= states_plus(user.plus_state_set)
@effective |= states_minus(user.minus_state_set)
# 不是普通攻击,技能也没有伤害设定的情况下
if skill.id > 0 and skill.power == 0 and skill.atk_f == 0
# 伤害值设为空或 Miss
self.damage = @states_changed ? "" : Vocab.miss
end
# 不在战斗中的情况下,伤害值设为nil
self.damage = nil unless $game_temp.in_battle
end
#--------------------------------------------------------------------------
# ● 应用未击中结果
#--------------------------------------------------------------------------
def apply_miss(user, skill)
# 伤害设置为Miss
self.damage = $game_temp.in_battle ? Vocab.miss : nil
# 清除会心一击标志
self.critical = false
end
#--------------------------------------------------------------------------
# ● 应用物品效果
# item : 物品
#--------------------------------------------------------------------------
def item_effect(item)
# 物品判定
return false unless item_can_apply?(item)
# 有效标志
@effective = false
# 物品准备
pre_item(item)
# 物品动作
perform_item(item)
# 物品收尾
post_item(item)
return @effective
end
#--------------------------------------------------------------------------
# ● 物品应用判定
#--------------------------------------------------------------------------
def item_can_apply?(item)
# 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
# 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
((item.scope == 5 or item.scope == 6) and self.hp >= 1)
# 过程结束
return false
end
return true
end
#--------------------------------------------------------------------------
# ● 物品准备
#--------------------------------------------------------------------------
def pre_item(item)
# 清除会心一击标志
self.critical = false
# 公共事件 ID 是有效的情况下,设置为有效标志
@effective |= item.common_event_id > 0
end
#--------------------------------------------------------------------------
# ● 物品动作
#--------------------------------------------------------------------------
def perform_item(item)
# 命中判定
if judge_item_hit(item)
# 计算伤害
calculate_item_damage(item)
# 应用击中效果
apply_item_hit(item)
else
# 应用未击中效果
apply_item_miss(item)
end
end
#--------------------------------------------------------------------------
# ● 使用物品后续处理
#--------------------------------------------------------------------------
def post_item(item)
end
#--------------------------------------------------------------------------
# ● 物品击中判定
#--------------------------------------------------------------------------
def judge_item_hit(item)
@effective |= item.hit < 100
rand(100) < item.hit
end
#--------------------------------------------------------------------------
# ● 计算伤害
#--------------------------------------------------------------------------
def calculate_item_damage(item)
# 计算回复量
calculate_recovery(item)
# 属性修正
calculate_element(item.element_set)
# 会心修正
calculate_item_critical(item)
# 分散修正
calculate_variance(item.variance)
# 防御修正
calculate_item_guarding(item)
end
#--------------------------------------------------------------------------
# ● 计算回复量
#--------------------------------------------------------------------------
def calculate_recovery(item)
recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
if recover_hp < 0
recover_hp += self.pdef * item.pdef_f * self.pdef_rate / 1000
recover_hp += self.mdef * item.mdef_f * self.pdef_rate / 1000
recover_hp = [recover_hp, 0].min
end
self.damage = [-recover_hp, -recover_sp]
end
#--------------------------------------------------------------------------
# ● 会心修正
#--------------------------------------------------------------------------
def calculate_item_critical(item)
end
#--------------------------------------------------------------------------
# ● 防御修正
#--------------------------------------------------------------------------
def calculate_item_guarding(item)
if self.damage[0] > 0 and self.guarding?
self.damage[0] = self.damage[0] * 100 / self.guarding_fold
end
end
#--------------------------------------------------------------------------
# ● 应用物品击中
#--------------------------------------------------------------------------
def apply_item_hit(item)
# 伤害处理
apply_item_damage(item)
# 能力值处理
apply_item_plus(item)
# 伤害显示处理
apply_item_display(item)
end
#--------------------------------------------------------------------------
# ● 伤害处理
#--------------------------------------------------------------------------
def apply_item_damage(item)
# HP 以及 SP 的回复
last_hp = self.hp
last_sp = self.sp
self.hp -= self.damage[0]
self.sp -= self.damage[1]
@effective |= self.hp != last_hp
@effective |= self.sp != last_sp
# 状态变化
@state_changed = false
@effective |= states_plus(item.plus_state_set)
@effective |= states_minus(item.minus_state_set)
end
#--------------------------------------------------------------------------
# ● 能力值处理
#--------------------------------------------------------------------------
def apply_item_plus(item)
if item.parameter_type > 0 and item.parameter_points != 0
parameter_name = [:@maxhp_plus, :@maxsp_plus, :@str_plus, :@dex_plus,
:@agi_plus, :@int_plus][item.parameter_type - 1]
value = instance_variable_get(parameter_name) + item.parameter_points
instance_variable_set(parameter_name, item.parameter_points)
@effective = true
end
end
#--------------------------------------------------------------------------
# ● 伤害显示处理
#--------------------------------------------------------------------------
def apply_item_display(item)
# HP 回复率与回复量为 0 的情况下
if item.recover_hp_rate == 0 and item.recover_hp == 0
# 设置伤害显示为SP伤害
self.damage = self.damage[1]
# SP 回复率与回复量为 0 的情况下
if item.recover_sp_rate == 0 and item.recover_sp == 0
# 设置伤害显示为能力上升量
self.damage = -item.parameter_points if item.parameter_type != 0
# 伤害仍然为0的情况下,设置为空或Miss
self.damage = @state_changed ? "" : Vocab.miss if self.damage == 0
end
else
# 设置伤害显示为HP伤害
self.damage = self.damage[0]
end
# 不在战斗中的情况下,伤害值设为nil
self.damage = nil unless $game_temp.in_battle
end
#--------------------------------------------------------------------------
# ● 应用物品未击中
#--------------------------------------------------------------------------
def apply_item_miss(item)
self.damage = $game_temp.in_battle ? Vocab.miss : nil
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
# 设置伤害
self.damage = self.maxhp / self.slip_rate
# 分散
self.damage = self.damage.variance(self.slip_variance, 100)
# HP 的伤害减法运算
self.hp -= self.damage
# 过程结束
return true
end
end
#==============================================================================
# ■ Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_setup)
alias sailcat_sepcore_setup setup
end
#--------------------------------------------------------------------------
# ● 后续处理内容
#--------------------------------------------------------------------------
def post_initialize
super
@forced_states = {}
end
#--------------------------------------------------------------------------
# ● 设置角色
#--------------------------------------------------------------------------
def setup(actor_id)
sailcat_sepcore_setup(actor_id)
post_setup
end
#--------------------------------------------------------------------------
# ● 后续设置
#--------------------------------------------------------------------------
def post_setup
@hp = maxhp
@sp = maxsp
end
#--------------------------------------------------------------------------
# ● 原型角色数据
#--------------------------------------------------------------------------
def data
$data_actors[@actor_id]
end
#--------------------------------------------------------------------------
# ● 当前职业数据
#--------------------------------------------------------------------------
def class
$data_classes[@class_id]
end
#--------------------------------------------------------------------------
# ● 装备的武器(RPG::Weapon)
#--------------------------------------------------------------------------
def weapon
$data_weapons[@weapon_id]
end
#--------------------------------------------------------------------------
# ● 装备的所有防具(RPG::Armor的集合)
#--------------------------------------------------------------------------
def all_armors
[@armor1_id, @armor2_id, @armor3_id, @armor4_id].map {|a| $data_armors[a]}
end
#--------------------------------------------------------------------------
# ● 装备的有效防具(RPG::Armor的非空集合)
#--------------------------------------------------------------------------
def armors
all_armors.compact
end
#--------------------------------------------------------------------------
# ● 有效装备集
#--------------------------------------------------------------------------
def equipment
weapon ? [weapon] + armors : armors
end
#--------------------------------------------------------------------------
# ● 获取 MaxHP
#--------------------------------------------------------------------------
def maxhp
n = (base_maxhp + @maxhp_plus).limit(1, MAXHP_MAX_ACTOR)
n *= @states.product {|i| $data_states[i].maxhp_rate / 100.0}
Integer(n).limit(1, MAXHP_MAX_ACTOR)
end
#--------------------------------------------------------------------------
# ● 设置 MaxHP
# maxhp : 新的 MaxHP
#--------------------------------------------------------------------------
def maxhp=(maxhp)
@maxhp_plus += maxhp - self.maxhp
@maxhp_plus = @maxhp_plus.limit(-MAXHP_MAX_ACTOR, MAXHP_MAX_ACTOR)
@hp = [@hp, self.maxhp].min
end
#--------------------------------------------------------------------------
# ● 获取基本力量
#--------------------------------------------------------------------------
def base_str
n = $data_actors[@actor_id].parameters[2, @level]
(n + equipment.sum {|e| e.str_plus}).limit(1, STR_MAX)
end
#--------------------------------------------------------------------------
# ● 获取基本灵巧
#--------------------------------------------------------------------------
def base_dex
n = $data_actors[@actor_id].parameters[3, @level]
(n + equipment.sum {|e| e.dex_plus}).limit(1, DEX_MAX)
end
#--------------------------------------------------------------------------
# ● 获取基本速度
#--------------------------------------------------------------------------
def base_agi
n = $data_actors[@actor_id].parameters[4, @level]
(n + equipment.sum {|e| e.agi_plus}).limit(1, AGI_MAX)
end
#--------------------------------------------------------------------------
# ● 获取基本魔力
#--------------------------------------------------------------------------
def base_int
n = $data_actors[@actor_id].parameters[5, @level]
(n + equipment.sum {|e| e.int_plus}).limit(1, INT_MAX)
end
#--------------------------------------------------------------------------
# ● 获取基本攻击力
#--------------------------------------------------------------------------
def base_atk
weapon ? weapon.atk : 0
end
#--------------------------------------------------------------------------
# ● 获取基本物理防御
#--------------------------------------------------------------------------
def base_pdef
equipment.sum {|e| e.pdef}
end
#--------------------------------------------------------------------------
# ● 获取基本魔法防御
#--------------------------------------------------------------------------
def base_mdef
equipment.sum {|e| e.mdef}
end
#--------------------------------------------------------------------------
# ● 获取基本回避修正
#--------------------------------------------------------------------------
def base_eva
armors.sum {|a| a.eva}
end
#--------------------------------------------------------------------------
# ● 普通攻击 获取攻击方动画 ID
#--------------------------------------------------------------------------
def animation1_id
weapon ? weapon.animation1_id : 0
end
#--------------------------------------------------------------------------
# ● 普通攻击 获取对像方动画 ID
#--------------------------------------------------------------------------
def animation2_id
weapon ? weapon.animation2_id : 0
end
#--------------------------------------------------------------------------
# ● 获取职业名称
#--------------------------------------------------------------------------
def class_name
self.class.name
end
#--------------------------------------------------------------------------
# ● 等级的比例
#--------------------------------------------------------------------------
def level_rate
initial_level = $data_actors[@actor_id].initial_level
final_level = $data_actors[@actor_id].final_level
return 1.0 if initial_level == final_level
return (@level - initial_level).to_f / (final_level - initial_level)
end
#--------------------------------------------------------------------------
# ● 经验的比例
#--------------------------------------------------------------------------
def exp_rate
next_level = @exp_list[@level + 1]
return 1.0 if next_level == 0
this_level = @exp_list[@level]
return (@exp - this_level).to_f / (next_level - this_level)
end
#--------------------------------------------------------------------------
# ● 更改 EXP
# exp : 新的 EXP
#--------------------------------------------------------------------------
def exp=(exp)
@exp = exp.limit(0, EXP_MAX)
# 升级
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
# 学会特技
for j in $data_classes[@class_id].learnings
if j.level == @level
learn_skill(j.skill_id)
end
end
end
# 降级
while @exp < @exp_list[@level]
@level -= 1
end
# 修正当前的 HP 与 SP 超过最大值
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
#--------------------------------------------------------------------------
# ● 更新自动状态
# old_equip : 卸下防具
# new_equip : 装备防具
#--------------------------------------------------------------------------
def update_auto_state(old_equip, new_equip)
# 强制解除卸下防具的自动状态
deprive_state(old_equip.auto_state_id) if old_equip
# 强制附加装备防具的自动状态
enforce_state(new_equip.auto_state_id) if new_equip
end
#--------------------------------------------------------------------------
# ● 强制附加自动状态
# state : 被附加的状态
#--------------------------------------------------------------------------
def enforce_state(s)
return if $data_states[s] == nil
# 对附加该状态的装备计数加1
@forced_states[s] = (@forced_states[s] || 0) + 1
# 第一件装备的状态,强制附加
add_state(s, true) if @forced_states[s] == 1
end
#--------------------------------------------------------------------------
# ● 强制解除自动状态
# state : 被附加的状态
#--------------------------------------------------------------------------
def deprive_state(s)
return if $data_states[s] == nil
# 对附加该状态的装备计数减1
@forced_states[s] = (@forced_states[s] || 1) - 1
# 计数已归0的情况下,强制解除
remove_state(s, true) if @forced_states[s] == 0
end
#--------------------------------------------------------------------------
# ● 学会的技能(按ID排序)
#--------------------------------------------------------------------------
def learned_skills
self.skills.map {|n| $data_skills[n]}
end
end
#==============================================================================
# ■ Game_Actors
#==============================================================================
class Game_Actors
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 获取角色
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def [](actor_id)
return nil if actor_id > DATA_MAX or $data_actors[actor_id].nil?
@data[actor_id] ||= Game_Actor.new(actor_id)
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_setup_starting_members)
alias sailcat_sepcore_setup_starting_members setup_starting_members
alias sailcat_sepcore_setup_battle_test_members setup_battle_test_members
end
#--------------------------------------------------------------------------
# ● 设置初期同伴
#--------------------------------------------------------------------------
def setup_starting_members
sailcat_sepcore_setup_starting_members
$game_player.transparent = START_TRANSPARENT
end
#--------------------------------------------------------------------------
# ● 设置战斗测试用同伴
#--------------------------------------------------------------------------
def setup_battle_test_members
sailcat_sepcore_setup_battle_test_members
@items.each_key {|k| @items[k] = ITEM_MAX}
end
#--------------------------------------------------------------------------
# ● 增加金钱 (减少)
# n : 金额
#--------------------------------------------------------------------------
def gain_gold(n)
@gold = (@gold + n).limit(0, GOLD_MAX)
end
#--------------------------------------------------------------------------
# ● 增加步数
#--------------------------------------------------------------------------
def increase_steps
@steps = (@steps + 1).limit(nil, STEPS_MAX)
end
#--------------------------------------------------------------------------
# ● 增加物品 (减少)
# item_id : 物品 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_item(item_id, n)
# 更新 hash 的个数数据
if item_id > 0
@items[item_id] = (item_number(item_id) + n).limit(0, ITEM_MAX)
end
end
#--------------------------------------------------------------------------
# ● 增加武器 (减少)
# weapon_id : 武器 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_weapon(weapon_id, n)
# 更新 hash 的个数数据
if weapon_id > 0
@weapons[weapon_id] = (weapon_number(weapon_id) + n).limit(0, ITEM_MAX)
end
end
#--------------------------------------------------------------------------
# ● 增加防具 (减少)
# armor_id : 防具 ID
# n : 个数
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
# 更新 hash 的个数数据
if armor_id > 0
@armors[armor_id] = (armor_number(armor_id) + n).limit(0, ITEM_MAX)
end
end
#--------------------------------------------------------------------------
# ● 队伍持有的物品
#--------------------------------------------------------------------------
def items
@items.select {|k, v| v > 0}.map {|k| $data_items[k[0]]}.compact
end
#--------------------------------------------------------------------------
# ● 队伍持有的物品(按ID排序)
#--------------------------------------------------------------------------
def sorted_items
items.sort_by {|item| item.id}
end
#--------------------------------------------------------------------------
# ● 队伍持有的武器
#--------------------------------------------------------------------------
def weapons
@weapons.select {|k, v| v > 0}.map {|k| $data_weapons[k[0]]}.compact
end
#--------------------------------------------------------------------------
# ● 队伍持有的武器(按ID排序)
#--------------------------------------------------------------------------
def sorted_weapons
weapons.sort_by {|item| item.id}
end
#--------------------------------------------------------------------------
# ● 队伍持有的防具
# kind : 装备的类型(0..3,-1为不限制)
#--------------------------------------------------------------------------
def armors(kind = -1)
a = @armors.select {|k, v| v > 0}.map {|k| $data_armors[k[0]]}.compact
kind == -1 ? a : a.select {|armor| armor.kind == kind}
end
#--------------------------------------------------------------------------
# ● 队伍持有的防具(按ID排序)
#--------------------------------------------------------------------------
def sorted_armors
armors.sort_by {|item| item.id}
end
#--------------------------------------------------------------------------
# ● 获得任意物品的所持数
#--------------------------------------------------------------------------
def any_number(item)
case item
when RPG::Item
item_number(item.id)
when RPG::Weapon
weapon_number(item.id)
when RPG::Armor
armor_number(item.id)
else
0
end
end
end
#==============================================================================
# ■ Game_Character
#==============================================================================
class Game_Character
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_move_type_custom)
alias sailcat_sepcore_move_type_custom move_type_custom
end
#--------------------------------------------------------------------------
# ● 移动类型 : 自定义
#--------------------------------------------------------------------------
def move_type_custom
sailcat_sepcore_move_type_custom
# 如果设置了等待帧数
if @wait_count > 0
# 按新的帧率修订帧数
wait = (@wait_count + 1) >> 1
@wait_count = wait * FRAME_SKIP - 1
end
end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_setup)
alias sailcat_sepcore_setup setup
end
#--------------------------------------------------------------------------
# ● 设置
# map_id : 地图 ID
#--------------------------------------------------------------------------
def setup(map_id)
sailcat_sepcore_setup(map_id)
post_setup
end
#--------------------------------------------------------------------------
# ● 后续设置处理
#--------------------------------------------------------------------------
def post_setup
@common_events.reject! {|k, v| $data_common_events[k].trigger == 0}
end
end
#==============================================================================
# ■ Spriteset
#------------------------------------------------------------------------------
# 游戏中场景用精灵集合的公用Mix-in模块,判定用。
#==============================================================================
module Spriteset
end
#==============================================================================
# ■ Spriteset_Map
#==============================================================================
class Spriteset_Map
include Spriteset
end
#==============================================================================
# ■ Spriteset_Battle
#==============================================================================
class Spriteset_Battle
include Spriteset
end
#==============================================================================
# ■ Window_Base
#==============================================================================
class Window_Base
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 等级的描画
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y)
contents.font.color = system_color
contents.draw_text(x, y, 32, 32, Vocab.level_a)
contents.font.color = normal_color
contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
end
#--------------------------------------------------------------------------
# ● 生成描绘用状态字符串
# actor : 角色
# width : 描画目标的宽度
# need_normal : [正常] 是否为必须 (true / false)
#--------------------------------------------------------------------------
def make_battler_state_text(battler, width, need_normal)
width -= contents.text_size("[]").width - contents.text_size("/").width
# 生成状态名字符串
text = ""
for i in battler.states
next if $data_states[i].rating == 0
new_text = text + $data_states[i].name + "/"
break if contents.text_size(new_text).width > width
text = new_text
end
text = "[" + text.chop + "]"
# 返回完成后的文字
return text == "[]" ? (need_normal ? Vocab.state_empty : "") : text
end
#--------------------------------------------------------------------------
# ● 描画 EXP
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_exp(actor, x, y)
contents.font.color = system_color
contents.draw_text(x, y, 24, 32, Vocab.exp_a)
contents.font.color = normal_color
contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
contents.draw_text(x + 108, y, 12, 32, "/", 1)
contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
end
end
#==============================================================================
# ■ Window_PlayTime
#==============================================================================
class Window_PlayTime
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_refresh)
alias sailcat_sepcore_refresh refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
sailcat_sepcore_refresh
contents.clear_rect(4, 0, 120, 32)
contents.font.color = system_color
contents.draw_text(4, 0, 120, 32, Vocab.playtime)
end
end
#==============================================================================
# ■ Window_Steps
#==============================================================================
class Window_Steps
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
contents.font.color = system_color
contents.draw_text(4, 0, 120, 32, Vocab.steps)
contents.font.color = normal_color
contents.draw_text(4, 32, 120, 32, $game_party.steps.to_s, 2)
end
end
#==============================================================================
# ■ Window_Status
#==============================================================================
class Window_Status
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_refresh)
alias sailcat_sepcore_refresh refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
sailcat_sepcore_refresh
contents.font.color = system_color
contents.clear_rect(320, 48, 80, 32)
contents.draw_text(320, 48, 80, 32, Vocab.exp)
contents.clear_rect(320, 80, 80, 32)
contents.draw_text(320, 80, 80, 32, Vocab.next_level)
contents.clear_rect(320, 160, 96, 32)
contents.draw_text(320, 160, 96, 32, Vocab.equipment)
end
end
#==============================================================================
# ■ Window_SaveFile
#==============================================================================
class Window_SaveFile
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_refresh)
alias sailcat_sepcore_refresh refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
sailcat_sepcore_refresh
contents.clear_rect(4, 0, @name_width, 32)
name = "#{Vocab.file} #{@file_index + 1}"
@name_width = contents.text_size(name).width
contents.draw_text(4, 0, @name_width, 32, name)
end
end
#==============================================================================
# ■ Window_ShopCommand
#==============================================================================
class Window_ShopCommand
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 64, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 3
@column_max = 3
@commands = [Vocab.buy, Vocab.sell, Vocab.cancel]
refresh
self.index = 0
end
end
#==============================================================================
# ■ Window_ShopBuy
#==============================================================================
class Window_ShopBuy
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
# 获取物品所持数
number = $game_party.any_number(item)
# 价格在所持金以下、并且所持数不是上限的情况下为普通文字颜色
# 除此之外的情况设置为无效文字色
if item.price <= $game_party.gold and (!ITEM_MAX or number < ITEM_MAX)
contents.font.color = normal_color
else
contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
contents.clear_rect(rect)
bitmap = RPG::Cache.icon(item.icon_name)
opacity = contents.font.color == normal_color ? 255 : 128
contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
contents.draw_text(x + 28, y, 212, 32, item.name, 0)
contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
end
#==============================================================================
# ■ Window_ShopNumber
#==============================================================================
class Window_ShopNumber
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
if self.active
change(+1) if Input.repeat?(Input::RIGHT) and (!@max or @number < @max)
change(-1) if Input.repeat?(Input::LEFT) and @number > 1
change(+10) if Input.repeat?(Input::UP) and (!@max or @number < @max)
change(-10) if Input.repeat?(Input::DOWN) and @number > 1
end
end
#--------------------------------------------------------------------------
# ● 更改数值
#--------------------------------------------------------------------------
def change(delta)
# 按下SHIFT键的情况下100倍变化
if Input.press?(Input::SHIFT)
fold = 100
# 按下CTRL键的情况下10000倍变化
elsif Input.press?(Input::CTRL)
fold = 10000
# 按下ALT键的情况下1000000倍变化
elsif Input.press?(Input::ALT)
fold = 1000000
# 1倍变化
else
fold = 1
end
$game_system.se_play($data_system.cursor_se)
@number = (@number + delta * fold).limit(1, @max)
refresh
end
end
#==============================================================================
# ■ Window_ShopStatus
#==============================================================================
class Window_ShopStatus
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_refresh)
alias sailcat_sepcore_refresh refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
sailcat_sepcore_refresh
contents.clear_rect(4, 0, 200, 32)
contents.font.color = system_color
contents.draw_text(4, 0, 200, 32, Vocab.hold_number)
end
end
#==============================================================================
# ■ Window_NameInput
#==============================================================================
class Window_NameInput
CHARACTER_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",".",",","?","!",
"`","~","@","#","$","%","^","&","-","+","1","2","3","4","5",
"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",":",";","(",")",
"=","[","]","{","}","<",">","'",'"',"_","6","7","8","9","0",
"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","。",",","?","!",
"`","~","@","#","$","%","^","&","-","+","1","2","3","4","5",
"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",":",";","(",")",
"=","[","]","{","}","<",">","'",""","_","6","7","8","9","0"
]
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_refresh)
alias sailcat_sepcore_refresh refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
sailcat_sepcore_refresh
contents.clear_rect(544, 288, 64, 32)
contents.draw_text(544, 288, 64, 32, Vocab.ok, 1)
end
end
#==============================================================================
# ■ Window_PartyCommand
#==============================================================================
class Window_PartyCommand
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
@commands = [Vocab.fight, Vocab.escape]
@item_max = 2
@column_max = 2
draw_item(0, normal_color)
draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
self.active = false
self.visible = false
self.index = 0
end
end
#==============================================================================
# ■ Window_BattleResult
#==============================================================================
class Window_BattleResult
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
x = 4
contents.font.color = normal_color
cx = contents.text_size(@exp.to_s).width
contents.draw_text(x, 0, cx, 32, @exp.to_s)
x += cx + 4
contents.font.color = system_color
cx = contents.text_size(Vocab.exp).width
contents.draw_text(x, 0, 64, 32, Vocab.exp)
x += cx + 16
contents.font.color = normal_color
cx = contents.text_size(@gold.to_s).width
contents.draw_text(x, 0, cx, 32, @gold.to_s)
x += cx + 4
contents.font.color = system_color
contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
y = 32
for item in @treasures
draw_item_name(item, 4, y)
y += 32
end
end
end
#==============================================================================
# ■ Interpreter
#==============================================================================
class Interpreter
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 方法重定义
#--------------------------------------------------------------------------
unless method_defined?(:sailcat_sepcore_command_355)
alias sailcat_sepcore_command_355 command_355
end
#--------------------------------------------------------------------------
# ● 转换帧数
#--------------------------------------------------------------------------
def frames(value)
value * FRAME_SKIP
end
#--------------------------------------------------------------------------
# ● 等待
#--------------------------------------------------------------------------
def command_106
# 设置等待计数
@wait_count = frames(@parameters[0])
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 变量操作
#--------------------------------------------------------------------------
def command_122
# 初始化值
value = 0
# 操作数的分支
case @parameters[3]
when 0 # 恒量
value = @parameters[4]
when 1 # 变量
value = $game_variables[@parameters[4]]
when 2 # 随机数
value = @parameters[4] + rand(@parameters[5] - @parameters[4] + 1)
when 3 # 物品
value = $game_party.item_number(@parameters[4])
when 4 # 角色
actor = $game_actors[@parameters[4]]
if actor != nil
case @parameters[5]
when 0 # 等级
value = actor.level
when 1 # EXP
value = actor.exp
when 2 # HP
value = actor.hp
when 3 # SP
value = actor.sp
when 4 # MaxHP
value = actor.maxhp
when 5 # MaxSP
value = actor.maxsp
when 6 # 力量
value = actor.str
when 7 # 灵巧
value = actor.dex
when 8 # 速度
value = actor.agi
when 9 # 魔力
value = actor.int
when 10 # 攻击力
value = actor.atk
when 11 # 物理防御
value = actor.pdef
when 12 # 魔法防御
value = actor.mdef
when 13 # 回避修正
value = actor.eva
end
end
when 5 # 敌人
enemy = $game_troop.enemies[@parameters[4]]
if enemy != nil
case @parameters[5]
when 0 # HP
value = enemy.hp
when 1 # SP
value = enemy.sp
when 2 # MaxHP
value = enemy.maxhp
when 3 # MaxSP
value = enemy.maxsp
when 4 # 力量
value = enemy.str
when 5 # 灵巧
value = enemy.dex
when 6 # 速度
value = enemy.agi
when 7 # 魔力
value = enemy.int
when 8 # 攻击力
value = enemy.atk
when 9 # 物理防御
value = enemy.pdef
when 10 # 魔法防御
value = enemy.mdef
when 11 # 回避修正
value = enemy.eva
end
end
when 6 # 角色
character = get_character(@parameters[4])
if character != nil
case @parameters[5]
when 0 # X 坐标
value = character.x
when 1 # Y 坐标
value = character.y
when 2 # 朝向
value = character.direction
when 3 # 画面 X 坐标
value = character.screen_x
when 4 # 画面 Y 坐标
value = character.screen_y
when 5 # 地形标记
value = character.terrain_tag
end
end
when 7 # 其它
case @parameters[4]
when 0 # 地图 ID
value = $game_map.map_id
when 1 # 同伴人数
value = $game_party.actors.size
when 2 # 金钱
value = $game_party.gold
when 3 # 步数
value = $game_party.steps
when 4 # 游戏时间
value = Graphics.frame_count / Graphics.frame_rate
when 5 # 计时器
value = $game_system.timer / Graphics.frame_rate
when 6 # 存档次数
value = $game_system.save_count
end
end
# 循环全部操作
for i in @parameters[0] .. @parameters[1]
# 操作分支
case @parameters[2]
when 0 # 代入
$game_variables[i] = value
when 1 # 加法
$game_variables[i] += value
when 2 # 减法
$game_variables[i] -= value
when 3 # 乘法
$game_variables[i] *= value
when 4 # 除法
if value != 0
$game_variables[i] /= value
end
when 5 # 剩余
if value != 0
$game_variables[i] %= value
end
end
# 检查上下限
$game_variables[i] = $game_variables[i].limit(-VAR_MAX, VAR_MAX)
end
# 刷新地图
$game_map.need_refresh = true
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 更改雾的色调
#--------------------------------------------------------------------------
def command_205
# 开始更改色调
$game_map.start_fog_tone_change(@parameters[0], frames(@parameters[1]))
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 更改雾的不透明度
#--------------------------------------------------------------------------
def command_206
# 开始更改不透明度
$game_map.start_fog_opacity_change(@parameters[0], frames(@parameters[1]))
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 更改画面色调
#--------------------------------------------------------------------------
def command_223
# 开始更改色调
$game_screen.start_tone_change(@parameters[0], frames(@parameters[1]))
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 画面闪烁
#--------------------------------------------------------------------------
def command_224
# 开始闪烁
$game_screen.start_flash(@parameters[0], frames(@parameters[1]))
# 继续
return true
end
#--------------------------------------------------------------------------
# ● 脚本
#--------------------------------------------------------------------------
def command_355
result = sailcat_sepcore_command_355
@index += 1 if result == false
return result
end
end
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
# 游戏中全部场景的公用模块。
#==============================================================================
module Scene_Base
include SailCat::Core_Config
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
return unless need_create?
create
post_create
Graphics.transition unless @custom_transition
update_scene until $scene != self
Graphics.freeze
pre_terminate
terminate
end
#--------------------------------------------------------------------------
# ● 建立预判
#--------------------------------------------------------------------------
def need_create?
true
end
#--------------------------------------------------------------------------
# ● 建立场景
#--------------------------------------------------------------------------
def create
prepare_data
create_spriteset
create_all_sprites
create_all_windows
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
end
#--------------------------------------------------------------------------
# ● 更新场景
#--------------------------------------------------------------------------
def update_scene
Graphics.update
Input.update
update
end
#--------------------------------------------------------------------------
# ● 终止场景
#--------------------------------------------------------------------------
def pre_terminate
end
#--------------------------------------------------------------------------
# ● 结束场景
#--------------------------------------------------------------------------
def terminate
dispose_spriteset
dispose_all_sprites
dispose_all_windows
after_effect
end
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
end
#--------------------------------------------------------------------------
# ● 建立精灵组
#--------------------------------------------------------------------------
def create_spriteset
end
#--------------------------------------------------------------------------
# ● 建立精灵
#--------------------------------------------------------------------------
def create_all_sprites
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
end
#--------------------------------------------------------------------------
# ● 更新窗口
#--------------------------------------------------------------------------
def update_all_windows
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.update if i.is_a?(Window) and not i.disposed?}
end
#--------------------------------------------------------------------------
# ● 释放精灵组
#--------------------------------------------------------------------------
def dispose_spriteset
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.dispose if i.is_a?(Spriteset)}
end
#--------------------------------------------------------------------------
# ● 释放精灵
#--------------------------------------------------------------------------
def dispose_all_sprites
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each do |i|
if i.is_a?(Sprite) and not i.disposed?
i.bitmap.dispose unless i.bitmap.disposed?
i.dispose
end
end
end
#--------------------------------------------------------------------------
# ● 释放窗口
#--------------------------------------------------------------------------
def dispose_all_windows
ivar = instance_variables.map {|i| instance_variable_get(i)}.flatten
ivar.each {|i| i.dispose if i.is_a?(Window) and not i.disposed?}
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
end
end
#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立预判
#--------------------------------------------------------------------------
def need_create?
# 战斗测试的情况下
if $BTEST
battle_test
return false
end
return true
end
#--------------------------------------------------------------------------
# ● 准备场景数据
#--------------------------------------------------------------------------
def prepare_data
# 载入数据库
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# 生成系统对像
$game_system = Game_System.new
end
#--------------------------------------------------------------------------
# ● 建立精灵
#--------------------------------------------------------------------------
def create_all_sprites
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
s1 = Vocab.new_game
s2 = Vocab.continue
s3 = Vocab.quit
@command_window = Window_Command.new(192, [s1, s2, s3])
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# 判定继续的有效性
# 存档文件一个也不存在的时候也调查
# 有効为 @continue_enabled 为 true、無効为 false
@continue_enabled = false
for i in 0..3
if FileTest.exist?("Save#{i+1}.rxdata")
@continue_enabled = true
end
end
# 继续为有效的情况下、光标停止在继续上
# 无效的情况下、继续的文字显示为灰色
if @continue_enabled
@command_window.index = 1
else
@command_window.disable_item(1)
end
# 演奏标题 BGM
$game_system.bgm_play($data_system.title_bgm)
# 停止演奏 ME、BGS
Audio.me_stop
Audio.bgs_stop
end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立精灵组
#--------------------------------------------------------------------------
def create_spriteset
@spriteset = Spriteset_Map.new
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@message_window = Window_Message.new
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
# 标题画面切换中的情况下
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
# 生成命令窗口
s1 = Vocab.item
s2 = Vocab.skill
s3 = Vocab.equip
s4 = Vocab.status
s5 = Vocab.save
s6 = Vocab.end_game
@command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
# 生成游戏时间窗口
@playtime_window = Window_PlayTime.new
# 生成步数窗口
@steps_window = Window_Steps.new
# 生成金钱窗口
@gold_window = Window_Gold.new
# 生成状态窗口
@status_window = Window_MenuStatus.new
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@command_window.index = @menu_index
# 同伴人数为 0 的情况下
if $game_party.actors.size == 0
# 物品、特技、装备、状态无效化
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# 禁止存档的情况下
if $game_system.save_disabled
# 存档无效
@command_window.disable_item(4)
end
@playtime_window.x = 0
@playtime_window.y = 224
@steps_window.x = 0
@steps_window.y = 320
@gold_window.x = 0
@gold_window.y = 416
@status_window.x = 160
@status_window.y = 0
end
end
#==============================================================================
# ■ Scene_Item
#==============================================================================
class Scene_Item
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@help_window = Window_Help.new
@item_window = Window_Item.new
@target_window = Window_Target.new
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
# 关联帮助窗口
@item_window.help_window = @help_window
@target_window.visible = false
@target_window.active = false
end
end
#==============================================================================
# ■ Scene_Skill
#==============================================================================
class Scene_Skill
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
@actor = $game_party.actors[@actor_index]
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@help_window = Window_Help.new
@status_window = Window_SkillStatus.new(@actor)
@skill_window = Window_Skill.new(@actor)
@target_window = Window_Target.new
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
# 关联帮助窗口
@skill_window.help_window = @help_window
@target_window.visible = false
@target_window.active = false
end
end
#==============================================================================
# ■ Scene_Equip
#==============================================================================
class Scene_Equip
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
@actor = $game_party.actors[@actor_index]
end
#--------------------------------------------------------------------------
# ● 生成窗口
#--------------------------------------------------------------------------
def create_all_windows
@help_window = Window_Help.new
@left_window = Window_EquipLeft.new(@actor)
@right_window = Window_EquipRight.new(@actor)
@item_window1 = Window_EquipItem.new(@actor, 0)
@item_window2 = Window_EquipItem.new(@actor, 1)
@item_window3 = Window_EquipItem.new(@actor, 2)
@item_window4 = Window_EquipItem.new(@actor, 3)
@item_window5 = Window_EquipItem.new(@actor, 4)
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
# 关联帮助窗口
@right_window.help_window = @help_window
@item_window1.help_window = @help_window
@item_window2.help_window = @help_window
@item_window3.help_window = @help_window
@item_window4.help_window = @help_window
@item_window5.help_window = @help_window
# 设置光标位置
@right_window.index = @equip_index
refresh
end
end
#==============================================================================
# ■ Scene_Status
#==============================================================================
class Scene_Status
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
@actor = $game_party.actors[@actor_index]
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@status_window = Window_Status.new(@actor)
end
end
#==============================================================================
# ■ Scene_File
#==============================================================================
class Scene_File
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
# 生成帮助窗口
@help_window = Window_Help.new
# 生成存档文件窗口
@savefile_windows = []
for i in 0..3
@savefile_windows.push(Window_SaveFile.new(i, make_filename(i)))
end
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@help_window.set_text(@help_text)
# 选择最后操作的文件
@file_index = $game_temp.last_file_index
@savefile_windows[@file_index].selected = true
end
end
#==============================================================================
# ■ Scene_End
#==============================================================================
class Scene_End
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
# 生成命令窗口
s1 = Vocab.to_title
s2 = Vocab.quit
s3 = Vocab.cancel
@command_window = Window_Command.new(192, [s1, s2, s3])
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 240 - @command_window.height / 2
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
# 如果在标题画面切换中的情况下
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
# 初始化战斗用的各种暂时数据
$game_temp.in_battle = true
$game_temp.battle_turn = 0
$game_temp.battle_event_flags.clear
$game_temp.battle_abort = false
$game_temp.battle_main_phase = false
$game_temp.battleback_name = $game_map.battleback_name
$game_temp.forcing_battler = nil
# 初始化战斗用事件解释器
$game_system.battle_interpreter.setup(nil, 0)
# 准备队伍
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
end
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
# 生成角色命令窗口
s1 = Vocab.attack
s2 = Vocab.skill
s3 = Vocab.guard
s4 = Vocab.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
# 生成其它窗口
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
end
#--------------------------------------------------------------------------
# ● 建立精灵组
#--------------------------------------------------------------------------
def create_spriteset
# 生成活动块
@spriteset = Spriteset_Battle.new
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
@help_window.back_opacity = 160
@help_window.visible = false
# 初始化等待计数
@wait_count = 0
# 执行过渡
@custom_transition = true
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# 开始自由战斗回合
start_phase1
end
#--------------------------------------------------------------------------
# ● 终止场景
#--------------------------------------------------------------------------
def pre_terminate
# 刷新地图
$game_map.refresh
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
# 标题画面切换中的情况
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
# 战斗测试或者游戏结束以外的画面切换中的情况
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 4 : 对像方动画)
#--------------------------------------------------------------------------
def update_phase4_step4
# 对像方动画
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != Vocab.miss)
end
# 限制动画长度、最低 8 帧
@wait_count = 8
# 移至步骤 5
@phase4_step = 5
end
end
#==============================================================================
# ■ Scene_Shop
#==============================================================================
class Scene_Shop
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@help_window = Window_Help.new
@command_window = Window_ShopCommand.new
@gold_window = Window_Gold.new
@dummy_window = Window_Base.new(0, 128, 640, 352)
@buy_window = Window_ShopBuy.new($game_temp.shop_goods)
@sell_window = Window_ShopSell.new
@number_window = Window_ShopNumber.new
@status_window = Window_ShopStatus.new
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
@gold_window.x = 480
@gold_window.y = 64
@buy_window.active = false
@buy_window.visible = false
@buy_window.help_window = @help_window
@sell_window.active = false
@sell_window.visible = false
@sell_window.help_window = @help_window
@number_window.active = false
@number_window.visible = false
@status_window.visible = false
end
#--------------------------------------------------------------------------
# ● 刷新画面 (购买窗口激活的情况下)
#--------------------------------------------------------------------------
def update_buy
# 设置状态窗口的物品
@status_window.item = @buy_window.item
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
# 删除帮助文本
@help_window.set_text("")
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 获取物品
@item = @buy_window.item
# 物品无效的情况下、或者价格在所持金以上的情况下
if @item == nil or @item.price > $game_party.gold
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 获取物品所持数
number = $game_party.any_number(@item)
# 如果拥有个数已达上限
if number == ITEM_MAX
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 计算可以最多购买的数量
max = @item.price == 0 ? ITEM_MAX : $game_party.gold / @item.price
max = [max, ITEM_MAX - number].min if ITEM_MAX
# 窗口状态转向数值输入模式
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
end
end
end
#==============================================================================
# ■ Scene_Name
#==============================================================================
class Scene_Name
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 加载数据
#--------------------------------------------------------------------------
def prepare_data
# 获取角色
@actor = $game_actors[$game_temp.name_actor_id]
end
#--------------------------------------------------------------------------
# ● 生成窗口
#--------------------------------------------------------------------------
def create_all_windows
@edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)
@input_window = Window_NameInput.new
end
end
#==============================================================================
# ■ Scene_Gameover
#==============================================================================
class Scene_Gameover
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立精灵
#--------------------------------------------------------------------------
def create_all_sprites
# 生成游戏结束图形
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.gameover($data_system.gameover_name)
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
# 停止 BGM、BGS
$game_system.bgm_play(nil)
$game_system.bgs_play(nil)
# 演奏游戏结束 ME
$game_system.me_play($data_system.gameover_me)
# 执行过渡
@custom_transition = true
Graphics.transition(120)
end
#--------------------------------------------------------------------------
# ● 结束效果
#--------------------------------------------------------------------------
def after_effect
# 执行过渡
Graphics.transition(40)
# 准备过渡
Graphics.freeze
# 战斗测试的情况下
$scene = nil if $BTEST
end
end
#==============================================================================
# ■ Scene_Debug
#==============================================================================
class Scene_Debug
remove_method :main
include Scene_Base
#--------------------------------------------------------------------------
# ● 建立窗口
#--------------------------------------------------------------------------
def create_all_windows
@left_window = Window_DebugLeft.new
@right_window = Window_DebugRight.new
@help_window = Window_Base.new(192, 352, 448, 128)
@help_window.contents = Bitmap.new(406, 96)
end
#--------------------------------------------------------------------------
# ● 设置场景
#--------------------------------------------------------------------------
def post_create
# 还原为上次选择的项目
@left_window.top_row = $game_temp.debug_top_row
@left_window.index = $game_temp.debug_index
@right_window.mode = @left_window.mode
@right_window.top_id = @left_window.top_id
end
#--------------------------------------------------------------------------
# ● 终止场景
#--------------------------------------------------------------------------
def pre_terminate
$game_map.refresh
end
#--------------------------------------------------------------------------
# ● 刷新画面 (右侧窗口被激活的情况下)
#--------------------------------------------------------------------------
def update_right
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 激活左侧窗口
@left_window.active = true
@right_window.active = false
@right_window.index = -1
# 删除帮助
@help_window.contents.clear
return
end
# 获取被选择的开关 / 变量的 ID
current_id = @right_window.top_id + @right_window.index
# 开关的情况下
if @right_window.mode == 0
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 逆转 ON / OFF 状态
$game_switches[current_id] = (not $game_switches[current_id])
@right_window.refresh
return
end
end
# 变量的情况下
if @right_window.mode == 1
# 按下右键的情况下
return set_variable(current_id, +1) if Input.repeat?(Input::RIGHT)
# 按下左键的情况下
return set_variable(current_id, -1) if Input.repeat?(Input::LEFT)
# 按下 R 键的情况下
return set_variable(current_id, +10) if Input.repeat?(Input::R)
# 按下 L 键的情况下
return set_variable(current_id, -10) if Input.repeat?(Input::L)
end
end
#--------------------------------------------------------------------------
# ● 更新变量值
#--------------------------------------------------------------------------
def set_variable(id, value)
# 按下SHIFT键的情况下100倍变化
if Input.press?(Input::SHIFT)
fold = 100
# 按下CTRL键的情况下10000倍变化
elsif Input.press?(Input::CTRL)
fold = 10000
# 按下ALT键的情况下1000000倍变化
elsif Input.press?(Input::ALT)
fold = 1000000
# 1倍变化
else
fold = 1
end
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
$game_variables[id] += value * fold
$game_variables[id] = $game_variables[id].limit(-VAR_MAX, VAR_MAX)
@right_window.refresh
end
end
Font.default_size = SailCat::Core_Config::FONT_SIZE_DEFAULT
Graphics.frame_rate = SailCat::Core_Config::FRAME_RATE