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

Project1

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

[已经过期] 关于ATB战斗系统脚本修改讨论和请教

[复制链接]

Lv2.观梦者

梦石
0
星屑
599
在线时间
333 小时
注册时间
2011-11-19
帖子
194
跳转到指定楼层
1
发表于 2015-7-19 10:43:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 q854240045 于 2015-7-19 11:25 编辑

先把脚本放出来:
RUBY 代码复制
  1. =begin
  2. YanFly Compatible Customisable ATB/Stamina Based Battle System Script
  3. by Fomar0153
  4. Version 1.2
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Requires Yanfly Engine Ace - Ace Battle Engine
  9. Customises the battle system to be similar to
  10. ATB or Stamina based battle systems.
  11. ----------------------
  12. Instructions
  13. ----------------------
  14. Edit variables in CBS to suit your needs.
  15. The guard status should be set to 2~2 turns.
  16. ----------------------
  17. Change Log
  18. ----------------------
  19. 1.0 -> 1.1 Added CTB related options
  20.            Added the ability to pass a turn
  21.            Added options for turn functionality to be based on time
  22.            or number of actions
  23.            Added the ability to change the bar colours based on states
  24. 1.1 -> 1.2 Fixed a bug when escaping using CTB mode
  25. ----------------------
  26. Known bugs
  27. ----------------------
  28. None
  29.  
  30. =end
  31.  
  32. $imported = {} if $imported.nil?
  33. $imported["Fomar0153-CBS"] = true
  34.  
  35. module CBS
  36.  
  37.   MAX_STAMINA = 1000
  38.   RESET_STAMINA = true
  39.  
  40.   # If ATB is set to false then the bars won't appear and
  41.   # the pauses where the bars would be filling up are removed
  42.   # effectively turning this into a CTB system
  43.   ATB = true
  44.   SAMINA_GAUGE_NAME = "行"
  45.   ENABLE_PASSING = true
  46.   PASSING_COST = 200
  47.  
  48.   # If TURN_LENGTH is set to 0 then a turn length will be
  49.   # decided on number of actions
  50.   # TURN_LENGTH is number of seconds per turn
  51.   TURN_LENGTH = 4
  52.  
  53.   ESCAPE_COST = 500
  54.   # If reset stamina is set to true then all characters
  55.   # will start with a random amount of stamina capped at
  56.   # the percentage you set.
  57.   # If reset stamina is set to false then this just
  58.   # affects enemies.
  59.   STAMINA_START_PERCENT = 20
  60.  
  61.   # Default skill cost
  62.   # If you want to customise skill costs do it like this
  63.   # SKILL_COST[skill_id] = cost
  64.   SKILL_COST = []
  65.   SKILL_COST[0] = 1000
  66.   # Attack
  67.   SKILL_COST[1] = 1000
  68.   # Guard
  69.   SKILL_COST[2] = 500
  70.   ITEM_COST = 1000
  71.  
  72.   # If you prefer to have states handle agility buffs then set STATES_HANDLE_AGI to true
  73.   STATES_HANDLE_AGI = true
  74.   # In the following section mult means the amount you multiply stamina gains by
  75.   # if STATES_HANDLE_AGI is set to true then it is only used to determine bar color
  76.   # with debuffs taking precedence over buffs
  77.   STAMINA_STATES = []
  78.   # Default colour
  79.   STAMINA_STATES[0] = [1,31,32]
  80.   # in the form
  81.   # STAMINA_STATES[STATE_ID] = [MULT,FILL_COLOUR,EMPTY_COLOR]
  82.   # e.g. Haste
  83.   STAMINA_STATES[10] = [2,4,32]
  84.   # e.g. Stop  
  85.   STAMINA_STATES[11] = [0,8,32]
  86.   # e.g. Slow  
  87.   STAMINA_STATES[12] = [0.5,8,32]
  88.  
  89.   #--------------------------------------------------------------------------
  90.   # ● New Method stamina_gain
  91.   #--------------------------------------------------------------------------
  92.   def self.stamina_gain(battler)
  93.     return ((2 + [0, battler.agi / 10].max) * self.stamina_mult(battler)).to_i
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● New Method stamina_gain
  97.   #--------------------------------------------------------------------------
  98.   def self.stamina_mult(battler)
  99.     return 1 if STATES_HANDLE_AGI
  100.     mult = STAMINA_STATES[0][0]
  101.     for state in battler.states
  102.       unless STAMINA_STATES[state.id].nil?
  103.         mult *= STAMINA_STATES[state.id][0]
  104.       end
  105.     end
  106.     return mult
  107.   end
  108.   #--------------------------------------------------------------------------
  109.   # ● New Method stamina_gain
  110.   #--------------------------------------------------------------------------
  111.   def self.stamina_colors(battler)
  112.     colors = STAMINA_STATES[0]
  113.     for state in battler.states
  114.       unless STAMINA_STATES[state.id].nil?
  115.         if STAMINA_STATES[state.id][0] < colors[0] or colors[0] == 1
  116.           colors = STAMINA_STATES[state.id]
  117.         end
  118.       end
  119.     end
  120.     return colors
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● New Method stamina_start
  124.   #--------------------------------------------------------------------------
  125.   def self.stamina_start(battler)
  126.     battler.stamina = rand(MAX_STAMINA * STAMINA_START_PERCENT / 100)
  127.   end
  128. end
  129.  
  130. class Game_BattlerBase
  131.   #--------------------------------------------------------------------------
  132.   # ● New attr_accessor
  133.   #--------------------------------------------------------------------------
  134.   attr_accessor :stamina
  135.   #--------------------------------------------------------------------------
  136.   # ● Aliases initialize
  137.   #--------------------------------------------------------------------------
  138.   alias yf_fomar_cbs_initialize initialize
  139.   def initialize
  140.     yf_fomar_cbs_initialize
  141.     @stamina = 0
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # ● New Method stamina_rate
  145.   #--------------------------------------------------------------------------
  146.   def stamina_rate
  147.     @stamina.to_f / CBS::MAX_STAMINA
  148.   end
  149.   #--------------------------------------------------------------------------
  150.   # ● New Method stamina_rate
  151.   #--------------------------------------------------------------------------
  152.   def stamina_gain
  153.     return if not movable?
  154.     @stamina = [CBS::MAX_STAMINA, @stamina + CBS.stamina_gain(self)].min
  155.   end
  156.   #--------------------------------------------------------------------------
  157.   # ● New Method stamina_color
  158.   #--------------------------------------------------------------------------
  159.   def stamina_color
  160.     for state in @states
  161.       unless CBS::STAMINA_STATES[state].nil?
  162.         return STAMINA_STATES[state]
  163.       end
  164.     end
  165.     return STAMINA_STATES[0]
  166.   end
  167. end
  168.  
  169. class Scene_Battle < Scene_Base
  170.   #--------------------------------------------------------------------------
  171.   # ● Rewrote update
  172.   #--------------------------------------------------------------------------
  173.   def update
  174.     super
  175.     if (CBS::ENABLE_PASSING and @actor_command_window.active) and Input.press?(:A)
  176.       command_pass
  177.     end
  178.     if BattleManager.in_turn? and !inputting?
  179.       while @subject.nil? and !CBS::ATB
  180.         process_stamina
  181.       end
  182.       if CBS::ATB
  183.         process_stamina
  184.       end
  185.       process_event
  186.       process_action
  187.     end
  188.     BattleManager.judge_win_loss
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● Rewrote Method update_info_viewport
  192.   #--------------------------------------------------------------------------
  193.   def update_info_viewport
  194.     move_info_viewport(0)   if @party_command_window.active
  195.     move_info_viewport(128) if @actor_command_window.active
  196.     move_info_viewport(64)  if BattleManager.in_turn? and !inputting?
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● New Method inputting?
  200.   #--------------------------------------------------------------------------
  201.   def inputting?
  202.     return @actor_command_window.active || @skill_window.active ||
  203.       @item_window.active || @actor_window.active || @enemy_window.active
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● New Method process_stamina
  207.   #--------------------------------------------------------------------------
  208.   def process_stamina
  209.     @actor_command_window.close
  210.     return if @subject
  211.     BattleManager.advance_turn
  212.     all_battle_members.each do |battler|
  213.       battler.stamina_gain
  214.     end
  215.     @status_window.refresh_stamina
  216.     if @status_window.close?
  217.       @status_window.open
  218.      end
  219.     if BattleManager.escaping?
  220.       $game_party.battle_members.each do |battler|
  221.         if battler.stamina < CBS::MAX_STAMINA
  222.           $game_troop.members.each do |enemy|
  223.             if enemy.stamina == CBS::MAX_STAMINA
  224.               enemy.make_actions
  225.               @subject = enemy
  226.             end
  227.           end
  228.           return
  229.         end
  230.       end
  231.       unless BattleManager.process_escape
  232.         $game_party.battle_members.each do |actor|
  233.           actor.stamina -= CBS::ESCAPE_COST
  234.         end
  235.         BattleManager.set_escaping(false) unless CBS::ATB
  236.       end
  237.     end
  238.     all_battle_members.each do |battler|
  239.       if battler.stamina == CBS::MAX_STAMINA
  240.         battler.make_actions
  241.         @subject = battler
  242.         if @subject.inputable? and battler.is_a?(Game_Actor)
  243.           @actor_command_window.setup(@subject)
  244.           @status_window.index = @subject.index
  245.           BattleManager.set_actor(battler)
  246.         end
  247.         return
  248.       end
  249.     end
  250.   end
  251.   #--------------------------------------------------------------------------
  252.   # ● Rewrote start_party_command_selection Yanfly version
  253.   #--------------------------------------------------------------------------
  254.   def start_party_command_selection
  255.     unless scene_changing?
  256.       refresh_status
  257.       @status_window.unselect
  258.       @status_window.open
  259.       if BattleManager.input_start
  260.         @actor_command_window.close
  261.         @party_command_window.setup
  262.       else
  263.         @party_command_window.deactivate
  264.         turn_start
  265.       end
  266.     end
  267.   end
  268.   #--------------------------------------------------------------------------
  269.   # ● Rewrote start_actor_command_selection
  270.   #--------------------------------------------------------------------------
  271.   def start_actor_command_selection
  272.     @party_command_window.close
  273.     BattleManager.set_escaping(false)
  274.     turn_start
  275.   end
  276.   #--------------------------------------------------------------------------
  277.   # ● Rewrote prior_command Yanfly version
  278.   #--------------------------------------------------------------------------
  279.   def prior_command
  280.     redraw_current_status
  281.     start_party_command_selection
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # ● Rewrote process_action
  285.   #--------------------------------------------------------------------------
  286.   def process_action
  287.     return if scene_changing?
  288.     if !@subject || !@subject.current_action
  289.       @subject = BattleManager.next_subject
  290.     end
  291.     if Input.trigger?(:B) and (@subject == nil)
  292.       start_party_command_selection
  293.     end
  294.     return unless @subject
  295.     if @subject.current_action
  296.       @subject.current_action.prepare
  297.       if @subject.current_action.valid?
  298.         @status_window.open
  299.         execute_action
  300.       end
  301.       @subject.remove_current_action
  302.       refresh_status
  303.       @log_window.display_auto_affected_status(@subject)
  304.       @log_window.wait_and_clear
  305.     end
  306.     process_action_end unless @subject.current_action
  307.   end
  308.   #--------------------------------------------------------------------------
  309.   # ● Aliases use_item
  310.   #--------------------------------------------------------------------------
  311.   alias cbs_use_item use_item
  312.   def use_item
  313.     cbs_use_item
  314.     @subject.stamina_loss
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● Rewrote turn_end
  318.   #--------------------------------------------------------------------------
  319.   def turn_end
  320.     all_battle_members.each do |battler|
  321.       battler.on_turn_end
  322.       refresh_status
  323.       @log_window.display_auto_affected_status(battler)
  324.       @log_window.wait_and_clear
  325.     end
  326.     #BattleManager.turn_end
  327.     #process_event
  328.     #start_party_command_selection
  329.   end
  330.   #--------------------------------------------------------------------------
  331.   # ● Rewrote command_fight
  332.   #--------------------------------------------------------------------------
  333.   def command_fight
  334.     BattleManager.next_command
  335.     start_actor_command_selection
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● Rewrote command_escape
  339.   #--------------------------------------------------------------------------
  340.   def command_escape
  341.     @party_command_window.close
  342.     BattleManager.set_escaping(true)
  343.     turn_start
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # ● New method command_pass
  347.   #--------------------------------------------------------------------------
  348.   def command_pass
  349.     BattleManager.actor.stamina -= CBS::PASSING_COST
  350.     BattleManager.clear_actor
  351.     @subject = nil
  352.     turn_start
  353.     @actor_command_window.active = false
  354.     @actor_command_window.close
  355.   end
  356.   #--------------------------------------------------------------------------
  357.   # ● Destroyed next_command
  358.   #--------------------------------------------------------------------------
  359.   def next_command
  360.     @status_window.show
  361.     @actor_command_window.show
  362.     @status_aid_window.hide
  363.   end
  364. end
  365.  
  366.  
  367.  
  368.  
  369. module BattleManager
  370.   #--------------------------------------------------------------------------
  371.   # ● Rewrote setup
  372.   #--------------------------------------------------------------------------
  373.   def self.setup(troop_id, can_escape = true, can_lose = false)
  374.     init_members
  375.     $game_troop.setup(troop_id)
  376.     @can_escape = can_escape
  377.     @can_lose = can_lose
  378.     make_escape_ratio
  379.     @escaping = false
  380.     @turn_counter = 0
  381.     @actions_per_turn = $game_party.members.size + $game_troop.members.size
  382.     ($game_party.members + $game_troop.members).each do |battler|
  383.       if battler.is_a?(Game_Enemy) or CBS::RESET_STAMINA
  384.         CBS.stamina_start(battler)
  385.       end
  386.     end
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● New Method set_escaping
  390.   #--------------------------------------------------------------------------
  391.   def self.set_escaping(escaping)
  392.     @escaping = escaping
  393.   end
  394.   #--------------------------------------------------------------------------
  395.   # ● New Method escaping?
  396.   #--------------------------------------------------------------------------
  397.   def self.escaping?
  398.     return @escaping
  399.   end
  400.   #--------------------------------------------------------------------------
  401.   # ● Rewrote turn_start Yanfly version
  402.   #--------------------------------------------------------------------------
  403.   def self.turn_start
  404.     @phase = :turn
  405.     clear_actor
  406.     $game_troop.increase_turn if $game_troop.turn_count == 0
  407.     @performed_battlers = []
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● New Method set_actor
  411.   #--------------------------------------------------------------------------
  412.   def self.set_actor(actor)
  413.     @actor_index = actor.index
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● New Increase action counter
  417.   #--------------------------------------------------------------------------
  418.   def self.add_action
  419.     return if @actions_per_turn.nil?
  420.     @turn_counter += 1
  421.     if @turn_counter == @actions_per_turn and CBS::TURN_LENGTH == 0
  422.       $game_troop.increase_turn
  423.       SceneManager.scene.turn_end
  424.       @turn_counter = 0
  425.     end
  426.   end
  427.   #--------------------------------------------------------------------------
  428.   # ● New Method advance_turn
  429.   #--------------------------------------------------------------------------
  430.   def self.advance_turn
  431.     return if CBS::TURN_LENGTH == 0
  432.     @turn_counter += 1
  433.     if @turn_counter == 60 * CBS::TURN_LENGTH
  434.       $game_troop.increase_turn
  435.       SceneManager.scene.turn_end
  436.       @turn_counter = 0
  437.     end
  438.   end
  439. end
  440.  
  441. class Game_Battler < Game_BattlerBase
  442.   #--------------------------------------------------------------------------
  443.   # ● Rewrote on_turn_end
  444.   #--------------------------------------------------------------------------
  445.   def on_turn_end
  446.     @result.clear
  447.     regenerate_all
  448.     update_state_turns
  449.     update_buff_turns
  450.     remove_states_auto(2)
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● New Method on_turn_end
  454.   #--------------------------------------------------------------------------
  455.   def stamina_loss
  456.     if self.actor?
  457.       @stamina -= input.stamina_cost
  458.     else
  459.       @stamina -= @actions[0].stamina_cost
  460.     end
  461.     BattleManager.add_action
  462.   end
  463. end
  464.  
  465. class Game_Actor < Game_Battler
  466.   #--------------------------------------------------------------------------
  467.   # ● Rewrote input
  468.   #--------------------------------------------------------------------------
  469.   def input
  470.     if @actions[@action_input_index] == nil
  471.       @actions[@action_input_index] = Game_Action.new(self)
  472.     end
  473.     return @actions[@action_input_index]
  474.   end
  475. end
  476.  
  477. class Game_Action
  478.   #--------------------------------------------------------------------------
  479.   # ● New Method stamina_cost
  480.   #--------------------------------------------------------------------------
  481.   def stamina_cost
  482.     if @item.is_skill?
  483.       return CBS::SKILL_COST[item.id] if CBS::SKILL_COST[item.id]
  484.       return CBS::SKILL_COST[0]
  485.     end
  486.     return CBS::ITEM_COST if @item.is_item?
  487.     return CBS::MAX_STAMINA
  488.   end
  489. end
  490.  
  491. class Window_BattleStatus < Window_Selectable
  492.   #--------------------------------------------------------------------------
  493.   # Aliases method: draw_item yanfly version
  494.   #--------------------------------------------------------------------------
  495. #~   alias prefomar_draw_item draw_item
  496. #~   def draw_item(index)
  497. #~     unless CBS::ATB
  498. #~       prefomar_draw_item(index)
  499. #~       return
  500. #~     end
  501. #~     return if index.nil?
  502. #~     clear_item(index)
  503. #~     actor = battle_members[index]
  504. #~     rect = item_rect(index)
  505. #~     return if actor.nil?
  506. #~     draw_actor_face(actor, rect.x+2, rect.y+2, actor.alive?)
  507. #~     draw_actor_name(actor, rect.x, rect.y, rect.width-8)
  508. #~     draw_actor_action(actor, rect.x, rect.y)
  509. #~     draw_actor_icons(actor, rect.x, line_height*1, rect.width)
  510. #~     gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
  511. #~     contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
  512. #~     draw_actor_hp(actor, rect.x+2, line_height*2, rect.width-4)
  513. #~     if draw_tp?(actor) && draw_mp?(actor)
  514. #~       dw = rect.width/2-2
  515. #~       dw += 1 if $imported["YEA-CoreEngine"] && YEA::CORE::GAUGE_OUTLINE
  516. #~       draw_actor_tp(actor, rect.x+2, line_height*2+gx, dw)
  517. #~       dw = rect.width - rect.width/2 - 2
  518. #~       draw_actor_mp(actor, rect.x+rect.width/2, line_height*2+gx, dw)
  519. #~     elsif draw_tp?(actor) && !draw_mp?(actor)
  520. #~       draw_actor_tp(actor, rect.x+2, line_height*2+gx, rect.width-4)
  521. #~     else
  522. #~       draw_actor_mp(actor, rect.x+2, line_height*2+gx, rect.width-4)
  523. #~     end
  524. #~     draw_actor_stamina(actor, rect.x+2, line_height*3, rect.width-4)
  525. #~   end
  526.   #--------------------------------------------------------------------------
  527.   # overwrite method: draw_item yanfly version
  528.   #--------------------------------------------------------------------------
  529.   def draw_item_stamina(index)
  530.     return if index.nil?
  531.     actor = battle_members[index]
  532.     rect = item_rect(index)
  533.     return if actor.nil?
  534.     gx = YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS
  535.     contents.font.size = YEA::BATTLE::BATTLESTATUS_TEXT_FONT_SIZE
  536.     draw_actor_stamina(actor, rect.x+2, line_height*3, rect.width-4)
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # new method: refresh_stamina
  540.   #--------------------------------------------------------------------------
  541.   def refresh_stamina
  542.     return unless CBS::ATB
  543.     item_max.times {|i| draw_item_stamina(i) }
  544.   end
  545.   #--------------------------------------------------------------------------
  546.   # new method: draw_actor_stamina
  547.   #--------------------------------------------------------------------------
  548.   def draw_actor_stamina(actor, dx, dy, width = 124)
  549.     draw_gauge(dx, dy, width, actor.stamina_rate, text_color(CBS.stamina_colors(actor)[2]),text_color(CBS.stamina_colors(actor)[1]))
  550.     change_color(system_color)
  551.     cy = (Font.default_size - contents.font.size) / 2 + 1
  552.     draw_text(dx+2, dy+cy, 30, line_height, CBS::SAMINA_GAUGE_NAME)
  553.   end
  554. end


