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

Project1

 找回密码
 注册会员
搜索
查看: 2335|回复: 6
打印 上一主题 下一主题

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

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1076
在线时间
172 小时
注册时间
2010-10-11
帖子
23
跳转到指定楼层
1
发表于 2019-5-3 17:38:22 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

DPS输出统计系统
http://rpg.blue/forum.php?mod=vi ... &fromuid=106151

这是我之前写的VX版的,这个系统主要就是用于统计单局队伍内各个成员的输出情况。
附上脚本。

RUBY 代码复制
  1. #==============================================================================
  2. # ■ DPS统计系统 by ZYYNOV
  3. # ■ Game_Battler
  4. #==============================================================================
  5. DPSswitch = true  #战斗结束后是否自动跳出DPS窗口
  6.                   #如果要手动呼出DPS窗口,请使用脚本SceneManager.call(Scene_DPS)
  7. class Game_Battler < Game_BattlerBase
  8.   attr_accessor :dps ##
  9.   #--------------------------------------------------------------------------
  10.   # ● 初始化对象
  11.   #--------------------------------------------------------------------------
  12.   alias zyynov_initialize initialize
  13.   def initialize
  14.     @dps = 0###
  15.     zyynov_initialize
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 处理伤害(在此处将伤害计入DPS)
  19.   #--------------------------------------------------------------------------
  20.   alias zyynov_execute_damage execute_damage
  21.   def execute_damage(user)
  22.     zyynov_execute_damage(user)
  23.     user.dps += @result.hp_damage###
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 战斗开始处理(战斗开始时清空上局DPS)
  27.   #--------------------------------------------------------------------------
  28.   alias zyynov_on_battle_start on_battle_start
  29.   def on_battle_start
  30.     zyynov_on_battle_start
  31.     for i in 0 .. 3##清空队伍成员的DPS
  32.       if $game_party.members[i] != nil
  33.       $game_party.members[i].dps = 0
  34.       end
  35.     end
  36.   end
  37.   ###
  38. end
  39.  
  40. #==============================================================================
  41. # ■ Window_DPS
  42. # 显示DPS的窗口
  43. #==============================================================================
  44. class Window_DPS < Window_Selectable
  45.   #--------------------------------------------------------------------------
  46.   # ● 初始化对象
  47.   #--------------------------------------------------------------------------
  48.   def initialize(actor)
  49.     super(0, 96, 544, 224)
  50.     @actor = actor
  51.     @adps = 1###
  52.     refresh
  53.     activate
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # ☆ 绘制角色战斗用肖像图
  57.   #     enabled : 有效的标志。false 的时候使用半透明效果绘制
  58.   #--------------------------------------------------------------------------
  59.   def draw_face(face_name, face_index, x, y, enabled = true)
  60.     bitmap = Cache.face(face_name)
  61.     rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96 + 32, 96, 22)
  62.     contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  63.     bitmap.dispose
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 刷新
  67.   #--------------------------------------------------------------------------
  68.   def refresh
  69.     ###
  70.     for i in 0 .. 3
  71.      if $game_party.members[i] != nil
  72.       @adps+=($game_party.members[i].dps).to_f
  73.      end
  74.     end
  75.     per1 = ($game_party.members[0].dps / @adps * 100).to_i
  76.     if $game_party.members[1] != nil
  77.     per2 = ($game_party.members[1].dps / @adps * 100).to_i
  78.     end
  79.     if $game_party.members[2] != nil
  80.     per3 = ($game_party.members[2].dps / @adps * 100).to_i
  81.     end
  82.     if $game_party.members[3] != nil
  83.     per4 = ($game_party.members[3].dps / @adps * 100).to_i
  84.     end
  85.     ###
  86.     contents.clear
  87.     change_color(system_color)
  88.     draw_text(x + 0, y - line_height * 4, 128, line_height, "名字")
  89.     draw_text(x + 128, y - line_height * 4, 128, line_height, "头像")
  90.     draw_text(x + 256, y - line_height * 4, 128, line_height, "输出")
  91.     draw_text(x + 384, y - line_height * 4, 128, line_height, "占比")
  92.     ###
  93.     change_color(normal_color)
  94.     if $game_party.members[0] != nil
  95.     draw_actor_face($game_party.members[0], x + 128 - 8, y - line_height * 2)
  96.     draw_text(x - 0, y - line_height * 2, 128, line_height, $game_party.members[0].name)
  97.     draw_text(x + 256, y - line_height * 2, 128, line_height, $game_party.members[0].dps)
  98.     draw_text(x + 384, y - line_height * 2, 128, line_height, per1.to_s + "%")
  99.     else
  100.     return
  101.     end
  102.     ###
  103.     if $game_party.members[1] != nil
  104.     draw_actor_face($game_party.members[1], x + 128 - 8, y - line_height * 1)
  105.     draw_text(x - 0, y - line_height * 1, 128, line_height, $game_party.members[1].name)
  106.     draw_text(x + 256, y - line_height * 1, 128, line_height, $game_party.members[1].dps)
  107.     draw_text(x + 384, y - line_height * 1, 128, line_height, per2.to_s + "%")
  108.     else
  109.     return
  110.     end
  111.     ###
  112.     if $game_party.members[2] != nil
  113.     draw_actor_face($game_party.members[2], x + 128 - 8, y - line_height * 0)
  114.     draw_text(x - 0, y - line_height * 0, 128, line_height, $game_party.members[2].name)
  115.     draw_text(x + 256, y - line_height * 0, 128, line_height, $game_party.members[2].dps)
  116.     draw_text(x + 384, y - line_height * 0, 128, line_height, per3.to_s + "%")
  117.     else
  118.     return
  119.     end
  120.     ###
  121.     if $game_party.members[3] != nil
  122.     draw_actor_face($game_party.members[3], x + 128 - 8, y + line_height * 1)
  123.     draw_text(x - 0, y + line_height * 1, 128, line_height, $game_party.members[3].name)
  124.     draw_text(x + 256, y + line_height * 1, 128, line_height, $game_party.members[3].dps)
  125.     draw_text(x + 384, y + line_height * 1, 128, line_height, per4.to_s + "%")
  126.     else
  127.     return
  128.     end
  129.     ###
  130.   end
  131. end
  132.  
  133. #==============================================================================
  134. # ■ Scene_DPS
  135. # 处理DPS画面
  136. #==============================================================================
  137.  
  138. class Scene_DPS < Scene_MenuBase
  139.   #--------------------------------------------------------------------------
  140.   # ● 开始处理
  141.   #--------------------------------------------------------------------------
  142.   def start
  143.     super
  144.     @dps_window = Window_DPS.new(@actor)
  145.     @dps_window.set_handler(:cancel,   method(:return_scene))
  146.   end
  147. end
  148.  
  149. #==============================================================================
  150. # ■ Scene_Battle
  151. #  战斗画面
  152. #==============================================================================
  153. class Scene_Battle < Scene_Base
  154.   #--------------------------------------------------------------------------
  155.   # ● 结束处理
  156.   #--------------------------------------------------------------------------
  157.   alias zyynov_terminate terminate
  158.   def terminate
  159.     zyynov_terminate
  160.     if DPSswitch == true
  161.      SceneManager.call(Scene_DPS)
  162.     end
  163.   end
  164. end

