Project1
标题: cp条战斗出错。求助 [打印本页]
作者: qq1046617273 时间: 2012-10-6 08:04
标题: cp条战斗出错。求助
倒霉倒霉。
——————————
我用的cp制
cp制脚本- #VX CP制战斗系统 V 1.00 BY SLICK
- $CP可见 = true
- #==============================================================================
- # ■ Game_Battler
- #------------------------------------------------------------------------------
- # 处理战斗者的类。这个类作为 Game_Actor 类与 Game_Enemy 类的
- # 超级类来使用。
- #==============================================================================
- class Game_Battler
- attr_accessor :cp
- attr_accessor :turn_count
- attr_accessor :my_turn #轮到这个家伙行动了吗?
- alias neoinitialize initialize
- def initialize
- @cp = 0
- @turn_count = 0
- @my_turn = false
- neoinitialize
- end
- #--------------------------------------------------------------------------
- # ● 可以输入命令判定
- #--------------------------------------------------------------------------
- def inputable?
- if @my_turn
- return (not @hidden and restriction <= 1)
- else
- return false
- end
- end
- end
- #==============================================================================
- # ■ Game_Troop
- #------------------------------------------------------------------------------
- # 处理敌人队伍和战斗相关资料的类,也可执行如战斗事件管理之类的功能。
- # 本类的实例请参考 $game_troop。
- #==============================================================================
- class Game_Troop < Game_Unit
- #--------------------------------------------------------------------------
- # ● 增加回合数
- #--------------------------------------------------------------------------
- def increase_turn(enemy)
- for page in troop.pages
- if page.span == 1
- @event_flags= false
- end
- end
- enemy.turn_count += 1
- aaa = []
- for iii in $game_troop.members
- aaa.push(iii.turn_count)
- end
- @turn_count = aaa.min
- end
- #--------------------------------------------------------------------------
- # ● 生成战斗行动
- #--------------------------------------------------------------------------
- def make_actions(enemy)
- enemy.make_action
- end
- end
- #==============================================================================
- # ■ Window_Blank
- #------------------------------------------------------------------------------
- # 用来放置CP的空白窗口。
- #==============================================================================
- class Window_Blank < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对像
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 544, 24)
- self.visible = $CP可见
- self.z = 490
- end
- #--------------------------------------------------------------------------
- # ● 生成窗口内容
- #--------------------------------------------------------------------------
- def create_contents
-
- end
- end
- #==============================================================================
- # ■ Scene_Battle
- #------------------------------------------------------------------------------
- # 处理战斗画面的类。
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # ● CP条生成
- #--------------------------------------------------------------------------
- def make_cp
- @blank_window = Window_Blank.new
- @cppic = {}
- @baseicons = Cache.system("Iconset")
- for iii in $game_party.members + $game_troop.members
- @cppic[iii] = Sprite.new
- @cppic[iii].bitmap = @baseicons
- @cppic[iii].x = 4
- @cppic[iii].y = 264
- @cppic[iii].z = 510
- @cppic[iii].zoom_x = 1.0
- @cppic[iii].zoom_y = 1.0
- @cppic[iii].opacity = 255
- @cppic[iii].visible = $CP可见
- end
- refresh_cp
- end
- #--------------------------------------------------------------------------
- # * 作战进程开始
- #--------------------------------------------------------------------------
- alias old_process_battle_start process_battle_start
- def process_battle_start
- old_process_battle_start
- unless $game_party.all_dead?
- make_cp
- end
- end
- #--------------------------------------------------------------------------
- # ● CP条更新
- #--------------------------------------------------------------------------
- def refresh_cp
- @blank_window.x = 0
- # @basepic.x = 144 - @info_viewport.ox
- for iii in $game_party.members + $game_troop.members
- if iii.is_a?(Game_Actor)
- icon_index = $data_weapons[iii.weapon_id].icon_index
- @cppic[iii].src_rect.set(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- else
- @cppic[iii].src_rect.set(312, 0, 24, 24)
- end
- if iii.hp > 0
- @cppic[iii].visible = $CP可见
- else
- @cppic[iii].visible = false
- end
- @cppic[iii].x = (iii.cp * 514 / 5000).to_i
- @cppic[iii].y = 0
- end
- end
- #--------------------------------------------------------------------------
- # ● CP条消去
- #--------------------------------------------------------------------------
- def dispose_cp
- for iii in $game_party.members + $game_troop.members
- @cppic[iii].dispose
- end
- @baseicons.dispose
- @blank_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- $game_temp.in_battle = true
- @spriteset = Spriteset_Battle.new
- @message_window = Window_BattleMessage.new
- @action_battlers = []
- # 清空CP,所有人从零开始
- for iii in $game_party.members + $game_troop.members
- iii.cp = 0
- end
- for iii in $game_party.members + $game_troop.members
- iii.turn_count = 0
- end
- # 谁的CP到顶了,谁才能动
- @enable_go = nil
- create_info_viewport
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_basic(true)
-
- if @help_window != nil
- if @help_window.visible
- @blank_window.visible = false
-
- end
- else
- @blank_window.visible = true
- end
- update_info_viewport # 更新资讯显示端口
- if $CP可见
- unless $game_party.all_dead?
- refresh_cp
- end
- end
- if $game_message.visible
- @info_viewport.visible = false
- @message_window.visible = true
- end
- unless $game_message.visible # 除非讯息显示中
- if judge_win_loss
- @cp_hide = true
- unless $game_party.all_dead?
- refresh_cp
- end
- end
- return if judge_win_loss # 判断胜负结果
- update_scene_change
- if @target_enemy_window != nil
- update_target_enemy_selection # 选择目标敌人
- elsif @target_actor_window != nil
- update_target_actor_selection # 选择目标角色
- elsif @skill_window != nil
- update_skill_selection # 选择技能
- elsif @item_window != nil
- update_item_selection # 选择物品
- elsif @party_command_window.active
- update_party_command_selection # 选择队伍命令
- elsif @actor_command_window.active
- update_actor_command_selection # 选择角色命令
- else
- # 等待:每个人的CP向前添加 =====================================================
- fullflag = false
- for iii in $game_troop.members + $game_party.members
- iii.cp += iii.agi * 1
- if iii.cp >= 5000
- iii.cp -= 5000
- @enable_go = iii
- iii.my_turn = true
- fullflag = true
- break
- end
- end
- # ==============================================================================
- unless fullflag
- return
- end
- process_battle_event # 战斗事件处理
- process_action # 战斗行动
- process_battle_event # 战斗事件处理
- if @enable_go.is_a?(Game_Actor)
- @status_window.refresh
- start_party_command_selection
- else
- $game_troop.make_actions(@enable_go)
- start_main
- end
- @enable_go = nil
- end
- end
- end
- #--------------------------------------------------------------------------
- # * 开始接收队伍选单项目选择指令输入资讯
- #--------------------------------------------------------------------------
- def start_party_command_selection
- if $game_temp.in_battle
- @status_window.refresh
- @status_window.index = @actor_index = -1
- @active_battler = nil
- @info_viewport.visible = true
- @message_window.visible = false
- @party_command_window.refresh
- @party_command_window.active = true
- @party_command_window.index = 0
- @actor_command_window.active = false
- $game_party.clear_actions
- if $game_troop.surprise or not $game_party.inputable?
- start_main
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 开始执行战斗处理
- #--------------------------------------------------------------------------
- def start_main
-
- for member in $game_troop.members
- $game_troop.increase_turn(member)
- end
- @info_viewport.visible = false
- @info_viewport.ox = 0
- @message_window.visible = true
- @party_command_window.active = false
- @actor_command_window.active = false
- @status_window.index = @actor_index = -1
- @active_battler = nil
- @message_window.clear
- for member in $game_troop.members
- $game_troop.make_actions(member)
- end
-
- make_action_orders
- wait(20)
- end
- #--------------------------------------------------------------------------
- # * 关于撤退的处理
- #--------------------------------------------------------------------------
- def process_escape
- @info_viewport.visible = false
- @message_window.visible = true
- text = sprintf(Vocab::EscapeStart, $game_party.name)
- $game_message.texts.push(text)
- if $game_troop.preemptive
- success = true
- else
- success = (rand(100) < @escape_ratio)
- end
- Sound.play_escape
- if success
- wait_for_message
- if @blank_window != nil
- dispose_cp
- end
- battle_end(1)
- else
- @escape_ratio += 10
- $game_message.texts.push('\.' + Vocab::EscapeFailure)
- wait_for_message
- $game_party.clear_actions
- start_main
- end
- end
- #--------------------------------------------------------------------------
- # * 关于作战胜利的处理
- #--------------------------------------------------------------------------
- alias old_process_victory process_victory
- def process_victory
- if @blank_window != nil
- dispose_cp
- end
- old_process_victory
- end
- #--------------------------------------------------------------------------
- # * 关于作战失败的处理
- #--------------------------------------------------------------------------
- alias old_process_defeat process_defeat
- def process_defeat
- if @blank_window != nil
- dispose_cp
- end
- old_process_defeat
- end
- #--------------------------------------------------------------------------
- # ● 生成行动顺序
- #--------------------------------------------------------------------------
- def make_action_orders
- @action_battlers = []
- for iii in $game_troop.members + $game_party.members
- if iii.my_turn
- @action_battlers.push(iii)
- iii.my_turn = false
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 回合结束
- #--------------------------------------------------------------------------
- def turn_end
- $game_troop.turn_ending = true
- $game_party.slip_damage_effect
- $game_troop.slip_damage_effect
- $game_party.do_auto_recovery
- $game_troop.preemptive = false
- $game_troop.surprise = false
- process_battle_event
- $game_troop.turn_ending = false
- end
- end
- #==============================================================================
- # ■ Window_Help
- #------------------------------------------------------------------------------
- # 特技及物品的说明、角色的状态显示的窗口。
- #==============================================================================
- class Window_Help < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 544, WLH + 32)
- self.z = 9999
- end
- end
复制代码