搜索附件  

DPS统计范例.zip

 

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

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

RUBY 代码
  1. #==============================================================================
  2. # ■DPS统计系统 by ZYYNOV
  3. #------------------------------------------------------------------------------
  4. # 此系统用于统计战斗时的输出数据,在战斗结束后显示各个队员造成的伤害及占比
  5. # 新的战斗开始时会清空上一局的DPS统计,并重新统计。
  6. #==============================================================================
  7. $DPSswitch = true#控制战后是否显示DPS
  8.                   #手动呼出使用代码$scene = Scene_DPS.new
  9. class Game_Battler
  10.   #--------------------------------------------------------------------------
  11.   # ● 定义实例变量
  12.   #--------------------------------------------------------------------------
  13.   attr_accessor :dps     ####
  14.   #--------------------------------------------------------------------------
  15.   # ● 初始化对像
  16.   #--------------------------------------------------------------------------
  17.   alias zyynov_initialize initialize
  18.   def initialize
  19.     @dps = 0##############
  20.     zyynov_initialize
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 伤害效果
  24.   #--------------------------------------------------------------------------
  25.   alias zyynov_execute_damage execute_damage
  26.   def execute_damage(user)
  27.     if@hp_damage > 0           # 若伤害为正数
  28.       user.dps += @hp_damage#######
  29.       remove_states_shock       # 攻击移除状态
  30.     end
  31.     zyynov_execute_damage(user)
  32.   end
  33.   ###
  34. end
  35. #==============================================================================
  36. # ■ RPG::Actor除错用
  37. #==============================================================================
  38. #=begin
  39. module RPG
  40.   class Actor
  41.     def initialize
  42.       @damage = 0  ##除错用
  43.     end
  44.     attr_accessor :damage
  45.   end
  46. end
  47. #=end
  48. #==============================================================================
  49. # ■ RPG::Enemy除错用
  50. #==============================================================================
  51. #=begin
  52. module RPG
  53.   class Enemy
  54.     def initialize
  55.       @damage = 0  ##除错用
  56.     end
  57.     attr_accessor :damage
  58.   end
  59. end
  60. #=end
  61. #==============================================================================
  62. # ■ Window_DPS
  63. #------------------------------------------------------------------------------
  64. #  DPS显示的窗口。  by ZYYNOV
  65. #==============================================================================
  66. class Window_DPS < Window_Base
  67.   #--------------------------------------------------------------------------
  68.   # ● 初始化对像
  69.   #     actor : 角色
  70.   #--------------------------------------------------------------------------
  71.   def initialize(actor)
  72.     super(0, 96, 544, 160)
  73.     @actor = actor
  74.     @adps = 1
  75.     refresh
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 刷新
  79.   #--------------------------------------------------------------------------
  80.   def refresh
  81.     for i in0 .. 3###计算队伍角色加起来的总输出,用来计算单个角色的输出占比
  82.       if$game_party.members[i] != nil
  83.       @adps += ($game_party.members[i].dps).to_f
  84.       end
  85.     end
  86.     ###
  87.     #--------------------------------------------------------------------------
  88.     # ● 绘制战斗状态头像
  89.     #     face_name  : 头像文件名
  90.     #     face_index : 头像号码
  91.     #     x     : 描画目标 X 坐标
  92.     #     y     : 描画目标 Y 坐标
  93.     #     size       : 显示大小
  94.     #--------------------------------------------------------------------------
  95.     def draw_status_face(face_name, face_index, x, y, size = 96)
  96.     bitmap = Cache.face(face_name)
  97.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96 + 32, 96, 22)
  98.     self.contents.blt(x, y, bitmap, rect)
  99.     bitmap.dispose
  100.     end
  101.     #--------------------------------------------------------------------------
  102.     # ● 绘制战斗状态头像
  103.     #     actor : 角色
  104.     #     x     : 描画目标 X 坐标
  105.     #     y     : 描画目标 Y 坐标
  106.     #     size  : 绘制大小
  107.     #--------------------------------------------------------------------------
  108.     def draw_statu_face(actor, x, y)
  109.     draw_status_face(actor.face_name, actor.face_index, x, y)
  110.     end
  111.     ###
  112.     self.contents.clear
  113.     self.contents.font.color = system_color
  114.     self.contents.draw_text(x - 32 , y-96, 96, 24, "名字", 2)
  115.     self.contents.draw_text(x + 96 , y-96, 96, 24, "头像", 2)
  116.     self.contents.draw_text(x + 224 , y-96, 96, 24, "输出", 2)
  117.     self.contents.draw_text(x + 352 , y-96, 96, 24, "占比", 2)
  118.     ###
  119.     self.contents.font.color = normal_color
  120.     if$game_party.members[0] != nil
  121.     draw_statu_face($game_party.members[0], x + 128, y-WLH*3)
  122.     self.contents.draw_text(x + 0, y-WLH*3, 64, 24, $game_party.members[0].name.to_s, 2)
  123.     self.contents.draw_text(x + 224, y-WLH*3, 96, 24, $game_party.members[0].dps.to_s, 2)
  124.     self.contents.draw_text(x + 352, y-WLH*3, 96, 24, (($game_party.members[0].dps.to_i/@adps*100).to_i).to_s + "%", 2)
  125.     else
  126.     return
  127.     end
  128.     ###
  129.     if$game_party.members[1] != nil
  130.     draw_statu_face($game_party.members[1], x + 128, y-WLH*2)
  131.     self.contents.draw_text(x + 0, y-WLH*2, 64, 24, $game_party.members[1].name.to_s, 2)
  132.     self.contents.draw_text(x + 224, y-WLH*2, 96, 24, $game_party.members[1].dps.to_s, 2)
  133.     self.contents.draw_text(x + 352, y-WLH*2, 96, 24, (($game_party.members[1].dps.to_i/@adps*100).to_i).to_s + "%", 2)
  134.     else
  135.     return
  136.     end
  137.     ###
  138.     if$game_party.members[2] != nil
  139.     draw_statu_face($game_party.members[2], x + 128, y-WLH)
  140.     self.contents.draw_text(x + 0, y-WLH, 64, 24, $game_party.members[2].name.to_s, 2)
  141.     self.contents.draw_text(x + 224, y-WLH, 96, 24, $game_party.members[2].dps.to_s, 2)
  142.     self.contents.draw_text(x + 352, y-WLH, 96, 24, (($game_party.members[2].dps.to_i/@adps*100).to_i).to_s + "%", 2)
  143.     else
  144.     return
  145.     end
  146.     ###
  147.     if$game_party.members[3] != nil
  148.     draw_statu_face($game_party.members[3], x + 128, y)
  149.     self.contents.draw_text(x + 0, y, 64, 24, $game_party.members[3].name.to_s, 2)
  150.     self.contents.draw_text(x + 224, y, 96, 24, $game_party.members[3].dps.to_s, 2)
  151.     self.contents.draw_text(x + 352, y, 96, 24, (($game_party.members[3].dps.to_i/@adps*100).to_i).to_s + "%", 2)
  152.     else
  153.     return
  154.     end
  155.   end
  156. end
  157. #==============================================================================
  158. # ■ Scene_Status
  159. #------------------------------------------------------------------------------
  160. #  处理DPS窗口的类。by ZYYNOV
  161. #==============================================================================
  162. class Scene_DPS < Scene_Base
  163.   #--------------------------------------------------------------------------
  164.   # ● 初始化对像
  165.   #     actor_index : 角色位置
  166.   #--------------------------------------------------------------------------
  167.   def initialize(actor_index = 0)
  168.     @actor_index = actor_index
  169.   end
  170.   #--------------------------------------------------------------------------
  171.   # ● 开始处理
  172.   #--------------------------------------------------------------------------
  173.   def start
  174.     super
  175.     create_menu_background
  176.     @actor = $game_party.members[@actor_index]
  177.     @dps_window = Window_DPS.new(@actor)
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 结束处理
  181.   #--------------------------------------------------------------------------
  182.   def terminate
  183.     super
  184.     dispose_menu_background
  185.     @dps_window.dispose
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # ● 回到原画面
  189.   #--------------------------------------------------------------------------
  190.   def return_scene
  191.     $scene = Scene_Map.new
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 更新画面
  195.   #--------------------------------------------------------------------------
  196.   def update
  197.     update_menu_background
  198.     @dps_window.update
  199.     if Input.trigger?(Input::B)
  200.       Sound.play_cancel
  201.       return_scene
  202.     end
  203.     super
  204.   end
  205. end
  206. #==============================================================================
  207. # ■ 战斗结束时显示DPS窗口
  208. #==============================================================================
  209. class Scene_Battle < Scene_Base
  210.   #--------------------------------------------------------------------------
  211.   # ● 开始处理
  212.   #--------------------------------------------------------------------------
  213.   alias zyy_nov_start start
  214.   def start
  215.     zyy_nov_start
  216.     for i in0 .. 3##清空队伍成员的DPS
  217.       if$game_party.members[i] != nil
  218.       $game_party.members[i].dps = 0
  219.       end
  220.     end
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ● 结束处理
  224.   #--------------------------------------------------------------------------
  225.   alias zyynov_terminate terminate
  226.   def terminate
  227.     zyynov_terminate
  228.     if$DPSswitch == true
  229.     $scene = Scene_DPS.new
  230.     end
  231.   end
  232. end
复制代码


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

QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

GMT+8, 2024-5-20 17:19 , Processed in 0.025836 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部