查看: 3022|回复: 2

[已经过期] 求教模仿HP伤害值美化脚本实现SP伤害美化

[复制链接]
梦石
0
星屑
80
在线时间
196 小时
注册时间
2013-8-7
回帖
13
发表于 2016-8-20 03:55:48 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
如题,范例里的脚本只能美化HP伤害值,众所周知XP里的SP伤害变化是不直接显示的,例如我想让角色吃魔法剂恢复500SP,让500以蓝色的数字显示出来,而如果发生SP减少的情况也要以别的颜色显示出来

Project1.rar

206 KB, 下载次数: 43

梦石
0
星屑
125
在线时间
171 小时
注册时间
2014-4-14
回帖
135
发表于 2016-8-20 14:18:27 | 显示全部楼层
本帖最后由 2357691704 于 2016-8-20 14:20 编辑

美化不会弄。
sp伤害显示[pre lang="ruby"]#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
#==========================================================================
#==============================================================================
# SP伤害显示 v1.0
#==============================================================================
# By 叶子  Date: 12-25-2005
# “23种战斗特效的公共事件版”作者:SailCat
# 本脚本同时整合了 SailCat 的“23种战斗特效的公共事件版”脚本
# 请访问shownews.asp?id=19 学习“23种战斗特效的公共事件版”的使用
# 感谢 SailCat,为战斗特效创造了无数可能
#==============================================================================
# SP伤害颜色设定:
#搜索 bitmap.font.color.set
# 显示使用者SP变化的特技:
# 在SHOW_SP_DAMAGE_SKILLS后面的中括号中填上需要显示使用者SP变化的特技ID,
# 中间以逗号“ , ”隔开
# 例如要5号,8号,16号特技显示使用者SP变化:
# SHOW_SP_DAMAGE_SKILLS = [5,8,16]
class Scene_Battle
SHOW_SP_DAMAGE_SKILLS = [1,2,3,4,5,6,7,8,9,10,57,58,59,60]
end
class Game_Battler
  attr_accessor :sp_damage_pop
  attr_accessor :sp_damage
  end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  战斗显示用活动块。Game_Battler 类的实例监视、
# 活动块的状态的监视。
#==============================================================================
class Sprite_Battler < RPG::Sprite
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
   super
   # 战斗者为 nil 的情况下
   if @battler == nil
     self.bitmap = nil
     loop_animation(nil)
     return
   end
   # 文件名和色相与当前情况有差异的情况下
   if @battler.battler_name != @battler_name or
      @battler.battler_hue != @battler_hue
     # 获取、设置位图
     @battler_name = @battler.battler_name
     @battler_hue = @battler.battler_hue
     self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
     @width = bitmap.width
     @height = bitmap.height
     self.ox = @width / 2
     self.oy = @height
     # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
     if @battler.dead? or @battler.hidden
       self.opacity = 0
     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
     #---------------------------------
     # 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

