赞 | 0 |
VIP | 3 |
好人卡 | 0 |
积分 | 1 |
经验 | 8935 |
最后登录 | 2017-3-15 |
在线时间 | 168 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 168 小时
- 注册时间
- 2007-7-26
- 帖子
- 477
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 cmmd1 于 2015-11-5 14:06 编辑
主角的位置要怎么改,希望队伍成员坐标都能改。
主角施放技能的时候没有跑到敌人面前释放动画,而是移动一小步就开始攻击了。
希望能帮帮忙啊大家!
熊式横版脚本:
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#
# ■ 熊式横版战斗 by 弗雷德 真移位:神思
#==============================================================================
#如果要需要Game_Battler3类的攻击、特技、物品的方法,请移至161-470行
#因为重写过这三个方法,在原方法里改是不会生效的。
#--------------------------------------------------------------------------
# ● 设定开始
#--------------------------------------------------------------------------
#伤害为0的时候是否显示无效文字,1为显示,0为不显示。
INVALIDSWITCH = 1
# 是否显示死亡图 1为显示,0为不显示。
DEADPIC = 1
# 是否显示总伤害 1为显示,0为不显示。
SHOW_TOTAL_DAMAGE = 1
# 是否显示连击数值 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 = 14
#设定人物的单帧图,如果不做设定,将直接使用默认的战斗图。
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_b5","bear_b6","bear_b7","bear_b8"],
"受伤" => ["bear_h"],
"防御" => ["bear_d"],
"死亡" => ["bear_die1","bear_die2","bear_die3","bear_die4"]
},
"赵云" => {
"待机" => ["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_b5","Fred_b6","Fred_b7","Fred_b8"],
"受伤" => ["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
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 - 3 #间距缩小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
( `ー´)
@弗雷德 |
|