运行了一下,是ATB战斗系统(应该没有错吧?)
自己使用的时候改了几个无关紧要的小地方,真的是无关紧要啊,就是一些宽啊,高啊,颜色稍微调深了一点点什么的,槽容量改小了一点点,结果运行时发现一些问题求请教~!
我以为是我改了之后才出了问题,结果用原脚本,问题依然存在,上面就是原脚本∧
问题如下:
1、战斗系统默认的偷袭和被偷袭无效了,我试了一下,结果弄不好,毕竟事件党,脚本只会最最最垃圾的。希望哪位大大修改一下,要么回复偷袭和被偷袭有效,即偷袭的一方一开始就可以发动攻击;要么就干脆取消偷袭与被偷袭,不然看得很别扭
2、游戏中敌人逃跑的话会出错,这个我还真的是毫无头绪,希望大大能够提出宝贵的教育(不知道是否用词适当啊~)
3、与Taroxd大大的额外战斗行动脚本冲突(基础脚本等配套脚本已经使用,无修改,在此谢谢大大了~!)具体表现是游戏中使用了额外战斗行动就会出错,不然没影响~
4、添加了无法行动的状态之后一直持续,除非技能物品,无法按照规定的时间解除了

小弟在此感激不尽,求大大赐教!
支持《彼岸之光》系列!加油!
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-16 08:27

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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