Project1

标题: 使用cp战斗系统后一使用技能菜单会消失 [打印本页]

作者: 是〢昔    时间: 2014-8-12 22:25
标题: 使用cp战斗系统后一使用技能菜单会消失

就像这张图这样,右侧战斗,防御什么的都看不到了,但其实操作还能正常进行,只是看不见,这是怎么回事啊,谢谢了
  1. #==============================================================================
  2. # ■ CP制战斗系统 v1.00
  3. #------------------------------------------------------------------------------
  4. #    适用于:RPG Maker VX Ace
  5. #    说明:把脚本放在Main的前面。
  6. #    所需素材:Graphics\Pictures\SL我方.png,SL敌方.png。
  7. #==============================================================================

  8. #encoding:utf-8
  9. #==============================================================================
  10. # ■ Scene_Battle
  11. #------------------------------------------------------------------------------
  12. #  战斗画面
  13. #==============================================================================

  14. class Scene_Battle < Scene_Base
  15.   attr_accessor :cp_quota
  16.   attr_accessor :rtab_wait
  17.   attr_accessor :active_members
  18.   #--------------------------------------------------------------------------
  19.   # ● 开始处理
  20.   #--------------------------------------------------------------------------
  21.   def start
  22.     super
  23.     @cp_quota = 0
  24.     create_spriteset
  25.     create_all_windows
  26.     BattleManager.method_wait_for_message = method(:wait_for_message)
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 战斗开始
  30.   #--------------------------------------------------------------------------
  31.   def battle_start
  32.     @rtab_wait = true
  33.     @active_members = []
  34.     BattleManager.battle_start
  35.     set_cp_quota
  36.     process_event
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 获取敌我双方人物的平均行动速度并决定CP槽的Quota值
  40.   #--------------------------------------------------------------------------
  41.   def set_cp_quota
  42.     sss = 0.0
  43.     for iii in $game_party.members
  44.       sss += iii.param(6)
  45.     end
  46.     sss /= $game_party.members.size
  47.     @cp_quota = sss * 45
  48.     @spriteset.cp_quota = @cp_quota
  49.     for iii in $game_party.members + $game_troop.members
  50.       iii.cp_quota = @cp_quota
  51.     end
  52.   end
  53.   #--------------------------------------------------------------------------
  54.   # ● 进行下一个指令输入
  55.   #--------------------------------------------------------------------------
  56.   def next_command
  57.     if BattleManager.next_command
  58.       start_actor_command_selection
  59.     else
  60.       turn_start(@active_members)
  61.     end
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 返回上一个指令输入
  65.   #--------------------------------------------------------------------------
  66.   def prior_command
  67.     if BattleManager.prior_command
  68.       start_actor_command_selection
  69.     else
  70.       start_party_command_selection
  71.     end
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 更新画面
  75.   #--------------------------------------------------------------------------
  76.   def update
  77.     super
  78.     if BattleManager.in_turn?
  79.       process_event
  80.       process_action
  81.     else
  82.       if @rtab_wait
  83.         for iii in $game_party.members + $game_troop.members
  84.           iii.in_turn = false
  85.           iii.rtab_cp += iii.param(6)
  86.           if iii.rtab_cp >= iii.cp_quota
  87.             @active_members.push(iii)
  88.             iii.in_turn = true
  89.           end
  90.         end
  91.         if @active_members.size > 0
  92.           @rtab_wait = false
  93.           start_party_command_selection
  94.         end
  95.       end
  96.     end
  97.     BattleManager.judge_win_loss
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 回合开始
  101.   #--------------------------------------------------------------------------
  102.   def turn_start(members)
  103.     @party_command_window.close
  104.     @actor_command_window.close
  105.     @status_window.unselect
  106.     @subject = nil
  107.     BattleManager.turn_start(members)
  108.     @log_window.wait
  109.     @log_window.clear
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 回合结束
  113.   #--------------------------------------------------------------------------
  114.   def turn_end
  115.     @active_members.each do |battler|
  116.       battler.on_turn_end
  117.       refresh_status
  118.       @log_window.display_auto_affected_status(battler)
  119.       @log_window.wait_and_clear
  120.     end
  121.     BattleManager.turn_end
  122.     process_event
  123.     @rtab_wait = true
  124.     @active_members = []
  125.   end
  126.   #--------------------------------------------------------------------------
  127.   # ● 处理战斗行动
  128.   #--------------------------------------------------------------------------
  129.   def process_action
  130.     return if scene_changing?
  131.     if !@subject || [email protected]_action
  132.       @subject = BattleManager.next_subject
  133.     end
  134.     return turn_end unless @subject
  135.     if @subject.current_action
  136.       @subject.current_action.prepare
  137.       if @subject.current_action.valid?
  138.         @status_window.open
  139.         execute_action
  140.       end
  141.       @subject.remove_current_action
  142.     end
  143.     process_action_end unless @subject.current_action
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 开始队伍指令的选择
  147.   #--------------------------------------------------------------------------
  148.   def start_party_command_selection
  149.     unless scene_changing?
  150.       refresh_status
  151.       @status_window.unselect
  152.       @status_window.open
  153.       if BattleManager.input_start
  154.         BattleManager.clear_actor
  155.         BattleManager.next_command
  156.         @status_window.select(BattleManager.actor.index)
  157.         @actor_command_window.setup(BattleManager.actor)
  158.       else
  159.         @party_command_window.deactivate
  160.         @actor_command_window.close
  161.         turn_start(@active_members)
  162.       end
  163.     end
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ● 生成角色指令窗口
  167.   #--------------------------------------------------------------------------
  168.   def create_actor_command_window
  169.     @actor_command_window = Window_ActorCommand.new
  170.     @actor_command_window.viewport = @info_viewport
  171.     @actor_command_window.set_handler(:attack, method(:command_attack))
  172.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  173.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  174.     @actor_command_window.set_handler(:item,   method(:command_item))
  175.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  176.     @actor_command_window.set_handler(:escape, method(:command_escape))
  177.     @actor_command_window.x = Graphics.width
  178.   end
  179.   #--------------------------------------------------------------------------
  180.   # ● 指令“撤退”
  181.   #--------------------------------------------------------------------------
  182.   def command_escape
  183.     unless BattleManager.process_escape
  184.       turn_start(@active_members)
  185.       for iii in @active_members
  186.         iii.rtab_cp = 0
  187.       end
  188.     end
  189.   end
  190. end

  191. #encoding:utf-8
  192. #==============================================================================
  193. # ■ Window_ActorCommand
  194. #------------------------------------------------------------------------------
  195. #  战斗画面中,选择角色行动的窗口。
  196. #==============================================================================

  197. class Window_ActorCommand < Window_Command
  198.   #--------------------------------------------------------------------------
  199.   # ● 生成指令列表
  200.   #--------------------------------------------------------------------------
  201.   def make_command_list
  202.     return unless @actor
  203.     add_attack_command
  204.     add_skill_commands
  205.     add_guard_command
  206.     add_item_command
  207.     add_escape_command
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ● 添加撤退指令
  211.   #--------------------------------------------------------------------------
  212.   def add_escape_command
  213.     add_command(Vocab::escape, :escape, BattleManager.can_escape?)
  214.   end
  215. end

  216. #encoding:utf-8
  217. #==============================================================================
  218. # ■ BattleManager
  219. #------------------------------------------------------------------------------
  220. #  战斗过程的管理器。
  221. #==============================================================================

  222. module BattleManager
  223.   #--------------------------------------------------------------------------
  224.   # ● 战斗开始
  225.   #--------------------------------------------------------------------------
  226.   def self.battle_start
  227.     $game_system.battle_count += 1
  228.     $game_party.on_battle_start
  229.     $game_troop.on_battle_start
  230.     $game_troop.enemy_names.each do |name|
  231.       $game_message.add(sprintf(Vocab::Emerge, name))
  232.     end
  233.     if @preemptive
  234.       $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
  235.     elsif @surprise
  236.       $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
  237.     end
  238.     wait_for_message
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # ● 遇敌时的处理
  242.   #--------------------------------------------------------------------------
  243.   def self.on_encounter
  244.     @preemptive = false
  245.     @surprise = false
  246.   end
  247.   #--------------------------------------------------------------------------
  248.   # ● 回合开始
  249.   #--------------------------------------------------------------------------
  250.   def self.turn_start(members)
  251.     @phase = :turn
  252.     clear_actor
  253.     $game_troop.increase_turn(members)
  254.     make_action_orders(members)
  255.   end
  256.   #--------------------------------------------------------------------------
  257.   # ● 生成行动顺序
  258.   #--------------------------------------------------------------------------
  259.   def self.make_action_orders(members)
  260.     @action_battlers = []
  261.     for iii in $game_party.members
  262.       if members.include?(iii)
  263.         @action_battlers.push(iii) unless @surprise
  264.       end
  265.     end
  266.     for iii in $game_troop.members
  267.       if members.include?(iii)
  268.         @action_battlers.push(iii) unless @preemptive
  269.       end
  270.     end
  271.     @action_battlers.each {|battler| battler.make_speed }
  272.     @action_battlers.sort! {|a,b| b.speed - a.speed }
  273.   end
  274. end

  275. #encoding:utf-8
  276. #==============================================================================
  277. # ■ Game_Battler
  278. #------------------------------------------------------------------------------
  279. #  处理战斗者的类。Game_Actor 和 Game_Enemy 类的父类。
  280. #==============================================================================

  281. class Game_Battler < Game_BattlerBase
  282.   attr_accessor :turn_count
  283.   attr_accessor :rtab_cp
  284.   attr_accessor :cp_quota
  285.   attr_accessor :in_turn
  286.   #--------------------------------------------------------------------------
  287.   # ● 初始化对象
  288.   #--------------------------------------------------------------------------
  289.   alias neoinitialize initialize
  290.   def initialize
  291.     @turn_count = 0
  292.     @rtab_cp = 0
  293.     @cp_quota = 100
  294.     @in_turn = false
  295.     neoinitialize
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # ● 战斗开始处理
  299.   #--------------------------------------------------------------------------
  300.   def on_battle_start
  301.     @turn_count = 0
  302.     @rtab_cp = 0
  303.     @cp_quota = 100
  304.     @in_turn = false
  305.     init_tp unless preserve_tp?
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 处理伤害
  309.   #    调用前需要设置好
  310.   #    @result.hp_damage   @result.mp_damage
  311.   #    @result.hp_drain    @result.mp_drain
  312.   #--------------------------------------------------------------------------
  313.   def execute_damage(user)
  314.     on_damage(@result.hp_damage) if @result.hp_damage > 0
  315.     self.hp -= @result.hp_damage
  316.     self.mp -= @result.mp_damage
  317.     user.hp += @result.hp_drain
  318.     user.mp += @result.mp_drain
  319.     # 受伤后计算CP退后量
  320.     cpback = @result.hp_damage + @result.mp_damage
  321.     cpback = (cpback < 0 ? 0 : cpback)
  322.     pent = 100.0 * cpback / self.mhp
  323.     cppentback = ((5 + pent / 10) * self.cp_quota / 100).to_i
  324.     @rtab_cp -= cppentback
  325.     @rtab_cp = (@rtab_cp < 0 ? 0 : @rtab_cp)
  326.   end
  327.   #--------------------------------------------------------------------------
  328.   # ● 判定是否可以输入指令
  329.   #--------------------------------------------------------------------------
  330.   def inputable?
  331.     normal? && !auto_battle? && @in_turn
  332.   end
  333.   #--------------------------------------------------------------------------
  334.   # ● 回合结束处理
  335.   #--------------------------------------------------------------------------
  336.   def on_turn_end
  337.     @result.clear
  338.     regenerate_all
  339.     update_state_turns
  340.     update_buff_turns
  341.     remove_states_auto(2)
  342.     # 该角色的回合计数加1并清空CP
  343.     @turn_count += 1
  344.     @rtab_cp = 0
  345.   end
  346. end

  347. #encoding:utf-8
  348. #==============================================================================
  349. # ■ Game_Troop
  350. #------------------------------------------------------------------------------
  351. #  管理敌群和战斗相关资料的类,也可执行如战斗事件管理之类的功能。
  352. #   本类的实例请参考 $game_troop 。
  353. #==============================================================================

  354. class Game_Troop < Game_Unit
  355.   #--------------------------------------------------------------------------
  356.   # ● 增加回合
  357.   #--------------------------------------------------------------------------
  358.   def increase_turn(members)
  359.     troop.pages.each {|page| @event_flags= false if page.span == 1 }
  360.     turnmax = []
  361.     for iii in members
  362.       turnmax.push(iii.turn_count)
  363.     end
  364.     @turn_count = turnmax.max
  365.   end
  366. end

  367. #encoding:utf-8
  368. #==============================================================================
  369. # ■ Spriteset_Battle
  370. #------------------------------------------------------------------------------
  371. #  处理战斗画面的精灵的类。本类在 Scene_Battle 类的内部使用。
  372. #==============================================================================

  373. class Spriteset_Battle
  374.   attr_accessor :icons
  375.   attr_accessor :cp_quota
  376.   #--------------------------------------------------------------------------
  377.   # ● 初始化对象
  378.   #--------------------------------------------------------------------------
  379.   def initialize
  380.     @cp_quota = 100
  381.     create_viewports
  382.     create_battleback1
  383.     create_battleback2
  384.     create_enemies
  385.     create_actors
  386.     create_pictures
  387.     create_timer
  388.     create_rtabcp_gauge
  389.     update
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   #--------------------------------------------------------------------------
  393.   # ● 生成战斗CP条
  394.   #--------------------------------------------------------------------------
  395.   def create_rtabcp_gauge
  396.     @cpgauge_back = Sprite.new(@viewport3)
  397.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  398.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  399.     @cpgauge_back.x = 16
  400.     @cpgauge_back.y = 16
  401.     # 各个角色生成其图标
  402.    @icons = {}
  403.     for iii in $game_party.members
  404.       index=iii.id
  405.       @icons[iii] = Sprite.new(@viewport3)
  406.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Actor/"+index.to_s+".png")
  407.       @icons[iii].ox = 12
  408.       @icons[iii].oy = 12
  409.       @icons[iii].x = 16
  410.       @icons[iii].y = 20
  411.       index+=1
  412.     end
  413.     for iii in $game_troop.members
  414.       index=iii.enemy_id
  415.       @icons[iii] = Sprite.new(@viewport3)
  416.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Troop/"+index.to_s+".png")
  417.       @icons[iii].ox = 12
  418.       @icons[iii].oy = 12
  419.       @icons[iii].x = 16
  420.       @icons[iii].y = 20
  421.       index+=1
  422.     end
  423.   end

  424.   #--------------------------------------------------------------------------
  425.   # ● 释放
  426.   #--------------------------------------------------------------------------
  427.   def dispose
  428.     dispose_battleback1
  429.     dispose_battleback2
  430.     dispose_enemies
  431.     dispose_actors
  432.     dispose_pictures
  433.     dispose_timer
  434.     dispose_viewports
  435.     dispose_rtabcp_gauge
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 消灭战斗CP条
  439.   #--------------------------------------------------------------------------
  440.   def dispose_rtabcp_gauge
  441.     @cpgauge_back.bitmap.dispose
  442.     @cpgauge_back.dispose
  443.     for iii in $game_party.members
  444.       @icons[iii].bitmap.dispose
  445.       @icons[iii].dispose
  446.     end
  447.     for iii in $game_troop.members
  448.       @icons[iii].bitmap.dispose
  449.       @icons[iii].dispose
  450.     end
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 更新画面
  454.   #--------------------------------------------------------------------------
  455.   def update
  456.     update_battleback1
  457.     update_battleback2
  458.     update_enemies
  459.     update_actors
  460.     update_cp
  461.     update_pictures
  462.     update_timer
  463.     update_viewports
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 更新CP条
  467.   #--------------------------------------------------------------------------
  468.   def update_cp
  469.     for iii in $game_party.members + $game_troop.members
  470.       @icons[iii].x = 16 + 200 * iii.rtab_cp / @cp_quota
  471.       @icons[iii].visible = iii.alive?
  472.     end
  473.   end
  474. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1