| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 16 |
| 经验 | |
| 最后登录 | 2016-2-12 |
| 在线时间 | 209 小时 |
- 梦石
- 0
- 星屑
- 1564
- 在线时间
- 209 小时
- 注册时间
- 2013-6-19
- 回帖
- 123
|
楼主 |
发表于 2013-8-4 02:26:11
|
显示全部楼层
喵呜喵5 发表于 2013-8-4 01:57 
1.关于第一个问题,请使用这个脚本
http://peachround.blog.fc2.com/blog-entry-9.html
先跟你說聲謝謝!
臉圖戰鬥- $脸图战斗 = true
- $imported = {} if $imported.nil?
- module YEA
- module BATTLE
- SKIP_PARTY_COMMAND = true
- BATTLESTATUS_NAME_FONT_SIZE = 20
- BATTLESTATUS_TEXT_FONT_SIZE = 16
- BATTLESTATUS_NO_ACTION_ICON = 185
- BATTLESTATUS_HPGAUGE_Y_PLUS = 11
- BATTLESTATUS_CENTER_FACES = false
- HELP_TEXT_ALL_FOES = "全體敵人"
- HELP_TEXT_ONE_RANDOM_FOE = "單個敵人"
- HELP_TEXT_MANY_RANDOM_FOE = "%d個隨機敵人"
- HELP_TEXT_ALL_ALLIES = "全體隊友"
- HELP_TEXT_ALL_DEAD_ALLIES = "全體死亡隊友"
- HELP_TEXT_ONE_RANDOM_ALLY = "單個隨機隊友"
- HELP_TEXT_RANDOM_ALLIES = "%d個隨機隊友"
- end
- end
- class Game_Battler
- def can_collapse?
- return false unless dead?
- unless actor?
- return false unless sprite.battler_visible
- array = [:collapse, :boss_collapse, :instant_collapse]
- return false if array.include?(sprite.effect_type)
- end
- return true
- end
- def draw_mp?
- return true
- end
- def draw_tp?
- return $data_system.opt_display_tp
- end
- end
- module Icon
- def self.no_action; return YEA::BATTLE::BATTLESTATUS_NO_ACTION_ICON; end
- end
- class Game_Temp
- attr_accessor :battle_aid
- attr_accessor :evaluating
- end
- class Game_Action
- alias evaluate_item_with_target_abe evaluate_item_with_target
- def evaluate_item_with_target(target)
- $game_temp.evaluating = true
- result = evaluate_item_with_target_abe(target)
- $game_temp.evaluating = false
- return result
- end
- end
- class Game_Actor < Game_Battler
- def draw_mp?
- return true unless draw_tp?
- for skill in skills
- next unless added_skill_types.include?(skill.stype_id)
- return true if skill.mp_cost > 0
- end
- return false
- end
- def draw_tp?
- return false unless $data_system.opt_display_tp
- for skill in skills
- next unless added_skill_types.include?(skill.stype_id)
- return true if skill.tp_cost > 0
- end
- return false
- end
- end
- class Window_BattleStatus < Window_Selectable
- def initialize
- super(0, 0, window_width, window_height)
- self.openness = 0
- @party = $game_party.battle_members.clone
- end
- def col_max; return $game_party.max_battle_members; end
- def battle_members; return $game_party.battle_members; end
- def actor; return battle_members[@index]; end
- def update
- super
- return if @party == $game_party.battle_members
- @party = $game_party.battle_members.clone
- refresh
- end
- def draw_item(index)
- return if index.nil?
- clear_item(index)
- actor = battle_members[index]
- rect = item_rect(index)
- return if actor.nil?
- draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
- draw_actor_name(actor, rect.x, rect.y, rect.width-8)
- draw_actor_action(actor, rect.x, rect.y)
- draw_actor_icons(actor, rect.x, line_height*1, rect.width)
- gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
- contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
- draw_actor_hp(actor, rect.x+2, line_height*2+gx, rect.width-4)
- if draw_tp?(actor) && draw_mp?(actor)
- dw = rect.width/2-2
- dw += 1 if $imported["YEA-CoreEngine"] && YEA::CORE::GAUGE_OUTLINE
- draw_actor_tp(actor, rect.x+2, line_height*3, dw)
- dw = rect.width - rect.width/2 - 2
- draw_actor_mp(actor, rect.x+rect.width/2, line_height*3, dw)
- elsif draw_tp?(actor) && !draw_mp?(actor)
- draw_actor_tp(actor, rect.x+2, line_height*3, rect.width-4)
- else
- draw_actor_mp(actor, rect.x+2, line_height*3, rect.width-4)
- end
- end
- def item_rect(index)
- rect = Rect.new
- rect.width = contents.width / $game_party.max_battle_members
- rect.height = contents.height
- rect.x = index * rect.width
- if YEA::BATTLE::BATTLESTATUS_CENTER_FACES
- rect.x += (contents.width - $game_party.members.size * rect.width) / 2
- end
- rect.y = 0
- return rect
- end
- def draw_face(face_name, face_index, dx, dy, enabled = true)
- bitmap = Cache.face(face_name)
- fx = [(96 - item_rect(0).width + 1) / 2, 0].max
- fy = face_index / 4 * 96 + 2
- fw = [item_rect(0).width - 4, 92].min
- rect = Rect.new(fx, fy, fw, 92)
- rect = Rect.new(face_index % 4 * 96 + fx, fy, fw, 92)
- contents.blt(dx, dy, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- end
- def draw_actor_name(actor, dx, dy, dw = 112)
- reset_font_settings
- contents.font.size = YEA::BATTLE::BATTLESTATUS_NAME_FONT_SIZE
- change_color(hp_color(actor))
- draw_text(dx+24, dy, dw-24, line_height, actor.name)
- end
- def draw_actor_action(actor, dx, dy)
- draw_icon(action_icon(actor), dx, dy)
- end
- def action_icon(actor)
- return Icon.no_action if actor.current_action.nil?
- return Icon.no_action if actor.current_action.item.nil?
- return actor.current_action.item.icon_index
- end
- def draw_tp?(actor)
- return actor.draw_tp?
- end
- def draw_mp?(actor)
- return actor.draw_mp?
- end
- def draw_current_and_max_values(dx, dy, dw, current, max, color1, color2)
- change_color(color1)
- draw_text(dx, dy, dw, line_height, current.to_s, 2)
- end
- def draw_actor_hp(actor, dx, dy, width = 124)
- draw_gauge(dx, dy, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
- change_color(system_color)
- cy = (Font.default_size - contents.font.size) / 2 + 1
- draw_text(dx+2, dy+cy, 30, line_height, Vocab::hp_a)
- draw_current_and_max_values(dx, dy+cy, width, actor.hp, actor.mhp,
- hp_color(actor), normal_color)
- end
- def draw_actor_mp(actor, dx, dy, width = 124)
- draw_gauge(dx, dy, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
- change_color(system_color)
- cy = (Font.default_size - contents.font.size) / 2 + 1
- draw_text(dx+2, dy+cy, 30, line_height, Vocab::mp_a)
- draw_current_and_max_values(dx, dy+cy, width, actor.mp, actor.mmp,
- mp_color(actor), normal_color)
- end
- def draw_actor_tp(actor, dx, dy, width = 124)
- draw_gauge(dx, dy, width, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
- change_color(system_color)
- cy = (Font.default_size - contents.font.size) / 2 + 1
- draw_text(dx+2, dy+cy, 30, line_height, Vocab::tp_a)
- change_color(tp_color(actor))
- draw_text(dx + width - 42, dy+cy, 42, line_height, actor.tp.to_i, 2)
- end
- end
- class Window_BattleActor < Window_BattleStatus
- def show
- create_flags
- super
- end
- def create_flags
- set_select_flag(:any)
- select(0)
- return if $game_temp.battle_aid.nil?
- if $game_temp.battle_aid.need_selection?
- select(0)
- set_select_flag(:dead) if $game_temp.battle_aid.for_dead_friend?
- elsif $game_temp.battle_aid.for_user?
- battler = BattleManager.actor
- id = battler.nil? ? 0 : $game_party.battle_members.index(battler)
- select(id)
- set_select_flag(:user)
- elsif $game_temp.battle_aid.for_all?
- select(0)
- set_select_flag(:all)
- set_select_flag(:all_dead) if $game_temp.battle_aid.for_dead_friend?
- elsif $game_temp.battle_aid.for_random?
- select(0)
- set_select_flag(:random) if $game_temp.battle_aid.for_random?
- end
- end
- def set_select_flag(flag)
- @select_flag = flag
- case @select_flag
- when :all, :all_dead, :random
- @cursor_all = true
- else
- @cursor_all = false
- end
- end
- def update_cursor
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, contents.height)
- self.top_row = 0
- elsif [url=home.php?mod=space&uid=370741]@Index[/url] < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- cursor_rect.set(item_rect(@index))
- end
- end
- def cursor_movable?
- return false if @select_flag == :user
- return super
- end
- def current_item_enabled?
- return true if $game_temp.battle_aid.nil?
- if $game_temp.battle_aid.need_selection?
- member = $game_party.battle_members[@index]
- return member.dead? if $game_temp.battle_aid.for_dead_friend?
- elsif $game_temp.battle_aid.for_dead_friend?
- for member in $game_party.battle_members
- return true if member.dead?
- end
- return false
- end
- return true
- end
- end
- class Window_BattleStatusAid < Window_BattleStatus
- attr_accessor :status_window
- def initialize
- super
- self.visible = false
- self.openness = 255
- end
- def window_width; return 128; end
- def show
- super
- refresh
- end
- def refresh
- contents.clear
- return if @status_window.nil?
- draw_item(@status_window.index)
- end
- def item_rect(index)
- return Rect.new(0, 0, contents.width, contents.height)
- end
- end
- class Window_BattleEnemy < Window_Selectable
- def initialize(info_viewport)
- super(0, Graphics.height, window_width, fitting_height(1))
- refresh
- self.visible = false
- @info_viewport = info_viewport
- end
- def col_max; return item_max; end
- def show
- create_flags
- super
- end
- def create_flags
- set_select_flag(:any)
- select(0)
- return if $game_temp.battle_aid.nil?
- if $game_temp.battle_aid.need_selection?
- select(0)
- elsif $game_temp.battle_aid.for_all?
- select(0)
- set_select_flag(:all)
- elsif $game_temp.battle_aid.for_random?
- select(0)
- set_select_flag(:random)
- end
- end
- def set_select_flag(flag)
- @select_flag = flag
- case @select_flag
- when :all, :random
- @cursor_all = true
- else
- @cursor_all = false
- end
- end
- def select_all?
- return true if @select_flag == :all
- return true if @select_flag == :random
- return false
- end
- def update_cursor
- if @cursor_all
- cursor_rect.set(0, 0, contents.width, contents.height)
- self.top_row = 0
- elsif @index < 0
- cursor_rect.empty
- else
- ensure_cursor_visible
- cursor_rect.set(item_rect(@index))
- end
- end
- def cursor_movable?
- return false if @select_flag == :user
- return super
- end
- def current_item_enabled?
- return true if $game_temp.battle_aid.nil?
- if $game_temp.battle_aid.need_selection?
- member = $game_party.battle_members[@index]
- return member.dead? if $game_temp.battle_aid.for_dead_friend?
- elsif $game_temp.battle_aid.for_dead_friend?
- for member in $game_party.battle_members
- return true if member.dead?
- end
- return false
- end
- return true
- end
- def enemy; @data[index]; end
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- def make_item_list
- @data = $game_troop.alive_members
- @data.sort! { |a,b| a.screen_x <=> b.screen_x }
- end
- def draw_item(index); return; end
- def update
- super
- return unless active
- enemy.sprite_effect_type = :whiten
- return unless select_all?
- for enemy in $game_troop.alive_members
- enemy.sprite_effect_type = :whiten
- end
- end
- end
- class Window_BattleHelp < Window_Help
- attr_accessor :actor_window
- attr_accessor :enemy_window
- def update
- super
- if !self.visible and @text != ""
- @text = ""
- return refresh
- end
- update_battler_name
- end
- def update_battler_name
- return unless @actor_window.active || @enemy_window.active
- if @actor_window.active
- battler = $game_party.battle_members[@actor_window.index]
- elsif @enemy_window.active
- battler = @enemy_window.enemy
- end
- if special_display?
- refresh_special_case(battler)
- else
- refresh_battler_name(battler) if battler_name(battler) != @text
- end
- end
- def battler_name(battler)
- text = battler.name.clone
- return text
- end
- def refresh_battler_name(battler)
- contents.clear
- reset_font_settings
- change_color(normal_color)
- @text = battler_name(battler)
- icons = battler.state_icons + battler.buff_icons
- dy = icons.size <= 0 ? line_height / 2 : 0
- draw_text(0, dy, contents.width, line_height, @text, 1)
- dx = (contents.width - (icons.size * 24)) / 2
- draw_actor_icons(battler, dx, line_height, contents.width)
- end
- def special_display?
- return false if $game_temp.battle_aid.nil?
- return false if $game_temp.battle_aid.for_user?
- return !$game_temp.battle_aid.need_selection?
- end
- def refresh_special_case(battler)
- if $game_temp.battle_aid.for_opponent?
- if $game_temp.battle_aid.for_all?
- text = YEA::BATTLE::HELP_TEXT_ALL_FOES
- else
- case $game_temp.battle_aid.number_of_targets
- when 1
- text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_FOE
- else
- number = $game_temp.battle_aid.number_of_targets
- text = sprintf(YEA::BATTLE::HELP_TEXT_MANY_RANDOM_FOE, number)
- end
- end
- else
- if $game_temp.battle_aid.for_dead_friend?
- text = YEA::BATTLE::HELP_TEXT_ALL_DEAD_ALLIES
- elsif $game_temp.battle_aid.for_random?
- case $game_temp.battle_aid.number_of_targets
- when 1
- text = YEA::BATTLE::HELP_TEXT_ONE_RANDOM_ALLY
- else
- number = $game_temp.battle_aid.number_of_targets
- text = sprintf(YEA::BATTLE::HELP_TEXT_RANDOM_ALLIES, number)
- end
- else
- text = YEA::BATTLE::HELP_TEXT_ALL_ALLIES
- end
- end
- return if text == @text
- @text = text
- contents.clear
- reset_font_settings
- draw_text(0, 0, contents.width, line_height*2, @text, 1)
- end
- end
- class Window_SkillList < Window_Selectable
- def spacing
- return 8 if $game_party.in_battle
- return super
- end
- end
- class Window_ItemList < Window_Selectable
- def spacing
- return 8 if $game_party.in_battle
- return super
- end
- end
- class Scene_Battle < Scene_Base
- attr_accessor :enemy_window
- attr_accessor :info_viewport
- attr_accessor :spriteset
- attr_accessor :status_window
- attr_accessor :status_aid_window
- attr_accessor :subject
- alias scene_battle_create_all_windows_abe create_all_windows
- def create_all_windows
- scene_battle_create_all_windows_abe
- create_battle_status_aid_window
- set_help_window
- end
- alias scene_battle_create_info_viewport_abe create_info_viewport
- def create_info_viewport
- scene_battle_create_info_viewport_abe
- @status_window.refresh
- end
- def create_battle_status_aid_window
- @status_aid_window = Window_BattleStatusAid.new
- @status_aid_window.status_window = @status_window
- @status_aid_window.x = Graphics.width - @status_aid_window.width
- @status_aid_window.y = Graphics.height - @status_aid_window.height
- end
- def create_help_window
- @help_window = Window_BattleHelp.new
- @help_window.hide
- end
- def set_help_window
- @help_window.actor_window = @actor_window
- @help_window.enemy_window = @enemy_window
- end
- alias scene_battle_create_skill_window_abe create_skill_window
- def create_skill_window
- scene_battle_create_skill_window_abe
- @skill_window.height = @info_viewport.rect.height
- @skill_window.width = Graphics.width - @actor_command_window.width
- @skill_window.y = Graphics.height - @skill_window.height
- end
- alias scene_battle_create_item_window_abe create_item_window
- def create_item_window
- scene_battle_create_item_window_abe
- @item_window.height = @skill_window.height
- @item_window.width = @skill_window.width
- @item_window.y = Graphics.height - @item_window.height
- end
- alias scene_battle_next_command_abe next_command
- def next_command
- @status_window.show
- redraw_current_status
- @actor_command_window.show
- @status_aid_window.hide
- scene_battle_next_command_abe
- end
- alias scene_battle_prior_command_abe prior_command
- def prior_command
- redraw_current_status
- scene_battle_prior_command_abe
- end
- def redraw_current_status
- return if @status_window.index < 0
- @status_window.draw_item(@status_window.index)
- end
- alias scene_battle_command_attack_abe command_attack
- def command_attack
- $game_temp.battle_aid = $data_skills[BattleManager.actor.attack_skill_id]
- scene_battle_command_attack_abe
- end
- alias scene_battle_command_skill_abe command_skill
- def command_skill
- scene_battle_command_skill_abe
- @status_window.hide
- @actor_command_window.hide
- @status_aid_window.show
- end
- alias scene_battle_command_item_abe command_item
- def command_item
- scene_battle_command_item_abe
- @status_window.hide
- @actor_command_window.hide
- @status_aid_window.show
- end
- def on_skill_ok
- [url=home.php?mod=space&uid=260100]@skill[/url] = @skill_window.item
- $game_temp.battle_aid = @skill
- BattleManager.actor.input.set_skill(@skill.id)
- BattleManager.actor.last_skill.object = @skill
- if @skill.for_opponent?
- select_enemy_selection
- elsif @skill.for_friend?
- select_actor_selection
- else
- @skill_window.hide
- next_command
- $game_temp.battle_aid = nil
- end
- end
- alias scene_battle_on_skill_cancel_abe on_skill_cancel
- def on_skill_cancel
- scene_battle_on_skill_cancel_abe
- @status_window.show
- @actor_command_window.show
- @status_aid_window.hide
- end
- def on_item_ok
- @item = @item_window.item
- $game_temp.battle_aid = @item
- BattleManager.actor.input.set_item(@item.id)
- if @item.for_opponent?
- select_enemy_selection
- elsif @item.for_friend?
- select_actor_selection
- else
- @item_window.hide
- next_command
- $game_temp.battle_aid = nil
- end
- $game_party.last_item.object = @item
- end
- alias scene_battle_on_item_cancel_abe on_item_cancel
- def on_item_cancel
- scene_battle_on_item_cancel_abe
- @status_window.show
- @actor_command_window.show
- @status_aid_window.hide
- end
- alias scene_battle_select_actor_selection_abe select_actor_selection
- def select_actor_selection
- @status_aid_window.refresh
- scene_battle_select_actor_selection_abe
- @status_window.hide
- @skill_window.hide
- @item_window.hide
- @help_window.show
- end
- alias scene_battle_on_actor_ok_abe on_actor_ok
- def on_actor_ok
- $game_temp.battle_aid = nil
- scene_battle_on_actor_ok_abe
- @status_window.show
- if $imported["YEA-BattleCommandList"] && !@confirm_command_window.nil?
- @actor_command_window.visible = !@confirm_command_window.visible
- else
- @actor_command_window.show
- end
- @status_aid_window.hide
- end
- alias scene_battle_on_actor_cancel_abe on_actor_cancel
- def on_actor_cancel
- BattleManager.actor.input.clear
- @status_aid_window.refresh
- $game_temp.battle_aid = nil
- scene_battle_on_actor_cancel_abe
- case @actor_command_window.current_symbol
- when :skill
- @skill_window.show
- when :item
- @item_window.show
- end
- end
- alias scene_battle_select_enemy_selection_abe select_enemy_selection
- def select_enemy_selection
- @status_aid_window.refresh
- scene_battle_select_enemy_selection_abe
- @help_window.show
- end
- alias scene_battle_on_enemy_ok_abe on_enemy_ok
- def on_enemy_ok
- $game_temp.battle_aid = nil
- scene_battle_on_enemy_ok_abe
- end
- alias scene_battle_on_enemy_cancel_abe on_enemy_cancel
- def on_enemy_cancel
- BattleManager.actor.input.clear
- @status_aid_window.refresh
- $game_temp.battle_aid = nil
- scene_battle_on_enemy_cancel_abe
- if @skill_window.visible || @item_window.visible
- @help_window.show
- else
- @help_window.hide
- end
- end
- def end_battle_conditions?
- return true if $game_party.members.empty?
- return true if $game_party.all_dead?
- return true if $game_troop.all_dead?
- return true if BattleManager.aborting?
- return false
- end
- def refresh_status
- #如果你是程序员,请顺手帮忙优化下这里,谢谢。
- @status_window.refresh
- for i in $game_party.battle_members
- @status_window.draw_item($game_party.battle_members.index(i))
- end
- end
- end
复制代码 加上圖書館的cp戰鬥系統- #==============================================================================
- # ●CP制战斗
- # 原作者:桜雅 在土, 和希 (XP版CP制),韩云溪(AT即时战斗)
- # 修改:pigsss
- # 更新日期:2012.05.09
- # 一个简单的cp战斗系统
- # 好吧,我还是不明白为什么那么多人喜欢用…
-
- # ·加强兼容性
- # ·修正先制/被偷袭bug
- # ·修正敌人隐藏bug
- # ·修正逃跑失败bug
-
- # ■✖ !注意-------------------------
- # ·敌人特殊能力【增加行动次数】不可用│
- # ---------------------------------
- #==============================================================================
- module CP
- #
- # 基本能力消耗的CP值
- #
- CP_COST_SKILL_ITEM_ACTION = 65535 # 技能 物品
- CP_COST_BASIC_ATTACK = 32768 # 攻撃
- CP_COST_BASIC_GUARD = 32768 # 防御
- CP_COST_BASIC_ESCAPE = 65535 #逃跑
- end
- #==============================================================================
- # □ CP_Thread
- #==============================================================================
- class CP_Thread
-
- # 战斗速度
- #
- BATTLE_SPEED = 1.0
- #
- # 战斗开始的时候气槽百分比
- #
- START_CP_PERCENT = 10
- #
- # CP满时的音效
- #
- FULL_SE = "Audio/SE/open1"
- #--------------------------------------------------------------------------
- # ○ 变量公开
- #--------------------------------------------------------------------------
- attr_accessor :stop # CP加算ストップ
- #----------------------------------------------------------------------------
- # ○ 初始化
- #----------------------------------------------------------------------------
- def initialize
- @battlers = []
- [url=home.php?mod=space&uid=9053]@cancel[/url] = false
- [url=home.php?mod=space&uid=76426]@stop[/url] = false
- @agi_total = 0
- # 配列 count_battlers を初期化
- count_battlers = []
- # エネミーを配列 count_battlers に追加
- for enemy in $game_troop.members
- count_battlers.push(enemy)
- end
- # アクターを配列 count_battlers に追加
- for actor in $game_party.battle_members
- count_battlers.push(actor)
- end
- for battler in count_battlers
- @agi_total += battler.agi
- end
-
- for battler in count_battlers
- battler.cp = [[65535 * START_CP_PERCENT * (rand(15) + 85) * 4 * battler.agi / @agi_total / 10000, 0].max, 65535].min
- battler.turn_count = 0
- end
- end
- #----------------------------------------------------------------------------
- # ○ CP更新
- #----------------------------------------------------------------------------
- def update
- # 停止刷新
- return if @stop
- #
- for battler in $game_party.battle_members + $game_troop.members
- # 行動出来なければ無視
- if battler.dead? || battler.hidden?
- battler.cp = 0
- next
- end
-
-
- battler.cp = [[battler.cp + BATTLE_SPEED * 2048 * battler.agi / @agi_total, 0].max, 65535].min
-
- # CP满时
-
- if battler.cp >= battler.max_cp
- Audio.se_play(FULL_SE)
- BattleManager.set_enable_go(battler)
- battler.my_turn = true
- BattleManager.input_start
- break
- end
- unless BattleManager.cp_updating?
- return
- end
-
- end
-
- def update?
- return !@stop
- end
- end
-
- #----------------------------------------------------------------------------
- # ○ CPカウントの開始
- #----------------------------------------------------------------------------
- def stop
- @cancel = true
- if @cp_thread != nil then
- @cp_thread.join
- @cp_thread = nil
- end
- end
- end
- #==============================================================================
- # ■ Game_BattlerBase
- #------------------------------------------------------------------------------
- # 管理战斗者的类。主要含有能力值计算的方法。Game_Battler 类的父类。
- #==============================================================================
- class Game_BattlerBase
- attr_reader :cp # CP
- attr_accessor :turn_count
- attr_accessor :my_turn
- include CP
- #------------------------------
- alias old_initialize initialize
- def initialize
- old_initialize
- @cp = 0
- @turn_count = 0
- @my_turn = false
- end
- #------------------------------
- def inputable?
- if @my_turn
- return normal? && !auto_battle?# && @cp >= 65535
- else
- return false
- end
- end
- #--------------------------------------------------------------------------
- # ● 更改 CP
- #--------------------------------------------------------------------------
- def cp=(cp)
- @cp = [[cp, max_cp].min, 0].max
- end
- #--------------------------------------------------------------------------
- # ● 获取 CP 的最大值
- #--------------------------------------------------------------------------
- def max_cp
- return 65535
- end
- #--------------------------------------------------------------------------
- # ● 获取 CP 的比率
- #--------------------------------------------------------------------------
- def cp_rate
- @cp.to_f / 65535
- end
- #--------------------------------------------------------------------------
- # ● 扣除技能的使用消耗
- #--------------------------------------------------------------------------
- alias :old_pay_skill_cost :pay_skill_cost
- def pay_skill_cost(skill)
- old_pay_skill_cost(skill)
- ###########
- case skill.id
- when 1
- @cp -= CP_COST_BASIC_ATTACK
- when 2
- @cp -= CP_COST_BASIC_GUARD
- when 3
- @cp -= CP_COST_SKILL_ITEM_ACTION
- when 4...999 # 可自订不同消耗的技能
- @cp -= 49151
- else
- @cp = 0
- end
- ###########
- end
- end
- #--------------------------------------------------------
- class Game_Battler < Game_BattlerBase
- include CP
- #--------------------------------------------------------------------------
- # ● 消耗物品
- #--------------------------------------------------------------------------
- alias :old_consume_item :consume_item
- def consume_item(item)
- old_consume_item(item)
- ###########
- case item.id
- when 0...999 # 可自订不同消耗的物品
- @cp -= CP_COST_SKILL_ITEM_ACTION
- else
- @cp = 0
- end
- ###########
- end
- end
- #-------------------------------------
- class Game_Party < Game_Unit
- def make_action(member)
- unless member == nil
- member.make_actions unless member.inputable?
- end
- end
- end
- #-------------------------------------
- class Game_Troop < Game_Unit
- def make_action(member)
- member.make_actions unless member == nil
- end
-
- def increase_turn(enemy)
- troop.pages.each {|page| @event_flags= false if page.span == 1 }
- enemy.turn_count += 1
- aaa = []
- for iii in $game_troop.members
- aaa.push(iii.turn_count)
- end
- @turn_count = aaa.max
- end
- end
- #-------------------------------------
- module BattleManager
- def self.battle_start
- $game_system.battle_count += 1
- $game_party.on_battle_start
- $game_troop.on_battle_start
- $game_troop.enemy_names.each do |name|
- $game_message.add(sprintf(Vocab::Emerge, name))
- end
-
- if @preemptive
- $game_message.add(sprintf(Vocab::Preemptive, $game_party.name))
- for b in $game_troop.members
- if !b.hidden?
- b.cp = 0
- end
- end
- for b in $game_party.battle_members
- if !b.hidden?
- b.cp = b.max_cp
- end
- end
- elsif @surprise
- $game_message.add(sprintf(Vocab::Surprise, $game_party.name))
- for b in $game_troop.members
- if !b.hidden?
- b.cp = b.max_cp
- end
- end
- for b in $game_party.battle_members
- if !b.hidden?
- b.cp = 0
- end
- end
- end
- wait_for_message
- end
-
- def self.enable_go
- @enable_go
- end
-
- def self.set_enable_go(b)
- @enable_go = b
- end
-
- def self.enable_go_clear
- @enable_go = nil
- end
-
- def self.max_agi
- @max_agi
- end
-
- def self.cp_updation
- @phase = :cp_update
- end
-
- def self.cp_updating?
- @phase == :cp_update
- end
- #--------------------------------------------------------------------------
- # ● 重定义:开始输入指令
- #--------------------------------------------------------------------------
- def self.input_start
- if @phase != :input
- @phase = :input
- $game_party.make_actions
- $game_troop.make_actions
- clear_actor
- end
- return $game_party.inputable?
- end
- #-------------------------------------------------------------------------
- # ● 重定义:回合开始
- #------------------------------------------------------------------------
- def self.turn_start
- @phase = :turn
- clear_actor
- make_action_orders
- end
- #-------------------------------------------------------------------------
- # ● 重定义:行动顺序
- #------------------------------------------------------------------------
- def self.make_action_orders
- @action_battlers = []
- for b in $game_troop.members + $game_party.battle_members
- if b.my_turn
- @action_battlers.push(b)
- end
- end
- exclude_battler = []
- for battler in @action_battlers
- if battler.cp < 65535
- exclude_battler.push(battler)
- end
- end
- @action_battlers -= exclude_battler
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 游戏中所有窗口的父类
- #==============================================================================
-
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 获取颜色
- #--------------------------------------------------------------------------
- def cp_gauge_color1; Color.new(0,100,250); end; # CP 值槽 1
- def cp_gauge_color2; Color.new(0,100,200); end; # CP 值槽 2
- #--------------------------------------------------------------------------
- # ● 绘制值槽(长宽自由版)
- # rate : 比率(1.0 为满值)
- # color1 : 渐变色的左端
- # color2 : 渐变色的右端
- #--------------------------------------------------------------------------
- def draw_gauge_free(x, y, width, rate, color1, color2, height)
- fill_w = (width * rate).to_i
- gauge_y = y + line_height - 8
- contents.fill_rect(x, gauge_y, width, height, gauge_back_color)
- contents.gradient_fill_rect(x, gauge_y, fill_w, height, color1, color2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制 CP
- #--------------------------------------------------------------------------
- def draw_actor_cp(actor, x, y, width = 124, height)
- draw_gauge_free(x, y, width, actor.cp_rate, cp_gauge_color1, cp_gauge_color2, height)
- change_color(system_color)
- end
- end
- ####################################
-
- class Window_CP < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, window_width, window_height)
- refresh
- self.openness = 0
- self.opacity = 200
- self.contents_opacity = 200
- end
-
-
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- 64
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的高度
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(visible_line_number)
- end
- #--------------------------------------------------------------------------
- # ● 获取显示行数
- #--------------------------------------------------------------------------
- def visible_line_number
- return 4
- end
- #--------------------------------------------------------------------------
- # ● 获取项目数
- #--------------------------------------------------------------------------
- def item_max
- $game_party.battle_members.size
- end
-
- #--------------------------------------------------------------------------
- # ● 获取值槽区域的宽度
- #--------------------------------------------------------------------------
- def gauge_area_width
- return 40
- end
- #--------------------------------------------------------------------------
- # ● 获取值槽区域的矩形
- #--------------------------------------------------------------------------
- def gauge_area_rect(index)
- rect = item_rect_for_text(index)
- rect.x += rect.width - gauge_area_width
- rect.width = gauge_area_width
- rect
- end
- #~ #--------------------------------------------------------------------------
- #~ # ● 绘制项目
- #~ #--------------------------------------------------------------------------
- #~ def draw_item(index)
- #~ actor = $game_party.battle_members[index]
- #~ rect = gauge_area_rect(index) ##
- #~ draw_actor_cp(actor, rect.x - 165, rect.y - 10, 100, 16) ##
- #~ draw_basic_area(basic_area_rect(index), actor)
- #~ draw_gauge_area(gauge_area_rect(index), actor)
- #~ end
- #--------------------------------------------------------------------------
- # ● 绘制项目
- #--------------------------------------------------------------------------
- def draw_cp(index)
- actor = $game_party.battle_members[index]
- rect = gauge_area_rect(index) ##
- draw_actor_cp(actor, rect.x , rect.y - 10, 40, 10) ##
- end
- #--------------------------------------------------------------------------
- # ● 绘制所有项目
- #--------------------------------------------------------------------------
- def draw_all_items_cp
- item_max.times {|i| draw_cp(i) }
- end
-
- def refresh_cp
- contents.clear
- draw_all_items_cp
- end
-
- end
- #---------------------------------------------------------------------------
-
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 重定义:开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_spriteset
- create_all_windows
- BattleManager.method_wait_for_message = method(:wait_for_message)
- @cp_thread = CP_Thread.new
- end
- #--------------------------------------------------------------------------
- # ● 重定义:开始后处理
- #--------------------------------------------------------------------------
- def post_start
- super
- battle_start
- @cp_thread.stop = false #
- end
- #--------------------------------------------------------------------------
- # ● 重定义:信息窗口打开时的更新
- # 在状态窗口关闭完成前,信息窗口的打开度设置为 0 。
- #--------------------------------------------------------------------------
- def update_message_open
- if $game_message.busy? && !@status_window.close?
- @message_window.openness = 0
- @status_window.close
- @party_command_window.close
- @actor_command_window.close
- @cp_window.close
- end
- end
- #--------------------------------------------------------------------------
- # ● 生成所有窗口
- #--------------------------------------------------------------------------
- alias :o_create_all_windows :create_all_windows
- def create_all_windows
- o_create_all_windows
- create_CP_window
- create_name_window
- end
- #--------------------------------------------------------------------------
- # ● 生成名字窗口
- #--------------------------------------------------------------------------
- def create_name_window
- @name_window = Window_Name.new
- @name_window.y = 250 + Graphics.height - 416
- end
- #--------------------------------------------------------------------------
- # ● 生成状态窗口
- #--------------------------------------------------------------------------
- def create_CP_window
- @cp_window = Window_CP.new
- @cp_window.x = 0
- @cp_window.y = Graphics.height - 120
- end
- #--------------------------------------------------------------------------
- # ● 重定义:开始角色指令的选择
- #--------------------------------------------------------------------------
- def start_actor_command_selection
- @status_window.select(BattleManager.actor.index)
- @party_command_window.close
- @actor_command_window.setup(BattleManager.actor)
- @name_window.setup(BattleManager.actor)
- @name_window.open
- end
-
- #-------------------------------------------------------------------------
- # ● 当cp满时的操作
- #------------------------------------------------------------------------
- def on_cp_full
- BattleManager.cp_updation
- if BattleManager.enable_go.is_a?(Game_Actor) and
- BattleManager.enable_go.inputable?
- BattleManager.enable_go.on_turn_end
- refresh_status
- start_party_command_selection
- @cp_window.close
- else
- if BattleManager.enable_go.is_a?(Game_Actor)
- BattleManager.enable_go.on_turn_end
- $game_party.make_action(BattleManager.enable_go)
- turn_start
- elsif BattleManager.enable_go.is_a?(Game_Enemy)
- BattleManager.enable_go.on_turn_end
- $game_troop.make_action(BattleManager.enable_go)
- $game_troop.increase_turn(BattleManager.enable_go)
- turn_start
- end
- end
- BattleManager.enable_go_clear
- end
- #-------------------------------------------------------------------------
- # ● 重定义:战斗开始
- #------------------------------------------------------------------------
- def battle_start
- BattleManager.battle_start
- process_event
- unless scene_changing?
- @status_window.unselect
- @status_window.open
- @cp_window.unselect
- @cp_window.open
- end
- on_cp_full
- end
- #-------------------------------------------------------------------------
- # ● cp刷新
- #------------------------------------------------------------------------
- def refresh_cp
- if @cp_thread.update?
- @cp_window.refresh_cp
- end
- end
- #--------------------------------------------------------------------------
- # ● 指令“撤退”
- #--------------------------------------------------------------------------
- def command_escape
- turn_start unless BattleManager.process_escape
- for a in $game_party.battle_members
- a.cp -= CP::CP_COST_BASIC_ESCAPE
- end
- end
- #-------------------------------------------------------------------------
- # ● 重定义:画面更新
- #------------------------------------------------------------------------
- def update
- super
- if BattleManager.cp_updating?
- @cp_thread.update
- #refresh_status
- refresh_cp
- on_cp_full
- elsif BattleManager.in_turn?
- process_event
- on_cp_full
- process_action
- end
-
- BattleManager.judge_win_loss
-
- end
- #--------------------------------------------------------------------------
- # ● 重定义:处理战斗行动
- #--------------------------------------------------------------------------
- def process_action
- @cp_thread.stop = true
- return if scene_changing?
- if !@subject || !@subject.current_action
- @subject = BattleManager.next_subject
- end
- return turn_end unless @subject
- if @subject.current_action
- @subject.current_action.prepare
- if @subject.current_action.valid?
- @status_window.open
- execute_action
- end
- @subject.remove_current_action
- end
- process_action_end unless @subject.current_action
- end
- #-------------------------------------------------------------------------
- # ● 重定义:行动结束
- #------------------------------------------------------------------------
- def process_action_end
- @subject.on_action_end
- @subject.my_turn = false
- if @subject.cp >= 65535
- @subject.cp = 0
- end
- refresh_status
- @log_window.display_auto_affected_status(@subject)
- @log_window.wait_and_clear
- @log_window.display_current_state(@subject)
- @log_window.wait_and_clear
- BattleManager.judge_win_loss
- @subject = nil
- @cp_thread.stop = false ###########
- end
- #--------------------------------------------------------------------------
- # ● 重定义:回合开始
- #--------------------------------------------------------------------------
- def turn_start
- @party_command_window.close
- @actor_command_window.close
- @name_window.close
- @cp_window.open #
- @status_window.unselect
- BattleManager.turn_start
- @log_window.wait
- @log_window.clear
- end
- #-------------------------------------------------------------------------
- # ● 重定义:回合结束
- #------------------------------------------------------------------------
- def turn_end
- all_battle_members.each do |battler|
- refresh_status
- @log_window.display_auto_affected_status(battler)
- @log_window.wait_and_clear
- end
- BattleManager.turn_end
- process_event
- on_cp_full
- end
- end
- class Window_Name < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(Graphics.width - 128, 0, window_width, fitting_height(1))
- self.openness = 0
- @actor = nil
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return 128
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- draw_actor_name(@actor, 0 , 0, 100)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def setup(actor)
- @actor = actor
- end
- #--------------------------------------------------------------------------
- # ● 打开窗口
- #--------------------------------------------------------------------------
- def open
- refresh
- super
- end
- end
- #==============================================================================
- # ■ Window_Base
- #------------------------------------------------------------------------------
- # 游戏中所有窗口的父类
- #==============================================================================
-
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 绘制角色肖像图
- # enabled : 有效的标志。false 的时候使用半透明效果绘制
- #--------------------------------------------------------------------------
- def draw_face_b(face_name, face_index, x, y, enabled = false)
- bitmap = Cache.face(face_name)
- rect = Rect.new(face_index % 4 * 96 ,face_index / 4 * 96 + 40, 96, 20)
- contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制角色肖像图
- #--------------------------------------------------------------------------
- def draw_actor_face_b(actor, x, y, enabled = true)
- draw_face_b(actor.face_name, actor.face_index, x, y, enabled)
- end
- end
- #==============================================================================
- # ■ Window_BattleStatus
- #------------------------------------------------------------------------------
- # 战斗画面中,显示“队伍成员状态”的窗口。
- #==============================================================================
- class Window_BattleStatus < Window_Selectable
-
-
- #--------------------------------------------------------------------------
- # ● 绘制基本区域
- #--------------------------------------------------------------------------
- def draw_basic_area(rect, actor)
- index = $game_party.members.index(actor)
- #draw_actor_face_b(actor, rect.x , rect.y + index * (0) + 4)
- draw_actor_name(actor, rect.x , rect.y, 100)
- draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
- end
- end
复制代码 |
|