| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 18 |
| 经验 | |
| 最后登录 | 2020-8-1 |
| 在线时间 | 2161 小时 |
酱油的
- 梦石
- 0
- 星屑
- 1840
- 在线时间
- 2161 小时
- 注册时间
- 2007-12-22
- 回帖
- 3216

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
- #==============================================================================
- # ■ 全动画战斗
- #------------------------------------------------------------------------------
- # By 禾西 on 2010.09.11
- # 应用脚本 彩虹神剑 By 66
- #==============================================================================
- # 基本上和另一个全动画脚本的设置一样
- #
- #简要介绍 by whbm:
- # 本脚本实现了战斗的动态效果,其中包含了待机、攻击、防御、挨打、胜利、死亡。类似于超级横版、超级战斗。但是本系统特色在于所有效果的实现并不是靠庞大的战斗图,而是使用了数据库中的动画。这样不仅突破了不同人不同祯数量的限制,并且方便了单动画单祯的修改。
- #使用方法:
- # 个人觉得还是比较简单,但是大量的怪物还是会令人头痛。
- # 1.数据库的设置
- # 敌人必要的动画有待机、挨打、死亡三个必要的动画
- # 角色必要的动画有待机、挨打、防御、死亡动态、胜利动态、死亡静态、胜利静态
- #
- # 死亡静态与胜利静态:动画中只有1祯,为相应动态动画的最后一祯
- #
- # 剩下的就是人物攻击的动画,和正常的动画是一样设置
- # 如图中的攻击等待动画只是为了在播放攻击动画的同时消除人物本身(素材原因,人物攻击的时候离开了原位,如果是在原位置放魔法是用不上的)
- # 2.战斗图的设置
- # 战斗图其实只是一个透明的图片,它只是用来描述一个敌人或者角色的大小,并与相应的战斗动画编号相衔接。
- # 战斗图的文件名格式如下:
- # 名字★待机★防御★挨打★死亡动态★死亡静态★胜利动态★胜利静态.png
- # (其中“名字”一项与动画无关)
- # 例如:
- # 紫烟★140★141★148★149★150★144★145.png
- # 对于敌人无胜利动画或者防御动画,请保持该位置为空,例如:
- # 蓝若冰★124★★126★127★★★.png
- # 综上,设置就这么完成了。
- #注意事项:
- # 1.由于系统中待机由动画实现,所以无法使用状态附带动画的功能。
- #
- #==============================================================================
- #// p.ori
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :animation1_id # 行动方动画ID
- alias battle_start_phase3 start_phase3
- alias battle_start_phase4 update_phase4_step3
- alias battle_start_phase5 start_phase5
- def start_phase3
- @spriteset.to_wait
- battle_start_phase3
- end
- def update_phase4_step3
- battle_start_phase4
- update_phase4_step4#//齊時動畫修改
- end
- def update_phase4_step5
- @help_window.visible = false
- @status_window.refresh
- @phase4_step = 6
- end
- def start_phase5
- @spriteset.win
- battle_start_phase5
- end
- end
- #==============================================================================
- # ■ Spriteset_Battle
- #==============================================================================
- class Spriteset_Battle
- def to_wait
- @actor_sprites.each do |sprite|
- sprite.to_wait if sprite.anim_mode == :guard
- end
- end
- def win
- @actor_sprites.each do |sprite| sprite.win 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
- @state_sprite = RPG::Sprite.new(viewport)
- end
- #--------------------------------------------------------------------------
- # ● x 值
- #--------------------------------------------------------------------------
- def x=(int)
- super
- @state_sprite.x = int
- end
- #--------------------------------------------------------------------------
- # ● y 值
- #--------------------------------------------------------------------------
- def y=(int)
- super
- @state_sprite.y = int
- end
- #--------------------------------------------------------------------------
- # ● z 值
- #--------------------------------------------------------------------------
- def z=(int)
- super
- @state_sprite.z = int
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 战斗者为 nil 的情况下,清空
- if self.clear? == true
- return false
- end
- # 文件名和色相与当前情况有差异的情况下
- if @battler.battler_name != @battler_name or
- @battler.battler_hue != @battler_hue
- self.set_battler_pic
- if @battler.is_a?(Game_Enemy) and( @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
- #@state_sprite.loop_animation($data_animations[@state_animation_id])
- end
- @state_sprite.update
- # 应该被显示的角色的情况下
- 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.guarding? and @anim_mode != :guard
- to_guard
- 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)
- @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
- display_anim
- end
- # 伤害
- if @battler.damage_pop
- damage(@battler.damage, @battler.critical)
- @battler.damage = nil
- @battler.critical = false
- @battler.damage_pop = false
- end
- # korapusu
- if @battler.damage == nil and @battler.dead?
- collapse
- end
- end
- # 设置活动块的坐标
- self.set_position
- if @flash_shake != 0 and @battler.damage != nil and 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
- #--------------------------------------------------------------------------
- # 清除
- #--------------------------------------------------------------------------
- def clear?
- if @battler.nil?
- self.bitmap = nil
- loop_animation(nil)
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # 重置人物
- #--------------------------------------------------------------------------
- def set_battler_pic
- # 获取、设置位图
- @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
- #.......................................................................
- if not @battler.hidden and not @battler.dead?
- to_wait
- end
- #.......................................................................
- end
- #--------------------------------------------------------------------------
- # 设置活动块的坐标
- #--------------------------------------------------------------------------
- def set_position
- self.x = @battler.screen_x
- self.y = @battler.screen_y
- self.z = @battler.screen_z
- end
- #--------------------------------------------------------------------------
- # 播放動畫
- #--------------------------------------------------------------------------
- def display_anim
- if $scene.animation1_id == @battler.animation_id
- to_attack
- else
- to_damage
- end
- @battler.animation_id = 0
- end
- #--------------------------------------------------------------------------
- # 出現
- #--------------------------------------------------------------------------
- alias battle_appear appear
- def appear
- battle_appear
- #......................................................................
- #//轉為待機
- to_wait
- #......................................................................
- end
- #--------------------------------------------------------------------------
- # 消失
- #--------------------------------------------------------------------------
- alias battle_collapse collapse
- def collapse
- 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
- #......................................................................
- if @anim_mode != :collapse
- to_collapse
- if @battler.is_a?(Game_Enemy)
- battle_collapse
- end
- end
- #......................................................................
- end
- #--------------------------------------------------------------------------
- # 勝利
- #--------------------------------------------------------------------------
- def win
- if not @battler.nil? and @battler.exist?
- to_win
- end
- end
- end
- #// p.ex
- #==============================================================================
- # ■ Sprite_Battler < RPG::Sprite
- #------------------------------------------------------------------------------
- # 全動畫戰鬪 meet with 鏡頭移動
- #==============================================================================
- class Sprite_Battler < RPG::Sprite
- attr_accessor :anim_mode
- #//接入update
- alias battle_update update
- def update
- update_battle_anim
- battle_update
- end
- def effect?
- @_whiten_duration > 0 or @_appear_duration > 0 or
- @_escape_duration > 0 or @_collapse_duration > 0 or
- @_damage_duration > 0 or @_animation_duration > 0 or
- @effect_duration != nil
- end
- #//刷新動畫效果
- def update_battle_anim
- return if @effect_duration.nil?
- if @effect_duration > 0
- #//effecting
- @effect_duration -= 1
- if @anim_mode == 1 and @effect_duration == 1
- to_wait if @battler.exist?
- end
- end
- return if @effect_duration != 0
- case @anim_mode
- when 1
- #//to wait
- when 2
- #//to wait
- if @battler.exist?
- to_wait
- @stop_ = false
- else
- collapse
- @stop_ = false
- return
- end
- when :collapse
- #//to dead
- id = self.gain_anim(:dead)
- loop_animation( $data_animations[id] )
- when :win
- #//to won
- id = self.gain_anim(:won)
- loop_animation( $data_animations[id] )
- end
- @effect_duration = nil
- end
- #//受傷動畫
- #----------------------------------------------------------------------
- def show_damage(hit)
- return if @battler.guarding? or @_animation.nil?
- if @battler_damage.is_a?(Numeric)
- return if @battler_damage < 0
- end
- if @stop_ != true
- if hit
- id = self.gain_anim(:damage)
- else
- id = self.gain_anim(:damage)
- end
- @_loop_animation_index = 0
- loop_animation( $data_animations[id] )
- @damaging ||= @_animation.timings.size - 2
- @damaging -= 1
- end
- end
- def terminate_damage
- if @damaging != nil and @_loop_animation_index == 0
- if @damaging <= 0
- id = self.gain_anim(:wait)
- loop_animation( $data_animations[id] )
- @stop_ = true
- @damaging = nil
- end
- end
- end
- #----------------------------------------------------------------------
- def setup_loop_anim(sym)
- id = self.gain_anim(sym)
- loop_animation( $data_animations[id] )
- @anim_mode = sym
- end
- #//轉為待機
- def to_wait
- setup_loop_anim(:wait)
- return true
- end
- #//轉為防御
- def to_guard
- setup_loop_anim(:guard)
- return true
- end
- #----------------------------------------------------------------------
- #//轉為攻擊
- def to_attack
- id = self.gain_anim(8)
- loop_animation( $data_animations[id])
- @effect_duration = @_loop_animation.frame_max*2
- @anim_mode = 1
- return true
- end
- #----------------------------------------------------------------------
- #//轉為挨打
- def to_damage
- id = self.gain_anim(8)
- @anim_mode = 2
- animation( $data_animations[id], @battler.animation_hit,
- @battler.damage, @battler.critical)
- @effect_duration = @_animation.frame_max*2
- return true
- end
- #----------------------------------------------------------------------
- #//轉為死亡
- def to_collapse
- @_loop_animation_index = 0
- setup_loop_anim(:collapse)
- @effect_duration = @_loop_animation.frame_max*2
- return true
- end
- #//轉為勝利
- def to_win
- @_loop_animation_index = 1
- setup_loop_anim(:win)
- #//勝利畫面的播放次數
- t = 1
- @effect_duration = @_loop_animation.frame_max*t*2
- return true
- end
- #----------------------------------------------------------------------
- #//讀取動畫
- def gain_anim(int)
- ary = @battler.battler_name.split(/★/)
- case int
- when :wait;
- return ary[1].to_i
- when :guard;
- return ary[2].to_i
- when :damage;
- return ary[3].to_i
- when :collapse;
- return ary[4].to_i
- when :dead;
- return ary[5].to_i
- when :win;
- return ary[6].to_i
- when :won;
- return ary[7].to_i
- when (8);
- return @battler.animation_id
- end
- end
- #----------------------------------------------------------------------
- end
- =begin
- ==============================================================================
- 彩虹神剑(伤害分段显示)显示总伤害版 v1.0f
- ==============================================================================
- 彩虹神剑 -柳柳
- 6-20-2006 v1.0 -叶子
- 在彩虹神剑的基础上增加了显示总伤害的功能,而且总伤害的数字是弹出伤害时逐渐增加的
- v1.0a -叶子
- 修正了显示伤害和实际伤害有差别的问题
- 修正了miss的情况下显示miss混乱的问题
- 修正了对己方技能重复显示伤害的问题
- 未修正播放目标动画第一帧时目标有时无端跳动的BUG
- v1.0b -叶子
- 修改了总伤害数字的位置和z坐标
- 未修正播放目标动画第一帧时目标有时无端跳动的BUG
- v1.0c -柳柳
- ? ? ?
- v1.0d -柳柳
- 1.0d最终解决了那个闪光问题,还有最末帧伤害多次的算法
- 7-24-2006 v1.0e -叶子
- 修正全屏幕闪烁弹出伤害错误的问题
- 修正连续伤害不会弹出伤害的问题
- 仍然未修正播放目标动画第一帧时目标有时无端跳动的BUG
- 2-20-2009 v1.0f -禾西
- 修正一次画面闪烁出现天文数字伤害的错误
- ==============================================================================
- =end
- # 核心的说明:
- # damage_pop 不再附带damage()的功能,这个放到animation里面去了
- module RPG
-
- class Sprite < ::Sprite
- #--------------------------------------------------------------------------
- # ● 常量设定
- #--------------------------------------------------------------------------
- # 是否显示总伤害
- SHOW_TOTAL_DAMAGE = true
- # 角色受攻击时是否跳一下
- BATTLER_JUMP = true
- #==========================================
- # 修改说明:
- # @flash_shake用来制作挨打时候跳跃
- # @_damage 用来记录每次打击之后弹出数字
- # @_total_damage 记录总伤害
- # @_total_damage_duration 总伤害持续帧
- #==========================================
- #--------------------------------------------------------------------------
- #initialize
- #==========================================================================
- alias rainbow_initialize initialize
- def initialize(viewport = nil)
- rainbow_initialize(viewport)
-
- @flash_shake = 0
- @_damages = []
- @_total_damage = 0
- @_total_damage_duration = 0
- #.........................................................................
- @hits = 0
- #.........................................................................
- 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 @_damages
- 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
- @_damages.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 = @_total_damage_duration * 16 - 128
- 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
- elsif @_total_damage_duration <= 7
- @_hits_sprite.opacity -= 32
- @_hits_sprite.x += 1
- 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
- terminate_damage
- 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
- #p/2 dispose
- #--------------------------------------------------------------------------
- #=======================================
- # 修改:更换清除伤害的算法,以防万一
- # 本内容在脚本中没有使用过
- #=======================================
- def dispose_damage
- for damage in @_damages.reverse
- damage[0].bitmap.dispose
- damage[0].dispose
- @_damages.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_weight = 1
- @_total_damage = 0
- @_last_frame = -1
- #.........................................................................
- @hits = 0
- #.........................................................................
- if @_animation_sprites != nil
- sprite = @_animation_sprites[0]
- if sprite != nil
- key = @_animation.animation_name + @_animation.animation_hue.to_s
- @@_reference_count[key] -= 1
- if @@_reference_count[key] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in @_animation_sprites
- sprite.dispose
- end
- @_animation_sprites = nil
- @_animation = nil
- end
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- #.damage(str/int, bool)
- def damage(value, critical)
- #.........................................................................
- #//dispose_damage #//清空 => p/2 dispose
- #清除hit数
- dispose_hit
- #.........................................................................
- if value.is_a?(Numeric)
- damage_string = value.abs.to_s
- else
- damage_string = value.to_s
- end
- #// 生成底圖
- bitmap = Bitmap.new(160, 48)
- #// 字體
- bitmap.font.name = "Comic Sans MS","Arial Black"
- #// layer 1
- 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)
- #// layer 2
- #=======================================
- # 修改:颜色
- #=======================================
- 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)
- #// layer 3
- 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
- #=======================================
- # 修改:推入新的伤害
- #=======================================
- @_damages.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
- # 总伤害处理
- make_total_damage(value)
- end
- #..........................................................................
- #--------------------------------------------------------------------------
- # ● 总伤害处理
- #--------------------------------------------------------------------------
- def make_total_damage(value)
- return unless (value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE)
- @_total_damage += value
- #// 生成底圖
- bitmap = Bitmap.new(300, 150)
- #// 字體
- bitmap.font.name = "Comic Sans MS","Arial Black"
- #// layer 4
- 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)
- #// layer 5
- 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 = 40
- @hits += 1
- hit
- #.........................................................................
- end
- #--------------------------------------------------------------------------
- # ● hit数的美化描绘
- #--------------------------------------------------------------------------
- #..........................................................................
- def hit
- # 如果伤害值是数值
- # 转为字符串
- value=@hits
- hits_string = value.to_s
- # 初始化位图
- bitmap = Bitmap.new(320, 64)
- bitmap.font.name = "Comic Sans MS","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
- #=======================================
- # 清除hit数
- #=======================================
- #...........................................................................
- def dispose_hit
- if @_hits_sprite != nil
- @_hits_sprite.bitmap.dispose
- @_hits_sprite.dispose
- @_hits_sprite = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 返回 @hits
- #--------------------------------------------------------------------------
- def get_hit
- return @hits
- 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
-
- name = @_animation.animation_name
- hue = @_animation.animation_hue
- bitmap = RPG::Cache.animation(name, hue)
-
- #=======================================
- # 修改:计算总闪光权限值
- #=======================================
- for timing in @_animation.timings
- weight = animation_process_timing(timing, hit, true)
- @all_weight += weight
-
- #//记录最后一次闪光
- @_last_frame = timing.frame if weight != 0
- end
- key = name + hue.to_s
- if @@_reference_count.include?(key)
- @@_reference_count[key] += 1
- else
- @@_reference_count[key] = 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 update_animation
- 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
- next unless timing.frame == frame_index
- t = 1.0 * animation_process_timing(timing, @_animation_hit)
- #p t,"当前权重", @all_weight,"总权重"
- if @battler_damage.is_a?(Numeric) and t != 0
- t *= @battler_damage
- t /= @all_weight
- t = t.to_i
- # 最后一次闪光的话,伤害修正
- if frame_index == @_last_frame
- @_total_damage = @battler_damage - t
- end
- damage(t, @battler_critical)
- # 防止重复播放miss
- elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
- damage(@battler_damage, @battler_critical)
- 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(@_loop_animation_sprites, cell_data, position)
- else
- @wait_count -= 1
- 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 dispose_loop_animation
- if @_loop_animation_sprites != nil
- sprite = @_loop_animation_sprites[0]
- if sprite != nil
- name = @_loop_animation.animation_name
- key = name + @_loop_animation.animation_hue.to_s
- @@_reference_count[key] -= 1
- if @@_reference_count[key] == 0
- sprite.bitmap.dispose
- end
- end
- for sprite in @_loop_animation_sprites
- sprite.dispose
- end
- @_loop_animation_sprites = nil
- @_loop_animation = nil
- end
- end
- #=======================================
- # 修改:敌人跳跃的功能 + 添加返回数值
- #=======================================
- def loop_animation(animation)
- return if animation == @_loop_animation
- dispose_loop_animation
- @_loop_animation = animation
- return if @_loop_animation == nil
- @_loop_animation_index = 0
- name = @_loop_animation.animation_name
- hue = @_loop_animation.animation_hue
- bitmap = RPG::Cache.animation(name, hue)
- key = name + hue.to_s
- if @@_reference_count.include?(key)
- @@_reference_count[key] += 1
- else
- @@_reference_count[key] = 1
- end
- @_loop_animation_sprites = []
- for i in 0..16
- sprite = ::Sprite.new(self.viewport)
- sprite.bitmap = bitmap
- sprite.visible = false
- @_loop_animation_sprites.push(sprite)
- end
- update_loop_animation
- 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 = self.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 animation_set_sprites_loop(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 = self.z
- 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 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
- unless $scene.animation1_id == @battler.animation_id
- show_damage(hit)
- end
- 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 and self.viewport != nil
- unless $scene.animation1_id == @battler.animation_id
- show_damage(hit)
- end
- self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
- end
- return timing.flash_color.alpha * timing.flash_duration
- when 3
- unless dontflash
- unless $scene.animation1_id == @battler.animation_id
- show_damage(hit)
- end
- self.flash(nil, timing.flash_duration * 2)
- end
- return timing.flash_color.alpha * timing.flash_duration
- end
- end
- return 0
- end
- #//虛函數
- def show_damage(hit)
- end
- def terminate_damage
- end
- end
- end
复制代码 |
|