#==============================================================================
#--
# RPG::Sprite
# 追加了 RPGXP 使用的各种效果处理的精灵的类。
#--
#==============================================================================
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 sp_damage(value)
     dispose_sp_damage
     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 = "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(170, 11, 127) # 粉紫
     else
       bitmap.font.color.set(0, 0, 205) # 适中的蓝色
     end
     bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
     @_sp_damage_sprite = ::Sprite.new(self.viewport)
     @_sp_damage_sprite.bitmap = bitmap
     @_sp_damage_sprite.ox = 80
     @_sp_damage_sprite.oy = 100
     @_sp_damage_sprite.x = self.x
     @_sp_damage_sprite.y = self.y - self.oy / 2
     @_sp_damage_sprite.z = 3000
     @_sp_damage_duration = 40
   end
   def dispose_sp_damage
     if @_sp_damage_sprite != nil
       @_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..39
         @_sp_damage_sprite.y -= 1
       end
       @_sp_damage_sprite.opacity = 256 - (40 - @_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
#==============================================================================
#23种战斗特效的公共事件版(整合SP伤害显示)
#原作者:SailCat
#整合:叶子
#Date: 12-25-2005
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader   :last_hp                  # 受效前的HP
attr_accessor :sp_damage                   # SP伤害值
attr_accessor :last_sp                            # 受效前的SP
attr_accessor :sp_damage_pop               # 显示SP伤害标志
end
class Scene_Battle
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :target_battlers
attr_accessor :active_battler
attr_reader :skill
#--------------------------------------------------------------------------
# ● 开始主回合
#--------------------------------------------------------------------------
def start_phase4
   #---------------------------------
   # 记录上回合SP
   for actor in $game_party.actors
     actor.last_sp = actor.sp
   end
   for enemy in $game_troop.enemies
     enemy.last_sp = enemy.sp
   end
   #---------------------------------
   # 转移到回合 4
   @phase = 4
   # 回合数计数
   $game_temp.battle_turn += 1
   # 搜索全页的战斗事件
   for index in 0...$data_troops[@troop_id].pages.size
     # 获取事件页
     page = $data_troops[@troop_id].pages[index]
     # 本页的范围是 [回合] 的情况下
     if page.span == 1
       # 设置已经执行标志
       $game_temp.battle_event_flags[index] = false
     end
   end
   # 设置角色为非选择状态
   @actor_index = -1
   @active_battler = nil
   # 有效化同伴指令窗口
   @party_command_window.active = false
   @party_command_window.visible = false
   # 无效化角色指令窗口
   @actor_command_window.active = false
   @actor_command_window.visible = false
   # 设置主回合标志
   $game_temp.battle_main_phase = true
   # 生成敌人行动
   for enemy in $game_troop.enemies
     enemy.make_action
   end
   # 生成行动顺序
   make_action_orders
   # 移动到步骤 1
   @phase4_step = 1
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
   # 执行战斗事件中的情况下
   if $game_system.battle_interpreter.running?
     # 刷新解释器
     $game_system.battle_interpreter.update
     # 强制行动的战斗者不存在的情况下
     if $game_temp.forcing_battler == nil
       # 执行战斗事件结束的情况下
       unless $game_system.battle_interpreter.running?
         # 继续战斗的情况下、再执行战斗事件的设置
         unless @common_event_id != 0
           unless judge
             setup_battle_event
           end
         end
       end
       # 如果不是结束战斗回合的情况下
       if @phase != 5 and @common_event_id == 0
         # 刷新状态窗口
         @status_window.refresh
       end
     end
   end
   # 系统 (计时器)、刷新画面
   $game_system.update
   $game_screen.update
   # 计时器为 0 的情况下
   if $game_system.timer_working and $game_system.timer == 0
     # 中断战斗
     $game_temp.battle_abort = true
   end
   # 刷新窗口
   @help_window.update
   @party_command_window.update
   @actor_command_window.update
   @status_window.update
   @message_window.update
   # 刷新活动块
   @spriteset.update
   # 处理过渡中的情况下
   if $game_temp.transition_processing
     # 清除处理过渡中标志
     $game_temp.transition_processing = false
     # 执行过渡
     if $game_temp.transition_name == ""
       Graphics.transition(20)
     else
       Graphics.transition(40, "Graphics/Transitions/" +
         $game_temp.transition_name)
     end
   end
   # 显示信息窗口中的情况下
   if $game_temp.message_window_showing
     return
   end
   # 显示效果中的情况下
   if @spriteset.effect?
     return
   end
   # 游戏结束的情况下
   if $game_temp.gameover
     # 切换到游戏结束画面
     $scene = Scene_Gameover.new
     return
   end
   # 返回标题画面的情况下
   if $game_temp.to_title
     # 切换到标题画面
     $scene = Scene_Title.new
     return
   end
   # 中断战斗的情况下
   if $game_temp.battle_abort
     # 还原为战斗前的 BGM
     $game_system.bgm_play($game_temp.map_bgm)
     # 战斗结束
     battle_end(1)
     return
   end
   # 等待中的情况下
   if @wait_count > 0
     # 减少等待计数
     @wait_count -= 1
     return
   end
   # 强制行动的角色存在、
   # 并且战斗事件正在执行的情况下
   if $game_temp.forcing_battler == nil and
      $game_system.battle_interpreter.running?
     return
   end
   # 回合分支
   case @phase
   when 1  # 自由战斗回合
     update_phase1
   when 2  # 同伴命令回合
     update_phase2
   when 3  # 角色命令回合
     update_phase3
   when 4  # 主回合
     update_phase4
   when 5  # 战斗结束回合
     update_phase5
   end
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 3 : 行动方动画)
#--------------------------------------------------------------------------
def update_phase4_step3
   # 行动方动画 (ID 为 0 的情况下是白色闪烁)
   if @animation1_id == 0
     @active_battler.white_flash = true
   else
     @active_battler.animation_id = @animation1_id
     @active_battler.animation_hit = true
   end
   # 公共事件 ID 有效的情况下
   if @common_event_id > 0
     # 设置事件
     common_event = $data_common_events[@common_event_id]
     $game_system.battle_interpreter.setup(common_event.list, 0)
   end
   # 移至步骤 4
   @phase4_step = 4
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 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
     #---------------------------------
     # 显示SP伤害
     if target.last_sp != nil and target.exist?
       target.sp_damage = target.sp - target.last_sp
       unless target.sp_damage == 0
         target.sp_damage_pop = true
       end
     end
     #---------------------------------
   end
   if @active_battler.damage != nil
     @active_battler.damage_pop = true
   end
   #---------------------------------
   # 特定技能显示SP伤害
   if SHOW_SP_DAMAGE_SKILLS.include?(@active_battler.current_action.skill_id)
     @active_battler.sp_damage = @active_battler.sp - @active_battler.last_sp
     @active_battler.sp_damage_pop = true
   end
   #---------------------------------
   # 移至步骤 6
   @phase4_step = 6
end
#--------------------------------------------------------------------------
# ● 刷新画面 (主回合步骤 6 : 刷新)
#--------------------------------------------------------------------------
def update_phase4_step6
   # 清除强制行动对像的战斗者
   $game_temp.forcing_battler = nil
   # 移至步骤 1
   @phase4_step = 1
end
end
#==========================================================================
# 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
#========================================================================== [/pre]

顺便把你的脚本贴出来,让大神修改。[pre lang="ruby"]#==============================================================================
# 本脚本来自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

# ============================================================================

module RPG

  class Sprite < ::Sprite

    #--------------------------------------------------------------------------

    # ● 伤害值描画

    #--------------------------------------------------------------------------

    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 = 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("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

  end

end
#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
[/pre]

点评

厉害,不过恢复SP还是不显示的,另外40和53行脚本多了一些代码,需要删除~  发表于 2016-8-20 18:49
Vanyogin
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部