Project1
标题:
求大神帮我看看我的两个脚本哪里出现问题了
[打印本页]
作者:
冰枫o鲍辰
时间:
2015-1-12 23:40
标题:
求大神帮我看看我的两个脚本哪里出现问题了
一个是横版战斗 另一个是即时消息 虽然放在一起能用但是战斗的时候即时消息的信息框不见了……(在原工程是会出现的QAQ)新人刚进坑几个月,希望大神能帮我看看 二楼上脚本……
作者:
冰枫o鲍辰
时间:
2015-1-12 23:44
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#
# ■ 熊式横版战斗 by 弗雷德 真移位:神思
#==============================================================================
#如果要需要Game_Battler3类的攻击、特技、物品的方法,请移至161-470行
#因为重写过这三个方法,在原方法里改是不会生效的。
#--------------------------------------------------------------------------
# ● 设定开始
#--------------------------------------------------------------------------
#伤害为0的时候是否显示无效文字,1为显示,0为不显示。
INVALIDSWITCH = 0
# 是否显示死亡图 1为显示,0为不显示。
DEADPIC = 1
# 是否显示总伤害 1为显示,0为不显示。
SHOW_TOTAL_DAMAGE = 0
# 是否显示连击数值 1为显示,0为不显示。
HITSWITCH = 1
# 是否显示SP伤害数值 1为显示,0为不显示。
SDMGSWITCH = 1
# 不是主状态的时候是否稍稍降低点透明度 1为降低,0为不降低
NACTSWITCH = 0
# 会心一击时的音效,不设置为不使用音效。
CRIVOICE = "Critital_hit"
# 会心一击是否开启画面晃动 1为开启,0为关闭
CRISHAKE = 1
# 会心一击是否开启画面闪烁,1为开启,0为关闭
CRIFLASH = 1
# 攻击时不移动的属性编号 默认为29号 参考数据库的设置
# 比如职业枪兵勾上了29号属性,那么当枪兵使用普通攻击时将不会移动。技能也是如此。
UNMOVE = 29
# 攻击到与敌人同一水平线前的属性编号 默认为30号 参考数据库的设置
HOMOVE = 30
##################################################################
module Scene_BattleName
# 设定移动速度
Move_Duration = 28
#设定人物的单帧图,如果不做设定,将直接使用默认的战斗图。
BattlerName = {
"熊大王" => {
"待机" => ["bear_s1","bear_s2","bear_s3","bear_s4"],
"移动" => ["bear_r1","bear_r2","bear_r3","bear_r4"],
"返回" => ["bear_b1","bear_b2","bear_b3","bear_b4"],
"受伤" => ["bear_h"],
"防御" => ["bear_d"],
"死亡" => ["bear_die1","bear_die2"]
},
"弗雷德" => {
"待机" => ["Fred_s1","Fred_s2","Fred_s3","Fred_s4"],
"移动" => ["Fred_r1","Fred_r2","Fred_r3","Fred_r4"],
"返回" => ["Fred_b1","Fred_b2","Fred_b3","Fred_b4"],
"受伤" => ["Fred_h"],
"防御" => ["Fred_d"],
"死亡" => ["Fred_die1","Fred_die2"]
},
}
end
#至于其它的:
#HP伤害数字间距偏移在602行修改。
#SP伤害数字间距偏移在667行修改。
#连击数字间距偏移在713行修改。
#总伤害数字间距偏移在759行修改。
#--------------------------------------------------------------------------
# ● 设定结束
#--------------------------------------------------------------------------
class Game_Battler
attr_accessor :movex # X坐标修正
attr_accessor :movey # Y坐标修正
attr_accessor :startactive # 行为
attr_accessor :damage_sp # 精神伤害值
alias bearrpg_initialize initialize
def initialize
bearrpg_initialize
@damage_sp = 0
@movex = 0
@movey = 0
@startactive = "待机"
end
def width #获取战斗图宽
return RPG::Cache.battler(@battler_name, @battler_hue).width
end
def height #获取战斗图高
return RPG::Cache.battler(@battler_name, @battler_hue).height
end
#--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 清除会心一击标志
self.critical = false
#######伤害开关初始化##################################################bearrpg
$damage_hp = false
$damage_sp = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit)
# 命中的情况下
if hit_result == true
# 计算基本伤害
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
# 属性修正
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 会心一击修正
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# 防御修正
if self.guarding?
self.damage /= 2
end
end
$damage_hp = true if self.damage.is_a?(Numeric)
# $damage_sp = true if self.damage_sp != 0 SP伤害数值开关
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
#####################################bearrpg
# 命中的情况下
if hit_result == true
# 状态冲击解除
remove_states_shock
# HP 的伤害计算
self.hp -= self.damage
# 状态变化
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
if self.damage == 0
self.damage = "无效" if INVALIDSWITCH >0
self.critical = false
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
# 清除会心一击标志
self.critical = false
end
# 过程结束
return true
end
#############################################bearrpg
#--------------------------------------------------------------------------
# ● 应用特技效果
# user : 特技的使用者 (battler)
# skill : 特技
#--------------------------------------------------------------------------
def skill_effect(user, skill)
#######伤害开关初始化##################################################bearrpg
$damage_hp = false
$damage_sp = false
# 清除会心一击标志
self.critical = false
# 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
# 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
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
# 清除有效标志
effective = false
# 公共事件 ID 是有效的情况下,设置为有效标志
effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
# 命中的情况下
if hit_result == true
# 计算威力
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# 计算倍率
rate = 20
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 = power * rate / 20
# 属性修正
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
end
$damage_hp = true if self.damage.is_a?(Numeric)
# $damage_sp = true if self.damage_sp != 0 SP伤害数值开关
# 命中的情况下
if hit_result == true
# 威力 0 以外的物理攻击的情况下
if skill.power != 0 and skill.atk_f > 0
# 状态冲击解除
remove_states_shock
# 设置有效标志
effective = true
end
# HP 的伤害减法运算
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
# 状态变化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
#############################################bearrpg
# 威力为 0 的场合
if skill.power == 0
# 伤害设置为空的字串
self.damage = ""
# 状态没有变化的情况下
unless @state_changed
# 伤害设置为 "Miss"
self.damage = "Miss"
end
elsif self.damage == 0
unless @state_changed
self.damage = "无效" if INVALIDSWITCH >0
else
self.damage = ""
end
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
end
# 不在战斗中的情况下
unless $game_temp.in_battle
# 伤害设置为 nil
self.damage = nil
end
# 过程结束
return effective
end
#############################################bearrpg
#--------------------------------------------------------------------------
# ● 应用物品效果
# item : 物品
#--------------------------------------------------------------------------
def item_effect(item)
# 清除会心一击标志
self.critical = false
# 物品的效果范围是 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
# 清除有效标志
effective = false
# 公共事件 ID 是有效的情况下,设置为有效标志
effective |= item.common_event_id > 0
# 命中判定
hit_result = (rand(100) < item.hit)
# 不确定的特技的情况下设置为有效标志
effective |= item.hit < 100
# 命中的情况
if hit_result == true
# 计算回复量
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 / 20
recover_hp += self.mdef * item.mdef_f / 20
recover_hp = [recover_hp, 0].min
end
# 属性修正
recover_hp *= elements_correct(item.element_set)
recover_hp /= 100
recover_sp *= elements_correct(item.element_set)
recover_sp /= 100
# 分散
if item.variance > 0 and recover_hp.abs > 0
amp = [recover_hp.abs * item.variance / 100, 1].max
recover_hp += rand(amp+1) + rand(amp+1) - amp
end
if item.variance > 0 and recover_sp.abs > 0
amp = [recover_sp.abs * item.variance / 100, 1].max
recover_sp += rand(amp+1) + rand(amp+1) - amp
end
# 回复量符号为负的情况下
if recover_hp < 0
# 防御修正
if self.guarding?
recover_hp /= 2
end
end
# HP 回复量符号的反转、设置伤害值
self.damage = -recover_hp
self.damage_sp = -recover_sp
# HP 以及 SP 的回复
last_hp = self.hp
last_sp = self.sp
self.hp += recover_hp
self.sp += recover_sp
###################################################################bearrpg
$damage_hp = true if self.damage.is_a?(Numeric)
$damage_sp = true if self.damage_sp.is_a?(Numeric) and recover_sp != 0
###################################################################bearrpg
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)
# 能力上升值有效的情况下
if item.parameter_type > 0 and item.parameter_points != 0
# 能力值的分支
case item.parameter_type
when 1 # MaxHP
@maxhp_plus += item.parameter_points
when 2 # MaxSP
@maxsp_plus += item.parameter_points
when 3 # 力量
@str_plus += item.parameter_points
when 4 # 灵巧
@dex_plus += item.parameter_points
when 5 # 速度
@agi_plus += item.parameter_points
when 6 # 魔力
@int_plus += item.parameter_points
end
# 设置有效标志
effective = true
end
# HP 回复率与回复量为 0 的情况下
if item.recover_hp_rate == 0 and item.recover_hp == 0
# 设置伤害为空的字符串
self.damage = ""
# SP 回复率与回复量为 0、能力上升值无效的情况下
if item.recover_sp_rate == 0 and item.recover_sp == 0 and
(item.parameter_type == 0 or item.parameter_points == 0)
# 状态没有变化的情况下
unless @state_changed
# 伤害设置为 "Miss"
self.damage = "Miss"
end
end
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
end
# 不在战斗中的情况下
unless $game_temp.in_battle
# 伤害设置为 nil
self.damage = nil
end
# 过程结束
return effective
end
end
class Game_Actor
def screen_x
if self.index != nil
return (640-self.index*50)/2 + 240 + @movex
else
return 0
end
end
def screen_y
return self.index*70+self.height/2 + 140 + @movey #(320-self.index*91+self.height)/2 + 100 + @movey
end
def screen_z
return self.screen_y-self.index * 10
end
end
class Game_Enemy
def screen_x
return $data_troops[@troop_id].members[@member_index].x + @movex
end
def screen_y
return $data_troops[@troop_id].members[@member_index].y + @movey
end
def screen_z
return self.screen_y#+self.height
end
end
class Sprite_Battler
include Scene_BattleName
end
module RPG
class Sprite < ::Sprite
#==========================================
def initialize(viewport = nil)
super(viewport)
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage_duration = 0
@_animation_duration = 0
@_blink = false
@flash_shake = 0
@_damage = []
@_damage_sp = []
@_total_damage = 0
@_total_damage_duration = 0
@p_dam=0
@hits=0
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
sprite.y = self.viewport.rect.height - 160
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x - self.ox + self.src_rect.width / 2
sprite.y = self.y - self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
if $scene.is_a?(Scene_Battle)
sprite.z = battler.screen_z+20
else
sprite.z = 9990
end
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
def damage(value, critical)
dispose_hit
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(300, 150)
bitmap.font.name = ["黑体","华文行楷", "宋体"]
bitmap.font.size = 32
if value.is_a?(Numeric)
# 分割伤害值字符串
damage_array = damage_string.scan(/./)
damage_x = 81 - damage_string.size * 9
# 会心一击标志打开的情况
if critical and value != "无效"
# 显示会心一击图画
cri_bitmap = RPG::Cache.picture("Critital")
bitmap.blt(damage_x+cri_bitmap.width, cri_bitmap.height*2, cri_bitmap, Rect.new(0, 0, cri_bitmap.width, cri_bitmap.height))
Audio.se_play("Audio/SE/"+CRIVOICE,100,100) if CRIVOICE != nil and CRIVOICE != ""
$game_screen.start_flash(Color.new(255, 5, 5, 155), 5) if CRIFLASH >0
$game_screen.start_shake(2,9,3) if CRISHAKE >0
end
# 伤害值为负的情况下
dmg_bitmap = RPG::Cache.picture("Normal_Damage")
if value < 0
# 调用回复数字表
bitmap.blt(damage_x-14, 32,dmg_bitmap,Rect.new(dmg_bitmap.width/12*10, 0, dmg_bitmap.width/12, dmg_bitmap.height/2))
else
# 调用伤害数字表
bitmap.blt(damage_x-14, 32, dmg_bitmap,Rect.new(dmg_bitmap.width/12*11, 0, dmg_bitmap.width/12, dmg_bitmap.height/2))
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 32, dmg_bitmap,
Rect.new(number * dmg_bitmap.width/12, 0, dmg_bitmap.width/12, dmg_bitmap.height/2))
#################################################################普通伤害数值
damage_x += dmg_bitmap.width/12 - 4#间距缩小4个像素,可以自行调整
#################################################################普通伤害数值
end
else
if value == "Miss"
miss_dmg = RPG::Cache.picture("miss")
bitmap.blt(miss_dmg.width, 0,miss_dmg, Rect.new(0, 0, miss_dmg.width, miss_dmg.height))
elsif value == "无效"
invalid_dmg = RPG::Cache.picture("invalid")
bitmap.blt(invalid_dmg.width, 0,invalid_dmg, Rect.new(0, 0, invalid_dmg.width,invalid_dmg.height))
#end
end
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
@_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
make_total_damage(value)
end
##################################################################sp伤害数值
def damage_sp(value, critical)
dispose_hit
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(300, 150)
bitmap.font.name = ["黑体","华文行楷", "宋体"]
bitmap.font.size = 32
if value.is_a?(Numeric)
# 分割伤害值字符串
damage_array = damage_string.scan(/./)
damage_x = 81 - damage_string.size * 9
# 会心一击标志打开的情况
if critical and value != "无效"
# 显示会心一击图画
cri_bitmap = RPG::Cache.picture("Critital")
bitmap.blt(damage_x+cri_bitmap.width, cri_bitmap.height*2, cri_bitmap, Rect.new(0, 0, cri_bitmap.width, cri_bitmap.height))
Audio.se_play("Audio/SE/"+CRIVOICE,100,100) if CRIVOICE != nil and CRIVOICE != ""
$game_screen.start_flash(Color.new(255, 5, 5, 155), 5) if CRIFLASH >0
$game_screen.start_shake(2,9,3) if CRISHAKE >0
end
# 伤害值为负的情况下
dmg_bitmap = RPG::Cache.picture("Normal_Damage")
if value < 0
# 调用回复数字表
bitmap.blt(damage_x-14, 32,dmg_bitmap,Rect.new(dmg_bitmap.width/12*10, dmg_bitmap.height/2, dmg_bitmap.width/12, dmg_bitmap.height/2))
else
# 调用伤害数字表
bitmap.blt(damage_x-14, 32, dmg_bitmap,Rect.new(dmg_bitmap.width/12*11, dmg_bitmap.height/2, dmg_bitmap.width/12, dmg_bitmap.height/2))
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 32, dmg_bitmap,
Rect.new(number * dmg_bitmap.width/12, dmg_bitmap.height/2, dmg_bitmap.width/12, dmg_bitmap.height/2))
#################################################################普通伤害数值
damage_x += dmg_bitmap.width/12 - 4#间距缩小4个像素,可以自行调整
#################################################################普通伤害数值
end
else
if value == "Miss"
miss_dmg = RPG::Cache.picture("miss")
bitmap.blt(miss_dmg.width, 0,miss_dmg, Rect.new(0, 0, miss_dmg.width, miss_dmg.height))
elsif value == "无效"
invalid_dmg = RPG::Cache.picture("invalid")
bitmap.blt(invalid_dmg.width, 0,invalid_dmg, Rect.new(0, 0, invalid_dmg.width,invalid_dmg.height))
#end
end
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
@_damage_sp.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
# make_total_damage(value)
end
def hit
# 如果伤害值是数值
# 转为字符串
value=@hits
hits_string = value.to_s
# 初始化位图
bitmap = Bitmap.new(320, 64)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
# 分割伤害值字符串
hits_array = hits_string.scan(/./)
hits_x = 81 - hits_string.size * 18.1
rect_y = 0
# 循环伤害值字符串
for char in hits_array
number = char.to_i
# 显示伤害数字
combo_num = RPG::Cache.picture("combo_num")
bitmap.blt(hits_x, 0, combo_num,
Rect.new(number * combo_num.width/10, 0, combo_num.width/10, combo_num.height))
#################################################################连击数数值
hits_x += combo_num.width/10 - 3#间距缩小3个像素,可以自行调整
#################################################################连击数数值
end
combo_tx = RPG::Cache.picture("combo_text")
bitmap.blt(hits_x, 0,combo_tx ,
Rect.new(0, 0, combo_tx.width, combo_tx.height))
# 伤害值定位
@_hits_sprite = ::Sprite.new(self.viewport)
@_hits_sprite.bitmap = bitmap
@_hits_sprite.ox = 81
@_hits_sprite.oy = 20
@_hits_sprite.x = 500
@_hits_sprite.y = 100
@_hits_sprite.opacity = HITSWITCH > 0 ? 255 : 0
@_hits_sprite.z = 3000
@_hits_duration = 40
end
#--------------------------------------------------------------------------
# ● 总伤害处理
#--------------------------------------------------------------------------
def make_total_damage(value)
if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE > 0
@_total_damage += value
# 绝对值转为字符串
damage_string = @_total_damage.abs.to_s
else
return
end
# 初始化位图
bitmap = Bitmap.new(350, 150)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
# 伤害值是数值的情况下
if value.is_a?(Numeric)
# 分割伤害值字符串
damage_array = damage_string.scan(/./)
damage_x = 40 - damage_string.size * 9
# 伤害值为负的情况下
name=RPG::Cache.picture("total_damage")
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 0, name,
Rect.new(number * name.width/10, 0, name.width/10, name.height))
#################################################################总伤害数值
damage_x += name.width/10 - 5 #间距缩小3个像素,可以自行调整
#################################################################总伤害数值
end
end
if @_total_damage_sprite.nil?
@_total_damage_sprite = ::Sprite.new(self.viewport)
@_total_damage_sprite.ox = 80
@_total_damage_sprite.oy = 40
@_total_damage_sprite.z = 3000
end
@_total_damage_sprite.bitmap = bitmap
@_total_damage_sprite.zoom_x = 1.0
@_total_damage_sprite.zoom_y = 1.0
@_total_damage_sprite.x = self.x
@_total_damage_sprite.y = self.y - self.oy / 2
@_total_damage_sprite.z = 3001
@_total_damage_duration = 80
#hit数描绘
@hits+=1
if @_total_damage > 0
hit
end
end
def animation(animation, hit, battler_damage="", battler_damage_sp="",battler_critical=false)
dispose_animation
@battler_damage = battler_damage
@battler_damage_sp = battler_damage_sp
@battler_critical = battler_critical
@_animation = animation
return if @_animation == nil
@_animation_hit = hit
@_animation_duration = @_animation.frame_max
animation_name = @_animation.animation_name
animation_hue = @_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
for timing in @_animation.timings
quanzhong = animation_process_timing(timing, @_animation_hit,true)
@all_quanzhong += quanzhong
@_last_frame = timing.frame if quanzhong != 0
end
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
if $scene.is_a?(Scene_Battle)
if $scene.animation1_id == @battler.animation_id
@battler_damage = ""
@battler_damage_sp = ""
end
end
@_animation_sprites = []
if @_animation.position != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new(self.viewport)
sprite.bitmap = bitmap
sprite.visible = false
@_animation_sprites.push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation
end
def dispose_damage
for damage in @_damage.reverse
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
end
for damage_sp in @_damage_sp.reverse
damage_sp[0].bitmap.dispose
damage_sp[0].dispose
@_damage_sp.delete(damage_sp)
end
@_total_damage = 0
@_last_frame = -1
if @_total_damage_sprite != nil
@_total_damage_duration = 0
@_total_damage_sprite.bitmap.dispose
@_total_damage_sprite.dispose
@_total_damage_sprite = nil
end
end
def dispose_hit
if @_hits_sprite != nil
@_hits_sprite.bitmap.dispose
@_hits_sprite.dispose
@_hits_sprite = nil
end
end
def dispose_animation
@battler_damage = nil
@battler_damage_sp = nil
@battler_critical = nil
@all_quanzhong = 1
@_total_damage = 0
@_last_frame = -1
if @_animation_sprites != nil
sprite = @_animation_sprites[0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in @_animation_sprites
sprite.dispose
end
@_animation_sprites = nil
@_animation = nil
end
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
for damage in @_damage
damage[0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2 +
(40 - damage[1]) * damage[3] / 10
damage[0].y -= damage[4]+damage[1]/10
damage[0].opacity = damage[1]*20
damage[1] -= 1
if damage[1]==0
damage[0].bitmap.dispose
damage[0].dispose
@_damage.delete(damage)
next
end
end
for damage_sp in @_damage_sp
damage_sp[0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2 +
(40 - damage_sp[1]) * damage_sp[3] / 10
damage_sp[0].y -= damage_sp[4]+damage_sp[1]/10
damage_sp[0].opacity = damage_sp[1]*20
damage_sp[1] -= 1
if damage_sp[1]==0
damage_sp[0].bitmap.dispose
damage_sp[0].dispose
@_damage_sp.delete(damage_sp)
next
end
end
end
if @_total_damage_duration > 0
@_total_damage_duration -= 1
@_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
if @_total_damage_sprite.zoom_x > 1.0
@_total_damage_sprite.zoom_x -= 0.05
end
if @_total_damage_sprite.zoom_y > 1.0
@_total_damage_sprite.zoom_y -= 0.05
end
@_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
if @_total_damage_duration <= 0
dispose_hit
@_total_damage = 0
@_total_damage_duration = 0
@_total_damage_sprite.bitmap.dispose
@_total_damage_sprite.dispose
@_total_damage_sprite = nil
end
end
#=======================================
if @_animation != nil and (Graphics.frame_count % 2 == 0)
@_animation_duration -= 1
update_animation
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 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 update_animation
if @_animation_duration > 0
frame_index = @_animation.frame_max - @_animation_duration
cell_data = @_animation.frames[frame_index].cell_data
position = @_animation.position
animation_set_sprites(@_animation_sprites, cell_data, position)
for timing in @_animation.timings
if timing.frame == frame_index
t = 1.0 * animation_process_timing(timing, @_animation_hit)
ts = 1.0 * animation_process_timing(timing, @_animation_hit)
if timing.se.name != ""
se=timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
if @battler_damage.is_a?(Numeric) and t != 0
if @battler.guarding?
@battler.startactive = "防御" if @battler_damage > 0
else
@battler.startactive = "受伤" if @battler_damage > 0
end
t *= @battler_damage
t /= @all_quanzhong
ts *= @battler_damage_sp
ts /= @all_quanzhong
t = t.to_i
ts = ts.to_i
if frame_index != @_last_frame
@p_dam+= t
end
if frame_index == @_last_frame
t=@battler_damage-@p_dam
end
if frame_index == @_last_frame
@_total_damage = @battler_damage - t
@p_dam=0
end
damage(t,@battler_critical) if $damage_hp == true
damage_sp(ts,@battler_critical) if $damage_sp == true
if frame_index == @_last_frame
@hits=0
end
elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
damage(@battler_damage,@battler_critical)
damage_sp(@battler_damage_sp,@battler_critical) if $damage_sp == true
end
end
end
else
dispose_animation
end
end
def animation_process_timing(timing, hit,dontflash=false)
if (timing.condition == 0) or
(timing.condition == 1 and hit == true) or
(timing.condition == 2 and hit == false)
case timing.flash_scope
when 1
unless dontflash
self.flash(timing.flash_color, timing.flash_duration * 2)
if @_total_damage >0
@flash_shake_switch = true
@flash_shake = 10
end
end
return timing.flash_color.alpha * timing.flash_duration
when 2
unless dontflash
if self.viewport != nil
self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
end
end
return timing.flash_color.alpha * timing.flash_duration
when 3
unless dontflash
self.flash(nil, timing.flash_duration * 2)
end
return timing.flash_color.alpha * timing.flash_duration
end
end
return 0
end
end
end
class Sprite_Battler < RPG::Sprite
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@flash_shake_switch = true
@number = 0#初始化编号
end
def update
super
# 战斗者为 nil 的情况下
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# 文件名和色相与当前情况有差异的情况下
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# 获取、设置位图
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
# 如果是战斗不能或者是隐藏状态就把透明度设置成 0
if @battler.dead? or @battler.hidden
self.opacity = 0 if DEADPIC != 1
end
end
###################################万兽熊最高#########################################
if @battler.startactive == "移动" or @battler.startactive == "返回"
if Graphics.frame_count % 4 == 0
unless BattlerName[@battler.name].nil?
@number = (@number + 1) % BattlerName[@battler.name][@battler.startactive].size
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
end
end
elsif @battler.startactive == "死亡"
if Graphics.frame_count % 4 == 0
unless BattlerName[@battler.name].nil?
if @number +1 <= BattlerName[@battler.name][@battler.startactive].size
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
@number += 1
else
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][BattlerName[@battler.name][@battler.startactive].size-1], @battler_hue)
end
end
end
else
if Graphics.frame_count % 10 == 0
unless BattlerName[@battler.name].nil?
@number = (@number + 1) % BattlerName[@battler.name][@battler.startactive].size
self.bitmap = RPG::Cache.battler(BattlerName[@battler.name][@battler.startactive][@number], @battler_hue)
end
end
end
#######################################################################################
# 动画 ID 与当前的情况有差异的情况下
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# 应该被显示的角色的情况下
if NACTSWITCH > 0
if @battler.is_a?(Game_Actor) and @battler_visible
# 不是主状态的时候稍稍降低点透明度
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
end
if @battler.blink
blink_on
else
blink_off
end
unless @battler_visible
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@battler_visible = true
end
end
if @battler_visible
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
if @battler.white_flash
whiten
@battler.white_flash = false
end
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit,@battler.damage,@battler.damage_sp, @battler.critical)
@battler.animation_id = 0
end
if @battler.damage_pop
@battler.damage = nil
@battler.damage_sp = 0
@battler.critical = false
@battler.damage_pop = false
end
if @battler.damage == nil and @battler.dead?
if DEADPIC >0
@battler.startactive = "死亡"
else
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@battler_visible = false
end
end
end
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
class Spriteset_Battle
alias bearrpg_initialize initialize
def initialize
@enemy_sprites = []
for enemy in $game_troop.enemies.reverse
#####修改敌人显示端口,与角色一样。
@enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
end
bearrpg_initialize
end
end
class Arrow_Enemy < Arrow_Base
def update
super
$game_troop.enemies.size.times do
break if self.enemy.exist?
@index += 1
@index %= $game_troop.enemies.size
end
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
$game_troop.enemies.size.times do
@index += $game_troop.enemies.size - 1
@index %= $game_troop.enemies.size
break if self.enemy.exist?
end
end
if self.enemy != nil
self.x = self.enemy.screen_x
self.y = self.enemy.screen_y
end
end
end
class Arrow_Actor < Arrow_Base
def update
super
if Input.repeat?(Input::UP)
$game_system.se_play($data_system.cursor_se)
@index += 1
@index %= $game_party.actors.size
end
if Input.repeat?(Input::DOWN)
$game_system.se_play($data_system.cursor_se)
@index += $game_party.actors.size - 1
@index %= $game_party.actors.size
end
if self.actor != nil
self.x = self.actor.screen_x
self.y = self.actor.screen_y
end
end
end
class Scene_Battle
include Scene_BattleName
attr_reader :animation1_id
def main
$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
@_move_duration = 0
$game_system.battle_interpreter.setup(nil, 0)
@troop_id = $game_temp.battle_troop_id
$game_troop.setup(@troop_id)
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.z = 900
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
@party_command_window = Window_PartyCommand.new
@party_command_window.z = 910
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.z = 920
@help_window.visible = false
@status_window = Window_BattleStatus.new
@status_window.z = 930
@message_window = Window_Message.new
@message_window.z = 940
@spriteset = Spriteset_Battle.new
@wait_count = 0
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
start_phase1
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
$game_map.refresh
Graphics.freeze
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
@spriteset.dispose
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
def start_phase1
# 转移到回合 1
@phase = 1
# 清除全体同伴的行动
$game_party.clear_actions
for actor in $game_party.actors
actor.startactive = actor.hp>0? "待机" : "死亡"
end
# 设置战斗事件
setup_battle_event
end
alias bearrpg_start_phase5 start_phase5
def start_phase5
bearrpg_start_phase5
@result_window.z = 999
@phase5_wait_count = 100
end
def start_enemy_select
@enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
@enemy_arrow.help_window = @help_window
@actor_command_window.active = false
@actor_command_window.visible = false
end
alias bearrpg_start_skill_select start_skill_select
def start_skill_select
bearrpg_start_skill_select
@skill_window.z = 999
end
alias bearrpg_start_item_select start_item_select
def start_item_select
bearrpg_start_item_select
@item_window.z = 999
end
def move(active_battler, target, ox, oy, 返回标记 = false)
ta_x = target[0]
ta_y = target[1]
if 返回标记
active_battler.movex = (active_battler.movex * (@_move_duration - 1) + ta_x.to_f - ox) / @_move_duration
active_battler.movey = (active_battler.movey * (@_move_duration - 1) + ta_y.to_f - oy) / @_move_duration
else
if @active_battler.is_a?(Game_Enemy)
active_battler.movex = (active_battler.movex * (@_move_duration - 1) + ta_x.to_f - ox ) / @_move_duration
active_battler.movey = (active_battler.movey * (@_move_duration - 1) + ta_y.to_f - oy ) / @_move_duration
else
active_battler.movex = (active_battler.movex * (@_move_duration - 1) + ta_x.to_f - ox ) / @_move_duration
active_battler.movey = (active_battler.movey * (@_move_duration - 1) + ta_y.to_f - oy ) / @_move_duration
end
end
end
def update_phase4_step3
####普通攻击的场合############################################################
if @active_battler.current_action.basic == 0 and
@active_battler.current_action.kind == 0
#开始执行移动
if not @active_battler.element_rate(UNMOVE)>100# 如果属性“不移动”不大于100
@active_battler.startactive = "移动"
@oldxy = [@active_battler.screen_x,@active_battler.screen_y]
ox,oy = @active_battler.screen_x,@active_battler.screen_y
if @active_battler.element_rate(HOMOVE)>100# 如果属性“半距离”大于100
@_move_duration = Move_Duration/2
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
if @target_battlers[0].is_a?(Game_Actor)
tag = [@target_battlers[0].screen_x-@target_battlers[0].width-(@target_battlers[0].screen_x-ox).abs/2.abs,@target_battlers[0].screen_y+1]
else
tag = [(@target_battlers[0].screen_x+@target_battlers[0].width/1.5)+(@target_battlers[0].screen_x-ox).abs/2,@target_battlers[0].screen_y+2]
end
move(@active_battler, tag, ox, oy)
@_move_duration -= 1
end
else
@_move_duration = Move_Duration
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
if @target_battlers[0].is_a?(Game_Actor)
tag = [@target_battlers[0].screen_x-@target_battlers[0].width/2,@target_battlers[0].screen_y+1]
else
tag = [@target_battlers[0].screen_x+@target_battlers[0].width/1.5,@target_battlers[0].screen_y+2]
end
move(@active_battler, tag, ox, oy)
@_move_duration -= 1
end
end
end
####普通攻击的场合############################################################
elsif @active_battler.current_action.kind == 1
####使用特技的场合############################################################
if not @skill.element_set.include?(UNMOVE)# 如果技能不包含“不移动属性”
@active_battler.startactive = "移动"
@oldxy = [@active_battler.screen_x,@active_battler.screen_y]
ox,oy = @active_battler.screen_x,@active_battler.screen_y
if @skill.element_set.include?(HOMOVE)#如果技能不包含“半距离”属性
@_move_duration = Move_Duration/2
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
if @target_battlers[0].is_a?(Game_Actor)
tag = [@target_battlers[0].screen_x-@target_battlers[0].width-(@target_battlers[0].screen_x-ox).abs/2.abs,@target_battlers[0].screen_y+1]
else
tag = [(@target_battlers[0].screen_x+@target_battlers[0].width/1.5)+(@target_battlers[0].screen_x-ox).abs/2,@target_battlers[0].screen_y+2]
end
move(@active_battler, tag, ox, oy)
@_move_duration -= 1
end
else
@_move_duration = Move_Duration
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
if @target_battlers[0].is_a?(Game_Actor)
tag = [@target_battlers[0].screen_x-@target_battlers[0].width,@target_battlers[0].screen_y+1]
else
tag = [@target_battlers[0].screen_x+@target_battlers[0].width/1.5,@target_battlers[0].screen_y+2]
end
move(@active_battler, tag, ox, oy)
@_move_duration -= 1
end
end
end
#####使用特技的场合##############################################################
end
if @active_battler.startactive != "防御"
@active_battler.startactive = "待机"
end
# 行动方动画 (ID 为 0 的情况下是白色闪烁)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
for target in @target_battlers
if target.guarding? and target.damage.is_a?(Numeric)
target.startactive = "防御" if target.damage > 0
end
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
end
# 移至步骤 4
@phase4_step = 4
end
##############################################################################
def update_phase4_step4
###########################万兽熊最高########################################
# 对像方动画
for target in @target_battlers
if target.damage != nil
target.damage_pop = true
end
end
# 限制动画长度、最低 8 帧
# @wait_count = 8
##############################################################################
# 移至步骤 5
@phase4_step = 5
end
####################万兽熊最高############################
def update_phase4_step5
# 隐藏帮助窗口
@help_window.visible = false
if @active_battler.current_action.basic == 0 and
@active_battler.current_action.kind == 0
####普通攻击的场合############################################################
#执行返回
if not @active_battler.element_rate(UNMOVE)>100# 如果属性“不移动”不大于100
@active_battler.startactive = "返回"
if @active_battler.element_rate(HOMOVE)>100# 如果属性“半距离”大于100
@_move_duration = Move_Duration/2
else
@_move_duration = Move_Duration
end
ox,oy = @active_battler.screen_x - @active_battler.movex,\
@active_battler.screen_y - @active_battler.movey
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
move(@active_battler, @oldxy, ox, oy, true)
@_move_duration -= 1
end
end
####普通攻击的场合############################################################
elsif @active_battler.current_action.kind == 1
if not @skill.element_set.include?(UNMOVE)#如果技能不包含“不移动”属性
@active_battler.startactive = "返回"
if @skill.element_set.include?(HOMOVE)#如果技能包含“半距离”属性
@_move_duration = Move_Duration/2
else
@_move_duration = Move_Duration
end
ox,oy = @active_battler.screen_x - @active_battler.movex,\
@active_battler.screen_y - @active_battler.movey
while @_move_duration > 0
Graphics.update
Input.update
@spriteset.update
move(@active_battler, @oldxy, ox, oy, true)
@_move_duration -= 1
end
end
####使用特技的场合############################################################
end
if @active_battler.startactive != "防御"
@active_battler.startactive = "待机"
end
# 刷新状态窗口
@status_window.refresh
# 显示伤害
for target in @target_battlers
target.startactive = "待机"
if target.damage != nil
target.damage_pop = true
end
end
# 移至步骤 6
@phase4_step = 6
end
def update_phase4_step6
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
@active_battler.movex = 0
@active_battler.movey = 0
@active_battler.startactive = "待机" if @active_battler.startactive != "死亡"
# 公共事件 ID 有效的情况下
if @common_event_id > 0
# 设置事件
common_event = $data_common_events[@common_event_id]
$game_system.battle_interpreter.setup(common_event.list, 0)
end
# 移至步骤 1
@phase4_step = 1
end
end
复制代码
这是熊大的横版……
作者:
冰枫o鲍辰
时间:
2015-1-12 23:45
#------------------制作by bluefool,转载请保留------------------
module Blue
#这个是控制显示最近的多少条信息的,当超出一屏能显示的值的话可通过先按一下shift
#然后用上下翻看内容。再按一次shift则解除激活
Blue_max = 12
#这个填写进如游戏时生成的系统语言,
INTRO = "欢迎进入游戏!"
#战斗画面时即时消息窗口的x坐标
BATAM_X = 0
#战斗画面时即时消息窗口的y坐标
BATAM_Y = 90
#用于清空hash表,可以不管它,但不要让Blue_max大于它,当然,它的值也可以改变
NAM_MAX = 50
#主要传递信息参数为函数$am,参见脚本内容
end
#-------------------------------------------
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# ● 确定时的处理
#--------------------------------------------------------------------------
def on_decision(filename)
# 文件不存在的情况下
unless FileTest.exist?(filename)
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏读档 SE
$game_system.se_play($data_system.load_se)
# 写入存档数据
file = File.open(filename, "rb")
read_save_data(file)
file.close
# 还原 BGM、BGS
$game_system.bgm_play($game_system.playing_bgm)
$game_system.bgs_play($game_system.playing_bgs)
# 刷新地图 (执行并行事件)
$a = {}
$game_map.update
# 切换到地图画面
$scene = Scene_Map.new
end
end
class Game_Player < Game_Character
def update
# 本地变量记录移动信息
last_moving = moving?
# 移动中、事件执行中、强制移动路线中、
# 信息窗口一个也不显示的时候
unless moving? or $game_system.map_interpreter.running? or
@move_route_forcing or $game_temp.message_window_showing or $ccc == 1
case Input.dir4
when 2
move_down
when 4
move_left
when 6
move_right
when 8
move_up
end
end
# 本地变量记忆坐标
last_real_x = @real_x
last_real_y = @real_y
super
# 角色向下移动、画面上的位置在中央下方的情况下
if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
# 画面向下卷动
$game_map.scroll_down(@real_y - last_real_y)
end
# 角色向左移动、画面上的位置在中央左方的情况下
if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
# 画面向左卷动
$game_map.scroll_left(last_real_x - @real_x)
end
# 角色向右移动、画面上的位置在中央右方的情况下
if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
# 画面向右卷动
$game_map.scroll_right(@real_x - last_real_x)
end
# 角色向上移动、画面上的位置在中央上方的情况下
if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
# 画面向上卷动
$game_map.scroll_up(last_real_y - @real_y)
end
# 不在移动中的情况下
unless moving?
# 上次主角移动中的情况
if last_moving
# 与同位置的事件接触就判定为事件启动
result = check_event_trigger_here([1,2])
# 没有可以启动的事件的情况下
if result == false
# 调试模式为 ON 并且按下 CTRL 键的情况下除外
unless $DEBUG and Input.press?(Input::CTRL)
# 遇敌计数下降
if @encounter_count > 0
@encounter_count -= 1
end
end
end
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 判定为同位置以及正面的事件启动
check_event_trigger_here([0])
check_event_trigger_there([0,1,2])
end
end
end
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
# 处理标题画面的类。
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
# ● 命令 : 新游戏
#--------------------------------------------------------------------------
def command_new_game
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 停止 BGM
Audio.bgm_stop
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# 设置初期同伴位置
$game_party.setup_starting_members
# 设置初期位置的地图
$game_map.setup($data_system.start_map_id)
# 主角向初期位置移动
$game_player.moveto($data_system.start_x, $data_system.start_y)
# 刷新主角
$game_player.refresh
# 执行地图设置的 BGM 与 BGS 的自动切换
$game_map.autoplay
# 刷新地图 (执行并行事件)
$game_map.update
$a = {}
$am = Blue::INTRO
$ccc = 0
# 切换地图画面
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 命令 : 继续
#--------------------------------------------------------------------------
def command_continue
# 继续无效的情况下
unless @continue_enabled
# 演奏无效 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到读档画面
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# ● 命令 : 退出
#--------------------------------------------------------------------------
def command_shutdown
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# BGM、BGS、ME 的淡入淡出
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# 退出
$scene = nil
end
#--------------------------------------------------------------------------
# ● 战斗测试
#--------------------------------------------------------------------------
def battle_test
# 载入数据库 (战斗测试用)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# 重置测量游戏时间用的画面计数器
Graphics.frame_count = 0
# 生成各种游戏对像
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
$a = {0=>"进入战斗测试."}
# 设置战斗测试用同伴
$game_party.setup_battle_test_members
# 设置队伍 ID、可以逃走标志、战斗背景
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# 演奏战斗开始 BGM
$game_system.se_play($data_system.battle_start_se)
# 演奏战斗 BGM
$game_system.bgm_play($game_system.battle_bgm)
# 切换到战斗画面
$scene = Scene_Battle.new
end
end
#-------------------------------------------------------
class Scene_Map
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
@spriteset = Spriteset_Map.new
@message_window = Window_Message.new
@down_window = Window_Down.new
####################################修改!
@v = Viewport.new(0,460,320,20)
@v.color.set(0,0,0,100)
@tf = Type_Field.new(@v,"",16)
####################################修改!
Graphics.transition
# 主循环
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
Graphics.freeze
@spriteset.dispose
@message_window.dispose
@down_window.dispose
############
@v.dispose
@tf.dispose
###############
if $scene.is_a?(Scene_Title)
Graphics.transition
Graphics.freeze
end
@am_size = $a.size
end
#---------------------
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 循环
loop do
# 按照地图、实例、主角的顺序刷新
# (本更新顺序不会在的满足事件的执行条件下成为给予角色瞬间移动
# 的机会的重要因素)
$game_map.update
$game_system.map_interpreter.update
$game_player.update
# 系统 (计时器)、画面刷新
$game_system.update
$game_screen.update
# 如果主角在场所移动中就中断循环
unless $game_temp.player_transferring
break
end
# 执行场所移动
transfer_player
# 处理过渡中的情况下、中断循环
if $game_temp.transition_processing
break
end
end
# 刷新活动块
@spriteset.update
# 刷新信息窗口
###########################此处有修改!###########################
# 输入法测试
@tf.update
if RInput.trigger?(RInput::ENTER) and Input.press?(Input::CTRL)
if (text = @tf.get_text) != ""
if (text = @tf.get_text) == "help"
$game_switches[1]=true
end
if (text = @tf.get_text) == "cheat"
$game_switches[2]=true
end
$am = $game_actors[1].name+": "
[email protected]
_text
$game_map.need_refresh = true
$scene = Scene_Map.new
end
end
################################################################
@message_window.update
# 游戏结束的情况下
if $game_temp.gameover
# 切换的游戏结束画面
$scene = Scene_Gameover.new
return
end
# 返回标题画面的情况下
if $game_temp.to_title
# 切换到标题画面
$scene = Scene_Title.new
return
end
# 处理过渡中的情况下
if $game_temp.transition_processing
# 清除过渡处理中标志
$game_temp.transition_processing = false
# 执行过渡
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# 显示信息窗口中的情况下
if $game_temp.message_window_showing
return
end
# 遇敌计数为 0 且、且遇敌列表不为空的情况下
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# 不是在事件执行中或者禁止遇敌中
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# 确定队伍
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# 队伍有效的话
if $data_troops[troop_id] != nil
# 设置调用战斗标志
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
#---------------------------------------------
bluefool_sort
if @am_size != $a.size
@down_window.refresh
if $a != nil and $a.size < Blue::Blue_max + 1
@down_window.index = $a.size/2 - 1
elsif $a != nil and $a.size > Blue::Blue_max
@down_window.index = Blue::Blue_max/2 - 1
end
@am_size = $a.size
end
# if Input.trigger?(Input::A)
# if @down_window.active == false
# @down_window.active = true
# $ccc = 1
# else
# @down_window.active = false
# $ccc = 0
# end
# end
# if Input.trigger?(Input::DOWN)#输入DOWN键的情况
# if @down_window.active == true and @down_window.index < (@down_window.item_max-1)/2
# @down_window.index += 1
# end
# end
# if Input.trigger?(Input::UP)#输入UP键的情况
# if @down_window.active == true and @down_window.index > 0
# @down_window.index -= 1
# end
# end
#----------------------------------------------
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 不是在事件执行中或菜单禁止中
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# 设置菜单调用标志以及 SE 演奏
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# 调试模式为 ON 并且按下 F9 键的情况下
if $DEBUG and Input.press?(Input::F9)
# 设置调用调试标志
$game_temp.debug_calling = true
end
# 不在主角移动中的情况下
unless $game_player.moving?
# 执行各种画面的调用
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
end
class Game_Battler
def bluefool_sort
if $am != nil
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
#--------------------------------------------------------------------------
# ● 应用连续伤害效果
#--------------------------------------------------------------------------
def slip_damage_effect
# 设置伤害
self.damage = self.maxhp / 10
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# HP 的伤害减法运算
self.hp -= self.damage
if self.damage > 0
$am = "异常状态使#{self.name}受到了#{self.damage}点伤害."
elsif self.damage < 0
$am = "异常状态使#{self.name}恢复了#{self.damage.abs}点#{$data_system.words.hp}"
end
bluefool_sort
# 过程结束
return true
end
#--------------------------------------------------------------------------
# ● 应用通常攻击效果
# attacker : 攻击者 (battler)
#--------------------------------------------------------------------------
def attack_effect(attacker)
# 清除会心一击标志
self.critical = false
# 第一命中判定
hit_result = (rand(100) < attacker.hit)
# 命中的情况下
if hit_result == true
# 计算基本伤害
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
# 属性修正
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 会心一击修正
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
# 命中的情况下
if hit_result == true
# 状态冲击解除
remove_states_shock
# HP 的伤害计算
self.hp -= self.damage
$am = "#{attacker.name}对#{self.name}造成了#{self.damage}伤害."
bluefool_sort
# 状态变化
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{attacker.name}击空了."
bluefool_sort
# 清除会心一击标志
self.critical = false
end
# 过程结束
return true
end
#--------------------------------------------------------------------------
# ● 应用特技效果
# user : 特技的使用者 (battler)
# skill : 特技
#--------------------------------------------------------------------------
def skill_effect(user, skill)
# 清除会心一击标志
self.critical = false
# 特技的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
# 或者特技的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
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
# 清除有效标志
effective = false
# 公共事件 ID 是有效的情况下,设置为有效标志
effective |= skill.common_event_id > 0
# 第一命中判定
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
# 命中的情况下
if hit_result == true
# 计算威力
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
# 计算倍率
rate = 20
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 = power * rate / 20
# 属性修正
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
# 伤害符号正确的情况下
if self.damage > 0
# 防御修正
if self.guarding?
self.damage /= 2
end
end
# 分散
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
# 第二命中判定
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
# 不确定的特技的情况下设置为有效标志
effective |= hit < 100
end
# 命中的情况下
if hit_result == true
# 威力 0 以外的物理攻击的情况下
if skill.power != 0 and skill.atk_f > 0
# 状态冲击解除
remove_states_shock
# 设置有效标志
effective = true
end
# HP 的伤害减法运算
last_hp = self.hp
self.hp -= self.damage
if self.damage > 0
$am = "#{user.name}对#{self.name}造成了#{self.damage}伤害."
elsif self.damage < 0
if user == self
$am = "#{user.name}恢复了自己#{self.damage.abs}点#{$data_system.words.hp}."
else
$am = "#{user.name}恢复了#{self.name}#{self.damage.abs}点#{$data_system.words.hp}."
end
end
bluefool_sort
effective |= self.hp != last_hp
# 状态变化
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
# 威力为 0 的场合
if skill.power == 0
# 伤害设置为空的字串
self.damage = ""
# 状态没有变化的情况下
unless @state_changed
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{user.name}没有击中."
bluefool_sort
end
end
# Miss 的情况下
else
# 伤害设置为 "Miss"
self.damage = "Miss"
$am = "#{user.name}没有击中."
bluefool_sort
end
# 不在战斗中的情况下
unless $game_temp.in_battle
# 伤害设置为 nil
self.damage = nil
end
# 过程结束
return effective
end
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 1 : 准备行动)
#--------------------------------------------------------------------------
def update_phase4_step1
# 隐藏帮助窗口
@help_window.visible = false
# 判定胜败
if judge
# 胜利或者失败的情况下 : 过程结束
return
end
# 强制行动的战斗者不存在的情况下
if $game_temp.forcing_battler == nil
# 设置战斗事件
setup_battle_event
# 执行战斗事件中的情况下
if $game_system.battle_interpreter.running?
return
end
end
# 强制行动的战斗者存在的情况下
if $game_temp.forcing_battler != nil
# 在头部添加后移动
@action_battlers.delete($game_temp.forcing_battler)
@action_battlers.unshift($game_temp.forcing_battler)
end
# 未行动的战斗者不存在的情况下 (全员已经行动)
if @action_battlers.size == 0
# 开始同伴命令回合
start_phase2
return
end
# 初始化动画 ID 和公共事件 ID
@animation1_id = 0
@animation2_id = 0
@common_event_id = 0
# 未行动的战斗者移动到序列的头部
@active_battler = @action_battlers.shift
# 如果已经在战斗之外的情况下
if @active_battler.index == nil
return
end
# 连续伤害
if @active_battler.hp > 0 and @active_battler.slip_damage?
@active_battler.slip_damage_effect
@active_battler.damage_pop = true
@down_window.refresh
end
# 自然解除状态
@active_battler.remove_states_auto
# 刷新状态窗口
@status_window.refresh
# 移至步骤 2
@phase4_step = 2
end
#--------------------------------------------------------------------------
# ● 开始结束战斗回合
#--------------------------------------------------------------------------
def start_phase5
# 转移到回合 5
@phase = 5
# 演奏战斗结束 ME
$game_system.me_play($game_system.battle_end_me)
# 还原为战斗开始前的 BGM
$game_system.bgm_play($game_temp.map_bgm)
# 初始化 EXP、金钱、宝物
exp = 0
gold = 0
treasures = []
# 循环
for enemy in $game_troop.enemies
# 敌人不是隐藏状态的情况下
unless enemy.hidden
# 获得 EXP、增加金钱
exp += enemy.exp
gold += enemy.gold
# 出现宝物判定
if rand(100) < enemy.treasure_prob
if enemy.item_id > 0
treasures.push($data_items[enemy.item_id])
end
if enemy.weapon_id > 0
treasures.push($data_weapons[enemy.weapon_id])
end
if enemy.armor_id > 0
treasures.push($data_armors[enemy.armor_id])
end
end
end
end
# 限制宝物数为 6 个
treasures = treasures[0..5]
# 获得 EXP
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
if actor.cant_get_exp? == false
last_level = actor.level
actor.exp += exp
if actor.level > last_level
@status_window.level_up(i)
end
end
end
# 获得金钱
$game_party.gain_gold(gold)
$am = "获得#{exp}经验,#{gold}#{$data_system.words.gold}"
bluefool_sort
@down_window.refresh
# 获得宝物
for item in treasures
case item
when RPG::Item
$game_party.gain_item(item.id, 1)
$am = "获得#{$data_items[item.id].name}"
bluefool_sort
when RPG::Weapon
$game_party.gain_weapon(item.id, 1)
$am = "获得#{$data_weapons[item.id].name}"
bluefool_sort
when RPG::Armor
$game_party.gain_armor(item.id, 1)
$am = "获得#{$data_armors[item.id].name}"
bluefool_sort
end
@down_window.refresh
end
# 生成战斗结果窗口
@result_window = Window_BattleResult.new(exp, gold, treasures)
# 设置等待计数
@phase5_wait_count = 100
end
#--------------------------------------------------------------------------
# ● 生成基本行动结果
#--------------------------------------------------------------------------
def make_basic_action_result
# 攻击的情况下
if @active_battler.current_action.basic == 0
# 设置攻击 ID
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
# 行动方的战斗者是敌人的情况下
if @active_battler.is_a?(Game_Enemy)
if @active_battler.restriction == 3
target = $game_troop.random_target_enemy
elsif @active_battler.restriction == 2
target = $game_party.random_target_actor
else
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
end
end
# 行动方的战斗者是角色的情况下
if @active_battler.is_a?(Game_Actor)
if @active_battler.restriction == 3
target = $game_party.random_target_actor
elsif @active_battler.restriction == 2
target = $game_troop.random_target_enemy
else
index = @active_battler.current_action.target_index
target = $game_troop.smooth_target_enemy(index)
end
end
# 设置对像方的战斗者序列
@target_battlers = [target]
for target in @target_battlers
$am = "#{@active_battler.name}对#{target.name}发起了进攻!"
bluefool_sort
target.attack_effect(@active_battler)
end
return
end
# 防御的情况下
if @active_battler.current_action.basic == 1
@help_window.set_text($data_system.words.guard, 1)
$am = "#{@active_battler.name}选择了防御."
bluefool_sort
return
end
# 逃跑的情况下
if @active_battler.is_a?(Game_Enemy) and
@active_battler.current_action.basic == 2
# 帮助窗口显示"逃跑"
@help_window.set_text("逃跑", 1)
# 逃跑
@active_battler.escape
return
end
# 什么也不做的情况下
if @active_battler.current_action.basic == 3
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
#--------------------------------------------------------------------------
# ● 生成特技行动结果
#--------------------------------------------------------------------------
def make_skill_action_result
# 获取特技
[url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[@active_battler.current_action.skill_id]
# 如果不是强制行动
unless @active_battler.current_action.forcing
# 因为 SP 耗尽而无法使用的情况下
unless @active_battler.skill_can_use?(@skill.id)
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
# 消耗 SP
@active_battler.sp -= @skill.sp_cost
# 刷新状态窗口
@status_window.refresh
# 在帮助窗口显示特技名
@help_window.set_text(@skill.name, 1)
# 设置动画 ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# 设置公共事件 ID
@common_event_id = @skill.common_event_id
# 设置对像侧战斗者
set_target_battlers(@skill.scope)
# 应用特技效果
for target in @target_battlers
case @skill.scope
when 1
$am = "#{@active_battler.name}使用#{@skill.name}攻击#{target.name}!"
when 2
$am = "#{@active_battler.name}使用#{@skill.name}攻击#{target.name}!"
when 7
$am = "#{@active_battler.name}对自己使用#{@skill.name}."
else
if target == @active_battler
$am = "#{@active_battler.name}对自己使用#{@skill.name}."
else
$am = "#{@active_battler.name}对#{target.name}使用#{@skill.name}."
end
end
bluefool_sort
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# ● 生成物品行动结果
#--------------------------------------------------------------------------
def make_item_action_result
# 获取物品
@item = $data_items[@active_battler.current_action.item_id]
# 因为物品耗尽而无法使用的情况下
unless $game_party.item_can_use?(@item.id)
# 移至步骤 1
@phase4_step = 1
return
end
# 消耗品的情况下
if @item.consumable
# 使用的物品减 1
$game_party.lose_item(@item.id, 1)
end
# 在帮助窗口显示物品名
@help_window.set_text(@item.name, 1)
# 设置动画 ID
@animation1_id = @item.animation1_id
@animation2_id = @item.animation2_id
# 设置公共事件 ID
@common_event_id = @item.common_event_id
# 确定对像
index = @active_battler.current_action.target_index
target = $game_party.smooth_target_actor(index)
# 设置对像侧战斗者
set_target_battlers(@item.scope)
# 应用物品效果
for target in @target_battlers
target.item_effect(@item)
if target == @active_battler
$am = "#{@active_battler.name}对自己使用了#{@item.name}"
else
$am = "#{@active_battler.name}对#{target.name}使用了#{@item.name}"
end
bluefool_sort
end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 4 : 对像方动画)
#--------------------------------------------------------------------------
def update_phase4_step4
# 对像方动画
for target in @target_battlers
target.animation_id = @animation2_id
target.animation_hit = (target.damage != "Miss")
end
@down_window.refresh
@wait_count = 8
# 移至步骤 5
@phase4_step = 5
end
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
def main
$am = "队伍进入战斗!"
bluefool_sort
$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)
#生成角色命令窗口
s1 = $data_system.words.attack
s2 = $data_system.words.skill
s3 = $data_system.words.guard
s4 = $data_system.words.item
@actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
@actor_command_window.y = 160
@actor_command_window.back_opacity = 160
@actor_command_window.active = false
@actor_command_window.visible = false
# 生成其它窗口
@party_command_window = Window_PartyCommand.new
@help_window = Window_Help.new
@help_window.back_opacity = 160
@help_window.visible = false
@status_window = Window_BattleStatus.new
@message_window = Window_Message.new
@down_window = Window_Down.new
@down_window.y = Blue::BATAM_Y
@down_window.z = @actor_command_window.z - 10
# 生成活动块
@spriteset = Spriteset_Battle.new
# 初始化等待计数
@wait_count = 0
# 执行过渡
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$data_system.battle_transition)
end
# 开始自由战斗回合
start_phase1
# 主循环
loop do
Graphics.update
Input.update
update
if $scene != self
break
end
end
# 刷新地图
$game_map.refresh
# 准备过渡
Graphics.freeze
# 释放窗口
@actor_command_window.dispose
@party_command_window.dispose
@help_window.dispose
@status_window.dispose
@message_window.dispose
@down_window.dispose
$am = "战斗结束"
bluefool_sort
if @skill_window != nil
@skill_window.dispose
end
if @item_window != nil
@item_window.dispose
end
if @result_window != nil
@result_window.dispose
end
# 释放活动块
@spriteset.dispose
# 标题画面切换中的情况
if $scene.is_a?(Scene_Title)
# 淡入淡出画面
Graphics.transition
Graphics.freeze
end
# 战斗测试或者游戏结束以外的画面切换中的情况
if $BTEST and not $scene.is_a?(Scene_Gameover)
$scene = nil
end
end
end
#---------------------------------------------------------
class Interpreter
def bluefool_sort
if $am != nil
if $a.size > Blue::NAM_MAX
a_temp = {}
j = 0
for i in ($a.size - Blue::Blue_max)...$a.size
a_temp[j] = $a[i]
j += 1
end
$a = a_temp
end
if $am.length < 54
$a[$a.size] = $am
else
while $am.length > 53
i = 53
while (/\W/ =~ $am[i-3,3]) != nil
i -= 1
end
$a[$a.size] = $am[0,i]
$am = $am[i ,$am.length - i]
end
$a[$a.size] = $am
end
$am = nil
end
end
def command_101
if $game_temp.message_text != nil
return false
end
# 设置信息结束后待机和返回调用标志
@message_waiting = true
$game_temp.message_proc = Proc.new { @message_waiting = false }
# message_text 设置为 1 行
$game_temp.message_text = @list[@index].parameters[0] + "\n"
if (@list[@index].parameters[0]).split(/\\/)[1] != nil
$am = @list[@index].parameters[0].split(/\\/)[0]
else
$am = @list[@index].parameters[0]
end
bluefool_sort
line_count = 1
# 循环
loop do
# 下一个事件指令为文章两行以上的情况
if @list[@index+1].code == 401
# message_text 添加到第 2 行以下
$game_temp.message_text += @list[@index+1].parameters[0] + "\n"
$am = @list[@index+1].parameters[0]
bluefool_sort
line_count += 1
# 事件指令不在文章两行以下的情况
else
# 下一个事件指令为显示选择项的情况下
if @list[@index+1].code == 102
# 如果选择项能收纳在画面里
if @list[@index+1].parameters[0].size <= 4 - line_count
# 推进索引
@index += 1
# 设置选择项
$game_temp.choice_start = line_count
setup_choices(@list[@index].parameters)
end
# 下一个事件指令为处理输入数值的情况下
elsif @list[@index+1].code == 103
# 如果数值输入窗口能收纳在画面里
if line_count < 4
# 推进索引
@index += 1
# 设置输入数值
$game_temp.num_input_start = line_count
$game_temp.num_input_variable_id = @list[@index].parameters[0]
$game_temp.num_input_digits_max = @list[@index].parameters[1]
end
end
# 继续
return true
end
# 推进索引
@index += 1
end
end
def command_125
value = operate_value(@parameters[0], @parameters[1], @parameters[2])
$game_party.gain_gold(value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value}#{$data_system.words.gold}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}#{$data_system.words.gold}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_126
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减物品
$game_party.gain_item(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_items[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_items[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_127
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减武器
$game_party.gain_weapon(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_weapons[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_weapons[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_128
value = operate_value(@parameters[1], @parameters[2], @parameters[3])
# 增减防具
$game_party.gain_armor(@parameters[0], value)
if value >= 0
$am = "#{$game_party.actors[0].name}得到了#{value.abs.to_s}个#{$data_armors[@parameters[0]].name}"
else
$am = "#{$game_party.actors[0].name}失去了#{value.abs.to_s}个#{$data_armors[@parameters[0]].name}"
end
bluefool_sort
Audio.se_play("Audio/SE/"+"006-System06",100,100)
return true
end
def command_129
# 获取角色
actor = $game_actors[@parameters[0]]
# 角色有效的情况下
if actor != nil
# 操作分支
if @parameters[1] == 0
if @parameters[2] == 1
$game_actors[@parameters[0]].setup(@parameters[0])
end
$game_party.add_actor(@parameters[0])
Audio.me_play("Audio/ME/"+"002-Victory02",100,100)
$am = "#{$game_actors[@parameters[0]].name}加入队伍!"
bluefool_sort
else
$game_party.remove_actor(@parameters[0])
Audio.me_play("Audio/ME/"+"015-Mystery01",100,100)
$am = "#{$game_actors[@parameters[0]].name}离开队伍!"
bluefool_sort
end
end
# 继续
return true
end
#-------------------------
end
#==============================================================================
# ■ Window_Down
#------------------------------------------------------------------------------
# 信息窗口。
#==============================================================================
class Window_Down < Window_Selectable
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 240, 330, 240)
@column_max = 1
self.opacity = 0
if $a != nil and $a.size < 21
self.index = $a.size/2
elsif $a != nil and $a.size > 20
self.index = 9
end
refresh
self.active = false
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if $a != nil and $a.size < Blue::Blue_max + 1
@item_max = $a.size
elsif $a != nil and $a.size > Blue::Blue_max
@item_max = Blue::Blue_max
end
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 16)
for i in 0...@item_max
draw_item(i)
end
end
end
def item_max
return @item_max
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目编号
#--------------------------------------------------------------------------
def draw_item(index)
if $a.size < Blue::Blue_max + 1
item = $a[index]
else
item = $a[index + $a.size - Blue::Blue_max]
end
x = 0
y = index * 16
self.contents.font.size = 14
self.contents.font.color = Color.new(-170,-170,-170,255)
self.contents.draw_text(x + 6, y + 1, self.contents.text_size(item).width, 16, item, 0)
self.contents.font.color = normal_color
self.contents.draw_text(x + 5, y, self.contents.text_size(item).width, 16, item, 0)
end
#--------------------------------------
# ● 刷新光标
#--------------------------------------
def update_cursor_rect
# 光标位置不满 0 的情况下
if @index < 0
self.cursor_rect.empty
return
end
# 获取当前的行
row = @index / @column_max
# 当前行被显示开头行前面的情况下
if row < self.top_row
# 从当前行向开头行滚动
self.top_row = row
end
# 当前行被显示末尾行之后的情况下
if row > self.top_row + (self.page_row_max - 1)
# 从当前行向末尾滚动
self.top_row = row - (self.page_row_max - 1)
end
# 计算光标的宽
cursor_width = self.width / @column_max - 32
cursor_width = 0
# 计算光标坐标
x = @index % @column_max * (cursor_width + 32)
y = @index / @column_max * 32 - self.oy
# 更新国标矩形
self.cursor_rect.set(x, y, cursor_width, 16)
end
end
复制代码
这是即时消息……
作者:
冰枫o鲍辰
时间:
2015-1-12 23:47
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1