设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2227|回复: 1

[原创发布] DPS输出统计系统

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1066
在线时间
172 小时
注册时间
2010-10-11
帖子
23
发表于 2019-4-29 01:53:29 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 719783572 于 2019-5-3 19:58 编辑

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

DPS统计范例.zip

254.07 KB, 下载次数: 145

最终版

Lv3.寻梦者

梦石
0
星屑
1066
在线时间
172 小时
注册时间
2010-10-11
帖子
23
 楼主| 发表于 2019-4-30 02:02:21 | 显示全部楼层
本帖最后由 719783572 于 2019-5-1 03:57 编辑

最终版范例和脚本已经放在一楼了
使用方法参考脚本说明。(暂时算是修复了所有bug,也脱离了冗杂的公共事件设置)

之前半夜里突发奇想,花了半个小时写完的东西,所以非常不完善,还是半成品就发上来了,见(习)谅(惯)见(就)谅(好)......
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-28 23:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表