1.PNG (257.98 KB, 下载次数: 19)

1.PNG

点评

道理我都懂,但占比合起来不是100%啊_(:3」∠)_  发表于 2019-5-3 20:45

评分

参与人数 1+1 收起 理由
897656o + 1 塞糖

查看全部评分

Lv5.捕梦者

梦石
10
星屑
39440
在线时间
1914 小时
注册时间
2010-11-14
帖子
3315

R考场第七期纪念奖

2
发表于 2019-5-3 20:41:30 | 只看该作者
……看到了一大堆的"for i in 0..3"和"$game_party.members[i]",还有一些重复率高达99%的语句。
这样对成员上限为4人的是没问题,但是成员上限多或少于4人的就有可能无法正常工作。

最好可以用块,直接迭代$game_party.battle_members
用头画头像,用脚写脚本
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1076
在线时间
172 小时
注册时间
2010-10-11
帖子
23
3
 楼主| 发表于 2019-5-3 21:39:18 | 只看该作者
emmm关于占比不是100这个问题,主要是因为写法是通过先用浮点数计算,然后再转换成整数输出,但是浮点数变成整数的过程是把小数点后面的数字一刀切,不会四舍五入,所以会出现一定的误差......

点评

最简单粗暴的方法就是最后一人的百分比用100减去前面人的和来得出  发表于 2019-5-3 23:41
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1076
在线时间
172 小时
注册时间
2010-10-11
帖子
23
4
 楼主| 发表于 2019-5-3 21:47:31 | 只看该作者
本帖最后由 719783572 于 2019-5-3 21:59 编辑
KB.Driver 发表于 2019-5-3 20:41
……看到了一大堆的"for i in 0..3"和"$game_party.members",还有一些重复率高达99%的语句。
这样对成员上 ...


确实没考虑五人以上战斗,毕竟不是脚本专业户,写的时候大概就是能更简单一些就按照简单的思路来实现。。。哈哈哈哈。其实还有很多功能没实现,比如辅助职业 团队增益这些都没考虑,还有抗伤控制等等。
其实最终版是打算做一个战斗评分系统的,包括控制抗伤回血团队buff等等。现在这个输出统计其实就是模仿一下DNF的DPS统计这些哈哈哈

然后队伍少于四人其实没有问题,因为各种计算都做了分歧,包括窗口的描绘,只有队伍成员不为nil才会继续运算,所以这个是不会报错的。至于五人以上的战斗系统,如果成员依旧放在$game_party中(不是一些很奇怪的宠物系统等等),我想只要
把Window_DPS扩写一下就行,再把0..3改0..X都行,方法比较笨,就是队伍有几个成员就用for in全部加起来,下次改写肯定要重写算法的

点评

可以看一下VA里each的写法,直接用$game_party.battle_members.each xxx 就能完成你写4遍的效果  发表于 2019-5-3 23:53
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 19:22

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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