#============================================================================== # ■ DPS统计系统 by ZYYNOV # ■ Game_Battler #============================================================================== DPSswitch = true #战斗结束后是否自动跳出DPS窗口 #如果要手动呼出DPS窗口,请使用脚本SceneManager.call(Scene_DPS) class Game_Battler < Game_BattlerBase attr_accessor :dps ## #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- alias zyynov_initialize initialize def initialize @dps = 0### zyynov_initialize end #-------------------------------------------------------------------------- # ● 处理伤害(在此处将伤害计入DPS) #-------------------------------------------------------------------------- alias zyynov_execute_damage execute_damage def execute_damage(user) zyynov_execute_damage(user) user.dps += @result.hp_damage### end #-------------------------------------------------------------------------- # ● 战斗开始处理(战斗开始时清空上局DPS) #-------------------------------------------------------------------------- alias zyynov_on_battle_start on_battle_start def on_battle_start zyynov_on_battle_start for i in 0 .. 3##清空队伍成员的DPS if $game_party.members[i] != nil $game_party.members[i].dps = 0 end end end ### end #============================================================================== # ■ Window_DPS # 显示DPS的窗口 #============================================================================== class Window_DPS < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize(actor) super(0, 96, 544, 224) @actor = actor @adps = 1### refresh activate end #-------------------------------------------------------------------------- # ☆ 绘制角色战斗用肖像图 # enabled : 有效的标志。false 的时候使用半透明效果绘制 #-------------------------------------------------------------------------- def draw_face(face_name, face_index, x, y, enabled = true) bitmap = Cache.face(face_name) rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96 + 32, 96, 22) contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha) bitmap.dispose end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh ### for i in 0 .. 3 if $game_party.members[i] != nil @adps+=($game_party.members[i].dps).to_f end end per1 = ($game_party.members[0].dps / @adps * 100).to_i if $game_party.members[1] != nil per2 = ($game_party.members[1].dps / @adps * 100).to_i end if $game_party.members[2] != nil per3 = ($game_party.members[2].dps / @adps * 100).to_i end if $game_party.members[3] != nil per4 = ($game_party.members[3].dps / @adps * 100).to_i end ### contents.clear change_color(system_color) draw_text(x + 0, y - line_height * 4, 128, line_height, "名字") draw_text(x + 128, y - line_height * 4, 128, line_height, "头像") draw_text(x + 256, y - line_height * 4, 128, line_height, "输出") draw_text(x + 384, y - line_height * 4, 128, line_height, "占比") ### change_color(normal_color) if $game_party.members[0] != nil draw_actor_face($game_party.members[0], x + 128 - 8, y - line_height * 2) draw_text(x - 0, y - line_height * 2, 128, line_height, $game_party.members[0].name) draw_text(x + 256, y - line_height * 2, 128, line_height, $game_party.members[0].dps) draw_text(x + 384, y - line_height * 2, 128, line_height, per1.to_s + "%") else return end ### if $game_party.members[1] != nil draw_actor_face($game_party.members[1], x + 128 - 8, y - line_height * 1) draw_text(x - 0, y - line_height * 1, 128, line_height, $game_party.members[1].name) draw_text(x + 256, y - line_height * 1, 128, line_height, $game_party.members[1].dps) draw_text(x + 384, y - line_height * 1, 128, line_height, per2.to_s + "%") else return end ### if $game_party.members[2] != nil draw_actor_face($game_party.members[2], x + 128 - 8, y - line_height * 0) draw_text(x - 0, y - line_height * 0, 128, line_height, $game_party.members[2].name) draw_text(x + 256, y - line_height * 0, 128, line_height, $game_party.members[2].dps) draw_text(x + 384, y - line_height * 0, 128, line_height, per3.to_s + "%") else return end ### if $game_party.members[3] != nil draw_actor_face($game_party.members[3], x + 128 - 8, y + line_height * 1) draw_text(x - 0, y + line_height * 1, 128, line_height, $game_party.members[3].name) draw_text(x + 256, y + line_height * 1, 128, line_height, $game_party.members[3].dps) draw_text(x + 384, y + line_height * 1, 128, line_height, per4.to_s + "%") else return end ### end end #============================================================================== # ■ Scene_DPS # 处理DPS画面 #============================================================================== class Scene_DPS < Scene_MenuBase #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super @dps_window = Window_DPS.new(@actor) @dps_window.set_handler(:cancel, method(:return_scene)) end end #============================================================================== # ■ Scene_Battle # 战斗画面 #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 结束处理 #-------------------------------------------------------------------------- alias zyynov_terminate terminate def terminate zyynov_terminate if DPSswitch == true SceneManager.call(Scene_DPS) end end end
1.PNG (257.98 KB, 下载次数: 29)
KB.Driver 发表于 2019-5-3 20:41
……看到了一大堆的"for i in 0..3"和"$game_party.members",还有一些重复率高达99%的语句。
这样对成员上 ...
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |