|
点此看截图- #====================================================
- # 制作:夜无边
- # 版本:1。01
- # 冲突可能:未知,战斗类的脚本都可能。有问题请联系本人:
- # QQ:315339915,E-mail:[email]s065741@mailserv.cuhk.edu.hk[/email]
- # MSN: [email]lvqing1988@hotmail.com[/email]
- # 说明:把本脚本插入MAIN之前,平时战斗按C就可以呼出菜单。
- # 附注:本脚本附带了一个画血条的draw_meter,是从别人的脚本里截取出来的= =
- # 但我自己也忘记了具体是哪个脚本……于是向该作者表示感谢……(OJZ)
- # 关于蓄力速度的计算方法,默认是速度(agi)和一个固定值的反比。
- # 如有更好的方法请告诉我……
- #====================================================
- module LVQING
- ATTACK=0 #在无法使用特技或道具时是否使用0普通攻击/1防御/2什么也不做
-
- SPEED=1 #蓄劲速度比例,1为平时,小于1为慢,大于1为快
-
- # 回合的计算方式,0为按人数计算,每人行动完毕算一回合,1为按时间算,
- # 固定循环了某一祯数为一回合,循环数在下边TIME设定。
- # 主要是为了方便设置战斗事件和考虑不能行动的状态。
- TURN=1
- TIME=100
-
- #这个最好不要改,是设定一次攻击之后,隔多少祯才能再按出菜单来。
- # 为0的话会有问题的……不然自己试试就明白了= =bb
- INPUT=20
- end
- #====================================================
- class Game_Battler
- attr_accessor :ct
- attr_accessor :maxct
- def initialize
- @battler_name = ""
- @battler_hue = 0
- @hp = 0
- @sp = 0
- @states = []
- @states_turn = {}
- @maxhp_plus = 0
- @maxsp_plus = 0
- @str_plus = 0
- @dex_plus = 0
- @agi_plus = 0
- @int_plus = 0
- @hidden = false
- @immortal = false
- @damage_pop = false
- @damage = nil
- @critical = false
- @animation_id = 0
- @animation_hit = false
- @white_flash = false
- @blink = false
- @current_action = Game_BattleAction.new
- @ct=0
- @maxct=0
- end
- #--------------------------------------------------------------------------
- # ● 获取 MaxCT
- #--------------------------------------------------------------------------
- def maxct
- n=10000
- return n
- end
- #--------------------------------------------------------------------------
- end
- class Window_Base < Window
-
- #--------------------------------------------------------------------------
- # ○ ゲージを描画
- #--------------------------------------------------------------------------
- def draw_meter(now, max, x, y, width, height, start_color, end_color=start_color )
- color=Color.new(128, 128, 128, 128)
- color1 = Color.new(192, 192, 192, 255)
- self.contents.fill_rect(x, y, width, height, color1)
- self.contents.fill_rect(x+1,y+1, width-1*2, height-1*2, color)
- now = now > max ? max : now
- percentage = max != 0 ? (width-2) * now / max.to_f : 0
- if start_color == end_color
- self.contents.fill_rect(x+1, y+1, percentage, height-2, start_color)
- else
- for i in 1..percentage
- r = start_color.red + (end_color.red - start_color.red) / percentage * i
- g = start_color.green + (end_color.green - start_color.green) / percentage * i
- b = start_color.blue + (end_color.blue - start_color.blue) / percentage * i
- a = start_color.alpha + (end_color.alpha - start_color.alpha) / percentage * i
- self.contents.fill_rect(x+i, y+1, 1, height-2, Color.new(r, g, b, a))
- end
- end
- end
- end
- #==============================================================================
- # ■ Scene_Battle (分割定义 1)
- #------------------------------------------------------------------------------
- # 处理战斗画面的类。
- #==============================================================================
- class Scene_Battle
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def main
- @jjudge=LVQING::INPUT
- @st=0
- # 初始化战斗用的各种暂时数据
- $game_temp.in_battle = true
- $game_temp.battle_turn = 0
- $game_temp.battle_event_flags.clear
- $game_temp.battle_abort = false
- $game_temp.battle_main_phase = false
- $game_temp.battleback_name = $game_map.battleback_name
- $game_temp.forcing_battler = nil
- #-----------------------------------
- # 初始化战斗用事件解释器
- $game_system.battle_interpreter.setup(nil, 0)
- # 准备队伍
- @active_actor
- @action_battlers=[]
- @troop_id = $game_temp.battle_troop_id
- $game_troop.setup(@troop_id)
- # 生成角色命令窗口
- s1 = $data_system.words.attack
- s2 = $data_system.words.skill
- s3 = $data_system.words.guard
- s4 = $data_system.words.item
- @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,"逃跑"])
- @actor_command_window.y = 128
- @actor_command_window.active = false
- @actor_command_window.visible = false
- # 生成其它窗口
- @help_window = Window_Help.new
- @help_window.back_opacity = 160
- @help_window.visible = false
- @status_window = Window_BattleStatus.new
- @message_window = Window_Message.new
- for battler in $game_party.actors
- battler.ct=rand(100)
- end
- for battler in $game_troop.enemies
- battler.ct=rand(100)
- end
- # 生成活动块
- @spriteset = Spriteset_Battle.new
- # 初始化等待计数
- @wait_count = 0
- # 执行过渡
- if $data_system.battle_transition == ""
- Graphics.transition(20)
- else
- Graphics.transition(40, "Graphics/Transitions/" +
- $data_system.battle_transition)
- end
- # 开始自由战斗回合
- start_phase1
- # 主循环
- loop do
- # 刷新游戏画面
- Graphics.update
- # 刷新输入信息
- Input.update
- # 刷新画面
- update
- # 如果画面切换的话就中断循环
- if $scene != self
- break
- end
- end
- # 刷新地图
- $game_map.refresh
- # 准备过渡
- Graphics.freeze
- @actor_command_window.dispose
- @help_window.dispose
- @status_window.dispose
- @message_window.dispose
- if @skill_window != nil
- @skill_window.dispose
- end
- if @item_window != nil
- @item_window.dispose
- end
- if @result_window != nil
- @result_window.dispose
- end
- # 释放活动块
- @spriteset.dispose
- # 标题画面切换中的情况
- if $scene.is_a?(Scene_Title)
- # 淡入淡出画面
- Graphics.transition
- Graphics.freeze
- end
- # 战斗测试或者游戏结束以外的画面切换中的情况
- if $BTEST and not $scene.is_a?(Scene_Gameover)
- $scene = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- # 执行战斗事件中的情况下
- if $game_system.battle_interpreter.running?
- # 刷新解释器
- $game_system.battle_interpreter.update
- # 强制行动的战斗者不存在的情况下
- if $game_temp.forcing_battler == nil
- # 执行战斗事件结束的情况下
- unless $game_system.battle_interpreter.running?
- # 继续战斗的情况下、再执行战斗事件的设置
- unless judge
- setup_battle_event
- end
- end
- # 如果不是结束战斗回合的情况下
- if @phase != 5
- # 刷新状态窗口
- @status_window.refresh
- end
- end
- end
- # 系统 (计时器)、刷新画面
- $game_system.update
- $game_screen.update
- # 计时器为 0 的情况下
- if $game_system.timer_working and $game_system.timer == 0
- # 中断战斗
- $game_temp.battle_abort = true
- end
- # 刷新窗口
- @help_window.update
- #@party_command_window.update
- @actor_command_window.update
- @status_window.update
- @message_window.update
- # 刷新活动块
- @spriteset.update
- # 处理过渡中的情况下
- if $game_temp.transition_processing
- # 清除处理过渡中标志
- $game_temp.transition_processing = false
- # 执行过渡
- if $game_temp.transition_name == ""
- Graphics.transition(20)
- else
- Graphics.transition(40, "Graphics/Transitions/" +
- $game_temp.transition_name)
- end
- end
- # 显示信息窗口中的情况下
- if $game_temp.message_window_showing
- return
- end
- # 显示效果中的情况下
- if @spriteset.effect?
- return
- end
- # 游戏结束的情况下
- if $game_temp.gameover
- # 切换到游戏结束画面
- $scene = Scene_Gameover.new
- return
- end
- # 返回标题画面的情况下
- if $game_temp.to_title
- # 切换到标题画面
- $scene = Scene_Title.new
- return
- end
- # 中断战斗的情况下
- if $game_temp.battle_abort
- # 还原为战斗前的 BGM
- $game_system.bgm_play($game_temp.map_bgm)
- # 战斗结束
- battle_end(1)
- return
- end
- # 等待中的情况下
- if @wait_count > 0
- # 减少等待计数
- @wait_count -= 1
- return
- end
- # 强制行动的角色存在、
- # 并且战斗事件正在执行的情况下
- if $game_temp.forcing_battler == nil and
- $game_system.battle_interpreter.running?
- return
- end
- update_ct
- # 回合分支
- end
- #--------------------------------------------------------------------------
- # ● 刷新CT
- #--------------------------------------------------------------------------
- def judge_ct
- return @actor_command_window.visible == false && @phase !=3 && @phase != 5 && @phase != 4 && @item_window == nil && @skill_window == nil
- end
- def update_ct
- case @phase
- when 0
- if @jjudge <20
- @jjudge += 1
- end
- when 1 # 自由战斗回合
- update_phase1
- when 3 # 角色命令回合
- update_phase3
- when 4
- update_phase4
- when 5 # 战斗结束回合
- update_phase5
- end
- if judge_ct
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- if actor.movable? && !actor.dead?
- if actor.ct < 10000
- actor.ct += actor.agi/LVQING::SPEED
- else
- @active_actor=actor
- @action_battlers.push(@active_actor)
- actor.ct=0
- # 搜索全页的战斗事件
- for index in 0...$data_troops[@troop_id].pages.size
- # 获取事件页
- page = $data_troops[@troop_id].pages[index]
- # 本页的范围是 [回合] 的情况下
- if page.span == 1
- # 设置已经执行标志
- $game_temp.battle_event_flags[index] = false
- end
- end
- end
- @status_window.refresh_ct(actor)
- end
- end
- for i in 0...$game_troop.enemies.size
- enemy = $game_troop.enemies[i]
- if enemy.movable? && !enemy.dead?
- if enemy.ct < 10000
- enemy.ct += enemy.agi/LVQING::SPEED
- else
- @active_actor=enemy
- @action_battlers.push(@active_actor)
- enemy.ct=0
- # 搜索全页的战斗事件
- for index in 0...$data_troops[@troop_id].pages.size
- # 获取事件页
- page = $data_troops[@troop_id].pages[index]
- # 本页的范围是 [回合] 的情况下
- if page.span == 1
- # 设置已经执行标志
- $game_temp.battle_event_flags[index] = false
- end
- end
- end
- end
- end
- # 自然解除状态
- #==========================================
- if LVQING::TURN == 1
- #@active_battler.remove_states_auto
- if @st < LVQING::TIME
- @st+=1
- else
- $game_temp.battle_turn += 1
- for battler in $game_party.actors
- battler.remove_states_auto
- end
- for battler in $game_troop.enemies
- battler.remove_states_auto
- end
- @st=0
- end
- end
- #==========================================
- if @action_battlers != []
- start_phase4
- end
- if Input.trigger?(Input::C) && judge_ct && (@jjudge == LVQING::INPUT)
- start_phase3
- end
- end
- end
- #======================scene_battle2===============================
- def start_phase1
- # 转移到回合 1
- @phase = 1
- # 清除全体同伴的行动
- $game_party.clear_actions
- # 设置战斗事件
- setup_battle_event
- end
- def update_phase1
- # 胜败判定
- if judge
- # 胜利或者失败的情况下 : 过程结束
- return
- end
- # 开始同伴命令回合
- start_phase3
- end
- def update_phase2_escape
- # 计算敌人速度的平均值
- enemies_agi = 0
- enemies_number = 0
- for enemy in $game_troop.enemies
- if enemy.exist?
- enemies_agi += enemy.agi
- enemies_number += 1
- end
- end
- if enemies_number > 0
- enemies_agi /= enemies_number
- end
- # 计算角色速度的平均值
- actors_agi = 0
- actors_number = 0
- for actor in $game_party.actors
- if actor.exist?
- actors_agi += actor.agi
- actors_number += 1
- end
- end
- if actors_number > 0
- actors_agi /= actors_number
- end
- # 逃跑成功判定
- success = rand(100) < 50 * actors_agi / enemies_agi
- # 成功逃跑的情况下
- if success
- # 演奏逃跑 SE
- $game_system.se_play($data_system.escape_se)
- $game_system.bgm_play($game_temp.map_bgm)
- # 战斗结束
- battle_end(1)
- # 逃跑失败的情况下
- else
- # 清除全体同伴的行动
- # 开始主回合
- @actor_command_window.visible=false
- @actor_command_window.active=false
- end
- end
- def phase3_setup_command_window
- # 角色指令窗口无效化
- @actor_command_window.active = true
- @actor_command_window.visible = true
- # 设置角色指令窗口的位置
- @actor_command_window.x = @actor_index * 160
- # 设置索引为 0
- @actor_command_window.index = 0
- end
- def start_phase3
- @phase = 3
- @actor_index = -1
- @active_battler = nil
- phase3_next_actor
- end
- def phase3_next_actor
- # 循环
- begin
- # 角色的明灭效果 OFF
- if @active_battler != nil
- @active_battler.blink = false
- end
- # 最后的角色的情况
- if @actor_index == $game_party.actors.size-1
- @jjudge=0
- @actor_command_window.active = false
- @actor_command_window.visible = false
- @actor_index=-1
- @phase = 0
- return
- end
- # 推进角色索引
- @actor_index += 1
- @active_battler = $game_party.actors[@actor_index]
- @active_battler.blink = true
- # 如果角色是在无法接受指令的状态就再试
- end until @active_battler.inputable?
- # 设置角色的命令窗口
- phase3_setup_command_window
- end
- def phase3_prior_actor
- # 循环
- begin
- # 角色的明灭效果 OFF
- if @active_battler != nil
- @active_battler.blink = false
- end
- # 最初的角色的情况下
- if @actor_index == 0
- @actor_command_window.visible=false
- @actor_command_window.active=false
- @phase=0
- return
- end
- # 返回角色索引
- @actor_index -= 1
- @active_battler = $game_party.actors[@actor_index]
- @active_battler.blink = true
- # 如果角色是在无法接受指令的状态就再试
- end until @active_battler.inputable?
- # 设置角色的命令窗口
- phase3_setup_command_window
- end
- def phase3_setup_command_window
- # 角色指令窗口无效化
- @actor_command_window.active = true
- @actor_command_window.visible = true
- # 设置角色指令窗口的位置
- @actor_command_window.x = 240
- # 设置索引为 0
- @actor_command_window.index = 0
- end
- end
- class Scene_Battle
- def start_phase4
- # 转移到回合 4
- @phase = 4
- # 回合数计数
- # 搜索全页的战斗事件
- for index in 0...$data_troops[@troop_id].pages.size
- # 获取事件页
- page = $data_troops[@troop_id].pages[index]
- # 本页的范围是 [回合] 的情况下
- if page.span == 1
- # 设置已经执行标志
- $game_temp.battle_event_flags[index] = false
- end
- end
- # 设置角色为非选择状态
- @actor_index = -1
- @active_battler = nil
- @actor_command_window.active = false
- @actor_command_window.visible = false
- # 设置主回合标志
- $game_temp.battle_main_phase = true
- # 生成敌人行动
- for enemy in $game_troop.enemies
- enemy.make_action
- end
- #-----------------------------------------
- # 生成行动顺序
- # 移动到步骤 1
- @phase4_step = 1
- #----------------------------------------
- end
- def update_phase4_step1
- # 隐藏帮助窗口
- @help_window.visible = false
- # 判定胜败
- if judge
- # 胜利或者失败的情况下 : 过程结束
- return
- end
- # 强制行动的战斗者不存在的情况下
- if $game_temp.forcing_battler == nil
- # 设置战斗事件
- setup_battle_event
- # 执行战斗事件中的情况下
- if $game_system.battle_interpreter.running?
- return
- end
- end
- # 强制行动的战斗者存在的情况下
- if $game_temp.forcing_battler != nil
- # 在头部添加后移动
- @action_battlers.delete($game_temp.forcing_battler)
- @action_battlers.unshift($game_temp.forcing_battler)
- end
- # 未行动的战斗者不存在的情况下 (全员已经行动)
- if @action_battlers.size == 0
- @phase=0
- return
- end
- # 初始化动画 ID 和公共事件 ID
- @animation1_id = 0
- @animation2_id = 0
- @common_event_id = 0
- # 未行动的战斗者移动到序列的头部
- @active_battler = @action_battlers.shift
- # 如果已经在战斗之外的情况下
- if @active_battler.index == nil
- return
- end
- # 连续伤害
- if @active_battler.hp > 0 and @active_battler.slip_damage?
- @active_battler.slip_damage_effect
- @active_battler.damage_pop = true
- end
- # 自然解除状态
- #==========================================
- if LVQING::TURN == 0
- $game_temp.battle_turn += 1
- #@active_battler.remove_states_auto
- if @st < $game_party.actors.size+$game_troop.enemies.size
- @st+=1
- else
- for battler in $game_party.actors
- battler.remove_states_auto
- end
- for battler in $game_troop.enemies
- battler.remove_states_auto
- end
- @st=0
- end
- end
- #==========================================
- # 刷新状态窗口
- @status_window.refresh
- # 移至步骤 2
- @phase4_step = 2
- end
- def make_skill_action_result
- # 获取特技
- @skill = $data_skills[@active_battler.current_action.skill_id]
- # 如果不是强制行动
- unless @active_battler.current_action.forcing
- # 因为 SP 耗尽而无法使用的情况下
- unless @active_battler.skill_can_use?(@skill.id)
- # 清除强制行动对像的战斗者
- #-------------------------------------------------
- if LVQING::ATTACK==0
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- make_basic_action_result
- return
- end
- if LVQING::ATTACK==1
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic =1
- # 帮助窗口显示"防御"
- @help_window.set_text($data_system.words.guard, 1)
- @phase4_step=1
- return
- end
- if LVQING::ATTACK==2
- $game_temp.forcing_battler = nil
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- #-------------------------------------------------
- end
- end
- # 消耗 SP
- @active_battler.sp -= @skill.sp_cost
- # 刷新状态窗口
- @status_window.refresh
- # 在帮助窗口显示特技名
- @help_window.set_text(@skill.name, 1)
- # 设置动画 ID
- @animation1_id = @skill.animation1_id
- @animation2_id = @skill.animation2_id
- # 设置公共事件 ID
- @common_event_id = @skill.common_event_id
- # 设置对像侧战斗者
- set_target_battlers(@skill.scope)
- # 应用特技效果
- for target in @target_battlers
- target.skill_effect(@active_battler, @skill)
- end
- end
- def make_item_action_result
- # 获取物品
- @item = $data_items[@active_battler.current_action.item_id]
- # 因为物品耗尽而无法使用的情况下
- unless $game_party.item_can_use?(@item.id)
- #-------------------------------------------------
-
- if LVQING::ATTACK==0
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic = 0
- make_basic_action_result
- return
- end
- if LVQING::ATTACK==1
- @active_battler.current_action.kind = 0
- @active_battler.current_action.basic =1
- # 帮助窗口显示"防御"
- @help_window.set_text($data_system.words.guard, 1)
- @phase4_step=1
- return
- end
- if LVQING::ATTACK==2
- $game_temp.forcing_battler = nil
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- #-------------------------------------------------
- end
- if @item.consumable
- $game_party.lose_item(@item.id, 1)
- end
- @help_window.set_text(@item.name, 1)
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- @common_event_id = @item.common_event_id
- index = @active_battler.current_action.target_index
- target = $game_party.smooth_target_actor(index)
- set_target_battlers(@item.scope)
- for target in @target_battlers
- target.item_effect(@item)
- end
- end
- end
- #----------------------------------------------------
- class Window_BattleStatus < Window_Base
- def refresh
- self.contents.clear
- @item_max = $game_party.actors.size
- for i in 0...$game_party.actors.size
- actor = $game_party.actors[i]
- actor_x = i * 160 + 4
- draw_actor_name(actor, actor_x, 0)
- draw_actor_hp(actor, actor_x, 22, 120)
- draw_actor_sp(actor, actor_x, 44, 120)
- @ct_color1 = Color.new(255,160,255,255)
- @ct_color2 = Color.new(145,100,255,255)
- draw_meter(actor.ct, actor.maxct, actor_x, 102, 108, 12, @ct_color1, @ct_color2)
- if @level_up_flags[i]
- self.contents.font.color = normal_color
- self.contents.draw_text(actor_x, 72, 120, 32, "LEVEL UP!")
- else
- draw_actor_state(actor, actor_x,72)
- end
- #--------------------------------
- end
- end
- def refresh_ct(actor)
- actor_x = actor.index * 160 + 4
- draw_meter(actor.ct, actor.maxct, actor_x, 102, 108, 12, @ct_color1, @ct_color2)
- end
- end
复制代码 |
|