想請問置頂裡的ARPG範例的問題(技能部分)
4 posters
想請問置頂裡的ARPG範例的問題(技能部分)
我把該腳本插入八方向腳本後怪物就不會動了...然後我的人物的技能也不會放...想請問一下我該怎樣修改呢?
最後的我想讓我的技能有連擊..可是卻沒有反應不然就是有BUG....想請問一下我該怎樣修改呢?(BUG顯示◆Arpg_Sprite_Character第60出錯)
以下是我的技能連擊腳本(採用彩虹神大大)
=end
# 核心的说明:
# damage_pop 不再附带damage()的功能,这个放到animation里面去了
module RPG
#--------------------------------------------------------------------------
# ● 常量设定
#--------------------------------------------------------------------------
# 是否显示总伤害
SHOW_TOTAL_DAMAGE = true
# 角色受攻击时是否跳一下
BATTLER_JUMP = false
# 连续伤害的动画ID
SLIP_DAMAGE_ANIMATION_ID = 105
class Sprite < ::Sprite
#==========================================
# 修改说明:
# @flash_shake用来制作挨打时候跳跃
# @_damage 用来记录每次打击之后弹出数字
# @_total_damage 记录总伤害
# @_total_damage_duration 总伤害持续帧
#==========================================
#alias 66RPG_rainbow_initialize : initialize
def initialize(viewport = nil)
#66RPG_rainbow_initialize(viewport)
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 = []
# 总伤害数字
@_total_damage = 0
# 总伤害持续帧
@_total_damage_duration = 0
#记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
@p_dam=0
@hits=0
end
#美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
def damage(value, critical)
# 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
#dispose_damage
#清除hit数
dispose_hit
# 如果伤害值是数值
if value.is_a?(Numeric)
# 绝对值转为字符串
damage_string = value.abs.to_s
else
# 转为字符串
damage_string = value.to_s
end
# 初始化位图
bitmap = Bitmap.new(162, 64)
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 value < 0
# 调用回复数字表
rect_y = 32
else
# 调用伤害数字表
rect_y = 0
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damagenew"),
Rect.new(number * 18, rect_y, 18, 32))
# 后移一位
damage_x += 18
end
# 伤害值不是数值的情况
else
# 如果伤害值不是 Miss
unless value == "Miss"
# 系统默认描画字符串
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
# Miss 的情况下
else
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
end
end
# 会心一击标志打开的情况
if critical
# 显示会心一击图画
bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 81
@_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
# hit数的美化描绘
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
# 显示伤害数字
bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
Rect.new(number * 36.2, rect_y, 36.2, 50))
# 后移一位
hits_x += 36.2
end
bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
Rect.new(0, -21, 90, 50))
# 伤害值定位
@_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.z = 3000
@_hits_duration = 40
end
#--------------------------------------------------------------------------
# ● 总伤害处理
#--------------------------------------------------------------------------
def make_total_damage(value)
if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
@_total_damage += value
# 绝对值转为字符串
damage_string = @_total_damage.abs.to_s
else
return
end
# 初始化位图
bitmap = Bitmap.new(300, 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
# 伤害值为负的情况下
if value < 0
# 调用回复数字表
name="Number3"
else
# 调用伤害数字表
name="Number2"
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
Rect.new(number * 36.2, 0, 36.2, 50))
# 后移一位
damage_x += 36.2
end
end
最後的我想讓我的技能有連擊..可是卻沒有反應不然就是有BUG....想請問一下我該怎樣修改呢?(BUG顯示◆Arpg_Sprite_Character第60出錯)
以下是我的技能連擊腳本(採用彩虹神大大)
=end
# 核心的说明:
# damage_pop 不再附带damage()的功能,这个放到animation里面去了
module RPG
#--------------------------------------------------------------------------
# ● 常量设定
#--------------------------------------------------------------------------
# 是否显示总伤害
SHOW_TOTAL_DAMAGE = true
# 角色受攻击时是否跳一下
BATTLER_JUMP = false
# 连续伤害的动画ID
SLIP_DAMAGE_ANIMATION_ID = 105
class Sprite < ::Sprite
#==========================================
# 修改说明:
# @flash_shake用来制作挨打时候跳跃
# @_damage 用来记录每次打击之后弹出数字
# @_total_damage 记录总伤害
# @_total_damage_duration 总伤害持续帧
#==========================================
#alias 66RPG_rainbow_initialize : initialize
def initialize(viewport = nil)
#66RPG_rainbow_initialize(viewport)
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 = []
# 总伤害数字
@_total_damage = 0
# 总伤害持续帧
@_total_damage_duration = 0
#记录已经发生的伤害的变量★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
@p_dam=0
@hits=0
end
#美化的伤害处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
def damage(value, critical)
# 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看......
#dispose_damage
#清除hit数
dispose_hit
# 如果伤害值是数值
if value.is_a?(Numeric)
# 绝对值转为字符串
damage_string = value.abs.to_s
else
# 转为字符串
damage_string = value.to_s
end
# 初始化位图
bitmap = Bitmap.new(162, 64)
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 value < 0
# 调用回复数字表
rect_y = 32
else
# 调用伤害数字表
rect_y = 0
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 32, RPG::Cache.picture("Damagenew"),
Rect.new(number * 18, rect_y, 18, 32))
# 后移一位
damage_x += 18
end
# 伤害值不是数值的情况
else
# 如果伤害值不是 Miss
unless value == "Miss"
# 系统默认描画字符串
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 27, 162, 36, damage_string, 1)
bitmap.draw_text(-1, 29, 162, 36, damage_string, 1)
bitmap.draw_text(+1, 29, 162, 36, damage_string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 28, 162, 36, damage_string, 1)
# Miss 的情况下
else
# 显示未击中图画
bitmap.blt(36, 28, RPG::Cache.picture("Damage"), Rect.new(90, 64, 90, 32))
end
end
# 会心一击标志打开的情况
if critical
# 显示会心一击图画
bitmap.blt(36, 0, RPG::Cache.picture("Damage"), Rect.new(0, 64, 90, 32))
end
# 伤害值定位
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 81
@_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
# hit数的美化描绘
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
# 显示伤害数字
bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
Rect.new(number * 36.2, rect_y, 36.2, 50))
# 后移一位
hits_x += 36.2
end
bitmap.blt(hits_x, 0, RPG::Cache.picture("HITS"),
Rect.new(0, -21, 90, 50))
# 伤害值定位
@_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.z = 3000
@_hits_duration = 40
end
#--------------------------------------------------------------------------
# ● 总伤害处理
#--------------------------------------------------------------------------
def make_total_damage(value)
if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
@_total_damage += value
# 绝对值转为字符串
damage_string = @_total_damage.abs.to_s
else
return
end
# 初始化位图
bitmap = Bitmap.new(300, 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
# 伤害值为负的情况下
if value < 0
# 调用回复数字表
name="Number3"
else
# 调用伤害数字表
name="Number2"
end
# 循环伤害值字符串
for char in damage_array
number = char.to_i
# 显示伤害数字
bitmap.blt(damage_x, 0, RPG::Cache.picture(name),
Rect.new(number * 36.2, 0, 36.2, 50))
# 后移一位
damage_x += 36.2
end
end
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
# if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
# @_total_damage += value
# else
# return
# end
# bitmap = Bitmap.new(300, 150)
# bitmap.font.name = "Arial Black"
# bitmap.font.size = 40
# bitmap.font.color.set(0, 0, 0)
# bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
# if @_total_damage < 0
# bitmap.font.color.set(80, 255, 00)
# else
# bitmap.font.color.set(255, 140, 0)
# end
# bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
# bitmap.font.color.set(55, 55,255)
if @_total_damage_sprite.nil?
@_total_damage_sprite = ::Sprite.new(self.viewport)
@_total_damage_sprite.ox = 80
@_total_damage_sprite.oy = 20
@_total_damage_sprite.z = 3000
end
@_total_damage_sprite.bitmap = bitmap
@_total_damage_sprite.zoom_x = 0.8
@_total_damage_sprite.zoom_y = 0.8
@_total_damage_sprite.x = self.x
@_total_damage_sprite.y = self.y - self.oy / 2 - 64
@_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_critical=false)
dispose_animation
#=======================================
# 修改:记录伤害和critical
#=======================================
@battler_damage = battler_damage
@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 = ""
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
@_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
#=======================================
# 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#=======================================
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_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
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)
#p t,"当前权重", @all_quanzhong,"总权重"
if @battler_damage.is_a?(Numeric) and t != 0
t *= @battler_damage
t /= @all_quanzhong
t = t.to_i
#在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index != @_last_frame
@p_dam+= t
end
#p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
#闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index == @_last_frame
t=@battler_damage-@p_dam
end
#p t,"当前伤害",@battler_damage,"总伤害"
# 最后一次闪光的话,伤害修正
if frame_index == @_last_frame
@_total_damage = @battler_damage - t
@p_dam=0 #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
end
#p t,@battler_damage,@all_quanzhong
damage(t,@battler_critical)
#连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index == @_last_frame
@hits=0
end
# 防止重复播放miss
elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
damage(@battler_damage,@battler_critical)
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)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
case timing.flash_scope
when 1
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
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
# 添加跳跃记录
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@flash_shake_switch = true
end
#--------------------------------------------------------------------------
# ● 刷新画面
# 增添跳跃功能
#--------------------------------------------------------------------------
def update
super
# 战斗者为 nil 的情况下
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# @_total_damage += value
# else
# return
# end
# bitmap = Bitmap.new(300, 150)
# bitmap.font.name = "Arial Black"
# bitmap.font.size = 40
# bitmap.font.color.set(0, 0, 0)
# bitmap.draw_text(+2, 12+2, 160, 40, @_total_damage.abs.to_s, 1)
# if @_total_damage < 0
# bitmap.font.color.set(80, 255, 00)
# else
# bitmap.font.color.set(255, 140, 0)
# end
# bitmap.draw_text(0, 12, 160, 40, @_total_damage.abs.to_s, 1)
# bitmap.font.color.set(55, 55,255)
if @_total_damage_sprite.nil?
@_total_damage_sprite = ::Sprite.new(self.viewport)
@_total_damage_sprite.ox = 80
@_total_damage_sprite.oy = 20
@_total_damage_sprite.z = 3000
end
@_total_damage_sprite.bitmap = bitmap
@_total_damage_sprite.zoom_x = 0.8
@_total_damage_sprite.zoom_y = 0.8
@_total_damage_sprite.x = self.x
@_total_damage_sprite.y = self.y - self.oy / 2 - 64
@_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_critical=false)
dispose_animation
#=======================================
# 修改:记录伤害和critical
#=======================================
@battler_damage = battler_damage
@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 = ""
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
@_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
#=======================================
# 清除hit数★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
#=======================================
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_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
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)
#p t,"当前权重", @all_quanzhong,"总权重"
if @battler_damage.is_a?(Numeric) and t != 0
t *= @battler_damage
t /= @all_quanzhong
t = t.to_i
#在闪光不是最后一次的情况下,把这次伤害加入到已经发生的伤害中★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index != @_last_frame
@p_dam+= t
end
#p @p_dam,"已发生伤害",@battler_damage,"总伤害"(调试用)★★★★★★★★★★★★★★★★★★★★★★★★★★
#闪光为最后一次的情况下,改变这次伤害的计算方法(总伤害-已经发生伤害)★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index == @_last_frame
t=@battler_damage-@p_dam
end
#p t,"当前伤害",@battler_damage,"总伤害"
# 最后一次闪光的话,伤害修正
if frame_index == @_last_frame
@_total_damage = @battler_damage - t
@p_dam=0 #已经发生的伤害归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
end
#p t,@battler_damage,@all_quanzhong
damage(t,@battler_critical)
#连击次数归0★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
if frame_index == @_last_frame
@hits=0
end
# 防止重复播放miss
elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
damage(@battler_damage,@battler_critical)
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)
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
case timing.flash_scope
when 1
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
#==============================================================================
# ■ Sprite_Battler
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 初始化对像
# 添加跳跃记录
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
super(viewport)
@battler = battler
@battler_visible = false
@flash_shake_switch = true
end
#--------------------------------------------------------------------------
# ● 刷新画面
# 增添跳跃功能
#--------------------------------------------------------------------------
def update
super
# 战斗者为 nil 的情况下
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
# 文件名和色相与当前情况有差异的情况下
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
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 @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
# 明灭
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
# @animation1_id = @active_battler.animation1_id.is_a?(Array) ? @active_battler.animation1_id.dup : @active_battler.animation1_id
# @animation2_id = @active_battler.animation2_id.is_a?(Array) ? @active_battler.animation2_id.dup : @active_battler.animation2_id
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
@battler.animation_id = 0
end
# 伤害
if @battler.damage_pop
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# korapusu
if @battler.damage == nil and @battler.dead?
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
# 设置活动块的坐标
if @flash_shake_switch == true
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
@flash_shake_switch = false
end
if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
case @flash_shake
when 9..10
self.x = @battler.screen_x
self.y -=4
self.z = @battler.screen_z
when 6..8
self.x = @battler.screen_x
self.y -=2
self.z = @battler.screen_z
when 3..5
self.x = @battler.screen_x
self.y +=2
self.z = @battler.screen_z
when 2
self.x = @battler.screen_x
self.y += 4
self.z = @battler.screen_z
when 1
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
@flash_shake -= 1
end
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :animation1_id # 行动方动画ID
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
# 处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
# 超级类来使用。
#class Game_Battler
# #--------------------------------------------------------------------------
# # ● 应用连续伤害效果
# #--------------------------------------------------------------------------
# alias rainbow_sword_slip_damage_effect slip_damage_effect
# def slip_damage_effect
# self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
# self.animation_hit = true
# rainbow_sword_slip_damage_effect
# end
#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
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 @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
# 明灭
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
# @animation1_id = @active_battler.animation1_id.is_a?(Array) ? @active_battler.animation1_id.dup : @active_battler.animation1_id
# @animation2_id = @active_battler.animation2_id.is_a?(Array) ? @active_battler.animation2_id.dup : @active_battler.animation2_id
animation = $data_animations[@battler.animation_id]
animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
@battler.animation_id = 0
end
# 伤害
if @battler.damage_pop
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# korapusu
if @battler.damage == nil and @battler.dead?
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
# 设置活动块的坐标
if @flash_shake_switch == true
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
@flash_shake_switch = false
end
if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
case @flash_shake
when 9..10
self.x = @battler.screen_x
self.y -=4
self.z = @battler.screen_z
when 6..8
self.x = @battler.screen_x
self.y -=2
self.z = @battler.screen_z
when 3..5
self.x = @battler.screen_x
self.y +=2
self.z = @battler.screen_z
when 2
self.x = @battler.screen_x
self.y += 4
self.z = @battler.screen_z
when 1
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
@flash_shake -= 1
end
end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
# 处理战斗画面的类。
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :animation1_id # 行动方动画ID
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
# 处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
# 超级类来使用。
#class Game_Battler
# #--------------------------------------------------------------------------
# # ● 应用连续伤害效果
# #--------------------------------------------------------------------------
# alias rainbow_sword_slip_damage_effect slip_damage_effect
# def slip_damage_effect
# self.animation_id = RPG::SLIP_DAMAGE_ANIMATION_ID
# self.animation_hit = true
# rainbow_sword_slip_damage_effect
# end
#end
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
你的八方向腳本可能有用到Game_Character類
我建議你不要用比較好...
我建議你不要用比較好...
雲的彼方- 拿著木劍的戰士
- 文章數 : 48
注冊日期 : 2008-08-09
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
感謝大大的指導我8方向的部分已經改完了,另外想請問一下各位大大...
技能的部分我想要給他有施法的動作(就是使用方的動畫),想請問一下我該怎樣改
才能讓施法動畫出現?還有狀態的部分,狀態名稱有出來可是中狀態的動畫卻沒出來
以上2個問題請問各位大大我該怎樣修改呢?
以及連擊的部分.....還是改不出所以然....
技能的部分我想要給他有施法的動作(就是使用方的動畫),想請問一下我該怎樣改
才能讓施法動畫出現?還有狀態的部分,狀態名稱有出來可是中狀態的動畫卻沒出來
以上2個問題請問各位大大我該怎樣修改呢?
以及連擊的部分.....還是改不出所以然....
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
s07901823 寫到:感謝大大的指導我8方向的部分已經改完了,另外想請問一下各位大大...
技能的部分我想要給他有施法的動作(就是使用方的動畫),想請問一下我該怎樣改
才能讓施法動畫出現?還有狀態的部分,狀態名稱有出來可是中狀態的動畫卻沒出來
以上2個問題請問各位大大我該怎樣修改呢?
以及連擊的部分.....還是改不出所以然....
這麼難的問題
愚大快點來幫我們解答吧>_<
雲的彼方- 拿著木劍的戰士
- 文章數 : 48
注冊日期 : 2008-08-09
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
s07901823 寫到:感謝大大的指導我8方向的部分已經改完了,另外想請問一下各位大大...
技能的部分我想要給他有施法的動作(就是使用方的動畫),想請問一下我該怎樣改
才能讓施法動畫出現?還有狀態的部分,狀態名稱有出來可是中狀態的動畫卻沒出來
以上2個問題請問各位大大我該怎樣修改呢?
以及連擊的部分.....還是改不出所以然....
1.狀態的部分我本來就沒寫狀態動畫所以不會有那種功能
2.請將下列腳本貼在Main之前(連擊)
- 代碼:
module RPG
#--------------------------------------------------------------------------
# ● 常量设定
#--------------------------------------------------------------------------
# 是否显示总伤害
SHOW_TOTAL_DAMAGE = true
# 角色受攻击时是否跳一下
BATTLER_JUMP = true
class Sprite < ::Sprite
#==========================================
# 修改说明:
# @flash_shake用来制作挨打时候跳跃
# @_damage 用来记录每次打击之后弹出数字
# @_total_damage 记录总伤害
# @_total_damage_duration 总伤害持续帧
#==========================================
#alias 66RPG_rainbow_initialize : initialize
def initialize(viewport = nil)
#66RPG_rainbow_initialize(viewport)
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 = []
# 总伤害数字
@_total_damage = 0
# 总伤害持续帧
@_total_damage_duration = 0
end
def damage(value,critical,sp_damage=nil)
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 60)
bitmap.font.name = "Arial Black"
bitmap.font.size = 32
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
#=======================================
# 修改:颜色
#=======================================
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 55, 55)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if sp_damage != nil
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 30-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 30-1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(-1, 30+1, 160, 36, sp_damage.to_s, 1)
bitmap.draw_text(+1, 30+1, 160, 36, sp_damage.to_s, 1)
bitmap.font.color.set(0, 255, 255)
bitmap.draw_text(0, 30, 160, 36, sp_damage.to_s, 1)
end
if critical
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
#=======================================
# 修改:推入新的伤害
#=======================================
@_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
# 总伤害处理
make_total_damage(value)
end
#--------------------------------------------------------------------------
# ● 总伤害处理
#--------------------------------------------------------------------------
def make_total_damage(value)
if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
@_total_damage += value
else
return
end
bitmap = Bitmap.new(300, 150)
bitmap.font.name = "Arial Black"
bitmap.font.size = 48
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
if @_total_damage < 0
bitmap.font.color.set(80, 255, 00)
else
bitmap.font.color.set(255, 140, 0)
end
bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
if @_total_damage_sprite.nil?
@_total_damage_sprite = ::Sprite.new(self.viewport)
@_total_damage_sprite.ox = 80
@_total_damage_sprite.oy = 20
@_total_damage_sprite.z = 3000
end
@_total_damage_sprite.bitmap = bitmap
@_total_damage_sprite.zoom_x = 1.5
@_total_damage_sprite.zoom_y = 1.5
@_total_damage_sprite.x = self.x
@_total_damage_sprite.y = self.y - self.oy / 2 - 64
@_total_damage_sprite.z = 3001
@_total_damage_duration = 80
end
def animation(animation, hit, battler_damage="", battler_critical=false, battler_sp_damage=nil)
dispose_animation
#=======================================
# 修改:记录伤害和critical
#=======================================
@battler_damage = battler_damage
@battler_critical = battler_critical
@battler_sp_damage = battler_sp_damage
@_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
@_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
@_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_animation
#=======================================
# 修改:清除记录的伤害,清除权重记录
#=======================================
@battler_damage = 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
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
@_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)
#p t,"当前权重", @all_quanzhong,"总权重"
if @battler_damage.is_a?(Numeric) and t != 0
t *= @battler_damage
t /= @all_quanzhong
#p t,"当前伤害",@battler_damage,"总伤害"
t = t.to_i
# 最后一次闪光的话,伤害修正
if frame_index == @_last_frame
@_total_damage = @battler_damage - t
end
#p t,@battler_damage,@all_quanzhong
damage(t,@battler_critical,@battler_sp_damage)
# 防止重复播放miss
elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
damage(@battler_damage,@battler_critical)
elsif @battler_sp_damage != nil
damage(nil,false,@battler_sp_damage)
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)
unless dontflash
if timing.se.name != ""
se = timing.se
Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
end
end
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)
return timing.flash_color.alpha * timing.flash_duration
end
end
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
愚零鬥武多 在 周一 8月 25, 2008 10:51 am 作了第 1 次修改
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
- 代碼:
#==============================================================================
# ■ Sprite_Character
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# ● 更新畫面
#--------------------------------------------------------------------------
def update
super
# 元件 ID、文件名稱、色相與現在的情況存在差異的情況下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 記憶元件 ID 與文件名稱、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 為有效值的情況下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 為無效值的情況下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 設定可視狀態
self.visible = (not @character.transparent)
# 圖形是角色的情況下
if @tile_id == 0
# 設定傳送目標的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 設定劇本的座標
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 動畫
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true, @character.damage, @character.critical, @character.sp_damage)
@character.animation_id = 0
end
# 傷害
if @character.damage_pop
@character.damage = nil
@character.sp_damage = nil
@character.critical = false
@character.damage_pop = false
end
end
end
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
@0@!!(發抖....)我沒看錯嗎....大大本人親自幫忙QQ....
感謝><
原來是這樣歐....那我該怎樣修改才能有狀態動畫以及使用方的動畫出現呢?
我是有想過既然使用方和中狀態那些動畫些是切換場景(橫向或縱向戰鬥)才會有所以我如果我把切換場景的那段腳本給刪除調是否就可以出現(有嘗試改過但因為都會錯誤就放棄...)
不管怎樣先感謝大大身自幫忙(A LI GA DO)
感謝><
原來是這樣歐....那我該怎樣修改才能有狀態動畫以及使用方的動畫出現呢?
我是有想過既然使用方和中狀態那些動畫些是切換場景(橫向或縱向戰鬥)才會有所以我如果我把切換場景的那段腳本給刪除調是否就可以出現(有嘗試改過但因為都會錯誤就放棄...)
不管怎樣先感謝大大身自幫忙(A LI GA DO)
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
修改狀態動畫以及使用方的動畫首先要在◆Arpg_Game_Character新增對應的狀態動畫實體變數與使用方動畫實體變數
例如
@animation1_id與@state_animation_id
然後在◆Arpg_Game_Battler的應用通常攻擊效果.應用特技效果.應用物品效果自行添加寫入的參數
◆Arpg_Sprite_Character要自己加入使用方動畫與狀態動畫的運作(可參考Sprite_Battler的作法)....
雖然如此但寫這些判定仍是一個大工程,我原先的架構就沒有寫這些功能因此等於整個要大改寫....
每位使用者都有不同的需求我是儘可能協助,但不可能幫每個人搞到完美而去整個改寫,
因此還請見諒。
例如
@animation1_id與@state_animation_id
然後在◆Arpg_Game_Battler的應用通常攻擊效果.應用特技效果.應用物品效果自行添加寫入的參數
◆Arpg_Sprite_Character要自己加入使用方動畫與狀態動畫的運作(可參考Sprite_Battler的作法)....
雖然如此但寫這些判定仍是一個大工程,我原先的架構就沒有寫這些功能因此等於整個要大改寫....
每位使用者都有不同的需求我是儘可能協助,但不可能幫每個人搞到完美而去整個改寫,
因此還請見諒。
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
恩恩感謝感謝
因為我在考慮把你的ARPG系統改成像楓之谷那種橫向式的RPG,不過因為我的8方向(有重力版本)
有卡到喝水系統放棄(喝水補血技能失效..不能補.但能攻擊....)只好作罷...所以我才會問這個問題XD.
(因為如果弄成楓之谷那種就不用使用方的動畫了)
先謝謝你了歐
因為我在考慮把你的ARPG系統改成像楓之谷那種橫向式的RPG,不過因為我的8方向(有重力版本)
有卡到喝水系統放棄(喝水補血技能失效..不能補.但能攻擊....)只好作罷...所以我才會問這個問題XD.
(因為如果弄成楓之谷那種就不用使用方的動畫了)
先謝謝你了歐
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
對了大大我再問一個問題.....(不好意思)
我想請問一下關於4方向動畫播放腳本(向右技能撥向右的技能向左撥向左的)我該從哪裡著手...
我去66RPG看該腳本然後自己也嘗試修改可是改出來卻變成顛倒的......上下完全顛倒...
像我的火箭是往45度方向由右上方向左下落下(人物面朝又),可是換成人物面向左邊技能確顛倒了,落點也不對....
打到後的燃燒動畫變成直線式的(正常要橫式的)...然後連擊及傷害處理就不見了
我是參考66RPG論壇裡的
我該怎樣做呢?
我是有想過ㄧ個技能4種方向然後用公共事件..可是怪怪的.....有時正常有時不正常
我想請問一下關於4方向動畫播放腳本(向右技能撥向右的技能向左撥向左的)我該從哪裡著手...
我去66RPG看該腳本然後自己也嘗試修改可是改出來卻變成顛倒的......上下完全顛倒...
像我的火箭是往45度方向由右上方向左下落下(人物面朝又),可是換成人物面向左邊技能確顛倒了,落點也不對....
打到後的燃燒動畫變成直線式的(正常要橫式的)...然後連擊及傷害處理就不見了
我是參考66RPG論壇裡的
我該怎樣做呢?
我是有想過ㄧ個技能4種方向然後用公共事件..可是怪怪的.....有時正常有時不正常
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
s07901823 寫到:對了大大我再問一個問題.....(不好意思)
我想請問一下關於4方向動畫播放腳本(向右技能撥向右的技能向左撥向左的)我該從哪裡著手...
我去66RPG看該腳本然後自己也嘗試修改可是改出來卻變成顛倒的......上下完全顛倒...
像我的火箭是往45度方向由右上方向左下落下(人物面朝又),可是換成人物面向左邊技能確顛倒了,落點也不對....
打到後的燃燒動畫變成直線式的(正常要橫式的)...然後連擊及傷害處理就不見了
我是參考66RPG論壇裡的
我該怎樣做呢?
我是有想過ㄧ個技能4種方向然後用公共事件..可是怪怪的.....有時正常有時不正常
這是當然的啊
你用的連擊和4方向動畫播放他們都同屬於Sprite類的animation函式
只能擇其一使用
愚零鬥武多- 不正常人類研究中心自慰隊員
- 文章數 : 421
注冊日期 : 2008-04-06
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
不好意思最近電腦壞掉不能上導致資料遺失=口=(汗...)
我該怎樣著手呢?如果改4方向動畫就一定要用到animation嗎?(希望渺茫....)如果是就算了....
另外...我最近想大改大大的arpg的腳本渴是就一直改不成功...如武器、技能的範圍、射程部分
我怎改就是一直有bug..改到發火= =|||最主要是資料遺失啦....(懶的再找了...)
我想請問例如我想改終點座標打1隻(遠程技能以及弓箭的攻擊)和終點座標範圍(4*4範圍以上或以下)
類似現在線上遊戲的範圍攻擊我該如何著手呢?因為最近想做類似暗黑破壞神那種玩法搭配滑鼠
(滑鼠左鍵前進+攻擊右鍵技能攻擊)所以大大的xy座標範圍判斷不能再用了....可是卻又改不了
(因該說不知道從哪裡下手)想請問一下如果我這樣做那大大的腳本是不是就完全不能用了
因為大大的腳本棄之可惜阿...
我該怎樣著手呢?如果改4方向動畫就一定要用到animation嗎?(希望渺茫....)如果是就算了....
另外...我最近想大改大大的arpg的腳本渴是就一直改不成功...如武器、技能的範圍、射程部分
我怎改就是一直有bug..改到發火= =|||最主要是資料遺失啦....(懶的再找了...)
我想請問例如我想改終點座標打1隻(遠程技能以及弓箭的攻擊)和終點座標範圍(4*4範圍以上或以下)
類似現在線上遊戲的範圍攻擊我該如何著手呢?因為最近想做類似暗黑破壞神那種玩法搭配滑鼠
(滑鼠左鍵前進+攻擊右鍵技能攻擊)所以大大的xy座標範圍判斷不能再用了....可是卻又改不了
(因該說不知道從哪裡下手)想請問一下如果我這樣做那大大的腳本是不是就完全不能用了
因為大大的腳本棄之可惜阿...
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
回復: 想請問置頂裡的ARPG範例的問題(技能部分)
對了關於技能等級我要怎樣做才能出現呢?因為我插入66RP的技能熟練度沒有效...我找個時間PO上來(現在手邊沒這筆資料...)
我想做技能有10等級每一等技能會追加變化像仙境傳說那種(如1等火箭打1下10等火箭打10下P.S追加動畫)
....我最近快找出該腳本的,只是想先問一下大大我該如何修改,因為之前改了他還是沒用.(效果沒出現...)
我想做技能有10等級每一等技能會追加變化像仙境傳說那種(如1等火箭打1下10等火箭打10下P.S追加動畫)
....我最近快找出該腳本的,只是想先問一下大大我該如何修改,因為之前改了他還是沒用.(效果沒出現...)
s07901823- 賣彩色內褲的小鱉三
- 文章數 : 9
注冊日期 : 2008-08-24
這個論壇的權限:
您 無法 在這個版面回復文章
|
|