Project1

标题: 求大神帮我改下脚本。 [打印本页]

作者: 游系风    时间: 2012-12-22 12:55
标题: 求大神帮我改下脚本。
还是行动条脚本的问题。前几天在这区求到了一个行动条脚本。
效果为在画面上端显示一个横条,敌我双方的“小图标”在上面从左向右走。
但是这个脚本里的图标只有2种。开战几回合之后,我方图标之间和敌方图标之间就彻底混在一起了。
无法精确的安排战术。
希望大神帮我修改一下,能给敌方某些人物设定“特殊的战斗图标”能给我方全员设定“战斗图标”。
拜托了!真的很需要这个效果。
  1. #==============================================================================
  2. # ■ CP制战斗系统 v1.00
  3. #------------------------------------------------------------------------------
  4. #    适用于:RPG Maker VX Ace
  5. #    说明:把脚本放在Main的前面。
  6. #    所需素材:Graphics\Pictures\SL我方.png,SL敌方.png。
  7. #==============================================================================

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

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

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

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

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

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

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

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

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

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

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

  373. class Spriteset_Battle
  374.   attr_accessor :icons
  375.   attr_accessor :cp_quota
  376.   #--------------------------------------------------------------------------
  377.   # ● 初始化对象
  378.   #--------------------------------------------------------------------------
  379.   def initialize
  380.     @cp_quota = 100
  381.     create_viewports
  382.     create_battleback1
  383.     create_battleback2
  384.     create_enemies
  385.     create_actors
  386.     create_pictures
  387.     create_timer
  388.     create_rtabcp_gauge
  389.     update
  390.   end
  391.   #--------------------------------------------------------------------------
  392.   # ● 生成战斗CP条
  393.   #--------------------------------------------------------------------------
  394.   def create_rtabcp_gauge
  395.     @cpgauge_back = Sprite.new(@viewport3)
  396.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  397.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  398.     @cpgauge_back.x = 16
  399.     @cpgauge_back.y = 16
  400.     # 各个角色生成其图标
  401.    @icons = {}
  402.     for iii in $game_party.members
  403.       @icons[iii] = Sprite.new(@viewport3)
  404.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL我方.png")
  405.       @icons[iii].ox = 12
  406.       @icons[iii].oy = 12
  407.       @icons[iii].x = 16
  408.       @icons[iii].y = 20
  409.     end
  410.     for iii in $game_troop.members
  411.       @icons[iii] = Sprite.new(@viewport3)
  412.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL敌方.png")
  413.       @icons[iii].ox = 12
  414.       @icons[iii].oy = 12
  415.       @icons[iii].x = 16
  416.       @icons[iii].y = 20
  417.     end
  418.   end
  419.   #--------------------------------------------------------------------------
  420.   # ● 释放
  421.   #--------------------------------------------------------------------------
  422.   def dispose
  423.     dispose_battleback1
  424.     dispose_battleback2
  425.     dispose_enemies
  426.     dispose_actors
  427.     dispose_pictures
  428.     dispose_timer
  429.     dispose_viewports
  430.     dispose_rtabcp_gauge
  431.   end
  432.   #--------------------------------------------------------------------------
  433.   # ● 消灭战斗CP条
  434.   #--------------------------------------------------------------------------
  435.   def dispose_rtabcp_gauge
  436.     @cpgauge_back.bitmap.dispose
  437.     @cpgauge_back.dispose
  438.     for iii in $game_party.members
  439.       @icons[iii].bitmap.dispose
  440.       @icons[iii].dispose
  441.     end
  442.     for iii in $game_troop.members
  443.       @icons[iii].bitmap.dispose
  444.       @icons[iii].dispose
  445.     end
  446.   end
  447.   #--------------------------------------------------------------------------
  448.   # ● 更新画面
  449.   #--------------------------------------------------------------------------
  450.   def update
  451.     update_battleback1
  452.     update_battleback2
  453.     update_enemies
  454.     update_actors
  455.     update_cp
  456.     update_pictures
  457.     update_timer
  458.     update_viewports
  459.   end
  460.   #--------------------------------------------------------------------------
  461.   # ● 更新CP条
  462.   #--------------------------------------------------------------------------
  463.   def update_cp
  464.     for iii in $game_party.members + $game_troop.members
  465.       @icons[iii].x = 16 + 200 * iii.rtab_cp / @cp_quota
  466.       @icons[iii].visible = iii.alive?
  467.     end
  468.   end
  469. end
复制代码

