| 赞 | 2 |
| VIP | |
| 好人卡 | |
| 积分 | 29 |
| 经验 | |
| 最后登录 | 2026-11-22 |
| 在线时间 | 665 小时 |
- 梦石
- 0
- 星屑
- 2914
- 在线时间
- 665 小时
- 注册时间
- 2012-5-3
- 回帖
- 78

|
楼主 |
发表于 2021-8-29 14:58:29
|
显示全部楼层
大佬也来拉,全动画脚本在这里,刚刚没有发完全。大佬能否帮我看看?
- #==============================================================================
- # ■ 全动画战斗系统(修改加强再加强版)
- #------------------------------------------------------------------------------
- # By whbm
- # 应用脚本 彩虹神剑 By 66
- # v1.0 by liulu 添加了23种战斗特技,另外有一部分在单技能连击脚本中
- #==============================================================================
- $fangyu = 0
- # 叮当猫的全动画脚本
- module RPG
- class Sprite < ::Sprite
- @@_animations = []
- @@_reference_count = {}
- #---------------------------------------------------------------------------
- # 释放
- #---------------------------------------------------------------------------
- def dispose
- dispose_damage
- dispose_animation
- dispose_loop_animation
- dispose_loop_animation1
- super
- end
- #---------------------------------------------------------------------------
- # 设置循环动画1
- #---------------------------------------------------------------------------
- def loop_animation1(animation)
- #如果动画重复跳出
- return if animation == @_loop_animation1
- #释放动画资源
- dispose_loop_animation1
- #动画变更
- @_loop_animation1 = animation
- #如果动画还为空跳出
- return if @_loop_animation1 == nil or @_loop_animation1 == []
- #精灵动画组清空
- @_loop_animation1_sprites_array = []
- #动画索引为0
- @_loop_animation1_index = []
- #状态动画深度
- tm_viewport = Viewport.new(0, 0, 640, 480)
- for temp_animation in @_loop_animation1
- #动画索引为0
- @_loop_animation1_index.push(0)
- #动画名
- animation_name = temp_animation.animation_name
- #动画色调
- animation_hue = temp_animation.animation_hue
- #从高速缓存中取得动画图像
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- #如果此动画被计数过则自加1,否则初始化1
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- #清空动画1精灵组
- @_loop_animation1_sprites = []
- #push 15次
- for i in 0..15
- #状态动画深度深入判断
- if temp_animation.name.split(/,/)[1] == "z"
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation1_sprites.push(sprite)
- else
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation1_sprites.push(sprite)
- end
- end
- @_loop_animation1_sprites_array.push(@_loop_animation1_sprites)
- end
- update_loop_animation1
- end
- #--------------------------------------------------------------------------
- # ● 释放循环动画1
- #--------------------------------------------------------------------------
- def dispose_loop_animation1
- #如果精灵组的动画组不为空
- if @_loop_animation1_sprites_array != nil
- #循环遍历精灵组的动画组
- for loop_animation1_sprites in @_loop_animation1_sprites_array
- #如果精灵组不为空
- if loop_animation1_sprites != nil
- #获得第一个精灵
- sprite = loop_animation1_sprites[0]
- #第一个精灵不为空的情况下
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- if @@_reference_count[sprite.bitmap] <= 0
- sprite.bitmap.dispose
- end
- end
- #遍历精灵组释放资源
- for sprite in loop_animation1_sprites
- sprite.dispose
- end
- #将当前精灵组清空
- loop_animation1_sprites = nil
- end
- end
- #将精灵组的动画组清空
- @_loop_animation1_sprites_array = nil
- #清空动画组
- @_loop_animation1 = nil
- end
- end
- #---------------------------------------------------------------------------
- # ● 闪烁
- #---------------------------------------------------------------------------
- def animation_process_timing(timing, hit)
- #判断闪烁条件
- if (timing.condition == 0) or
- (timing.condition == 1 and hit == true) or
- (timing.condition == 2 and hit == false)
- if timing.se.name != ""
- se = timing.se
- Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
- end
- case timing.flash_scope
- when 1
- self.flash(timing.flash_color, timing.flash_duration * 2)
- when 2
- if self.viewport != nil
- self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
- end
- when 3
- self.flash(nil, timing.flash_duration * 2)
- end
- end
- end
- #---------------------------------------------------------------------------
- # ● 更新循环动画1
- #---------------------------------------------------------------------------
- def update_loop_animation1
- for index in 0..@_loop_animation1.size - 1
- #帧索引赋值
- frame_index = @_loop_animation1_index[index]
- #动画当前帧的式样(大小,透明,旋转,等等)
- cell_data = @_loop_animation1[index].frames[frame_index].cell_data
- #动画相对于屏幕的位置(上,中,下,画面)
- position = @_loop_animation1[index].position
- #·改·
- if @wait_count.to_i <= 0
- @wait_count = 0
- animation_set_sprites(@_loop_animation1_sprites_array[index], cell_data, position)
- else
- for sprite in @_loop_animation1_sprites_array[index]
- sprite.visible = false
- end
- end
- if @wait_flash.to_i <= 0
- @wait_flash = 0
- else
- @wait_flash -= 1
- for sprite in @_loop_animation1_sprites_array[index]
- sprite.blend_type = 1
- end
- end
- #循环判断动画闪烁
- for timing in @_loop_animation1[index].timings
- if timing.frame == frame_index
- #闪烁
- animation_process_timing(timing, true)
- end
- end
- end
- end
- end
- end
- # 新加部分
- class Spriteset_Battle
- #--------------------------------------------------------------------------
- # ● 初始化变量
- #--------------------------------------------------------------------------
- def initialize
- # 生成显示端口
- @viewport1 = Viewport.new(0, 0, 640, 480)
- @viewport2 = Viewport.new(0, 0, 640, 480)
- @viewport3 = Viewport.new(0, 0, 640, 480)
- @viewport2.z = 5000
- @viewport3.z = 200
- # 生成战斗背景活动块
- @battleback_sprite = Sprite.new(@viewport1)
- # 生成敌人活动块
- @enemy_sprites = []
- for enemy in $game_troop.enemies.reverse
- @enemy_sprites.push(Sprite_Battler.new(@viewport2, enemy))
- end
- # 生成角色活动块
- @actor_sprites = []
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- #第5-10个角色
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- @actor_sprites.push(Sprite_Battler.new(@viewport2))
- # 生成图片活动块
- @picture_sprites = []
- for i in 51..53
- @picture_sprites.push(Sprite_Picture.new(@viewport3,
- $game_screen.pictures[i]))
- end
- # 刷新画面
- update
- end
- #--------------------------------------------------------------------------
- # ● 胜利图
- #--------------------------------------------------------------------------
- def win
- for sprite in @actor_sprites
- sprite.win
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 刷新角色的活动块 (对应角色的替换)
- @actor_sprites[0].battler = $game_party.actors[0]
- @actor_sprites[1].battler = $game_party.actors[1]
- @actor_sprites[2].battler = $game_party.actors[2]
- @actor_sprites[3].battler = $game_party.actors[3]
- @actor_sprites[4].battler = $game_party.actors[4]
- @actor_sprites[5].battler = $game_party.actors[5]
- @actor_sprites[6].battler = $game_party.actors[6]
- @actor_sprites[7].battler = $game_party.actors[7]
- @actor_sprites[8].battler = $game_party.actors[8]
- @actor_sprites[9].battler = $game_party.actors[9]
- # 战斗背景的文件名与现在情况有差异的情况下
- if @battleback_name != $game_temp.battleback_name
- @battleback_name = $game_temp.battleback_name
- if @battleback_sprite.bitmap != nil
- @battleback_sprite.bitmap.dispose
- end
- @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
- @battleback_sprite.src_rect.set(0, 0, 640, 480)
- end
- # 刷新战斗者的活动块
- for sprite in @enemy_sprites + @actor_sprites
- sprite.update
- end
- # 刷新图片活动块
- for sprite in @picture_sprites
- sprite.update
- end
- # 设置画面的色调与震动位置
- @viewport1.tone = $game_screen.tone
- @viewport1.ox = $game_screen.shake
- # 刷新显示端口
- @viewport1.update
- @viewport2.update
- end
- end
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :last_hp # 受效前的HP
- #--------------------------------------------------------------------------
- # ● 设置显示伤害
- #--------------------------------------------------------------------------
- def show_damage(value)
- @show_damage_value = value
- end
- #--------------------------------------------------------------------------
- # ● 显示伤害
- #--------------------------------------------------------------------------
- def show_damage_value
- return @show_damage_value
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def battler_ani
- return @battler_ani
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def setup_battler_ani(battler_ani, once = 0)
- @battler_ani = battler_ani
- @once = once
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def setup_battler_hurt_ani(hurt)
- @hurt = hurt
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def setup_battler_dead_ani(over)
- @over = over
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def battler_dead_ani
- return @over
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def battler_ani_once
- return @once
- end
- #--------------------------------------------------------------------------
- # ● 获取循环的动画 ID
- #--------------------------------------------------------------------------
- def battler_hurt_ani
- return @hurt
- end
- end
- module RPG
- #--------------------------------------------------------------------------
- # ● 常量设定
- #--------------------------------------------------------------------------
- # 是否显示总伤害
- SHOW_TOTAL_DAMAGE = false
- # 角色受攻击时是否跳一下
- BATTLER_JUMP = false
- # 伤害美化字符串文件夹名(放在Pictures文件夹中的子文件夹)
- #STRING_DOCUMENTS = ""
- # 是否使用伤害美化效果
- USE_DAMAGE = true
- class Sprite < ::Sprite
- # 修改说明:
- # @flash_shake用来制作挨打时候跳跃
- # @_damage 用来记录每次打击之后弹出数字
- # @_total_damage 记录总伤害
- # @_total_damage_duration 总伤害持续帧
- #---------------------------------------------------------------------------
- # ● 初始化
- #---------------------------------------------------------------------------
- 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 = []
- # 总伤害数字
- @_total_damage = 0
- # 总伤害持续帧
- @_total_damage_duration = 0
- #记录已经发生的伤害的变量
- @p_dam=0
- @hits=0
- #记录前一次攻击次数
- @temp_hits=0
- #判断是否为最后一次攻击
- @last_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]
- sprite.z =1
- 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)
- if USE_DAMAGE == true then
- # 释放伤害,效果是伤害数字快速消失,觉得不如不消失好看
- # 清除hit数
- dispose_hit
- # 如果伤害值是数值
- if value.is_a?(Numeric)
- # 绝对值转为字符串
- damage_string = value.to_i.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 = 15
- else
- # 调用伤害数字表
- rect_y = 0
- end
- # 循环伤害值字符串
- for char in damage_array
- number = char.to_i
- # 显示伤害数字
- bitmap.blt(damage_x, 32, RPG::Cache.picture( "Damage"),
- Rect.new(number * 14, rect_y, 15, 15))
- #Rect.new(number * 18, rect_y, 18, 32))
- # 后移一位
- damage_x += 15
- #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(71, 30, 71, 32))
- #bitmap.blt(36, 28, RPG::Cache.picture("damage-1"), Rect.new(90, 64, 90, 32))
- end
- end
- # 会心一击标志打开的情况
- if critical
- # 显示会心一击图画
- bitmap.blt(36, 0, RPG::Cache.picture( "Damage"), Rect.new(0, 30, 71, 32))
- #bitmap.blt(36, 0, RPG::Cache.picture( "damage"), Rect.new(0, 64, 90, 32))
- end
- end
- # 结束USE_DAMAGE == true
- # 伤害值定位
- @_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
- #--------------------------------------------------------------------------
- # ● 返回 @hits
- #--------------------------------------------------------------------------
- def get_hit
- return @hits
- 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 = - 36.2
- rect_y = 0
- # 循环伤害值字符串
- for char in hits_array
- # 后移一位
- hits_x += 36.2
- number = char.to_i
- # 显示伤害数字
- bitmap.blt(hits_x, 0, RPG::Cache.picture("Number"),
- Rect.new(number * 36.2, rect_y, 36.2, 50))
- end
- hits_x += 18.1
- 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.x = 560 - hits_string.size * 36.2
- @_hits_sprite.y = 70
- @_hits_sprite.z = 3000
- @_hits_duration = 40
- end
- #--------------------------------------------------------------------------
- # ● 美化的总伤害处理
- #--------------------------------------------------------------------------
- def make_total_damage(value)
- if USE_DAMAGE == true then
- if value.is_a?(Numeric)
- @_total_damage += value
- # 绝对值转为字符串
- damage_string = @_total_damage.abs.to_s
- else
- return
- end
- if SHOW_TOTAL_DAMAGE
- # 初始化位图
- bitmap = Bitmap.new(300, 150)
- bitmap.font.name = "Arial Black"
- bitmap.font.size = 30
- # 伤害值是数值的情况下
- 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 * 30, 0, 30, 50))
- # 后移一位
- damage_x += 26
- end
- end
- end
- else
- if value.is_a?(Numeric)
- @_total_damage += value
- else
- return
- end
- if SHOW_TOTAL_DAMAGE
- 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)
- end
- end
- if @_total_damage_sprite.nil?
- @_total_damage_sprite = ::Sprite.new
- @_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 = 40
- # hit数描绘
- @hits+=1
- hit
- 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
- @last_frame = @_last_frame
- 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
- @hits = 0
- if @_animation_sprites != nil
- sprite = @_animation_sprites[0]
- if sprite != nil
- @@_reference_count[sprite.bitmap] -= 1
- #条件改为<=0
- 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 <= 7 and @_total_damage_duration > 0
- @_hits_sprite.opacity -= 32
- @_hits_sprite.x += 1
- end
- if @_total_damage_duration <= 0
- dispose_hit
- @_total_damage = 0
- @_total_damage = 0
- @_total_damage_duration = 0
- if SHOW_TOTAL_DAMAGE
- @_total_damage_sprite.bitmap.dispose
- end
- @_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_once = 0
- @loop_animation_once = 1 if @once == 1 and @_loop_animation_index == @_loop_animation.frame_max
- @_loop_animation_index %= @_loop_animation.frame_max
- end
- if @_loop_animation1 != nil and (Graphics.frame_count % 2 == 0)
- for index in 0..(@_loop_animation1.size) - 1
- update_loop_animation1
- @_loop_animation1_index[index] += 1
- @_loop_animation1_index[index] %= @_loop_animation1[index].frame_max
- end
- 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 loop_animation_once
- return @_loop_animation_once
- end
- def update_animation
- #如果动画剩余帧数大于0
- if @_animation_duration > 0
- #获得当前动画帧索引
- frame_index = @_animation.frame_max - @_animation_duration
- @frame_index = frame_index
- #获得当前帧样式
- 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
- # 已经发生的伤害归0
- @p_dam=0
- end
- damage(t,@battler_critical)
- #连击次数归0
- if frame_index == @_last_frame
- @last_hits=1
- @temp_hits=0
- @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 update_loop_animation
- frame_index = @_loop_animation_index
- cell_data = @_loop_animation.frames[frame_index].cell_data
- position = @_loop_animation.position
- #·改·
- if @wait_count.to_i <= 0
- @wait_count = 0
- animation_set_sprites(@_loop_animation_sprites, cell_data, position)
- else
- @wait_count -= 1
- for sprite in @_loop_animation_sprites
- sprite.visible = false
- end
- end
- if @wait_flash.to_i <= 0
- @wait_flash = 0
- else
- @wait_flash -= 1
- for sprite in @_loop_animation_sprites
- sprite.blend_type = 1
- end
- end
- #·改·
- for timing in @_loop_animation.timings
- if timing.frame == frame_index
- animation_process_timing(timing, true)
- end
- end
- end
- # 循环动画
- def loop_animation(animation)
- #如果动画重复return
- return if animation == @_loop_animation
- #释放原有动画
- dispose_loop_animation
- #加载新动画
- @_loop_animation = animation
- #如果动画为空return
- return if @_loop_animation == nil
- #动画索引初始化
- @_loop_animation_index = 0
- animation_name = @_loop_animation.animation_name
- animation_hue = @_loop_animation.animation_hue
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_loop_animation_sprites = []
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation_sprites.push(sprite)
- end
- update_loop_animation
- end
- # 修改: 敌人跳跃功能 (伤害数值被敌人遮盖)
- def loop_animation_s(animation)
- return if animation == @_loop_animation
- dispose_loop_animation
- @_loop_animation = animation
- return if @_loop_animation == nil
- @_loop_animation_index = 0
- animation_name = @_loop_animation.animation_name
- animation_hue = @_loop_animation.animation_hue
- bitmap = RPG::Cache.animation(animation_name, animation_hue)
- if @@_reference_count.include?(bitmap)
- @@_reference_count[bitmap] += 1
- else
- @@_reference_count[bitmap] = 1
- end
- @_loop_animation_sprites = []
- for i in 0..15
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation_sprites.push(sprite)
- end
- update_loop_animation
- 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)
- @wait_flash = timing.flash_duration
- 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)
- @wait_count = timing.flash_duration
- end
- return timing.flash_color.alpha * timing.flash_duration
- end
- end
- return 0
- end
- end
- end
复制代码 |
|