赞 | 0 |
VIP | 0 |
好人卡 | 2 |
积分 | 5 |
经验 | 14444 |
最后登录 | 2023-7-25 |
在线时间 | 193 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 463
- 在线时间
- 193 小时
- 注册时间
- 2014-8-25
- 帖子
- 30
|
含SP显示的数值美化
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
- # ============================================================================
- # 伤害效果美化 v1.0 by SailCat
- # ============================================================================
- # 脚本使用说明:
- # 1.使用时需要将Damage.png复制到你的游戏的Graphics/Pictures目录下
- # 2.Damage.png文件的格式:
- # 大小为180 x 96
- # (0, 0) - (179, 31)为伤害值的数字表,其中每个数字宽18,高32
- # (0, 32) - (179, 63)为回复值(伤害负值)的数字表,其中每个数字宽18,高32
- # (0, 64) - (89, 95)为会心一击标记的图画,长宽为90 x 32
- # (90, 64) - (179, 95)为未命中标记的图画,长宽为90 x 32
- # 3.sp使用方式与其相同,不插入图片也可以使用。
- # ============================================================================
- class Game_Battler
- attr_accessor :sp_damage_pop # 显示SP标志
- alias new_initialize initialize
- def initialize
- @sp_damage_pop = false
- new_initialize
- end
- #--------------------------------------------------------------------------
- # ● 应用物品效果
- # item : 物品
- #--------------------------------------------------------------------------
- def item_effect(item)
- # 清除会心一击标志
- self.critical = false
- # 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
- # 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
- if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
- ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
- # 过程结束
- return false
- end
- # 清除有效标志
- effective = false
- # 公共事件 ID 是有效的情况下,设置为有效标志
- effective |= item.common_event_id > 0
- # 命中判定
- hit_result = (rand(100) < item.hit)
- # 不确定的特技的情况下设置为有效标志
- effective |= item.hit < 100
- # 命中的情况
- if hit_result == true
- # 计算回复量
- recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp
- recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp
- if recover_hp < 0
- recover_hp += self.pdef * item.pdef_f / 20
- recover_hp += self.mdef * item.mdef_f / 20
- recover_hp = [recover_hp, 0].min
- end
- # 属性修正
- recover_hp *= elements_correct(item.element_set)
- recover_hp /= 100
- recover_sp *= elements_correct(item.element_set)
- recover_sp /= 100
- # 分散
- if item.variance > 0 and recover_hp.abs > 0
- amp = [recover_hp.abs * item.variance / 100, 1].max
- recover_hp += rand(amp+1) + rand(amp+1) - amp
- end
- if item.variance > 0 and recover_sp.abs > 0
- amp = [recover_sp.abs * item.variance / 100, 1].max
- recover_sp += rand(amp+1) + rand(amp+1) - amp
- end
- # 回复量符号为负的情况下
- if recover_hp < 0
- # 防御修正
- if self.guarding?
- recover_hp /= 2
- end
- end
- # HP 回复量符号的反转、设置伤害值
- self.damage = -recover_hp
- # ========================================================
- # SP变动
- # =======================================================
- self.sp_damage = -recover_sp
- # ========================================================
- # SP变动
- # =======================================================
- # HP 以及 SP 的回复
- last_hp = self.hp
- last_sp = self.sp
- self.hp += recover_hp
- self.sp += recover_sp
- effective |= self.hp != last_hp
- effective |= self.sp != last_sp
- # 状态变化
- @state_changed = false
- effective |= states_plus(item.plus_state_set)
- effective |= states_minus(item.minus_state_set)
- # 能力上升值有效的情况下
- if item.parameter_type > 0 and item.parameter_points != 0
- # 能力值的分支
- case item.parameter_type
- when 1 # MaxHP
- @maxhp_plus += item.parameter_points
- when 2 # MaxSP
- @maxsp_plus += item.parameter_points
- when 3 # 力量
- @str_plus += item.parameter_points
- when 4 # 灵巧
- @dex_plus += item.parameter_points
- when 5 # 速度
- @agi_plus += item.parameter_points
- when 6 # 魔力
- @int_plus += item.parameter_points
- end
- # 设置有效标志
- effective = true
- end
- # HP 回复率与回复量为 0 的情况下
- if item.recover_hp_rate == 0 and item.recover_hp == 0
- # 设置伤害为空的字符串
- self.damage = ""
- # SP 回复率与回复量为 0、能力上升值无效的情况下
- if item.recover_sp_rate == 0 and item.recover_sp == 0 and
- (item.parameter_type == 0 or item.parameter_points == 0)
- # 状态没有变化的情况下
- unless @state_changed
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- end
- end
- # Miss 的情况下
- else
- # 伤害设置为 "Miss"
- self.damage = "Miss"
- end
- # 不在战斗中的情况下
- unless $game_temp.in_battle
- # 伤害设置为 nil
- self.damage = nil
- end
- # 过程结束
- return effective
- end
- end
- #==============================================================================
- # ■ Sprite_Battler
- #==============================================================================
- class Sprite_Battler < RPG::Sprite
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- super
- # 战斗者为 nil 的情况下
- if [url=home.php?mod=space&uid=133701]@battler[/url] == nil
- self.bitmap = nil
- loop_animation(nil)
- return
- end
- # 文件名和色相与当前情况有差异的情况下
- if @battler.battler_name != @battler_name or
- @battler.battler_hue != @battler_hue
- # 获取、设置位图
- @battler_name = @battler.battler_name
- @battler_hue = @battler.battler_hue
- self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
- @width = bitmap.width
- [url=home.php?mod=space&uid=291977]@height[/url] = 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
- animation = $data_animations[@battler.animation_id]
- animation(animation, @battler.animation_hit)
- @battler.animation_id = 0
- end
- # 伤害
- if @battler.damage_pop
- damage(@battler.damage, @battler.critical)
- @battler.damage = nil
- @battler.critical = false
- @battler.damage_pop = false
- end
- # ====================================================================
- # SP变动
- # ====================================================================
- if @battler.sp_damage_pop
- sp_damage(@battler.sp_damage)
- @battler.sp_damage = nil
- @battler.sp_damage_pop = false
- end
- # ====================================================================
- # SP变动
- # ====================================================================
- # 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
- # 设置活动块的坐标
- self.x = @battler.screen_x
- self.y = @battler.screen_y
- self.z = @battler.screen_z
- end
- end
- #==============================================================================
- # ■ Scene_Battle (分割定义 4)
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 刷新画面 (主回合步骤 5 : 显示伤害)
- #--------------------------------------------------------------------------
- def update_phase4_step5
- # 隐藏帮助窗口
- @help_window.visible = false
- # 刷新状态窗口
- @status_window.refresh
- # 显示伤害
- for target in @target_battlers
- if target.damage != nil
- target.damage_pop = true
- end
- end
- # =========================================================
- # SP变动
- # =========================================================
- for target in @target_battlers
- if target.sp_damage != nil
- target.sp_damage_pop = true
- end
- end
- # =========================================================
- # SP变动
- # =========================================================
- # 移至步骤 6
- @phase4_step = 6
- end
- end
- # =========================================================
- # 脚本核心
- # =========================================================
- module RPG
- class Sprite < ::Sprite
- def initialize(viewport = nil)
- super(viewport)
- @_whiten_duration = 0
- @_appear_duration = 0
- @_escape_duration = 0
- @_collapse_duration = 0
- @_damage_duration = 0
- @_sp_damage_duration = 0
- @_animation_duration = 0
- @_blink = false
- end
- def dispose
- dispose_damage
- dispose_sp_damage
- dispose_animation
- dispose_loop_animation
- super
- end
- #--------------------------------------------------------------------------
- # ● 伤害值描画
- #--------------------------------------------------------------------------
- def damage(value, critical)
- # 释放伤害
- dispose_damage
- # 如果伤害值是数值
- 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 = "Arial Black"
- bitmap.font.size = 28
- # 伤害值是数值的情况下
- 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("Damage"),
- 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
- end
- #--------------------------------------------------------------------------
- # ● SP变动
- #--------------------------------------------------------------------------
- def sp_damage(value)
- # 释放伤害
- dispose_sp_damage
- # 如果伤害值是数值
- if value.is_a?(Numeric)
- # 绝对值转为字符串
- sp_damage_string = value.abs.to_s
- else
- # 转为字符串
- sp_damage_string = value.to_s
- end
- # 初始化位图
- bitmap = Bitmap.new(162, 64)
- bitmap.font.name = "Arial Black"
- bitmap.font.size = 28
- # 伤害值是数值的情况下
- if value.is_a?(Numeric)
- # 分割伤害值字符串
- sp_damage_array = sp_damage_string.scan(/./)
- sp_damage_x = 81 - sp_damage_string.size * 9
- # 伤害值为负的情况下
- if value < 0
- # 调用回复数字表
- rect_y = 32
- else
- # 调用伤害数字表
- rect_y = 0
- end
- # 循环伤害值字符串
- for char in sp_damage_array
- number = char.to_i
- # 显示伤害数字
- bitmap.blt(sp_damage_x, 32, RPG::Cache.picture("Damagesp"),
- Rect.new(number * 18, rect_y, 18, 32))
- # 后移一位
- sp_damage_x += 18
- end
- # 伤害值不是数值的情况
- else
- # 系统默认描画字符串
- bitmap.font.color.set(0, 0, 0)
- bitmap.draw_text(-1, 27, 162, 36, sp_damage_string, 1)
- bitmap.draw_text(+1, 27, 162, 36, sp_damage_string, 1)
- bitmap.draw_text(-1, 29, 162, 36, sp_damage_string, 1)
- bitmap.draw_text(+1, 29, 162, 36, sp_damage_string, 1)
- bitmap.font.color.set(255, 255, 255)
- bitmap.draw_text(0, 28, 162, 36, sp_damage_string, 1)
- end
- # 伤害值定位
- @_sp_damage_sprite = ::Sprite.new(Viewport.new(0, 0, 640, 480))
- @_sp_damage_sprite.bitmap = bitmap
- @_sp_damage_sprite.ox = 81
- @_sp_damage_sprite.oy = 40
- @_sp_damage_sprite.x = self.x
- @_sp_damage_sprite.y = self.y - self.oy / 2
- @_sp_damage_sprite.z = 3000
- @_sp_damage_sprite.viewport.z = self.viewport.z + 1
- @_sp_damage_duration = 40
- end
- def dispose_sp_damage
- if @_sp_damage_sprite != nil
- @_sp_damage_sprite.viewport.dispose
- @_sp_damage_sprite.bitmap.dispose
- @_sp_damage_sprite.dispose
- @_sp_damage_sprite = nil
- @_sp_damage_duration = 0
- end
- end
- # ============================================================================
- #
- # ============================================================================
- def effect?
- @_whiten_duration > 0 or
- @_appear_duration > 0 or
- @_escape_duration > 0 or
- @_collapse_duration > 0 or
- @_damage_duration > 0 or
- @_sp_damage_duration > 0 or
- @_animation_duration > 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
- case @_damage_duration
- when 38..39
- @_damage_sprite.y -= 4
- when 36..37
- @_damage_sprite.y -= 2
- when 34..35
- @_damage_sprite.y += 2
- when 28..33
- @_damage_sprite.y += 4
- end
- @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
- if @_damage_duration == 0
- dispose_damage
- end
- end
- if @_sp_damage_duration > 0
- @_sp_damage_duration -= 1
- case @_sp_damage_duration
- # 这里把SP伤害数值的显示设成往上飘了
- # 如要往下飘,把@_sp_damage_sprite.y后的-换成+
- when 0..30
- @_sp_damage_sprite.y -= 1
- end
- @_sp_damage_sprite.opacity = 255 - (10 - @_sp_damage_duration) * 7
- if @_sp_damage_duration == 0
- dispose_sp_damage
- 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
- end
- end
- #==============================================================================
- # 本脚本来自www.66RPG.com,使用和转载请保留此信息
- #==============================================================================
复制代码 |
|