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

Project1

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

[已经过期] 求一个VA的CP制脚本(或者把我这个VX的帮忙改一下)

[复制链接]

Lv1.梦旅人

梦石
0
星屑
168
在线时间
45 小时
注册时间
2012-9-4
帖子
30
跳转到指定楼层
1
发表于 2012-12-2 12:58:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
  1. #★战斗者类
  2. #================================================
  3. class Game_Battler
  4.    attr_accessor :cp
  5.    attr_accessor :cp_total
  6.    attr_accessor :cp_turn #角色能不行动时,计算角色实际cp爆满次数,用以代替回合,计算状态解除时机
  7.       
  8.    attr_accessor :slip_damage
  9.    attr_accessor :auto_damage
  10.   
  11.    
  12.    alias oldinitialize  initialize
  13.    def initialize
  14.      @cp = 0
  15.      @cp_total = false
  16.      @cp_turn = 0
  17.      @act_status = 0
  18.      @slip_damage = 0
  19.      @auto_damage = 0
  20.    
  21.      oldinitialize
  22.    end
  23.   def maxcp
  24.     return 100
  25.   end  
  26. #--------------------------------------------------------------------------
  27.   # ● 应用连续伤害效果
  28.   #--------------------------------------------------------------------------
  29.   def slip_damage_effect
  30.     if slip_damage? and @hp > 0
  31.       @hp_damage = apply_variance(maxhp / 10, 10)
  32.       @hp_damage = @hp - 1 if @hp_damage >= @hp
  33.       @slip_damage = @hp_damage
  34.       self.hp -= @hp_damage
  35.     end
  36.   end

  37. end #class  
  38. #============================================================================
  39. #===============================================
  40. #★角色队伍类
  41. #===============================================
  42. class Game_Party < Game_Unit
  43. attr_accessor :actor_battler
  44. alias oldinitialize initialize
  45. def initialize
  46.   oldinitialize
  47.   @actor_battler = []
  48. end
  49. end #class  
  50. #================================================
  51. #★敌人队伍类
  52. #================================================
  53. class Game_Troop < Game_Unit
  54.   attr_accessor :enemy_battler
  55. alias  oldinitialize initialize
  56. def initialize
  57.    oldinitialize
  58.    @enemy_battler = []
  59. end  

  60. end#class
  61. #================================================
  62. #★cp条处理类
  63. #================================================

  64. class Scene_CP
  65.     attr_accessor :stop
  66.     attr_accessor :in_battler
  67.     attr_accessor :cp_battler
  68.     BATTLE_SPEED = 0.8
  69.     def initialize
  70.       [url=home.php?mod=space&uid=76426]@stop[/url] = false
  71.       @all_agi = 0
  72.       @v =  Viewport.new(0, 0, 544, 90)
  73.       @count = 0
  74.       @cpline = Sprite.new(@v)
  75.       @cpline.bitmap = Bitmap.new(544,416)
  76.       bitmap = Bitmap.new("Graphics/system/cp条")
  77.       @cpline.bitmap.blt(105,8,bitmap,bitmap.rect)
  78.       @cp_battler = {}
  79.       for battler in $game_party.members + $game_troop.members
  80.         @all_agi += battler.agi
  81.         @cp_battler[battler] = Sprite_cpbattler.new
  82.         if battler.is_a?(Game_Actor)
  83.           name = battler.id.to_s + "_cp"
  84.           if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  85.               bitmap = Bitmap.new("Graphics/system/#{name}")
  86.               rect = bitmap.rect
  87.               @cp_battler[battler].bitmap = bitmap
  88.           else
  89.               
  90.                
  91.                bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
  92.                 sign = battler.character_name[/^[\!\$]./]
  93.                 if sign != nil and sign.include?('$')
  94.                   cw = bitmap.width / 3
  95.                   ch = bitmap.height / 4
  96.                   
  97.                 else
  98.                   cw = bitmap.width / 12
  99.                   ch = bitmap.height / 8
  100.                   
  101.                 end
  102.                  n = battler.character_index
  103.                  rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
  104.                
  105.                  @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
  106.           end
  107.          
  108.          
  109.           @cp_battler[battler].bitmap.blt(0, 0,bitmap,rect)
  110.          
  111.         else
  112.           name = battler.original_name + "_敌人cp"
  113.           if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  114.              @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  115.           else
  116.              @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
  117.           end
  118.              @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
  119.         end  
  120.         @cp_battler[battler].z = 101
  121.         @cp_battler[battler].visible = false
  122.         
  123.       end
  124.     end   
  125.    
  126.     #===========================================
  127.    
  128.    
  129.    
  130.    
  131.     #===========================================
  132.    
  133.    
  134.     def update
  135.      
  136.       return if @stop
  137.       
  138.       
  139.       for battler in $game_party.members + $game_troop.members
  140.         if (@cp_battler[battler].disposed? or @cp_battler[battler].opacity == 0) and battler.dead?
  141.           @cp_battler.delete(@cp_battler[battler])
  142.           next
  143.         end  
  144.         if battler.dead?
  145.          if  @cp_battler.include?(battler)
  146.              @cp_battler[battler].collapse = true
  147.             
  148.           end   
  149.           battler.cp = 0
  150.           next
  151.         end  
  152.        battler.cp = [[battler.cp + BATTLE_SPEED*10*battler.agi / @all_agi,0].max,battler.maxcp].min if battler.movable?
  153.        battler.cp_turn = [[battler.cp_turn+BATTLE_SPEED*10*battler.agi / @all_agi, 0].max,battler.maxcp].min
  154.        if battler.cp == battler.maxcp
  155.            if battler.is_a?(Game_Actor)
  156.               name = battler.id.to_s + "_a_cp"
  157.               if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  158.                bitmap = Bitmap.new("Graphics/system/#{name}")
  159.                rect = bitmap.rect
  160.                @cp_battler[battler].bitmap = bitmap
  161.               else
  162.                
  163.                 bitmap = Bitmap.new("Graphics/Characters/#{battler.character_name}")
  164.                 sign = battler.character_name[/^[\!\$]./]
  165.                 if sign != nil and sign.include?('$')
  166.                   cw = bitmap.width / 3
  167.                   ch = bitmap.height / 4
  168.                 else
  169.                   cw = bitmap.width / 12
  170.                   ch = bitmap.height / 8
  171.                 end
  172.                  n = battler.character_index
  173.                  
  174.                  rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
  175.                
  176.                  @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
  177.                  
  178.               end
  179.               
  180.               @cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
  181.            
  182.           else
  183.             name = battler.original_name + "_a_cp"
  184.             if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  185.             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  186.             else
  187.             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/a_敌人cp")
  188.             end
  189.             @cp_battler[battler].bitmap.blt(80,60,  @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
  190.           end  
  191.             @cp_battler[battler].z = 101
  192.             battler.cp_total = true
  193.       elsif battler.cp_total == true
  194.           if battler.is_a?(Game_Actor)
  195.              name = battler.id.to_s + "_cp"
  196.              if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  197.               bitmap = Bitmap.new("Graphics/system/#{name}")
  198.               rect = bitmap.rect
  199.               @cp_battler[battler].bitmap = bitmap
  200.              else
  201.               
  202.                 bitmap =  Bitmap.new("Graphics/Characters/#{battler.character_name}")
  203.                 sign = battler.character_name[/^[\!\$]./]
  204.                 if sign != nil and sign.include?('$')
  205.                   cw = bitmap.width / 3
  206.                   ch = bitmap.height / 4
  207.                 else
  208.                   cw = bitmap.width / 12
  209.                   ch = bitmap.height / 8
  210.                 end
  211.                  n = battler.character_index
  212.                  rect = Rect.new((n%4*3+1)*cw, (n/4*4+2)*ch, cw, ch)
  213.                  
  214.                  @cp_battler[battler].bitmap = Bitmap.new(cw,ch)
  215.                  
  216.                  
  217.               end
  218.             
  219.              @cp_battler[battler].bitmap.blt(0,0,bitmap,rect)
  220.             
  221.           else
  222.                 name = battler.original_name + "_敌人cp"
  223.              if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  224.                  @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  225.                
  226.              else
  227.                  @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
  228.                
  229.              end
  230.                
  231.                @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
  232.             end
  233.             battler.cp_total = false
  234.             @cp_battler[battler].z = 105
  235.             
  236.       end
  237.          
  238.       @cp_battler[battler].visible = true if @cp_battler[battler].visible == false
  239.       @cp_battler[battler].opacity = 255
  240.       @cp_battler[battler].y = 30
  241.       @cp_battler[battler].x = 95+300*battler.cp/battler.maxcp
  242.       if battler.cp_turn == battler.maxcp
  243.         #=================================
  244.         last_st = battler.states
  245.         #=================================
  246.         battler.remove_states_auto unless battler.movable?
  247.         battler.slip_damage_effect
  248.         battler.do_auto_recovery if battler.is_a?(Game_Actor)
  249.         #====================================
  250.         if battler.states != last_st
  251.           $scene.display_state_changes(battler)
  252.         
  253.         end
  254.         #====================================
  255.         
  256.         battler.cp_turn = 0
  257.       end  
  258.       if battler.cp == battler.maxcp
  259.          if battler.is_a?(Game_Actor)
  260.            $game_party.actor_battler.push(battler)
  261.          else
  262.            battler.make_action
  263.            $game_troop.enemy_battler.push(battler)
  264.            battler.make_action
  265.           end   
  266.       else
  267.         next
  268.       end  
  269.       
  270.       
  271.       
  272.    end     
  273. end

  274.   def dispose
  275.     for j in 0..25
  276.     @cpline.opacity -= 10
  277.     for i in @cp_battler.values
  278.       unless i.disposed?
  279.       i.opacity -= 10
  280.       end
  281.     end  
  282.      Graphics.update
  283.     end  
  284.     @v.dispose
  285.     @cpline.dispose
  286.     for i in @cp_battler.values
  287.       i.dispose
  288.     end
  289.   end  
  290. end
  291.   
  292.   
  293.   
  294.   
  295.   
  296.   
  297.   
  298.   
  299.   class Sprite_cpbattler < Sprite
  300.     attr_accessor :collapse
  301.    
  302.     def initialize (viewport = nil)
  303.       super (viewport)
  304.      
  305.       @effect_duration = 0        
  306.       @collapse = false
  307.     end
  308.     def update
  309.        super
  310.   
  311.      if self.collapse == true and self.opacity != 0
  312.    
  313.       @effect_type = 5
  314.       @effect_duration = 48
  315.       self.color.set(255, 128, 128, 128)
  316.       for i in 0..48
  317.       self.opacity = 256 - (48 - @effect_duration) * 6
  318.       if self.opacity == 0
  319.    
  320.       break
  321.       end  
  322.       Graphics.update
  323.       @effect_duration -= 1
  324.       end
  325.      
  326.       self.collapse = false
  327.       self.color.set(255,255,255,5)
  328.      end
  329.      
  330.     end
  331.    
  332. def dispose
  333.      if self.bitmap != nil
  334.       self.bitmap.dispose
  335.      end
  336.    
  337.     super
  338.   end
  339.       
  340. end  

  341. #==========================================================================
  342. #
  343. #==========================================================================
  344. class Scene_Battle < Scene_Base
  345. #--------------------------------------------------------------------------
  346.   # ● 开始处理
  347.   #--------------------------------------------------------------------------
  348.   def start
  349.     super
  350.     $game_temp.in_battle = true
  351.     @spriteset = Spriteset_Battle.new
  352.     @message_window = Window_BattleMessage.new
  353.     @action_battlers = []
  354.     @cp_battle = Scene_CP.new
  355.     @cp_battle.stop = false
  356.     create_info_viewport
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 更新画面
  360.   #--------------------------------------------------------------------------
  361.   def update
  362.     super
  363.     update_basic(true)
  364.     update_info_viewport                  # 更新显示信息的视区
  365.     if $game_message.visible
  366.       @info_viewport.visible = false
  367.       @message_window.visible = true
  368.     end
  369.     unless $game_message.visible          # 在显示消息以外的情况
  370.       return if judge_win_loss            # 判断胜败
  371.       update_scene_change
  372.       if @target_enemy_window != nil
  373.         update_target_enemy_selection     # 选择敌方对象
  374.       elsif @target_actor_window != nil
  375.         update_target_actor_selection     # 选择对象角色
  376.       elsif @skill_window != nil
  377.         update_skill_selection            # 选择特技
  378.       elsif @item_window != nil
  379.         update_item_selection             # 选择物品
  380.       elsif @party_command_window.active
  381.         update_party_command_selection    # 选择同伴指令
  382.       elsif @actor_command_window.active
  383.         update_actor_command_selection    # 选择角色指令
  384.       #=================================
  385.       elsif @cp_battle.stop ==  false
  386.         active_battler_update
  387.       #=================================  
  388.         
  389.       else
  390.         process_battle_event              # 战斗处理
  391.         process_action                    # 战斗行动
  392.         process_battle_event              # 处理战斗事件
  393.       end
  394.     end
  395.   end

  396.   #=============================================
  397.   #★角色回合的处理函数
  398.   #=============================================
  399.   
  400.   
  401.   def next_actor
  402.    
  403.    
  404.     @info_viewport.visible = true
  405.    
  406.     @message_window.visible = true
  407.     @status_window.update
  408.   
  409.     loop do
  410.    
  411.       if @actor_index == @actor_battler.size - 1
  412.         
  413.         start_main
  414.         return
  415.         
  416.       end   
  417.       
  418.       @actor_index += 1
  419.       
  420.       index = 0
  421.       for battler in $game_party.members
  422.         if battler == @actor_battler[@actor_index]
  423.           break
  424.         else
  425.           index += 1
  426.         end
  427.       end  
  428.       @status_window.index = index
  429.      
  430.       
  431.       @active_battler = @actor_battler[@actor_index]
  432.      
  433.      
  434.      
  435.      
  436.       if @active_battler.auto_battle
  437.         @active_battler.make_action
  438.         next
  439.       end
  440.       break if @active_battler.inputable?
  441.     end
  442.   
  443.     start_party_command
  444.   end
  445.   
  446.   #====================================================
  447.   #★开始角色战斗与逃跑选择
  448.   #====================================================
  449.   def start_party_command
  450.       @status_window.refresh
  451.       @party_command_window.active = true
  452.       @party_command_window.index = 0
  453.       @actor_command_window.active = false
  454.       @message_window.visible = false
  455.       
  456.   
  457.   end
  458.   #=====================================================
  459.   #--------------------------------------------------------------------------
  460.   # ● 更新同伴战斗指令
  461.   #--------------------------------------------------------------------------
  462.   def update_party_command_selection
  463.     if Input.trigger?(Input::C)
  464.       case @party_command_window.index
  465.       when 0  # 战斗
  466.         Sound.play_decision
  467.       
  468.         start_actor_command_selection
  469.       when 1  # 逃跑
  470.         if $game_troop.can_escape == false
  471.           Sound.play_buzzer
  472.           return
  473.         end
  474.         Sound.play_decision
  475.         process_escape
  476.       end
  477.     end
  478.   end
  479.   #--------------------------------------------------------------------------
  480.   # ● 开始选择角色指令
  481.   #--------------------------------------------------------------------------
  482.   def start_actor_command_selection
  483.     @party_command_window.active = false
  484.     @actor_command_window.setup(@active_battler)
  485.     @actor_command_window.active = true
  486.     @actor_command_window.index = 0
  487.    

  488.   end
  489.   #==============================================
  490.   #★指令窗口刷新
  491.   #==============================================
  492.    def update_actor_command_selection
  493.    
  494.     if Input.trigger?(Input::B)
  495.       Sound.play_cancel
  496.       start_party_command
  497.     elsif Input.trigger?(Input::C)
  498.       case @actor_command_window.index
  499.       when 0  # 攻击
  500.         Sound.play_decision
  501.         @active_battler.action.set_attack
  502.         start_target_enemy_selection
  503.       when 1  # 特技
  504.         Sound.play_decision
  505.         start_skill_selection
  506.       when 2  # 防御
  507.         Sound.play_decision
  508.         @active_battler.action.set_guard
  509.         
  510.         @active_battler.cp = 0
  511.         next_actor
  512.       when 3  # 物品
  513.         Sound.play_decision
  514.         start_item_selection
  515.       
  516.       when 4 #逃跑
  517.         if $game_troop.can_escape == false
  518.           Sound.play_buzzer
  519.           return
  520.         end
  521.         Sound.play_decision
  522.         process_escape
  523.     end
  524.     end
  525.   end
  526.   #========================================================
  527.   #--------------------------------------------------------------------------
  528.   # ● 更新选择对象敌方角色
  529.   #--------------------------------------------------------------------------
  530.   def update_target_enemy_selection
  531.     @target_enemy_window.update
  532.     if Input.trigger?(Input::B)
  533.       Sound.play_cancel
  534.       end_target_enemy_selection
  535.     elsif Input.trigger?(Input::C)
  536.       Sound.play_decision
  537.       @active_battler.action.target_index = @target_enemy_window.enemy.index
  538.       end_target_enemy_selection
  539.       end_skill_selection
  540.       end_item_selection
  541.      
  542.       #============================
  543.        @active_battler.cp = 0
  544.       #============================
  545.        next_actor
  546.     end
  547.   end
  548.   #--------------------------------------------------------------------------
  549.   # ● 更新对象角色选择
  550.   #--------------------------------------------------------------------------
  551.   def update_target_actor_selection
  552.     @target_actor_window.update
  553.     if Input.trigger?(Input::B)
  554.       Sound.play_cancel
  555.       end_target_actor_selection
  556.     elsif Input.trigger?(Input::C)
  557.       Sound.play_decision
  558.       @active_battler.action.target_index = @target_actor_window.index
  559.       end_target_actor_selection
  560.       end_skill_selection
  561.       end_item_selection
  562.      
  563.       #=========================
  564.       @active_battler.cp = 0
  565.       #=========================
  566.        next_actor
  567.     end
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ● 确定特技
  571.   #--------------------------------------------------------------------------
  572.   def determine_skill
  573.     @active_battler.action.set_skill(@skill.id)
  574.     @skill_window.active = false
  575.     if @skill.need_selection?
  576.       if @skill.for_opponent?
  577.         start_target_enemy_selection
  578.       else
  579.         start_target_actor_selection
  580.       end
  581.     else
  582.       end_skill_selection
  583.       
  584.       #=========================
  585.       @active_battler.cp = 0
  586.       #=========================
  587.       @party_command_window.active = false
  588.       next_actor
  589.     end
  590.   end
  591.   #=========================================
  592.   #★物品使用决定  处理
  593.   #=========================================
  594.   
  595.   
  596.   def determine_item
  597.     @active_battler.action.set_item(@item.id)
  598.     @item_window.active = false
  599.     if @item.need_selection?
  600.       if @item.for_opponent?
  601.         start_target_enemy_selection
  602.       else
  603.         start_target_actor_selection
  604.       end
  605.     else
  606.       end_item_selection
  607.       
  608.        @active_battler.cp = 0
  609.       next_actor
  610.     end
  611.   end
  612.   #--------------------------------------------------------------------------
  613.   # ● 开始处理战斗
  614.   #--------------------------------------------------------------------------
  615.   def process_battle_start
  616.     @message_window.clear
  617.     wait(10)
  618.     for name in $game_troop.enemy_names
  619.       text = sprintf(Vocab::Emerge, name)
  620.       $game_message.texts.push(text)
  621.     end
  622.     if $game_troop.preemptive
  623.       text = sprintf(Vocab::Preemptive, $game_party.name)
  624.       $game_message.texts.push(text)
  625.        for battler in $game_party.members
  626.          battler.cp = battler.maxcp
  627.        end  
  628.        $game_troop.preemptive = false
  629.     elsif $game_troop.surprise
  630.       text = sprintf(Vocab::Surprise, $game_party.name)
  631.       $game_message.texts.push(text)
  632.       for battler in $game_troop.members
  633.         battler.cp = battler.maxcp
  634.       end
  635.       $game_troop.surprise = false
  636.     end
  637.     wait_for_message
  638.     @message_window.clear
  639.     @message_window.visible = false
  640.     make_escape_ratio
  641.     process_battle_event
  642.    
  643.     #=====================
  644.    
  645.     @status_window.index = @actor_index = -1
  646.     @cp_battle.stop = false
  647.     #=====================
  648.   end
  649.   #--------------------------------------------------------------------------
  650.   # ● 处理逃跑
  651.   #--------------------------------------------------------------------------
  652.   def process_escape
  653.     @info_viewport.visible = false
  654.     @party_command_window.active = false
  655.     @message_window.visible = true
  656.     text = sprintf(Vocab::EscapeStart, $game_party.name)
  657.     $game_message.texts.push(text)
  658.     if $game_troop.preemptive
  659.       success = true
  660.     else
  661.       success = (rand(100) < @escape_ratio)
  662.     end
  663.     Sound.play_escape
  664.     if success
  665.       #=============================
  666.       @cp_battle.dispose
  667.       #=============================
  668.       for battler in $game_party.members
  669.         battler.cp = 0
  670.       end  
  671.       wait_for_message
  672.       battle_end(1)
  673.     else
  674.       @escape_ratio += 10
  675.       @active_battler.cp = 0
  676.       $game_message.texts.push('\.' + Vocab::EscapeFailure)
  677.       wait_for_message
  678.       @active_battler.action.clear
  679.       @message_window.visible = false
  680.       next_actor
  681.     end
  682.   end
  683.    #--------------------------------------------------------------------------
  684.   # ● 处理胜利
  685.   #--------------------------------------------------------------------------
  686.   def process_victory
  687.     @info_viewport.visible = false
  688.     @message_window.visible = true
  689.     RPG::BGM.stop
  690.     $game_system.battle_end_me.play
  691.      for battler in $game_troop.members
  692.       if battler.dead?
  693.          if  @cp_battle.cp_battler.include?(battler)
  694.               @cp_battle.cp_battler[battler].collapse = true
  695.               
  696.               next
  697.           end  
  698.        end     
  699.     end
  700.      @cp_battle.cp_battler.each{|key,value|
  701.       if value.disposed?
  702.         @cp_battler.delete(key)
  703.         next
  704.       end
  705.       value.update}
  706.     #=============================
  707.     @cp_battle.dispose
  708.     #=============================
  709.    for battler in $game_party.members
  710.      battler.cp = 0
  711.     end
  712.    
  713.    
  714.     unless $BTEST
  715.       $game_temp.map_bgm.play
  716.       $game_temp.map_bgs.play
  717.     end
  718.     display_exp_and_gold
  719.     display_drop_items
  720.     display_level_up
  721.     battle_end(0)
  722.   end
  723.   #--------------------------------------------------------------------------
  724.   # ● 失败处理
  725.   #--------------------------------------------------------------------------
  726.   def process_defeat
  727.     @info_viewport.visible = false
  728.     @message_window.visible = true
  729.     @cp_battle.dispose
  730.     for battler in $game_party.members + $game_troop.members
  731.      battler.cp = 0
  732.     end
  733.     text = sprintf(Vocab::Defeat, $game_party.name)
  734.     $game_message.texts.push(text)
  735.     wait_for_message
  736.     battle_end(2)
  737.   end
  738.   #=============================================================================
  739.   #★CP战斗的主要刷新★
  740.   #=============================================================================
  741.   
  742.    def active_battler_update
  743.    
  744.     #===================================
  745.     @actor_battler = []
  746.     @enemy_battler = []
  747.     $game_party.actor_battler = []
  748.     $game_troop.enemy_battler = []
  749.     #===================================
  750.     @cp_battle.update
  751.     @actor_battler = $game_party.actor_battler
  752.     @enemy_battler = $game_troop.enemy_battler
  753.    
  754.     if @actor_battler.size != 0
  755.       @cp_battle.stop = true
  756.       next_actor
  757.       Audio.se_play("Audio/SE/Jump2",100,100)
  758.     elsif @enemy_battler.size != 0  
  759.    
  760.     #================
  761.     @cp_battle.stop = true
  762.     start_main
  763.     #================
  764.    
  765.    
  766.      
  767.    end
  768.   
  769. end
  770. #--------------------------------------------------------------------------
  771.   # ● 开始执行战斗处理
  772.   #--------------------------------------------------------------------------
  773.   def start_main
  774.    
  775.     @info_viewport.visible = false
  776.     @info_viewport.ox = 0
  777.     @message_window.visible = true
  778.   
  779.     @actor_command_window.active = false
  780.     @status_window.index = @actor_index = -1
  781.     @active_battler = nil
  782.     @message_window.clear
  783.     $game_troop.make_actions
  784.     make_action_orders
  785.     wait(20)
  786.     #=============================
  787.   
  788.    while @action_battlers.size != 0 and judge_win_loss == false
  789.      
  790.      process_action
  791.      process_battle_event
  792.    end
  793.    @cp_battle.stop = false
  794.    #=============================
  795.    
  796.    
  797.   end
  798. #=====================================
  799. #★行动顺序生成
  800. #=====================================


  801. def make_action_orders
  802.     @action_battlers = []
  803.    
  804.     unless $game_troop.surprise
  805.       @action_battlers += @actor_battler if @actor_battler.size != 0
  806.     end
  807.    
  808.    
  809.     unless $game_troop.preemptive
  810.       @action_battlers += @enemy_battler if @enemy_battler.size != 0
  811.     end
  812.     for battler in @action_battlers
  813.       battler.action.make_speed
  814.     end
  815.     @action_battlers.sort! do |a,b|
  816.       b.action.speed - a.action.speed
  817.     end
  818.   end
  819.   #--------------------------------------------------------------------------
  820.   # ● 处理战斗行动
  821.   #--------------------------------------------------------------------------
  822.   def process_action
  823.     return if judge_win_loss
  824.     return if $game_temp.next_scene != nil
  825.     set_next_active_battler
  826.     return if @active_battler == nil
  827.     return if @active_battler.dead?
  828.     @message_window.clear
  829.     wait(5)
  830.     @active_battler.white_flash = true
  831.     unless @active_battler.action.forcing
  832.       @active_battler.action.prepare
  833.     end
  834.     if @active_battler.action.valid?
  835.       execute_action
  836.     end
  837.     unless @active_battler.action.forcing
  838.       @message_window.clear
  839.       remove_states_auto
  840.       display_current_state
  841.     end
  842.     @active_battler.white_flash = false
  843.     @message_window.clear
  844.   end
  845.   #--------------------------------------------------------------------------
  846.   # ● 执行战斗行动: 攻击
  847.   #--------------------------------------------------------------------------
  848.   def execute_action_attack
  849.     text = sprintf(Vocab::DoAttack, @active_battler.name)
  850.     @message_window.add_instant_text(text)
  851.     targets = @active_battler.action.make_targets
  852.     display_attack_animation(targets)
  853.     wait(20)
  854.     for target in targets
  855.       target.attack_effect(@active_battler)
  856.       display_action_effects(target)
  857.     end
  858.     #=====================
  859.     @active_battler.cp = 0
  860.     #=====================
  861.    
  862.   end
  863.   #--------------------------------------------------------------------------
  864.   # ● 执行战斗行动 : 防御
  865.   #--------------------------------------------------------------------------
  866.   def execute_action_guard
  867.     text = sprintf(Vocab::DoGuard, @active_battler.name)
  868.     @message_window.add_instant_text(text)
  869.     wait(45)
  870.     #=====================
  871.     @active_battler.cp = 0
  872.     #=====================
  873.   end
  874.   #--------------------------------------------------------------------------
  875.   # ● 执行战斗行动 : 逃走
  876.   #--------------------------------------------------------------------------
  877.   def execute_action_escape
  878.     text = sprintf(Vocab::DoEscape, @active_battler.name)
  879.     @message_window.add_instant_text(text)
  880.     @active_battler.escape
  881.     Sound.play_escape
  882.     wait(45)
  883.     #=====================
  884.     @active_battler.cp = 0
  885.     #=====================
  886.    
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # ● 执行战斗行动 : 待机
  890.   #--------------------------------------------------------------------------
  891.   def execute_action_wait
  892.     text = sprintf(Vocab::DoWait, @active_battler.name)
  893.     @message_window.add_instant_text(text)
  894.     wait(45)
  895.     #=====================
  896.     @active_battler.cp = 0
  897.     #=====================
  898.   end
  899.   #--------------------------------------------------------------------------
  900.   # ● 执行战斗行动 : 特技
  901.   #--------------------------------------------------------------------------
  902.   def execute_action_skill
  903.     skill = @active_battler.action.skill
  904.     text = @active_battler.name + skill.message1
  905.     @message_window.add_instant_text(text)
  906.     unless skill.message2.empty?
  907.       wait(10)
  908.       @message_window.add_instant_text(skill.message2)
  909.     end
  910.     targets = @active_battler.action.make_targets
  911.     display_animation(targets, skill.animation_id)
  912.     @active_battler.mp -= @active_battler.calc_mp_cost(skill)
  913.     $game_temp.common_event_id = skill.common_event_id
  914.     for target in targets
  915.       target.skill_effect(@active_battler, skill)
  916.       display_action_effects(target, skill)
  917.     end
  918.     #=====================
  919.     @active_battler.cp = 0
  920.     #=====================
  921.    
  922.   end
  923.    #--------------------------------------------------------------------------
  924.   # ● 执行战斗行动 : 物品
  925.   #--------------------------------------------------------------------------
  926.   def execute_action_item
  927.     item = @active_battler.action.item
  928.     text = sprintf(Vocab::UseItem, @active_battler.name, item.name)
  929.     @message_window.add_instant_text(text)
  930.     targets = @active_battler.action.make_targets
  931.     display_animation(targets, item.animation_id)
  932.     $game_party.consume_item(item)
  933.     $game_temp.common_event_id = item.common_event_id
  934.     for target in targets
  935.       target.item_effect(@active_battler, item)
  936.       display_action_effects(target, item)
  937.     end
  938.     #=====================
  939.     @active_battler.cp = 0
  940.     #=====================
  941.    
  942.    
  943.   end
  944.   #--------------------------------------------------------------------------
  945.   # ● 显示 HP 伤害
  946.   #     target : 对象者
  947.   #     obj    : 特技或者物品
  948.   #--------------------------------------------------------------------------
  949.   def display_hp_damage(target, obj = nil)
  950.     if target.hp_damage == 0                # 空伤害
  951.       return if obj != nil and obj.damage_to_mp
  952.       return if obj != nil and obj.base_damage == 0
  953.       fmt = target.actor? ? Vocab::ActorNoDamage : Vocab::EnemyNoDamage
  954.       text = sprintf(fmt, target.name)
  955.     elsif target.absorbed                   # 吸收
  956.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  957.       text = sprintf(fmt, target.name, Vocab::hp, target.hp_damage)
  958.       target.cp -= target.hp_damage/100
  959.       target.cp = [target.cp,0].max
  960.       @cp_battle.cp_battler[target].x = 95+300*target.cp/target.maxcp
  961.      if target.dead?
  962.          @cp_battle.cp_battler[target].collapse = true
  963.          target.cp = 0
  964.          @cp_battle.cp_battler[target].update
  965.       end
  966.       
  967.     elsif target.hp_damage > 0              # 伤害
  968.       if target.actor?
  969.         text = sprintf(Vocab::ActorDamage, target.name, target.hp_damage)
  970.         Sound.play_actor_damage
  971.         $game_troop.screen.start_shake(5, 5, 10)
  972.       else
  973.         text = sprintf(Vocab::EnemyDamage, target.name, target.hp_damage)
  974.         Sound.play_enemy_damage
  975.         target.blink = true
  976.       end
  977.       target.cp -= target.hp_damage/100
  978.       target.cp = [target.cp,0].max
  979.       @cp_battle.cp_battler[target].x = 95+300*target.cp/target.maxcp
  980.       if target.dead?
  981.          @cp_battle.cp_battler[target].collapse = true
  982.          target.cp = 0
  983.          @cp_battle.cp_battler[target].update
  984.       end
  985.       
  986.     else                                    # 回复
  987.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  988.       text = sprintf(fmt, target.name, Vocab::hp, -target.hp_damage)
  989.       Sound.play_recovery
  990.     end
  991.     @message_window.add_instant_text(text)
  992.     wait(30)
  993.   end
  994.   #--------------------------------------------------------------------------
  995.   # ● 显示 MP 伤害
  996.   #     target : 对象者
  997.   #     obj    : 特技或者物品
  998.   #--------------------------------------------------------------------------
  999.   def display_mp_damage(target, obj = nil)
  1000.     return if target.dead?
  1001.     return if target.mp_damage == 0
  1002.     if target.absorbed                      # 吸收
  1003.       fmt = target.actor? ? Vocab::ActorDrain : Vocab::EnemyDrain
  1004.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1005.       target.cp -= target.mp_damage/100
  1006.       target.cp = [target.cp,0].max
  1007.       @cp_battle.cp_battler[target].x = 95+300*target.cp/target.maxcp
  1008.     elsif target.mp_damage > 0              # 伤害
  1009.       fmt = target.actor? ? Vocab::ActorLoss : Vocab::EnemyLoss
  1010.       text = sprintf(fmt, target.name, Vocab::mp, target.mp_damage)
  1011.       target.cp -= target.mp_damage/100
  1012.       target.cp = [target.cp,0].max
  1013.       @cp_battle.cp_battler[target].x = 95+300*target.cp/target.maxcp
  1014.       
  1015.     else                                    # 回复
  1016.       fmt = target.actor? ? Vocab::ActorRecovery : Vocab::EnemyRecovery
  1017.       text = sprintf(fmt, target.name, Vocab::mp, -target.mp_damage)
  1018.       Sound.play_recovery
  1019.     end
  1020.     @message_window.add_instant_text(text)
  1021.     wait(30)
  1022.   end
  1023.   
  1024.   
  1025. end #class


  1026. #======================================================
  1027. #★角色处理类
  1028. #======================================================
  1029. class Game_Actor < Game_Battler
  1030.   #--------------------------------------------------------------------------
  1031.   # ● 执行自动回复 (回合结束时调用)
  1032.   #--------------------------------------------------------------------------
  1033.   def do_auto_recovery
  1034.     if auto_hp_recover and not dead?
  1035.       self.hp += maxhp / 20
  1036.       @auto_damage = maxhp / 20
  1037.     end
  1038.   end
  1039.   
  1040. end #class
  1041.   
复制代码

Lv1.梦旅人

梦石
0
星屑
50
在线时间
616 小时
注册时间
2010-10-29
帖子
463
2
发表于 2012-12-6 06:13:30 | 只看该作者
你可以试试脚本图书馆里的,或者善用搜索。

当然,你能力够强的话可以试试mog的战斗
我命令你给我点下面的东西!

LBQ Works
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-5-7 22:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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