作者: 345912390    时间: 2012-12-22 12:55
游系风 发表于 2012-12-22 14:25
不用战斗中换人,战前就换好了。
我想弄一个,除了主角外,其他同伴可以随便搭配的游戏(不同的角色,不 ...

修改脚本中def create_rtabcp_gauge
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 生成战斗CP条
  3.   #--------------------------------------------------------------------------
  4.   def create_rtabcp_gauge
  5.     @cpgauge_back = Sprite.new(@viewport3)
  6.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  7.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  8.     @cpgauge_back.x = 16
  9.     @cpgauge_back.y = 16
  10.     # 各个角色生成其图标
  11.    @icons = {}
  12.     for iii in $game_party.members
  13.       index=iii.id
  14.       @icons[iii] = Sprite.new(@viewport3)
  15.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Actor/"+index.to_s+".png")
  16.       @icons[iii].ox = 12
  17.       @icons[iii].oy = 12
  18.       @icons[iii].x = 16
  19.       @icons[iii].y = 20
  20.       index+=1
  21.     end
  22.     for iii in $game_troop.members
  23.       index=iii.enemy_id
  24.       @icons[iii] = Sprite.new(@viewport3)
  25.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/Troop/"+index.to_s+".png")
  26.       @icons[iii].ox = 12
  27.       @icons[iii].oy = 12
  28.       @icons[iii].x = 16
  29.       @icons[iii].y = 20
  30.       index+=1
  31.     end
  32.   end

角色图标目录 /Graphics/Pictures/Actor/
如角色A的Id为1 那图标为 1.png
敌人图标目录 /Graphics/Pictures/Troop/
如敌人A的Id为1 那图标为 1.png

作者: 345912390    时间: 2012-12-22 13:49
修改脚本中的def create_rtabcp_gauge
RUBY 代码复制
  1. #--------------------------------------------------------------------------
  2.   # ● 生成战斗CP条
  3.   #--------------------------------------------------------------------------
  4.   def create_rtabcp_gauge
  5.     @cpgauge_back = Sprite.new(@viewport3)
  6.     @cpgauge_back.bitmap = Bitmap.new(200, 8)
  7.     @cpgauge_back.bitmap.gradient_fill_rect(0, 0, 200, 16, Color.new(0, 255, 0), Color.new(255, 0, 0))
  8.     @cpgauge_back.x = 16
  9.     @cpgauge_back.y = 16
  10.     # 各个角色生成其图标
  11.    @icons = {}
  12.    index=0
  13.     for iii in $game_party.members
  14.       @icons[iii] = Sprite.new(@viewport3)
  15.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL我方"+index.to_s+".png")
  16.       @icons[iii].ox = 12
  17.       @icons[iii].oy = 12
  18.       @icons[iii].x = 16
  19.       @icons[iii].y = 20
  20.       index+=1
  21.     end
  22.     index=0
  23.     for iii in $game_troop.members
  24.       @icons[iii] = Sprite.new(@viewport3)
  25.       @icons[iii].bitmap = Bitmap.new("Graphics/Pictures/SL敌方"+index.to_s+".png")
  26.       @icons[iii].ox = 12
  27.       @icons[iii].oy = 12
  28.       @icons[iii].x = 16
  29.       @icons[iii].y = 20
  30.       index+=1
  31.     end
  32.   end
  

Graphics/Pictures/  目录中的图标文件按序号增加0-7

作者: 游系风    时间: 2012-12-22 14:14
345912390 发表于 2012-12-22 13:49
修改脚本中的def create_rtabcp_gauge
#--------------------------------------------------------------- ...

我方角色似乎只能设置前八人啊?无法给25号角色替换(仍然是第0号战斗图)
地方角色没弄成功,一直是“SL敌方0”
作者: 345912390    时间: 2012-12-22 14:21
游系风 发表于 2012-12-22 14:14
我方角色似乎只能设置前八人啊?无法给25号角色替换(仍然是第0号战斗图)
地方角色没弄成功,一直是“SL ...

你想把它战斗时换人的脚本整合在一起?我没有战斗换人的脚本

我发的那个是以队伍为编号,并不是以角色ID 为编号。
如果以角色ID为编号,那个需要大量的图标文件

作者: 游系风    时间: 2012-12-22 14:25
345912390 发表于 2012-12-22 14:21
你想把它战斗时换人的脚本整合在一起?我没有战斗换人的脚本

我发的那个是以队伍为编号,并不是以角色ID ...

不用战斗中换人,战前就换好了。
我想弄一个,除了主角外,其他同伴可以随便搭配的游戏(不同的角色,不同的脸)。
敌人的图标,是因为要区分敌方BOSS。
能把脚本改成根据ID来修改图标吗?
作者: 游系风    时间: 2012-12-22 14:46
345912390 发表于 2012-12-22 14:40
修改脚本中def create_rtabcp_gauge
#-------------------------------------------------------------- ...

谢谢大神相助!!




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