module Taroxd
#--------------------------------------------------------------------------
# ● 游戏常数设置区域(如果要用默认值,请改为 false)
#--------------------------------------------------------------------------
MAX_TP = 100 # TP的最大值
BASIC_FLOOR_DAMAGE = 10 # 地形伤害的基础值
ATTACK_SKILL_ID = 1 # 默认攻击技能ID
GUARD_SKILL_ID = 2 # 默认防御技能ID
DEATH_STATE_ID = 1 # 默认死亡状态ID
PARAM_LIMIT = 999999 # 能力值的最大值
MAX_BATTLE_MEMBERS = 4 # 出战角色最大值
CRITICAL_RATE = 3 # 关键一击伤害倍率
DAMAGE_CHARGE_TP_RATE = 50 # 受到伤害时 TP 补充率
LUK_EFFECT_RATE = 0.001 # 幸运值影响程度
SUBSTITUTE_HP_RATE = 0.25 # HP 比率达到多少以下会触发保护弱者
STEPS_FOR_RUN = 20 # 地图上多少步等于一回合
SAVEFILE_MAX = 16 # 存档文件的最大个数
MAX_GOLD = 99999999 # 持有金钱的最大值
ESCAPE_RATIO_UP = 0.1 # 撤退失败后,撤退成功率提升值
BUSH_DEPTH = 8 # 流体地形的深度
BUSH_OPACITY = 128 # 流体地形的不透明度
font_default_name = '字体名称' # 默认字体名称
font_default_size = 24 # 默认字体大小
#--------------------------------------------------------------------------
# ● 检查并设置默认字体
#--------------------------------------------------------------------------
font_exist = [*font_default_name].any? {|n| Font.exist?(n) }
Font.default_name = font_default_name if font_exist
Font.default_size = font_default_size if font_default_size
end
module Taroxd::Def
#------------------------------------------------------------------------
# ● 导入
#------------------------------------------------------------------------
Module.send :include, self
#------------------------------------------------------------------------
# ● 获取方法的访问限制
#------------------------------------------------------------------------
def get_access_control(sym)
return :public if public_method_defined? sym
return :protected if protected_method_defined? sym
return :private if private_method_defined? sym
nil
end
#------------------------------------------------------------------------
# ● 私有方法
#------------------------------------------------------------------------
private
#------------------------------------------------------------------------
# ● 在原方法之后添加内容
#------------------------------------------------------------------------
def def_after(sym, hook = nil, &b)
_def_base(sym) do |old|
if b
define_method sym, &b
hook = instance_method sym
end
if hook.respond_to? :to_sym
hook = hook.to_sym
define_method sym do |*args, &block|
old_value = old.bind(self).(*args, &block)
__send__ hook, *args, &block
old_value
end
elsif hook.respond_to? :call
define_method sym do |*args, &block|
old_value = old.bind(self).(*args, &block)
hook.(*args, &block)
old_value
end
elsif hook.respond_to? :bind
define_method sym do |*args, &block|
old_value = old.bind(self).(*args, &block)
hook.bind(self).(*args, &block)
old_value
end
end
end
end
#------------------------------------------------------------------------
# ● 在原方法之前添加内容
#------------------------------------------------------------------------
def def_before(sym, hook = nil, &b)
_def_base(sym) do |old|
if b
define_method sym, &b
hook = instance_method sym
end
if hook.respond_to? :to_sym
hook = hook.to_sym
define_method sym do |*args, &block|
__send__ hook, *args, &block
old.bind(self).(*args, &block)
end
elsif hook.respond_to? :call
define_method sym do |*args, &block|
hook.(*args, &block)
old.bind(self).(*args, &block)
end
elsif hook.respond_to? :bind
define_method sym do |*args, &block|
hook.bind(self).(*args, &block)
old.bind(self).(*args, &block)
end
end
end
end
#------------------------------------------------------------------------
# ● 利用原方法的返回值重定义方法
#------------------------------------------------------------------------
def def_with(sym, &b)
_def_base(sym) do |old|
define_method sym, &b
new_meth = instance_method sym
define_method sym do |*args, &block|
old_value = old.bind(self).(*args, &block)
new_meth.bind(self).(old_value, *args, &block)
end
end
end
#------------------------------------------------------------------------
# ● 利用原方法重定义方法
#------------------------------------------------------------------------
def def_chain(sym, &b)
_def_base(sym) do |old|
define_method sym, &b
new_meth = instance_method sym
define_method sym do |*args, &block|
new_meth.bind(self).(old.bind(self), *args, &block)
end
end
end
#------------------------------------------------------------------------
# ● 获取旧方法
#------------------------------------------------------------------------
def _def_base(sym)
access = get_access_control sym
old = instance_method sym
yield old
send access, sym
sym
end
end
module Taroxd::Def::Singleton
#------------------------------------------------------------------------
# ● 导入
#------------------------------------------------------------------------
Object.send :include, self
#------------------------------------------------------------------------
# ● 在原方法之后添加内容
#------------------------------------------------------------------------
def singleton_def_after(sym, hook = nil, &b)
_singleton_def_base(sym) do |old|
if b
define_singleton_method sym, &b
hook = method sym
end
if hook.respond_to? :to_sym
hook = hook.to_sym
define_singleton_method sym do |*args, &block|
old_value = old.(*args, &block)
__send__ hook, *args, &block
old_value
end
elsif hook.respond_to? :call
define_singleton_method sym do |*args, &block|
old_value = old.(*args, &block)
hook.(*args, &block)
old_value
end
elsif hook.respond_to? :bind
define_singleton_method sym do |*args, &block|
old_value = old.(*args, &block)
hook.bind(self).(*args, &block)
old_value
end
end
end
end
#------------------------------------------------------------------------
# ● 在原方法之前添加内容
#------------------------------------------------------------------------
def singleton_def_before(sym, hook = nil, &b)
_singleton_def_base(sym) do |old|
if b
define_singleton_method sym, &b
hook = method sym
end
if hook.respond_to? :to_sym
hook = hook.to_sym
define_singleton_method sym do |*args, &block|
__send__ hook, *args, &block
old.(*args, &block)
end
elsif hook.respond_to? :call
define_singleton_method sym do |*args, &block|
hook.(*args, &block)
old.(*args, &block)
end
elsif hook.respond_to? :bind
define_singleton_method sym do |*args, &block|
hook.bind(self).(*args, &block)
old.(*args, &block)
end
end
end
end
#------------------------------------------------------------------------
# ● 利用原方法的返回值重定义方法
#------------------------------------------------------------------------
def singleton_def_with(sym, &b)
_singleton_def_base(sym) do |old|
define_singleton_method sym, &b
new_meth = method sym
define_singleton_method sym do |*args, &block|
new_meth.(old.(*args, &block), *args, &block)
end
end
end
#------------------------------------------------------------------------
# ● 利用原方法重定义方法
#------------------------------------------------------------------------
def singleton_def_chain(sym, &b)
_singleton_def_base(sym) do |old|
define_singleton_method sym, &b
new_meth = method sym
define_singleton_method sym do |*args, &block|
new_meth.(old, *args, &block)
end
end
end
#------------------------------------------------------------------------
# ● 获取旧方法
#------------------------------------------------------------------------
def _singleton_def_base(sym)
access = singleton_class.get_access_control sym
old = method sym
yield old
singleton_class.send access, sym
sym
end
end
%w(def_after def_before def_with def_chain).each do |name|
method = Kernel.method(name)
define_singleton_method(name) {|*a, &b| method.(*a, &b) }
end
module Taroxd::Web
API = Win32API.new('shell32.dll', 'ShellExecuteA', %w(p p p p p i), 'i')
module_function
#--------------------------------------------------------------------------
# ● 打开网页
#--------------------------------------------------------------------------
def open(addr)
API.call(0, 'open', addr, 0, 0, 1)
end
end
module Taroxd::ReadNote
#------------------------------------------------------------------------
# ● 导入
#------------------------------------------------------------------------
include RPG
BaseItem.extend self
Map.extend self
Tileset.extend self
Class::Learning.extend self
#------------------------------------------------------------------------
# ● 任意备注
#------------------------------------------------------------------------
def note_any(name, default, re, capture)
name = name.to_s
mark = name.slice!(/[?!]\Z/)
if method_defined? name
message = "already defined method `#{name}' for #{self}"
raise NameError.new(message, name.to_sym)
end
re = "/<#{name.gsub(/_/, '\s*')}#{re.source}>/i"
default = default.inspect
class_eval %{
def #{name}
return @#{name} if instance_variable_defined? :@#{name}
@#{name} = @note =~ #{re} ? (#{capture}) : (#{default})
end
}, __FILE__, __LINE__
alias_method name + mark, name if mark
end
#------------------------------------------------------------------------
# ● 备注整数
#------------------------------------------------------------------------
def note_i(name, default = 0)
note_any(name, default, /\s*(-?\d+)/, '$1.to_i')
end
#------------------------------------------------------------------------
# ● 备注小数
#------------------------------------------------------------------------
def note_f(name, default = 0.0)
note_any(name, default, /\s*(-?\d+(?:\.\d+)?)/, '$1.to_f')
end
#------------------------------------------------------------------------
# ● 备注字符串
#------------------------------------------------------------------------
def note_s(name, default = '')
note_any(name, default, /\s*(\S.*)/, '$1')
end
#------------------------------------------------------------------------
# ● 备注是否匹配
#------------------------------------------------------------------------
def note_bool(name)
note_any(name, false, //, 'true')
end
end
class Object
#--------------------------------------------------------------------------
# ● 输出并返回自身
#--------------------------------------------------------------------------
def p_self; p self; end
#--------------------------------------------------------------------------
# ● 深度复制
#--------------------------------------------------------------------------
def deep_clone; Marshal.load Marshal.dump self; end
end
class Fixnum < Integer
#---------------------------------------------------------------------------
# ● 获取 id
#---------------------------------------------------------------------------
def id; self; end
end
module Enumerable
#---------------------------------------------------------------------------
# ● 元素之和
#---------------------------------------------------------------------------
def sum(base = 0)
block_given? ? inject(base) {|a, e| a + yield(e) } : inject(base, :+)
end
#---------------------------------------------------------------------------
# ● 元素之积
#---------------------------------------------------------------------------
def pdt(base = 1)
block_given? ? inject(base) {|a, e| a * yield(e) } : inject(base, :*)
end
#---------------------------------------------------------------------------
# ● 元素之平均值(base可取0.0)
#---------------------------------------------------------------------------
def average(base = 0, &block)
sum(base, &block) / [count, 1].max
end
end
#-----------------------------------------------------------------------------
# ● 创建颜色
#-----------------------------------------------------------------------------
def Color(*args)
case args.size
when 1, 2 then Color.code(*args)
when 0, 3, 4 then Color.new(*args)
end
end
Color.define_singleton_method :[], method(:Color)
class << Color
#---------------------------------------------------------------------------
# ● 通过颜色代码创建颜色
#---------------------------------------------------------------------------
def code(code, alpha = 255)
new(code >> 16, (code & 0xff00) >> 8, code & 0xff, alpha)
end
#---------------------------------------------------------------------------
# ● 访问简单颜色
#---------------------------------------------------------------------------
def black; code(0x000000); end
def red; code(0xFF0000); end
def green; code(0x00FF00); end
def blue; code(0x0000FF); end
def white; code(0xFFFFFF); end
end
class Plane_Base < Plane
#---------------------------------------------------------------------------
# ● 初始化
#---------------------------------------------------------------------------
def initialize(viewport = nil)
super
@__visible = true
end
#---------------------------------------------------------------------------
# ● 设置是否可见
#---------------------------------------------------------------------------
def visible=(visible)
super
@__visible = visible
end
#---------------------------------------------------------------------------
# ● 获取是否可见
#---------------------------------------------------------------------------
def visible
@__visible
end
end
#--------------------------------------------------------------------------
# ● 存档文件的最大数
#--------------------------------------------------------------------------
def DataManager.savefile_max
Taroxd::SAVEFILE_MAX
end if Taroxd::SAVEFILE_MAX
module SceneManager
#--------------------------------------------------------------------------
# ● 获取当前场景
#--------------------------------------------------------------------------
def scene; SceneManager.scene; end
#--------------------------------------------------------------------------
# ● 判定当前场景的所属类
#--------------------------------------------------------------------------
def scene_is?(scene_class); SceneManager.scene_is?(scene_class); end
end
#--------------------------------------------------------------------------
# ● 撤退时的处理
#--------------------------------------------------------------------------
def BattleManager.process_escape
$game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
success = @preemptive ? true : (rand < @escape_ratio)
Sound.play_escape
if success
process_abort
else
@escape_ratio += Taroxd::ESCAPE_RATIO_UP
$game_message.add('\.' + Vocab::EscapeFailure)
$game_party.clear_actions
end
wait_for_message
success
end if Taroxd::ESCAPE_RATIO_UP
#----------------------------------------------------------------------------
# ● 重置开关、变量、独立开关
#----------------------------------------------------------------------------
code = %{
def clear
@data.clear
on_change
self
end
alias reset clear
}
Game_Switches.class_eval code
Game_Variables.class_eval code
Game_SelfSwitches.class_eval code
class Game_Pictures
include Enumerable
#--------------------------------------------------------------------------
# ● 迭代
#--------------------------------------------------------------------------
def each
return to_enum(__method__) unless block_given?
@data.each {|picture| yield picture if picture }
self
end
end
class Game_BaseItem
#--------------------------------------------------------------------------
# ● 获取属性
#--------------------------------------------------------------------------
attr_reader :item_id
alias id item_id
#--------------------------------------------------------------------------
# ● 设置装备的 ID
#--------------------------------------------------------------------------
def set_equip(is_weapon, item_id)
@class = is_weapon ? RPG::Weapon : RPG::Armor
@item_id = item_id
self
end
end
class Game_BattlerBase
#--------------------------------------------------------------------------
# ● 最大 TP
#--------------------------------------------------------------------------
def max_tp; Taroxd::MAX_TP; end if Taroxd::MAX_TP
#--------------------------------------------------------------------------
# ● 最大 TP
#--------------------------------------------------------------------------
def mtp; max_tp; end
#--------------------------------------------------------------------------
# ● 获取 TP 的比率
#--------------------------------------------------------------------------
def tp_rate; @tp.fdiv(max_tp); end
#--------------------------------------------------------------------------
# ● 更改 TP
#--------------------------------------------------------------------------
def_after(:tp=) {|_| refresh }
#--------------------------------------------------------------------------
# ● 获取死亡的状态ID
#--------------------------------------------------------------------------
def death_state_id; Taroxd::DEATH_STATE_ID; end if Taroxd::DEATH_STATE_ID
#--------------------------------------------------------------------------
# ● 获取普通能力的最小值
#--------------------------------------------------------------------------
def param_min(param_id); 0; end if Taroxd::PARAM_LIMIT
#--------------------------------------------------------------------------
# ● 获取普通能力的最大值
#--------------------------------------------------------------------------
def param_max(param_id); Taroxd::PARAM_LIMIT; end if Taroxd::PARAM_LIMIT
end
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● 拥有备注的实例构成的数组
#--------------------------------------------------------------------------
def note_objects; feature_objects + skills; end
#--------------------------------------------------------------------------
# ● 受到伤害时增加的 TP
#--------------------------------------------------------------------------
def charge_tp_by_damage(damage_rate)
self.tp += Taroxd::DAMAGE_CHARGE_TP_RATE * damage_rate * tcr
end if Taroxd::DAMAGE_CHARGE_TP_RATE
#--------------------------------------------------------------------------
# ● 获取幸运影响程度
#--------------------------------------------------------------------------
def luk_effect_rate(user)
[1.0 + (user.luk - luk) * Taroxd::LUK_EFFECT_RATE, 0.0].max
end if Taroxd::LUK_EFFECT_RATE
#--------------------------------------------------------------------------
# ● TP 自动恢复
#--------------------------------------------------------------------------
def regenerate_tp; self.tp += mtp * trg; end
#--------------------------------------------------------------------------
# ● 应用关键一击
#--------------------------------------------------------------------------
def apply_critical(damage)
damage * Taroxd::CRITICAL_RATE
end if Taroxd::CRITICAL_RATE
#--------------------------------------------------------------------------
# ● 获取实例
#--------------------------------------------------------------------------
def battler; end
#--------------------------------------------------------------------------
# ● 获取备注
#--------------------------------------------------------------------------
def note; battler.note; end
#--------------------------------------------------------------------------
# ● 获取 ID
#--------------------------------------------------------------------------
def id; battler.id; end
#--------------------------------------------------------------------------
# ● 获取技能实例的数组
#--------------------------------------------------------------------------
def skills
(basic_skills | added_skills).sort.map {|id| $data_skills[id] }
end
#--------------------------------------------------------------------------
# ● 是否拥有技能
#--------------------------------------------------------------------------
def skill?(skill)
basic_skills.include?(skill.id) || added_skills.include?(skill.id)
end
#--------------------------------------------------------------------------
# ● 是否学会技能
#--------------------------------------------------------------------------
def skill_learn?(skill)
skill.kind_of?(RPG::Skill) && basic_skills.include?(skill.id)
end
private
#--------------------------------------------------------------------------
# ● 获取基本技能 ID 所构成的数组
#--------------------------------------------------------------------------
def basic_skills; []; end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● 获取实例
#--------------------------------------------------------------------------
def battler; actor; end
#--------------------------------------------------------------------------
# ● 属性上限
#--------------------------------------------------------------------------
remove_method :param_max if Taroxd::PARAM_LIMIT
#--------------------------------------------------------------------------
# ● 等级最小值
#--------------------------------------------------------------------------
def min_level; 1; end
def min_level?; @level <= min_level; end
#--------------------------------------------------------------------------
# ● 经验值变化
#--------------------------------------------------------------------------
def change_exp(exp, show)
@exp[@class_id] = [exp, 0].max
last_level = @level
last_skills = skills
level_up while !max_level? && self.exp >= next_level_exp
level_down while !min_level? && self.exp < current_level_exp
display_level_up(skills - last_skills) if show && @level > last_level
refresh
end
#--------------------------------------------------------------------------
# ● 获取地形伤害的基础值
#--------------------------------------------------------------------------
def basic_floor_damage
Taroxd::BASIC_FLOOR_DAMAGE
end if Taroxd::BASIC_FLOOR_DAMAGE
#--------------------------------------------------------------------------
# ● 获取普通攻击的技能 ID
#--------------------------------------------------------------------------
def attack_skill_id
Taroxd::ATTACK_SKILL_ID
end if Taroxd::ATTACK_SKILL_ID
#--------------------------------------------------------------------------
# ● 获取防御的技能 ID
#--------------------------------------------------------------------------
def guard_skill_id
Taroxd::GUARD_SKILL_ID
end if Taroxd::GUARD_SKILL_ID
#--------------------------------------------------------------------------
# ● 地图上的多少步等于一回合?
#--------------------------------------------------------------------------
def steps_for_turn
Taroxd::STEPS_FOR_RUN
end if Taroxd::STEPS_FOR_RUN
#--------------------------------------------------------------------------
# ● 是否装备武器
#--------------------------------------------------------------------------
def weapon?(weapon)
@equips.any? {|item| item.id == weapon.id && item.is_weapon? }
end
#--------------------------------------------------------------------------
# ● 是否装备护甲
#--------------------------------------------------------------------------
def armor?(armor)
@equips.any? {|item| item.id == armor.id && item.is_armor? }
end
private
#--------------------------------------------------------------------------
# ● 获取基本技能 ID 所构成的数组
#--------------------------------------------------------------------------
def basic_skills; @skills; end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 获取实例
#--------------------------------------------------------------------------
def battler; enemy; end
#--------------------------------------------------------------------------
# ● 获取敌人 ID
#--------------------------------------------------------------------------
attr_reader :enemy_id
alias id enemy_id
#--------------------------------------------------------------------------
# ● 获取敌人的位图(不自动释放)
#--------------------------------------------------------------------------
def bitmap; Cache.battler(battler_name, battler_hue); end
#--------------------------------------------------------------------------
# ● 获取战斗图的高度
#--------------------------------------------------------------------------
def height; [url=home.php?mod=space&uid=291977]@height[/url] ||= bitmap.height; end
#--------------------------------------------------------------------------
# ● 获取战斗图的宽度
#--------------------------------------------------------------------------
def width; @width ||= bitmap.width; end
private
#--------------------------------------------------------------------------
# ● 获取基本技能 ID 所构成的数组
#--------------------------------------------------------------------------
def basic_skills; enemy.actions.map(&:skill_id); end
end
class Game_Actors
include Enumerable
#--------------------------------------------------------------------------
# ● 迭代
#--------------------------------------------------------------------------
def each
return to_enum(__method__) unless block_given?
@data.each {|actor| yield actor if actor }
self
end
#--------------------------------------------------------------------------
# ● 是否包含
#--------------------------------------------------------------------------
def include?(actor)
@data[actor.id]
end
end
class Game_Unit
include Enumerable
#--------------------------------------------------------------------------
# ● 转为数组
#--------------------------------------------------------------------------
def to_a; members; end
#--------------------------------------------------------------------------
# ● 迭代每位成员
#--------------------------------------------------------------------------
def each
return to_enum(__method__) unless block_given?
members.each {|battler| yield battler }
self
end
alias each_member each
#--------------------------------------------------------------------------
# ● 获取成员
#--------------------------------------------------------------------------
def [](*args); members[*args]; end
alias slice []
#--------------------------------------------------------------------------
# ● 是否为空
#--------------------------------------------------------------------------
def empty?; members.empty?; end
#--------------------------------------------------------------------------
# ● 获取成员人数
#--------------------------------------------------------------------------
def size; members.size; end
alias length size
end
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 增加持有金钱
#--------------------------------------------------------------------------
def +(gold)
gain_gold(gold)
self
end
#--------------------------------------------------------------------------
# ● 减少持有金钱
#--------------------------------------------------------------------------
def -(gold)
lose_gold(gold)
self
end
#--------------------------------------------------------------------------
# ● 使角色离队
#--------------------------------------------------------------------------
def delete(actor)
return unless include?(actor)
remove_actor(actor.id)
actor
end
#--------------------------------------------------------------------------
# ● 使指定位置的成员离队
#--------------------------------------------------------------------------
def delete_at(index)
delete(members[index])
end
#--------------------------------------------------------------------------
# ● 使指定位置的成员离队
#--------------------------------------------------------------------------
def slice!(*args)
actors = members[*args]
if actors.kind_of?(Array)
actors.each {|actor| delete(actor) }
else
delete(actors)
end
end
#--------------------------------------------------------------------------
# ● 删除符合 block 条件的角色
#--------------------------------------------------------------------------
def delete_if
return to_enum(__method__) unless block_given?
members.each {|actor| delete(actor) if yield actor }
self
end
#--------------------------------------------------------------------------
# ● 删除最后的队员
#--------------------------------------------------------------------------
def pop(n = nil)
return slice!(-1) unless n
n = size if n > size
slice!(-n, n)
end
#--------------------------------------------------------------------------
# ● 添加队员
#--------------------------------------------------------------------------
def <<(actor)
add_actor(actor.id)
self
end
#--------------------------------------------------------------------------
# ● 添加队员
#--------------------------------------------------------------------------
def push(*actors)
actors.each {|actor| add_actor(actor.id) }
self
end
#--------------------------------------------------------------------------
# ● 删除领头的队员
#--------------------------------------------------------------------------
def shift(n = nil); n ? slice!(0, n) : slice!(0); end
#--------------------------------------------------------------------------
# ● 获取持有金钱的最大值
#--------------------------------------------------------------------------
def max_gold; Taroxd::MAX_GOLD; end if Taroxd::MAX_GOLD
#--------------------------------------------------------------------------
# ● 获取参战角色的最大数
#--------------------------------------------------------------------------
def max_battle_members
Taroxd::MAX_BATTLE_MEMBERS
end if Taroxd::MAX_BATTLE_MEMBERS
end
class Game_Map
#--------------------------------------------------------------------------
# ● 获取 id
#--------------------------------------------------------------------------
attr_reader :map_id
alias id map_id
#--------------------------------------------------------------------------
# ● 备注
#--------------------------------------------------------------------------
def note; @map.note; end
end
class Game_CharacterBase
#--------------------------------------------------------------------------
# ● 更新草木的深度
#--------------------------------------------------------------------------
def update_bush_depth
if normal_priority? && !object_character? && bush? && !jumping?
@bush_depth = Taroxd::BUSH_DEPTH unless moving?
else
@bush_depth = 0
end
end if Taroxd::BUSH_DEPTH
end
class Game_Followers
include Enumerable
#--------------------------------------------------------------------------
# ● 迭代
#--------------------------------------------------------------------------
def each
return to_enum(__method__) unless block_given?
@data.each {|follower| yield follower }
self
end
#--------------------------------------------------------------------------
# ● 迭代(逆向)
#--------------------------------------------------------------------------
def reverse_each
return to_enum(__method__) unless block_given?
@data.reverse_each {|follower| yield follower }
self
end
end
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● 初始化草木的不透明度
#--------------------------------------------------------------------------
def_after :initialize do |_, _ = nil|
self.bush_opacity = Taroxd::BUSH_OPACITY
end if Taroxd::BUSH_OPACITY
end
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 地图是否变更
#--------------------------------------------------------------------------
def map_changed?; @taroxd_map_id != $game_map.map_id; end
#--------------------------------------------------------------------------
# ● 更新地图 ID
#--------------------------------------------------------------------------
def_after(:update) { @taroxd_map_id = $game_map.map_id }
end
class Window_Variable < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x=0,y=0,width=Graphics.width,height=Graphics.height)
super
self.opacity = 0
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
super
self.visible = show?
refresh if visible && varied?
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@variable = variable
contents.clear
draw_variable
end
#--------------------------------------------------------------------------
# ● 去除边框
#--------------------------------------------------------------------------
def standard_padding; 0; end
#--------------------------------------------------------------------------
# ● 是否显示
#--------------------------------------------------------------------------
def show?; true; end
#--------------------------------------------------------------------------
# ● 绘制内容
#--------------------------------------------------------------------------
def draw_variable; end
#--------------------------------------------------------------------------
# ● 内容
#--------------------------------------------------------------------------
def variable; end
#--------------------------------------------------------------------------
# ● 内容是否改变
#--------------------------------------------------------------------------
def varied?; @variable != variable; end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 检查是否能使用保护弱者
#--------------------------------------------------------------------------
def check_substitute(target, item)
target.hp_rate < Taroxd::SUBSTITUTE_HP_RATE && (!item || !item.certain?)
end if Taroxd::SUBSTITUTE_HP_RATE
#--------------------------------------------------------------------------
# ● 追加战斗信息
#--------------------------------------------------------------------------
def add_battlelog(text)
@log_window.add_text(text)
end
end