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

Project1

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

[已经过期] 战斗中换人脚本,战斗结束经验获得问题.

 关闭 [复制链接]

Lv2.观梦者

梦石
0
星屑
253
在线时间
574 小时
注册时间
2006-8-25
帖子
969
跳转到指定楼层
1
发表于 2011-6-5 23:15:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 jhhuang 于 2011-6-7 15:18 编辑

战斗中换人脚本可以设置出战人物只有1个,然后我队伍人物为1~8人.战斗结束后只有最后参战的人有经验....怎么改成队伍中所有人都获得经验.
  1. module LimBattlePlug

  2. # 队伍最大人数
  3. MaxPartySize = 8
  4. # 出战人数
  5. MaxBattlerSize = 1
  6. # 换人语句
  7. WordChangeBattler = "支援"
  8. # 换人时播放的动画
  9. AnimationChangeBattler = 450
  10. end

  11. class Game_BattleAction
  12.   attr_accessor :change_to_battler
  13.   # 初始化
  14.   alias lbp_initialize initialize
  15.   def initialize
  16.     lbp_initialize
  17.     @change_to_battler = 0
  18.   end
  19.   # 欲更换角色编号
  20.   def set_change_battler
  21.     @kind = 3
  22.   end
  23.   # 判断行动是否为更换角色
  24.   def is_change_battler?
  25.     return (@kind == 3)
  26.   end
  27. end

  28. class Game_Party
  29.   include LimBattlePlug
  30.   attr_reader :actors2
  31.   alias lpb_initialize initialize
  32.   def initialize
  33.     lpb_initialize
  34.     @actors2 = []
  35.   end
  36.   # 角色加入
  37.   def add_actor(actor_id)
  38.     actor = $game_actors[actor_id]
  39.     if @actors.size < MaxPartySize and not @actors.include?(actor)
  40.       @actors.push(actor)
  41.       $game_player.refresh
  42.     end
  43.   end
  44.   # 设置战斗的角色
  45.   def set_actor_to_battle
  46.     @actors2 = []
  47.     @actors.each do |actor|
  48.       @actors2.push(actor)
  49.     end
  50.     @actors = []
  51.     @actors2.each do |actor|
  52.       @actors.push(actor)
  53.       break if @actors.size == MaxBattlerSize
  54.     end
  55.   end
  56.   # 还原战斗的角色
  57.   def set_actor_to_normal
  58.     @actors = []
  59.     @actors2.each do |actor|
  60.       @actors.push(actor)
  61.     end
  62.   end
  63.   # 获取角色id数组
  64.   def get_actors_id
  65.     id = []
  66.     @actors.each{|actor|id.push(actor.id)}
  67.     return id
  68.   end
  69.   # 获取角色id数组
  70.   def get_actors2_id
  71.     id = []
  72.     @actors2.each{|actor|id.push(actor.id)}
  73.     return id
  74.   end
  75.   # 兑换角色
  76.   def change_actor(index,id)
  77.     @actors[index] = $game_actors[id]
  78.   end
  79.   # 全灭判定
  80.   def all_dead?
  81.     # 同伴人数为 0 的情况下
  82.     if $game_party.actors.size == 0
  83.       return false
  84.     end
  85.     # 同伴中无人 HP 在 0 以上
  86.     for actor in @actors2
  87.       if actor.hp > 0
  88.         return false
  89.       end
  90.     end
  91.     for actor in @actors
  92.       if actor.hp > 0
  93.         return false
  94.       end
  95.     end
  96.     # 全灭
  97.     return true
  98.   end
  99.   # 其他角色
  100.   def other_actors
  101.     actors = []
  102.     @actors2.each{|actor|actors.push(actor) if [email protected]?(actor)}
  103.     return actors
  104.   end
  105.   # 角色位置互换
  106.   def change_actor_pos(id1,id2)
  107.     actor_id = []
  108.     @actors.each do |actor|
  109.       actor_id.push(actor.id)
  110.     end
  111.     return if !actor_id.include?(id1) and !actor_id.include?(id2)
  112.     id1_index = id2_index = -1
  113.     (0...actor_id.size).each do |i|
  114.       if actor_id[i] == id1
  115.         id1_index = i
  116.       elsif actor_id[i] == id2
  117.         id2_index = i
  118.       end
  119.     end
  120.     temp_actor = @actors[id1_index]
  121.     @actors[id1_index] = @actors[id2_index]
  122.     @actors[id2_index] = temp_actor
  123.   end
  124. end

  125. class Window_Actor < Window_Selectable
  126.   # 初始化
  127.   def initialize
  128.     super(16,64,608,288)
  129.     self.z = 9999
  130.     self.back_opacity = 160
  131.     refresh
  132.     self.index = -1
  133.     self.active = false
  134.   end
  135.   # 刷新
  136.   def refresh
  137.     @item_max = $game_party.actors2.size
  138.     @data = []
  139.     $game_party.actors.each do |actor|
  140.       @data.push(actor)
  141.     end
  142.     $game_party.actors2.each do |actor|
  143.       @data.push(actor) if [email protected]?(actor)
  144.     end
  145.     if self.contents != nil
  146.       self.contents.clear
  147.       self.contents = nil
  148.     end
  149.     self.contents = Bitmap.new(576,@data.size*32)
  150.     x = 4
  151.     y = 0
  152.     @data.each do |actor|
  153.       bitmap = RPG::Cache.character(actor.character_name,actor.character_hue)
  154.       rect = Rect.new(0,0,bitmap.width/4,31)
  155.       self.contents.blt(x+16-bitmap.width/8,y,bitmap,rect)
  156.       draw_actor_name(actor,40,y)
  157.       draw_actor_state(actor,164,y)
  158.       draw_actor_hp(actor,276,y,96)
  159.       draw_actor_sp(actor,396,y,96)
  160.       if $game_party.actors.include?(actor)
  161.         self.contents.font.color = text_color(6)
  162.         cword = "出战"
  163.       else
  164.         self.contents.font.color = text_color(0)
  165.         cword = "待命"
  166.       end
  167.       self.contents.draw_text(508,y,48,32,cword)
  168.       y += 32
  169.     end
  170.   end
  171.   # 获取当前角色编号
  172.   def actor_id
  173.     return @data[self.index].id
  174.   end
  175.   # 刷新帮助
  176.   def update_help
  177.     @help_window.set_text(@data[self.index] == nil ?\
  178.                           "" : @data[self.index].name)
  179.   end
  180. end

  181. class Scene_Battle
  182.   include LimBattlePlug
  183.   # 初始化
  184.   def initialize
  185.     $game_party.set_actor_to_battle
  186.   end
  187.   # 主处理
  188.   def main
  189.     # 初始化战斗用的各种暂时数据
  190.     $game_temp.in_battle = true
  191.     $game_temp.battle_turn = 0
  192.     $game_temp.battle_event_flags.clear
  193.     $game_temp.battle_abort = false
  194.     $game_temp.battle_main_phase = false
  195.     $game_temp.battleback_name = $game_map.battleback_name
  196.     $game_temp.forcing_battler = nil
  197.     # 初始化战斗用事件解释器
  198.     $game_system.battle_interpreter.setup(nil, 0)
  199.     # 准备队伍
  200.     @troop_id = $game_temp.battle_troop_id
  201.     $game_troop.setup(@troop_id)
  202.     # 生成角色命令窗口
  203.     s1 = $data_system.words.attack
  204.     s2 = $data_system.words.skill
  205.     #s3 = $data_system.words.guard
  206.     s3 = $data_system.words.item
  207.     s4 = WordChangeBattler
  208.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,"逃跑"])
  209.     @actor_command_window.z = 9999 #小改动
  210.     @actor_command_window.y = 160
  211.     @actor_command_window.back_opacity = 160
  212.     @actor_command_window.active = false
  213.     @actor_command_window.visible = false
  214.     # 生成其它窗口
  215.     @party_command_window = Window_PartyCommand.new
  216.     @help_window = Window_Help.new
  217.     @help_window.back_opacity = 160
  218.     @help_window.visible = false
  219.     @status_window = Window_BattleStatus.new
  220.     @message_window = Window_Message.new
  221.     # 生成活动块
  222.     @spriteset = Spriteset_Battle.new
  223.     # 初始化等待计数
  224.     @wait_count = 0
  225.     ###########################
  226.     #战斗开始加入图片
  227.     @sprite = Sprite.new
  228.     @sprite.bitmap = RPG::Cache.picture("战斗界面" + $game_party.actors.size.to_s)
  229.     ###########################
  230.     # 执行过渡
  231.     if $data_system.battle_transition == ""
  232.       Graphics.transition(20)
  233.     else
  234.       randtra = rand(19)
  235.       case randtra
  236.       when 0
  237.         Graphics.transition(40, "Graphics/Transitions/001-Blind01.png" )
  238.       when 1
  239.         Graphics.transition(40, "Graphics/Transitions/002-Blind02.png")
  240.       when 2
  241.         Graphics.transition(40, "Graphics/Transitions/003-Blind03.png" )
  242.       when 3
  243.         Graphics.transition(40, "Graphics/Transitions/004-Blind04.png" )
  244.       when 4
  245.         Graphics.transition(40, "Graphics/Transitions/005-Stripe01.png" )
  246.       when 5
  247.         Graphics.transition(40, "Graphics/Transitions/006-Stripe02.png")
  248.       when 6
  249.         Graphics.transition(40, "Graphics/Transitions/007-Line01.png")
  250.       when 7
  251.         Graphics.transition(40, "Graphics/Transitions/008-Line02.png" )
  252.       when 8
  253.         Graphics.transition(40, "Graphics/Transitions/009-Random01.png" )
  254.       when 9
  255.         Graphics.transition(40, "Graphics/Transitions/010-Random02.png" )
  256.       when 10
  257.         Graphics.transition(40, "Graphics/Transitions/011-Random03.png")
  258.       when 11
  259.         Graphics.transition(40, "Graphics/Transitions/012-Random04.png")
  260.       when 12
  261.         Graphics.transition(40, "Graphics/Transitions/013-Square01.png" )
  262.       when 13
  263.         Graphics.transition(40, "Graphics/Transitions/014-Square02.png" )
  264.       when 14
  265.         Graphics.transition(40, "Graphics/Transitions/015-Diamond01.png" )
  266.       when 15
  267.         Graphics.transition(40, "Graphics/Transitions/016-Diamond02.png")
  268.       when 16
  269.         Graphics.transition(40, "Graphics/Transitions/017-Brick01.png")
  270.       when 17
  271.         Graphics.transition(40, "Graphics/Transitions/018-Brick02.png" )
  272.       when 18
  273.         Graphics.transition(40, "Graphics/Transitions/019-Whorl01.png" )
  274.       when 19
  275.         Graphics.transition(40, "Graphics/Transitions/020-Flat01.png" )
  276.       end
  277.     end
  278.     # 开始自由战斗回合
  279.     start_phase1
  280.     # 主循环
  281.     loop do
  282.       # 刷新游戏画面
  283.       Graphics.update
  284.       # 刷新输入信息
  285.       Input.update
  286.       # 刷新画面
  287.       update
  288.       # 如果画面切换的话就中断循环
  289.       if $scene != self
  290.         break
  291.       end
  292.     end
  293.     # 刷新地图
  294.     $game_map.refresh
  295.     # 准备过渡
  296.     Graphics.freeze
  297.     # 释放窗口
  298.     @actor_command_window.dispose
  299.     @party_command_window.dispose
  300.     @help_window.dispose
  301.     @status_window.dispose
  302.     @message_window.dispose
  303.     if @skill_window != nil
  304.       @skill_window.dispose
  305.     end
  306.     if @item_window != nil
  307.       @item_window.dispose
  308.     end
  309.     if @actor_window != nil
  310.       @actor_window.dispose
  311.     end
  312.     if @result_window != nil
  313.       @result_window.dispose
  314.     end
  315.     # 释放活动块
  316.     @spriteset.dispose
  317.     # 标题画面切换中的情况
  318.     if $scene.is_a?(Scene_Title)
  319.       # 淡入淡出画面
  320.       Graphics.transition
  321.       Graphics.freeze
  322.     end
  323.     # 战斗测试或者游戏结束以外的画面切换中的情况
  324.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  325.       $scene = nil
  326.     end
  327.   end
  328.   #--------------------------------------------------------------------------
  329.   # 战斗结束
  330.   #--------------------------------------------------------------------------
  331.   alias lpb_battle_end battle_end
  332.   def battle_end(n)
  333.     lpb_battle_end(n)
  334.     $game_party.set_actor_to_normal
  335.   end
  336.   # 开始回合3
  337.   alias lbp_start_phase3 start_phase3
  338.   def start_phase3
  339.     @changed_battler_id = []
  340.     lbp_start_phase3
  341.   end
  342.   # 刷新角色命令回合画面
  343.   def update_phase3
  344.     # 敌人光标有效的情况下
  345.     if @enemy_arrow != nil
  346.       update_phase3_enemy_select
  347.     # 角色光标有效的情况下
  348.     elsif @actor_arrow != nil
  349.       update_phase3_actor_select
  350.     # 特技窗口有效的情况下
  351.     elsif @skill_window != nil
  352.       update_phase3_skill_select
  353.     # 物品窗口有效的情况下
  354.     elsif @item_window != nil
  355.       update_phase3_item_select
  356.     elsif @actor_window != nil
  357.       update_phase3_battler_select
  358.     # 角色指令窗口有效的情况下
  359.     elsif @actor_command_window.active
  360.       update_phase3_basic_command
  361.     end
  362.   end
  363.   #--------------------------------------------------------------------------
  364.   # ● 刷新画面 (角色命令回合 : 基本命令)
  365.   #--------------------------------------------------------------------------
  366.   def update_phase3_basic_command
  367.     # 按下 B 键的情况下
  368.     if Input.trigger?(Input::B)
  369.       # 演奏取消 SE
  370.       $game_system.se_play($data_system.cancel_se)
  371.       # 转向前一个角色的指令输入
  372.       phase3_prior_actor
  373.       return
  374.     end
  375.     # 按下 C 键的情况下
  376.     if Input.trigger?(Input::C)
  377.       # 角色指令窗口光标位置分之
  378.       case @actor_command_window.index
  379.       when 0  # 攻击
  380.         # 演奏确定 SE
  381.         $game_system.se_play($data_system.decision_se)
  382.         # 设置行动
  383.         @active_battler.current_action.kind = 0
  384.         @active_battler.current_action.basic = 0
  385.         # 开始选择敌人
  386.         start_enemy_select
  387.       when 1  # 特技
  388.         # 演奏确定 SE
  389.         $game_system.se_play($data_system.decision_se)
  390.         # 设置行动
  391.         @active_battler.current_action.kind = 1
  392.         # 开始选择特技
  393.         start_skill_select
  394.       when 2  # 物品
  395.         # 演奏确定 SE
  396.         $game_system.se_play($data_system.decision_se)
  397.         # 设置行动
  398.         @active_battler.current_action.kind = 2
  399.         # 开始选择物品
  400.         start_item_select
  401.       when 3  # 换人
  402.         $game_system.se_play($data_system.decision_se)
  403.         @active_battler.current_action.set_change_battler
  404.         start_battler_select
  405.       when 4  # 逃跑
  406.         if $game_temp.battle_can_escape == false
  407.           # 演奏冻结 SE
  408.           $game_system.se_play($data_system.buzzer_se)
  409.           return
  410.         end
  411.         # 演奏确定 SE
  412.         $game_system.se_play($data_system.decision_se)
  413.         # 逃走处理
  414.         update_phase3_escape_select
  415.       end
  416.       return
  417.     end
  418.   end
  419.   # 开始角色选择
  420.   def start_battler_select
  421.     @actor_window = Window_Actor.new
  422.     @actor_window.active = true
  423.     @actor_window.index = 0
  424.     #@actor_window.help_window = @help_window
  425.     @actor_command_window.active = false
  426.     @actor_command_window.visible = false
  427.   end
  428.   # 结束角色选择
  429.   def end_battler_select
  430.     @actor_window.dispose
  431.     @actor_window = nil
  432.     #@help_window.visible = false
  433.     @actor_command_window.active = true
  434.     @actor_command_window.visible = true
  435.   end
  436.   # 刷新角色选择
  437.   def update_phase3_battler_select
  438.     @actor_window.visible = true
  439.     @actor_window.update
  440.     if Input.trigger?(Input::B)
  441.       $game_system.se_play($data_system.cancel_se)
  442.       end_battler_select
  443.       return
  444.     end
  445.     if Input.trigger?(Input::C)
  446.       actor_id = @actor_window.actor_id
  447.       if $game_party.get_actors_id.include?(actor_id) or
  448.          $game_actors[actor_id].dead? or
  449.          @changed_battler_id.include?(actor_id)
  450.         $game_system.se_play($data_system.buzzer_se)
  451.         return
  452.       end
  453.       $game_system.se_play($data_system.decision_se)
  454.       @active_battler.current_action.change_to_battler = actor_id
  455.       @changed_battler_id.push(actor_id)
  456.       end_battler_select
  457.       phase3_next_actor
  458.       return
  459.     end
  460.   end
  461.   #--------------------------------------------------------------------------
  462.   # ● 刷新画面 (主回合步骤 3 : 行动方动画)
  463.   #--------------------------------------------------------------------------
  464.   #def update_phase4_step3
  465.     #if @active_battler.current_action.is_change_battler?
  466.     #  @animation1_id = AnimationChangeBattler
  467.     #  @target_battlers = []
  468.     #end
  469.     # 行动方动画 (ID 为 0 的情况下是白色闪烁)
  470.   #  if @animation1_id == 0
  471.   #    @active_battler.white_flash = true
  472.   #  else
  473.   #    @active_battler.animation_id = @animation1_id
  474.   #    @active_battler.animation_hit = true
  475.   #  end
  476.   #  # 移至步骤 4
  477.   #  @phase4_step = 4
  478.   #end
  479.   #--------------------------------------------------------------------------
  480.   # ● 刷新画面 (主回合步骤 4 : 对像方动画)
  481.   #--------------------------------------------------------------------------
  482.   #def update_phase4_step4
  483.     #if @active_battler.current_action.is_change_battler?
  484.     #  actor1_id = @active_battler.current_action.change_to_battler
  485.     #  actor2_id = @active_battler.id
  486.     #  (0...$game_party.actors.size).each do |i|
  487.     #    if $game_party.actors[i].id == actor2_id
  488.     #      $game_party.change_actor(i,actor1_id)
  489.     #      @active_battler = $game_actors[actor1_id]
  490.     #      @status_window.refresh
  491.     #    end
  492.     #  end
  493.     #end
  494.     # 对像方动画
  495.   #  for target in @target_battlers
  496.   #    target.animation_id = @animation2_id
  497.   #    target.animation_hit = (target.damage != "Miss")
  498.   #  end
  499.   #  # 限制动画长度、最低 8 帧
  500.   #  @wait_count = 8
  501.   #  # 移至步骤 5
  502.   #  @phase4_step = 5
  503.   #end
  504.   #--------------------------------------------------------------------------
  505.   # ● 刷新画面 (主回合步骤 5 : 显示伤害)
  506.   #--------------------------------------------------------------------------
  507.   def update_phase4_step5
  508.     # 隐藏帮助窗口
  509.     @help_window.visible = false
  510.     # 刷新状态窗口
  511.     @status_window.refresh
  512.     # 显示伤害
  513.     for target in @target_battlers
  514.       if target.damage != nil
  515.         target.damage_pop = true
  516.       end
  517.     end
  518.     # 移至步骤 6
  519.     @phase4_step = 6
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ● 刷新画面 (主回合步骤 6 : 刷新)  
  523.   #--------------------------------------------------------------------------
  524.   def update_phase4_step6
  525.     ##################################################
  526.     #反击技能脚本用
  527.     original_update_phase4_step6_before_counter_action()
  528.     clear_counter_action(@active_battler)
  529.     activate_counter_action(@action_battlers)
  530.     ##################################################
  531.     @target_battlers.each do |target|
  532.       if target.is_a?(Game_Actor) and target.dead? and
  533.          !$game_party.other_actors.all?{|actor|actor.dead?}
  534.         @actor_window = Window_Actor.new
  535.         @actor_window.index = 0
  536.         @actor_window.active = true
  537.         @actor_window.help_window = @help_window
  538.         actor_id = -1
  539.         loop do
  540.           Graphics.update
  541.           Input.update
  542.           @actor_window.update
  543.           if Input.trigger?(Input::C)
  544.             actor = $game_actors[@actor_window.actor_id]
  545.             if actor.dead? or
  546.                (@changed_battler_id.include?(actor.id) and
  547.                 target.current_action.change_to_battler != actor.id) or
  548.                $game_party.actors.include?(actor)
  549.               $game_system.se_play($data_system.buzzer_se)
  550.             else
  551.               actor_id = actor.id
  552.             end
  553.           end
  554.           break if actor_id >= 0
  555.         end
  556.         @actor_window.visible = false
  557.         @actor_window.dispose
  558.         @actor_window = nil
  559.         @help_window.visible = false
  560.         (0...$game_party.actors.size).each do |i|
  561.           if $game_party.actors[i].id == target.id
  562.             $game_party.change_actor(i,actor_id)
  563.             @status_window.refresh
  564.           end
  565.         end
  566.       end
  567.     end
  568.     # 清除强制行动对像的战斗者
  569.     $game_temp.forcing_battler = nil
  570.     # 公共事件 ID 有效的情况下
  571.     if @common_event_id > 0
  572.       # 设置事件
  573.       common_event = $data_common_events[@common_event_id]
  574.       $game_system.battle_interpreter.setup(common_event.list, 0)
  575.     end
  576.     # 移至步骤 1
  577.     @phase4_step = 1
  578.   end
  579. end
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-12-2 02:49

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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