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

Project1

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

[已经过期] 关于脸图战斗很卡的问题

[复制链接]

Lv1.梦旅人

梦石
0
星屑
75
在线时间
231 小时
注册时间
2014-10-5
帖子
296
跳转到指定楼层
1
发表于 2014-10-29 20:01:45 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

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

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

x
RT 请问,怎么能优化一下这个脚本,让脸图战斗的时候,不是那么卡,FPS我设置的是固定80,战斗的时候,只要有这个脚本,直接到32以下
下面附上脚本
RUBY 代码复制
  1. #$脸图战斗 = true
  2. $imported = {} if $imported.nil?
  3. module YEA
  4.   module BATTLE
  5.     SKIP_PARTY_COMMAND = true
  6.     BATTLESTATUS_NAME_FONT_SIZE = 20
  7.     BATTLESTATUS_TEXT_FONT_SIZE = 16
  8.     BATTLESTATUS_NO_ACTION_ICON = 0
  9.     BATTLESTATUS_HPGAUGE_Y_PLUS = 11
  10.     BATTLESTATUS_CENTER_FACES   = false
  11.     HELP_TEXT_ALL_FOES        = "全体敌人"
  12.     HELP_TEXT_ONE_RANDOM_FOE  = "单个敌人"
  13.     HELP_TEXT_MANY_RANDOM_FOE = "%d个随机敌人"
  14.     HELP_TEXT_ALL_ALLIES      = "全体队友"
  15.     HELP_TEXT_ALL_DEAD_ALLIES = "全体死亡队友"
  16.     HELP_TEXT_ONE_RANDOM_ALLY = "单个随机队友"
  17.     HELP_TEXT_RANDOM_ALLIES   = "%d个随机队友"
  18.   end
  19. end
  20. class Game_Battler
  21.   def can_collapse?
  22.     return false unless dead?
  23.     unless actor?
  24.       return false unless sprite.battler_visible
  25.       array = [:collapse, :boss_collapse, :instant_collapse]
  26.       return false if array.include?(sprite.effect_type)
  27.     end
  28.     return true
  29.   end
  30. end
  31. module Icon
  32.   def self.no_action; return YEA::BATTLE::BATTLESTATUS_NO_ACTION_ICON; end
  33. end
  34. class Game_Temp
  35.   attr_accessor :battle_aid
  36.   attr_accessor :evaluating
  37. end
  38. class Game_Action
  39.   alias evaluate_item_with_target_abe evaluate_item_with_target
  40.   def evaluate_item_with_target(target)
  41.     $game_temp.evaluating = true
  42.     result = evaluate_item_with_target_abe(target)
  43.     $game_temp.evaluating = false
  44.     return result
  45.   end
  46. end
  47. class Game_Actor < Game_Battler
  48.   def draw_mp?
  49.     return true unless draw_tp?
  50.     for skill in skills
  51.       next unless added_skill_types.include?(skill.stype_id)
  52.       return true if skill.mp_cost > 0
  53.     end
  54.     return false
  55.   end
  56.   def draw_tp?
  57.     return false unless $data_system.opt_display_tp
  58.     for skill in skills
  59.       next unless added_skill_types.include?(skill.stype_id)
  60.       return true if skill.tp_cost > 0
  61.     end
  62.     return false
  63.   end
  64. end
  65. class Window_BattleStatus < Window_Selectable
  66.   def initialize
  67.     super(0, 0, window_width, window_height)
  68.     self.openness = 0
  69.     @party = $game_party.battle_members.clone
  70.   end
  71.   def col_max; return $game_party.max_battle_members; end
  72.   def battle_members; return $game_party.battle_members; end
  73.   def actor; return battle_members[@index]; end
  74.   def update
  75.     super
  76.     return if @party == $game_party.battle_members
  77.     @party = $game_party.battle_members.clone
  78.     refresh
  79.   end
  80.   def draw_item(index)
  81.     return if index.nil?
  82.     clear_item(index)
  83.     actor = battle_members[index]
  84.     rect = item_rect(index)
  85.     return if actor.nil?
  86.     draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
  87.     draw_actor_name(actor, rect.x, rect.y, rect.width-8)
  88.     draw_actor_action(actor, rect.x, rect.y)
  89.     draw_actor_icons(actor, rect.x, line_height*1, rect.width)
  90.     gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
  91.     contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
  92.     draw_crhp(rect.x+3,rect.y+60,actor.hp,actor.mhp,"")
  93.     draw_crmp(rect.x+3,rect.y+73,actor.mp,actor.mmp,"")
  94.     draw_actor_tp(actor, rect.x+2, line_height*3, rect.width-4)
  95.   end
  96.   def item_rect(index)
  97.     rect = Rect.new
  98.     rect.width = contents.width / $game_party.max_battle_members
  99.     rect.height = contents.height
  100.     rect.x = index * rect.width
  101.     if YEA::BATTLE::BATTLESTATUS_CENTER_FACES
  102.       rect.x += (contents.width - $game_party.members.size * rect.width) / 2
  103.     end
  104.     rect.y = 0
  105.     return rect
  106.   end
  107.   def draw_face(face_name, face_index, dx, dy, enabled = true)
  108.     bitmap = Cache.face(face_name)
  109.     fx = [(96 - item_rect(0).width + 1) / 2, 0].max
  110.     fy = face_index / 4 * 96 + 2
  111.     fw = [item_rect(0).width - 4, 92].min
  112.     rect = Rect.new(fx, fy, fw, 92)
  113.     rect = Rect.new(face_index % 4 * 96 + fx, fy, fw, 92)
  114.     contents.blt(dx, dy-24, bitmap, rect, enabled ? 255 : translucent_alpha)
  115.     bitmap.dispose
  116.   end
  117.   def draw_actor_name(actor, dx, dy, dw = 112)
  118.     reset_font_settings
  119.     contents.font.size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE
  120.     change_color(hp_color(actor))
  121.     draw_text(dx+24, dy, dw-24, line_height, actor.name)
  122.   end
  123.   def draw_actor_action(actor, dx, dy)
  124.     draw_icon(action_icon(actor), dx, dy)
  125.   end
  126.   def action_icon(actor)
  127.     return Icon.no_action if actor.current_action.nil?
  128.     return Icon.no_action if actor.current_action.item.nil?
  129.     return actor.current_action.item.icon_index
  130.   end
  131.   def draw_mp?(actor)
  132.     return draw_crmp(rect.x + 0,rect.y+80,actor.mp,actor.mmp,"MP")
  133.   end
  134.   def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2)
  135.     change_color(color1)
  136.     draw_text(dx, dy, dw, line_height, current.to_s, 2)
  137.   end
  138.   def draw_actor_hp(actor, dx, dy, width = 124)
  139.     draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  140.     change_color(system_color)
  141.     cy = (Font.default_size - contents.font.size) / 2 + 1
  142.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
  143.     draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,
  144.       hp_color(actor), normal_color)
  145.     end
  146.   def draw_actor_mp(actor, dx, dy, width = 124)
  147.     draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  148.     change_color(system_color)
  149.     cy = (Font.default_size - contents.font.size) / 2 + 1
  150.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
  151.     draw_current_and_max_values(dx, dy+cy, width, actor.mp, actor.mmp,
  152.       mp_color(actor), normal_color)
  153.     end
  154.   def draw_actor_tp(actor, dx, dy, width = 124)
  155.     draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
  156.     change_color(system_color)
  157.     cy = (Font.default_size - contents.font.size) / 2 + 1
  158.     draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a)
  159.     change_color(tp_color(actor))
  160.     draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2)
  161.   end
  162. end
  163. class Window_BattleActor < Window_BattleStatus
  164.   def show
  165.     create_flags
  166.     super
  167.   end
  168.   def create_flags
  169.     set_select_flag(:any)
  170.     select(0)
  171.     return if $game_temp.battle_aid.nil?
  172.     if $game_temp.battle_aid.need_selection?
  173.       select(0)
  174.       set_select_flag(:dead) if $game_temp.battle_aid.for_dead_friend?
  175.     elsif $game_temp.battle_aid.for_user?
  176.       battler = BattleManager.actor
  177.       id = battler.nil? ? 0 : $game_party.battle_members.index(battler)
  178.       select(id)
  179.       set_select_flag(:user)
  180.     elsif $game_temp.battle_aid.for_all?
  181.       select(0)
  182.       set_select_flag(:all)
  183.       set_select_flag(:all_dead) if $game_temp.battle_aid.for_dead_friend?
  184.     elsif $game_temp.battle_aid.for_random?
  185.       select(0)
  186.       set_select_flag(:random) if $game_temp.battle_aid.for_random?
  187.     end
  188.   end
  189.   def set_select_flag(flag)
  190.     @select_flag = flag
  191.     case @select_flag
  192.     when :all, :all_dead, :random
  193.       @cursor_all = true
  194.     else
  195.       @cursor_all = false
  196.     end
  197.   end
  198.   def update_cursor
  199.     if @cursor_all
  200.       cursor_rect.set(0, 0, contents.width, contents.height)
  201.       self.top_row = 0
  202.     elsif @index < 0
  203.       cursor_rect.empty
  204.     else
  205.       ensure_cursor_visible
  206.       cursor_rect.set(item_rect(@index))
  207.     end
  208.   end
  209.   def cursor_movable?
  210.     return false if @select_flag == :user
  211.     return super
  212.   end
  213.   def current_item_enabled?
  214.     return true if $game_temp.battle_aid.nil?
  215.     if $game_temp.battle_aid.need_selection?
  216.       member = $game_party.battle_members[@index]
  217.       return member.dead? if $game_temp.battle_aid.for_dead_friend?
  218.     elsif $game_temp.battle_aid.for_dead_friend?
  219.       for member in $game_party.battle_members
  220.         return true if member.dead?
  221.       end
  222.       return false
  223.     end
  224.     return true
  225.   end
  226. end
  227. class Window_BattleStatusAid < Window_BattleStatus
  228.   attr_accessor :status_window
  229.   def initialize
  230.     super
  231.     self.visible = false
  232.     self.openness = 255
  233.   end
  234.   def window_width; return 128; end
  235.   def show
  236.     super
  237.     refresh
  238.   end
  239.   def refresh
  240.     contents.clear
  241.     return if @status_window.nil?
  242.     draw_item(@status_window.index)
  243.   end
  244.   def item_rect(index)
  245.     return Rect.new(0, 0, contents.width, contents.height)
  246.   end
  247. end
  248.  
  249. class Window_BattleHelp < Window_Help
  250.   attr_accessor :actor_window
  251.   attr_accessor :enemy_window
  252.   def update
  253.     super
  254.     if !self.visible and @text != ""
  255.       @text = ""
  256.       return refresh
  257.     end
  258.     update_battler_name
  259.   end
  260.   def update_battler_name
  261.     return unless @actor_window.active || @enemy_window.active
  262.     if @actor_window.active
  263.       battler = $game_party.battle_members[@actor_window.index]
  264.     elsif @enemy_window.active
  265.       battler = @enemy_window.enemy
  266.     end
  267.     if special_display?
  268.       refresh_special_case(battler)
  269.     else
  270.       refresh_battler_name(battler) if battler_name(battler) != @text
  271.     end
  272.   end
  273.   def battler_name(battler)
  274.     text = battler.name.clone
  275.     return text
  276.   end
  277.   def refresh_battler_name(battler)
  278.     contents.clear
  279.     reset_font_settings
  280.     change_color(normal_color)
  281.     @text = battler_name(battler)
  282.     icons = battler.state_icons + battler.buff_icons
  283.     dy = icons.size <= 0 ? line_height / 2 : 0
  284.     draw_text(0, dy, contents.width, line_height, @text, 1)
  285.     dx = (contents.width - (icons.size * 24)) / 2
  286.     draw_actor_icons(battler, dx, line_height, contents.width)
  287.   end
  288.   def special_display?
  289.     return false if $game_temp.battle_aid.nil?
  290.     return false if $game_temp.battle_aid.for_user?
  291.     return !$game_temp.battle_aid.need_selection?
  292.   end
  293.   def refresh_special_case(battler)
  294.     if $game_temp.battle_aid.for_opponent?
  295.       if $game_temp.battle_aid.for_all?
  296.         text = YEA::BATTLE::HELP_TEXT_ALL_FOES
  297.       else
  298.         case $game_temp.battle_aid.number_of_targets
  299.         when 1
  300.           text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_FOE
  301.         else
  302.           number = $game_temp.battle_aid.number_of_targets
  303.           text = sprintf(YEA::BATTLE::HELP_TEXT_MANY_RANDOM_FOE, number)
  304.         end
  305.       end
  306.     else
  307.       if $game_temp.battle_aid.for_dead_friend?
  308.         text = YEA::BATTLE::HELP_TEXT_ALL_DEAD_ALLIES
  309.       elsif $game_temp.battle_aid.for_random?
  310.         case $game_temp.battle_aid.number_of_targets
  311.         when 1
  312.           text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_ALLY
  313.         else
  314.           number = $game_temp.battle_aid.number_of_targets
  315.           text = sprintf(YEA::BATTLE::HELP_TEXT_RANDOM_ALLIES, number)
  316.         end
  317.       else
  318.         text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES
  319.       end
  320.     end
  321.     return if text == @text
  322.     @text = text
  323.     contents.clear
  324.     reset_font_settings
  325.     draw_text(0, 0, contents.width, line_height*2, @text, 1)
  326.   end
  327. end
  328. class Window_SkillList < Window_Selectable
  329.   def spacing
  330.     return 8 if $game_party.in_battle
  331.     return super
  332.   end
  333. end
  334. class Window_ItemList < Window_Selectable
  335.   def spacing
  336.     return 8 if $game_party.in_battle
  337.     return super
  338.   end
  339. end
  340. class Scene_Battle < Scene_Base
  341.   attr_accessor :enemy_window
  342.   attr_accessor :info_viewport
  343.   attr_accessor :spriteset
  344.   attr_accessor :status_window
  345.   attr_accessor :status_aid_window
  346.   attr_accessor :subject
  347.   alias scene_battle_create_all_windows_abe create_all_windows
  348.   def create_all_windows
  349.     scene_battle_create_all_windows_abe
  350.     create_battle_status_aid_window
  351.     set_help_window
  352.   end
  353.   alias scene_battle_create_info_viewport_abe create_info_viewport
  354.   def create_info_viewport
  355.     scene_battle_create_info_viewport_abe
  356.     @status_window.refresh
  357.   end
  358.   def create_battle_status_aid_window
  359.     @status_aid_window = Window_BattleStatusAid.new
  360.     @status_aid_window.status_window = @status_window
  361.     @status_aid_window.x = Graphics.width - @status_aid_window.width
  362.     @status_aid_window.y = Graphics.height - @status_aid_window.height
  363.   end
  364.   def create_help_window
  365.     @help_window = Window_BattleHelp.new
  366.     @help_window.hide
  367.   end
  368.   def set_help_window
  369.     @help_window.actor_window = @actor_window
  370.     @help_window.enemy_window = @enemy_window
  371.   end
  372.   alias scene_battle_create_skill_window_abe create_skill_window
  373.   def create_skill_window
  374.     scene_battle_create_skill_window_abe
  375.     @skill_window.height = @info_viewport.rect.height
  376.     @skill_window.width = Graphics.width - @actor_command_window.width
  377.     @skill_window.y = Graphics.height - @skill_window.height
  378.   end
  379.   alias scene_battle_create_item_window_abe create_item_window
  380.   def create_item_window
  381.     scene_battle_create_item_window_abe
  382.     @item_window.height = @skill_window.height
  383.     @item_window.width = @skill_window.width
  384.     @item_window.y = Graphics.height - @item_window.height
  385.   end
  386.   alias scene_battle_next_command_abe next_command
  387.   def next_command
  388.     @status_window.show
  389.     redraw_current_status
  390.     @actor_command_window.show
  391.     @status_aid_window.hide
  392.     scene_battle_next_command_abe
  393.   end
  394.   alias scene_battle_prior_command_abe prior_command
  395.   def prior_command
  396.     redraw_current_status
  397.     scene_battle_prior_command_abe
  398.   end
  399.   def redraw_current_status
  400.     return if @status_window.index < 0
  401.     @status_window.draw_item(@status_window.index)
  402.   end
  403.   alias scene_battle_command_attack_abe command_attack
  404.   def command_attack
  405.     $game_temp.battle_aid = $data_skills[BattleManager.actor.attack_skill_id]
  406.     scene_battle_command_attack_abe
  407.   end
  408.   alias scene_battle_command_skill_abe command_skill
  409.   def command_skill
  410.     scene_battle_command_skill_abe
  411.     @status_window.hide
  412.     @actor_command_window.hide
  413.     @status_aid_window.show
  414.   end
  415.   alias scene_battle_command_item_abe command_item
  416.   def command_item
  417.     scene_battle_command_item_abe
  418.     @status_window.hide
  419.     @actor_command_window.hide
  420.     @status_aid_window.show
  421.   end
  422.   def on_skill_ok
  423.     [url=home.php?mod=space&uid=260100]@skill[/url] = @skill_window.item
  424.     $game_temp.battle_aid = @skill
  425.     BattleManager.actor.input.set_skill(@skill.id)
  426.     BattleManager.actor.last_skill.object = @skill
  427.     if @skill.for_opponent?
  428.       select_enemy_selection
  429.     elsif @skill.for_friend?
  430.       select_actor_selection
  431.     else
  432.       @skill_window.hide
  433.       next_command
  434.       $game_temp.battle_aid = nil
  435.     end
  436.   end
  437.   alias scene_battle_on_skill_cancel_abe on_skill_cancel
  438.   def on_skill_cancel
  439.     scene_battle_on_skill_cancel_abe
  440.     @status_window.show
  441.     @actor_command_window.show
  442.     @status_aid_window.hide
  443.   end
  444.   def on_item_ok
  445.     @item = @item_window.item
  446.     $game_temp.battle_aid = @item
  447.     BattleManager.actor.input.set_item(@item.id)
  448.     if @item.for_opponent?
  449.       select_enemy_selection
  450.     elsif @item.for_friend?
  451.       select_actor_selection
  452.     else
  453.       @item_window.hide
  454.       next_command
  455.       $game_temp.battle_aid = nil
  456.     end
  457.     $game_party.last_item.object = @item
  458.   end
  459.   alias scene_battle_on_item_cancel_abe on_item_cancel
  460.   def on_item_cancel
  461.     scene_battle_on_item_cancel_abe
  462.     @status_window.show
  463.     @actor_command_window.show
  464.     @status_aid_window.hide
  465.   end
  466.   alias scene_battle_select_actor_selection_abe select_actor_selection
  467.   def select_actor_selection
  468.     @status_aid_window.refresh
  469.     scene_battle_select_actor_selection_abe
  470.     @status_window.hide
  471.     @skill_window.hide
  472.     @item_window.hide
  473.     @help_window.show
  474.   end
  475.   alias scene_battle_on_actor_ok_abe on_actor_ok
  476.   def on_actor_ok
  477.     $game_temp.battle_aid = nil
  478.     scene_battle_on_actor_ok_abe
  479.     @status_window.show
  480.     if $imported["YEA-BattleCommandList"] && !@confirm_command_window.nil?
  481.       @actor_command_window.visible = !@confirm_command_window.visible
  482.     else
  483.       @actor_command_window.show
  484.     end
  485.     @status_aid_window.hide
  486.   end
  487.   alias scene_battle_on_actor_cancel_abe on_actor_cancel
  488.   def on_actor_cancel
  489.     BattleManager.actor.input.clear
  490.     @status_aid_window.refresh
  491.     $game_temp.battle_aid = nil
  492.     scene_battle_on_actor_cancel_abe
  493.     case @actor_command_window.current_symbol
  494.     when :skill
  495.       @skill_window.show
  496.     when :item
  497.       @item_window.show
  498.     end
  499.   end
  500.   alias scene_battle_select_enemy_selection_abe select_enemy_selection
  501.   def select_enemy_selection
  502.     @status_aid_window.refresh
  503.     scene_battle_select_enemy_selection_abe
  504.     @help_window.show
  505.   end
  506.   alias scene_battle_on_enemy_ok_abe on_enemy_ok
  507.   def on_enemy_ok
  508.     $game_temp.battle_aid = nil
  509.     scene_battle_on_enemy_ok_abe
  510.   end
  511.   alias scene_battle_on_enemy_cancel_abe on_enemy_cancel
  512.   def on_enemy_cancel
  513.     BattleManager.actor.input.clear
  514.     @status_aid_window.refresh
  515.     $game_temp.battle_aid = nil
  516.     scene_battle_on_enemy_cancel_abe
  517.     if @skill_window.visible || @item_window.visible
  518.       @help_window.show
  519.     else
  520.       @help_window.hide
  521.     end
  522.   end
  523.   def end_battle_conditions?
  524.     return true if $game_party.members.empty?
  525.     return true if $game_party.all_dead?
  526.     return true if $game_troop.all_dead?
  527.     return true if BattleManager.aborting?
  528.     return false
  529.   end
  530.   def refresh_status
  531.     #如果你是程序员,请顺手帮忙优化下这里,谢谢。
  532.     @status_window.refresh
  533.     for i in $game_party.battle_members
  534.       @status_window.draw_item($game_party.battle_members.index(i))
  535.     end
  536.   end
  537. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-6 12:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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