じ☆ve冰风 发表于 2024-4-18 15:49:12

DPS输出统计系统

其实严格意义来说DPS这个概念用在这儿是错误的,因为RM原生的回合制战斗模式不存在DPS的概念。
但总而言之......这就是个统计单局队伍内各个成员输出情况的脚本。
至于这个系统到底有什么用,其实就是模仿一下WeGame上的DNF DPS统计,或者像王者LOL对局完后的单局数据统计这些。
主要还是提供个思路。附上简陋的范例

PS:最终版已经更新完毕,详情参考脚本说明,自行设置~最后附上脚本,即插即用

RUBY 代码
#==============================================================================
# ■DPS统计系统 by ZYYNOV
#------------------------------------------------------------------------------
# 此系统用于统计战斗时的输出数据,在战斗结束后显示各个队员造成的伤害及占比
# 新的战斗开始时会清空上一局的DPS统计,并重新统计。
#==============================================================================
$DPSswitch = true#控制战后是否显示DPS
                  #手动呼出使用代码$scene = Scene_DPS.new
class Game_Battler
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :dps   ####
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
alias zyynov_initialize initialize
def initialize
    @dps = 0##############
    zyynov_initialize
end
#--------------------------------------------------------------------------
# ● 伤害效果
#--------------------------------------------------------------------------
alias zyynov_execute_damage execute_damage
def execute_damage(user)
    if@hp_damage > 0         # 若伤害为正数
      user.dps += @hp_damage#######
      remove_states_shock       # 攻击移除状态
    end
    zyynov_execute_damage(user)
end
###
end

#==============================================================================
# ■ RPG::Actor除错用
#==============================================================================
#=begin
module RPG
class Actor
    def initialize
      @damage = 0##除错用
    end
    attr_accessor :damage
end
end
#=end
#==============================================================================
# ■ RPG::Enemy除错用
#==============================================================================
#=begin
module RPG
class Enemy
    def initialize
      @damage = 0##除错用
    end
    attr_accessor :damage
end
end
#=end

#==============================================================================
# ■ Window_DPS
#------------------------------------------------------------------------------
#  DPS显示的窗口。by ZYYNOV
#==============================================================================
class Window_DPS < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#   actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
    super(0, 96, 544, 160)
    @actor = actor
    @adps = 1
    refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
    for i in0 .. 3###计算队伍角色加起来的总输出,用来计算单个角色的输出占比
      if$game_party.members != nil
      @adps += ($game_party.members.dps).to_f
      end
    end
    ###
    #--------------------------------------------------------------------------
    # ● 绘制战斗状态头像
    #   face_name: 头像文件名
    #   face_index : 头像号码
    #   x   : 描画目标 X 坐标
    #   y   : 描画目标 Y 坐标
    #   size       : 显示大小
    #--------------------------------------------------------------------------
    def draw_status_face(face_name, face_index, x, y, size = 96)
    bitmap = Cache.face(face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96 + 32, 96, 22)
    self.contents.blt(x, y, bitmap, rect)
    bitmap.dispose
    end
    #--------------------------------------------------------------------------
    # ● 绘制战斗状态头像
    #   actor : 角色
    #   x   : 描画目标 X 坐标
    #   y   : 描画目标 Y 坐标
    #   size: 绘制大小
    #--------------------------------------------------------------------------
    def draw_statu_face(actor, x, y)
    draw_status_face(actor.face_name, actor.face_index, x, y)
    end
    ###
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(x - 32 , y-96, 96, 24, "名字", 2)
    self.contents.draw_text(x + 96 , y-96, 96, 24, "头像", 2)
    self.contents.draw_text(x + 224 , y-96, 96, 24, "输出", 2)
    self.contents.draw_text(x + 352 , y-96, 96, 24, "占比", 2)
    ###
    self.contents.font.color = normal_color
    if$game_party.members != nil
    draw_statu_face($game_party.members, x + 128, y-WLH*3)
    self.contents.draw_text(x + 0, y-WLH*3, 64, 24, $game_party.members.name.to_s, 2)
    self.contents.draw_text(x + 224, y-WLH*3, 96, 24, $game_party.members.dps.to_s, 2)
    self.contents.draw_text(x + 352, y-WLH*3, 96, 24, (($game_party.members.dps.to_i/@adps*100).to_i).to_s + "%", 2)
    else
    return
    end
    ###
    if$game_party.members != nil
    draw_statu_face($game_party.members, x + 128, y-WLH*2)
    self.contents.draw_text(x + 0, y-WLH*2, 64, 24, $game_party.members.name.to_s, 2)
    self.contents.draw_text(x + 224, y-WLH*2, 96, 24, $game_party.members.dps.to_s, 2)
    self.contents.draw_text(x + 352, y-WLH*2, 96, 24, (($game_party.members.dps.to_i/@adps*100).to_i).to_s + "%", 2)
    else
    return
    end
    ###
    if$game_party.members != nil
    draw_statu_face($game_party.members, x + 128, y-WLH)
    self.contents.draw_text(x + 0, y-WLH, 64, 24, $game_party.members.name.to_s, 2)
    self.contents.draw_text(x + 224, y-WLH, 96, 24, $game_party.members.dps.to_s, 2)
    self.contents.draw_text(x + 352, y-WLH, 96, 24, (($game_party.members.dps.to_i/@adps*100).to_i).to_s + "%", 2)
    else
    return
    end
    ###
    if$game_party.members != nil
    draw_statu_face($game_party.members, x + 128, y)
    self.contents.draw_text(x + 0, y, 64, 24, $game_party.members.name.to_s, 2)
    self.contents.draw_text(x + 224, y, 96, 24, $game_party.members.dps.to_s, 2)
    self.contents.draw_text(x + 352, y, 96, 24, (($game_party.members.dps.to_i/@adps*100).to_i).to_s + "%", 2)
    else
    return
    end
end
end

#==============================================================================
# ■ Scene_Status
#------------------------------------------------------------------------------
#  处理DPS窗口的类。by ZYYNOV
#==============================================================================

class Scene_DPS < Scene_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#   actor_index : 角色位置
#--------------------------------------------------------------------------
def initialize(actor_index = 0)
    @actor_index = actor_index
end
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
    super
    create_menu_background
    @actor = $game_party.members[@actor_index]
    @dps_window = Window_DPS.new(@actor)
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
    super
    dispose_menu_background
    @dps_window.dispose
end
#--------------------------------------------------------------------------
# ● 回到原画面
#--------------------------------------------------------------------------
def return_scene
    $scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
    update_menu_background
    @dps_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    end
    super
end
end

#==============================================================================
# ■ 战斗结束时显示DPS窗口
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
alias zyy_nov_start start
def start
    zyy_nov_start
    for i in0 .. 3##清空队伍成员的DPS
      if$game_party.members != nil
      $game_party.members.dps = 0
      end
    end
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
alias zyynov_terminate terminate
def terminate
    zyynov_terminate
    if$DPSswitch == true
    $scene = Scene_DPS.new
    end
end
end


            本帖来自P1论坛作者719783572,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=477010若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
页: [1]
查看完整版本: DPS输出统计系统