幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1987|回复: 5

[RMVX] 求助,脚本冲突,在线等高手。

[复制链接]

1

主题

5

帖子

42

积分

②入门

积分
42
发表于 2010-3-26 13:39:58 | 显示全部楼层 |阅读模式
    你好,我是属于VX的新手,当我调用了cp半即时战斗(普通版1.02a)脚本时后,一切正常,可是在调用了 装备升级脚本后,横板战斗的人物却无法显示了,自己找了很久也没有找到原因,希望有高手能帮我解答一下是哪里冲突。(当我删除装备升级的脚本以后,恢复正常。)谢谢。。
回复

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2010-3-26 13:46:07 | 显示全部楼层
先把脚本贴出来吧。。。谁有时间就会给你看的。。但是整合这种事情。。。愿意做的人少
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

1

主题

5

帖子

42

积分

②入门

积分
42
 楼主| 发表于 2010-3-26 13:55:18 | 显示全部楼层
哦,不管怎么说先谢了。。
cp半即时战斗(普通版1.02a)
  1. #=============================================================================
  2. #★Zhong RMVX 半即时战斗系统 1.02a版★
  3. #-----------------------------------------------------------------------------
  4. #★Scene_CP核心部分参考自 : 神思  《战斗真位移》战斗系统
  5. #★作者: Zhong_zw
  6. #★联系方式: 66rpg.com论坛短信 或 [email]zhong8890@126.com[/email]
  7. #★游戏中如若引用本脚本,请保留以上信息,并作相关说明.
  8. #☆如若转载本脚本请联系本人☆
  9. #=============================================================================
  10. #=============================================================================
  11. #☆1.01版修正问题:
  12. #1、物品、特技窗口选择我方人物时,头像重叠
  13. #2、连续伤害及自动回复效果无效。
  14. #☆1.02版修正问题:
  15. #1、减少刷新次数,提高速度
  16. #2、修正被打击时有可能退到cp槽外
  17. #☆1.02a版修正问题:
  18. #1、复活问题.
  19. #2、头像刷新问题.
  20. #☆使用方法说明☆
  21. #☆使用方法基本与我之前发的朴素横版战斗相同
  22. #☆动画设置:
  23. #1、武器、特技、物品的施展动画直接在其备注填入动画id即可。如果为空即不显示施展动画。
  24. #2、敌人普通攻击动画,在其备注里填写格式如下:
  25. #  a1=XX #施展动画id
  26. #  a2=XX #对方动画id
  27. #如果为空即使用默认普通动画(画面震动).
  28. #☆战斗图设置:
  29. #3、角色战斗图的的命名方式是角色id后面加上_z,如1_z.存放在Battlers文件夹。
  30. #4、默认待机图为两帧,只要在Battlers文件夹里放一个“战斗图名+待“的文件,就会自动循环播放
  31. #这两个战斗图,如1_b待,没有则没待机动作。
  32. #☆战斗背景设置:
  33. #5、在Graphics目录下新建Battlebacks文件夹。
  34. #6、战斗时先搜索文件夹内是否有与角色所在区域同名的战斗图,如果没有则搜索文件夹里是否
  35. #存在与地图同名的图片。
  36. #7、简而言之,你须储存与你地图同名的战斗背景在Battlebacks,如果想在同一幅地图实现不同地域
  37. #战斗背景不同,就在Battlebacks文件夹里储存与这个地域同名的战斗背景.至少保证战斗的地图
  38. #都有一幅该地图同名的战斗背景,不然战斗时会提示找不到地图.(可参考《拉尔夫战记》或朴素横版的范例)
  39. #☆CP条设置:
  40. #8、CP条:在system文件夹里储存一个命名为"cp条"的图片,默认长度为327,如果需要可在Scene_CP类里调整相
  41. #关参数.
  42. #9、角色cp图命名方式是"角色id+_cp",如:1_cp,角色活跃cp图命名方式是"角色id+_a_cp",如1_a_cp,
  43. #敌人cp图命名方式是"敌人名 + _敌人cp",如史莱姆_敌人cp,敌人活跃cp图是"敌人名+_a_cp".
  44. #亦可在system文件夹里储存名为"敌人cp"的图片,作为敌人的统一cp图,活跃图名为"a_敌人cp",默认如果找不到敌人相关cp图就直接
  45. #用这张图片.
  46. #☆选择光标设置
  47. #10、在system文件夹里储存名为"光标"的图片作为选择光标.
  48. #=============================================================================
  49. #================================================
  50. #★战斗者类
  51. #================================================
  52. class Game_Battler
  53.    attr_accessor :cp
  54.    attr_accessor :cp_total
  55.    attr_accessor :cp_turn #角色能不行动时,计算角色实际cp爆满次数,用以代替回合,计算状态解除时机
  56.    #=======================================
  57.   attr_accessor :animation2_id   
  58.   attr_accessor :act_status
  59.   attr_accessor :damage
  60.   attr_accessor :damage_pop
  61.   attr_accessor :slip_damage
  62.   attr_accessor :auto_damage
  63.   #=========================================
  64.    
  65.    alias oldinitialize  initialize
  66.    def initialize
  67.      @cp = 0
  68.      @cp_total = false
  69.      @cp_turn = 0
  70.      @damage = nil
  71.      @damage_pop = false
  72.      @act_status = 0
  73.      @slip_damage = 0
  74.      @auto_damage = 0
  75.      oldinitialize
  76.    end
  77.   def maxcp
  78.     return 100
  79.   end  
  80.   #--------------------------------------------------------------------------
  81.   # ● 应用连续伤害效果
  82.   #--------------------------------------------------------------------------
  83.   def slip_damage_effect
  84.     if slip_damage? and @hp > 0
  85.       @hp_damage = apply_variance(maxhp / 10, 10)
  86.       @hp_damage = @hp - 1 if @hp_damage >= @hp
  87.       @slip_damage = @hp_damage
  88.       self.hp -= @hp_damage
  89.     end
  90.   end
  91. end #class   
  92. #===============================================
  93. #★角色队伍类
  94. #===============================================
  95. class Game_Party < Game_Unit
  96. attr_accessor :actor_battler
  97. alias oldinitialize initialize
  98. def initialize
  99.   oldinitialize
  100.   @actor_battler = []
  101. end
  102. end #class  
  103. #================================================
  104. #★敌人队伍类
  105. #================================================
  106. class Game_Troop < Game_Unit
  107.   attr_accessor :enemy_battler
  108. alias  oldinitialize initialize
  109. def initialize
  110.    oldinitialize
  111.    @enemy_battler = []
  112. end  
  113. end#class
  114. #================================================
  115. #★cp条处理类
  116. #================================================
  117. class Scene_CP
  118.     attr_accessor :stop
  119.     attr_accessor :in_battler
  120.     attr_accessor :cp_battler
  121.     BATTLE_SPEED = 0.8
  122.     def initialize
  123.       @stop = false
  124.       @all_agi = 0
  125.       @v =  Viewport.new(0, 0, 544, 90)
  126.       @count = 0
  127.       @cpline = Sprite.new(@v)
  128.       @cpline.bitmap = Bitmap.new(544,416)
  129.       bitmap = Bitmap.new("Graphics/system/cp条")
  130.       @cpline.bitmap.blt(105,8,bitmap,bitmap.rect)
  131.       @cp_battler = {}
  132.       for battler in $game_party.members + $game_troop.members
  133.         @all_agi += battler.agi
  134.         @cp_battler[battler] = Sprite_cpbattler.new
  135.         if battler.is_a?(Game_Actor)
  136.           @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_cp")
  137.           @cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].bitmap.rect)
  138.         else
  139.           name = battler.original_name + "_敌人cp"
  140.           if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  141.              @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  142.           else
  143.              @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
  144.           end
  145.              @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
  146.         end  
  147.         @cp_battler[battler].z = 101
  148.         @cp_battler[battler].visible = false
  149.         
  150.       end
  151.     end   
  152.    
  153.     #===========================================
  154.    
  155.    
  156.    
  157.    
  158.     #===========================================
  159.    
  160.    
  161.     def update
  162.       #@cp_battler.each{|key,value|
  163.       #if value.disposed? or value.opacity == 0
  164.       #  @cp_battler.delete(key)
  165.       #  next
  166.       #end
  167.       #value.update}
  168.       return if @stop
  169.       
  170.       
  171.       for battler in $game_party.members + $game_troop.members
  172.         if (@cp_battler[battler].disposed? or @cp_battler[battler].opacity == 0) and battler.dead?
  173.           @cp_battler.delete(@cp_battler[battler])
  174.           next
  175.         end  
  176.         if battler.dead?
  177.          if  @cp_battler.include?(battler)
  178.               @cp_battler[battler].collapse = true
  179.           end   
  180.           battler.cp = 0
  181.           next
  182.         end  
  183.        battler.cp = [[battler.cp + BATTLE_SPEED*10*battler.agi / @all_agi,0].max,battler.maxcp].min if battler.movable?
  184.        battler.cp_turn = [[battler.cp_turn+BATTLE_SPEED*10*battler.agi / @all_agi, 0].max,battler.maxcp].min
  185.        if battler.cp == battler.maxcp
  186.            if battler.is_a?(Game_Actor)
  187.               @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_a_cp")
  188.               @cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].bitmap.rect)
  189.             
  190.            else
  191.             name = battler.original_name + "_a_cp"
  192.             if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  193.             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  194.             else
  195.             @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/a_敌人cp")
  196.             end
  197.             @cp_battler[battler].bitmap.blt(80,60,  @cp_battler[battler].bitmap,  @cp_battler[battler].bitmap.rect)
  198.           end  
  199.             @cp_battler[battler].z = 101
  200.             battler.cp_total = true
  201.       elsif battler.cp_total == true
  202.           if battler.is_a?(Game_Actor)
  203.              @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{battler.id.to_s}_cp")
  204.              @cp_battler[battler].bitmap.blt(80,60,@cp_battler[battler].bitmap,@cp_battler[battler].bitmap.rect)
  205.            else
  206.                 name = battler.original_name + "_敌人cp"
  207.              if FileTest.exist?("Graphics/system/#{name}.jpg") or FileTest.exist?("Graphics/system/#{name}.png") or FileTest.exist?("Graphics/system/#{name}.bmp")
  208.                  @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/#{name}")
  209.                
  210.              else
  211.                  @cp_battler[battler].bitmap = Bitmap.new("Graphics/system/敌人cp")
  212.                
  213.              end
  214.                
  215.                @cp_battler[battler].bitmap.blt(80,60, @cp_battler[battler].bitmap, @cp_battler[battler].bitmap.rect)
  216.             end
  217.             battler.cp_total = false
  218.             @cp_battler[battler].z = 105
  219.             
  220.       end
  221.          
  222.       @cp_battler[battler].visible = true if @cp_battler[battler].visible == false
  223.       @cp_battler[battler].opacity = 255
  224.       @cp_battler[battler].y = 30
  225.       @cp_battler[battler].x = 95+300*battler.cp/battler.maxcp
  226.       if battler.cp_turn == battler.maxcp
  227.         battler.remove_states_auto unless battler.movable?
  228.         battler.slip_damage_effect
  229.         battler.do_auto_recovery if battler.is_a?(Game_Actor)
  230.         battler.damage_pop = true if battler.slip_damage != 0 or battler.auto_damage != 0
  231.         battler.cp_turn = 0
  232.       end  
  233.       if battler.cp == battler.maxcp
  234.          if battler.is_a?(Game_Actor)
  235.            $game_party.actor_battler.push(battler)
  236.          else
  237.            battler.make_action
  238.            $game_troop.enemy_battler.push(battler)
  239.            battler.make_action
  240.           end   
  241.       else
  242.         next
  243.       end  
  244.       
  245.       
  246.       
  247.    end     
  248. end
  249.   def dispose
  250.     for j in 0..25
  251.     @cpline.opacity -= 10
  252.     for i in @cp_battler.values
  253.       unless i.disposed?
  254.       i.opacity -= 10
  255.       end
  256.     end  
  257.      Graphics.update
  258.     end  
  259.     @v.dispose
  260.     @cpline.dispose
  261.     for i in @cp_battler.values
  262.       i.dispose
  263.     end
  264.   end  
  265. end
  266.   
  267.   
  268.   
  269.   
  270.   
  271.   
  272.   
  273.   
  274.   class Sprite_cpbattler < Sprite
  275.     attr_accessor :collapse
  276.    
  277.     def initialize (viewport = nil)
  278.       super (viewport)
  279.      
  280.       @effect_duration = 0        
  281.       @collapse = false
  282.     end
  283.     def update
  284.        super
  285.   
  286.      if self.collapse == true and self.opacity != 0
  287.       @effect_type = 5
  288.       @effect_duration = 48
  289.       self.color.set(255, 128, 128, 128)
  290.       for i in 0..48
  291.       self.opacity = 256 - (48 - @effect_duration) * 6
  292.       if self.opacity == 0
  293.    
  294.       break
  295.       end  
  296.       Graphics.update
  297.       @effect_duration -= 1
  298.       end
  299.      
  300.       self.collapse = false
  301.       self.color.set(255,255,255,5)
  302.      end
  303.      
  304.     end
  305.    
  306. def dispose
  307.      if self.bitmap != nil
  308.       self.bitmap.dispose
  309.      end
  310.    
  311.     super
  312.   end
  313.       
  314. end  
  315. #==========================================================================
  316. #
  317. #==========================================================================
  318. class Scene_Battle < Scene_Base
  319.   
  320.   #--------------------------------------------------------------------------
  321.   # ● 開始処理
  322.   #--------------------------------------------------------------------------
  323.   def start
  324.     super
  325.     #======================
  326.     @select_input = true
  327.     #======================
  328.     $game_temp.in_battle = true
  329.     #=============================================
  330.     unless  $BTEST
  331.       @battleback = nil
  332.       for area in  $data_areas.values
  333.          if $game_player.in_area?(area)
  334.              name = area.name
  335.              @battleback = Cache.battleback("#{name}")if FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.jpg") or FileTest.exist?("Graphics/Battlebacks/#{name}.bmp")
  336.                break
  337.           end
  338.       end     
  339.         if @battleback == nil
  340.              name = $game_map.name
  341.              @battleback = Cache.battleback("#{name}")
  342.         end      
  343.       $game_temp.background_bitmap  = @battleback
  344.     end
  345.    #==================================================
  346.     @spriteset = Spriteset_Battle.new
  347.     @message_window = Window_BattleMessage.new
  348.     @message_window.visible = false
  349.     @action_battlers = []
  350.     @cp_battle = Scene_CP.new
  351.     @cp_battle.stop = false
  352.     create_info_viewport
  353.    
  354.    
  355.     @select_icon = Sprite.new
  356.     @select_icon.z = 148
  357.     @select_icon.bitmap = Bitmap.new("Graphics/system/光标")
  358.     @select_icon.opacity = 240
  359.     @select_icon.visible = false
  360.     @c_c = 0
  361.    
  362.    
  363.   end
  364.   
  365.   #==============================================================
  366.   #★ 定义光标刷新
  367.   #==============================================================
  368.    
  369.   def select_icon_update(s_sw = false)
  370.     if s_sw == false
  371.       @select_icon.visible = false
  372.     else
  373.       @select_icon.visible = true
  374.       @select_icon.x = $game_troop.members[@target_enemy_window.enemy.index].screen_x
  375.       @select_icon.y = $game_troop.members[@target_enemy_window.enemy.index].screen_y - 30
  376.       
  377.       if @c_c%2 == 0
  378.       @select_icon.opacity += 30
  379.       else
  380.       @select_icon.opacity -= 30  
  381.       end
  382.     end  
  383.    
  384.   end   
  385.   
  386.   
  387.   #=================================================
  388.   #★主刷新部分
  389.   #=================================================
  390.   
  391.   
  392.   def update
  393.     super
  394.    
  395.     @c_c += 1
  396.   
  397.     update_basic(true)
  398.     update_info_viewport               
  399.       return if judge_win_loss            
  400.       update_scene_change
  401.       if @target_enemy_window != nil
  402.         update_target_enemy_selection     
  403.       elsif @target_actor_window != nil
  404.         update_target_actor_selection     
  405.       elsif @skill_window != nil
  406.         update_skill_selection            
  407.       elsif @item_window != nil
  408.         update_item_selection            
  409.       
  410.       elsif @actor_command_window.active
  411.         update_actor_command_selection   
  412.       #=================================
  413.       elsif @cp_battle.stop ==  false
  414.         active_battler_update
  415.       #=================================  
  416.       else
  417.         process_battle_event            
  418.         process_action                    
  419.         process_battle_event              
  420.       end
  421.       
  422.     #end
  423.   
  424.       
  425.   end
  426.   #================================================
  427.   #★战斗初始化
  428.   #===============================================
  429.   
  430.   def start_party_command_selection
  431.     if $game_temp.in_battle
  432.       @status_window.refresh
  433.       @status_window.index = @actor_index = -1
  434.       @active_battler = nil
  435.      
  436.      @actor_command_window.active = false
  437.       $game_party.clear_actions
  438.    
  439.     for i in 0..$game_party.members.size-1
  440.       if $game_party.members[i].act_status != -1
  441.         $game_party.members[i].act_status = -1
  442.       end  
  443.     end
  444.    
  445.       if $game_troop.surprise or not $game_party.inputable?
  446.         start_main
  447.       end
  448.     end
  449.   end
  450.   
  451.   #=============================================
  452.   #★角色回合的处理函数
  453.   #=============================================
  454.   
  455.   
  456.   def next_actor
  457.    
  458.     for i in 0..$game_party.members.size-1
  459.       if $game_party.members[i].act_status != -1
  460.         $game_party.members[i].act_status = -1
  461.       end  
  462.     end
  463.   
  464.     @info_viewport.visible = true
  465.     @status_window.refresh
  466.     @now_face = -1
  467.     @actor_command_window.update
  468.     @status_window.update
  469.   
  470.     loop do
  471.    
  472.       if @actor_index == @actor_battler.size - 1
  473.       
  474.         start_main
  475.         return
  476.         
  477.       end   
  478.       @actor_index += 1
  479.       index = 0
  480.       for battler in $game_party.members
  481.         if battler == @actor_battler[@actor_index]
  482.           break
  483.         else
  484.           index += 1
  485.         end
  486.       end  
  487.       @status_window.index = index
  488.      
  489.        if @active_battler != nil and @active_battler != @actor_battler[@actor_index] and @active_battler.is_a?(Game_Actor)
  490.         @active_battler.act_status = -1
  491.       end
  492.       
  493.       @active_battler = @actor_battler[@actor_index]
  494.      
  495.      
  496.       @active_battler.act_status = 1
  497.      
  498.       if @active_battler.auto_battle
  499.         @active_battler.make_action
  500.         next
  501.       end
  502.       break if @active_battler.inputable?
  503.     end
  504.     start_actor_command_selection
  505.   end
  506.   
  507.   #===================================================
  508.   #★激活角色指令窗口
  509.   #===================================================
  510.   
  511.   def start_actor_command_selection
  512.     @actor_command_window.setup(@active_battler)
  513.     @actor_command_window.active = true
  514.     @actor_command_window.index = 0
  515.   end
  516.   
  517.   #==============================================
  518.   #★指令窗口刷新
  519.   #==============================================
  520.    def update_actor_command_selection
  521.    
  522.     if Input.trigger?(Input::C)
  523.       case @actor_command_window.index
  524.       when 0  # 攻击
  525.         Sound.play_decision
  526.         @active_battler.action.set_attack
  527.         start_target_enemy_selection
  528.       when 1  # 特技
  529.         Sound.play_decision
  530.         start_skill_selection
  531.       when 2  # 防御
  532.         Sound.play_decision
  533.         @active_battler.action.set_guard
  534.         next_actor
  535.         @active_battler.cp = 0
  536.       when 3  # 物品
  537.         Sound.play_decision
  538.         start_item_selection
  539.       
  540.       when 4 #逃跑
  541.         if $game_troop.can_escape == false
  542.           Sound.play_buzzer
  543.           return
  544.         end
  545.         Sound.play_decision
  546.         process_escape
  547.     end
  548.     end
  549.   end
  550.   
  551.   #====================================
  552.   #★选择敌人
  553.   #====================================
  554.   def start_target_enemy_selection
  555.      if @skill_window != nil
  556.       @skill_window.visible = false
  557.     end
  558.     if @item_window != nil
  559.       @item_window.visible = false
  560.     end  
  561.     @target_enemy_window = Window_TargetEnemy.new
  562.     @target_enemy_window.opacity = 0
  563.     @target_enemy_window.contents_opacity = 0
  564.     #@target_enemy_window.y = @info_viewport.rect.y
  565.     #@info_viewport.rect.x += @target_enemy_window.width
  566.     #@info_viewport.ox += @target_enemy_window.width
  567.     @actor_command_window.active = false
  568.   
  569.     select_icon_update(true)
  570.   end
  571.   #===========================================================
  572.   #★结束敌人选择
  573.   #===========================================================
  574.    def end_target_enemy_selection
  575.     #@info_viewport.rect.x -= @target_enemy_window.width
  576.     #@info_viewport.ox -= @target_enemy_window.width
  577.     @target_enemy_window.dispose
  578.     @target_enemy_window = nil
  579.    
  580.     select_icon_update
  581.    
  582.     if @actor_command_window.index == 0
  583.       @actor_command_window.active = true
  584.     end
  585.   end  
  586.   #=======================================================
  587.   #★敌人选择刷新
  588.   #=======================================================
  589.   def update_target_enemy_selection
  590.    @target_enemy_window.update
  591.    
  592.     select_icon_update(true)
  593.     if Input.trigger?(Input::B)
  594.       Sound.play_cancel
  595.       if @skill_window != nil
  596.         @skill_window.visible = true
  597.       end
  598.       if @item_window != nil
  599.         @item_window.visible = true
  600.       end  
  601.       end_target_enemy_selection
  602.     elsif Input.trigger?(Input::C)
  603.       Sound.play_decision
  604.       @active_battler.action.target_index = @target_enemy_window.enemy.index
  605.       end_target_enemy_selection
  606.       end_skill_selection
  607.       end_item_selection
  608.       next_actor
  609.       @active_battler.cp = 0
  610.     end
  611.   end
  612.   
  613.   #======================================================
  614.   #★己方选择
  615.   #======================================================
  616.   def start_target_actor_selection
  617.     @target_actor_window = Window_BattleStatus.new
  618.     @target_actor_window.index = 0
  619.     @target_actor_window.active = true
  620.     @target_actor_window.y = @info_viewport.rect.y
  621.     @target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
  622.     @info_viewport.rect.x += @target_actor_window.width
  623.     @info_viewport.ox += @target_actor_window.width
  624.     @actor_command_window.active = false
  625.     #=====================
  626.     #☆减少刷新次数
  627.     #=====================
  628.     @last_index = -1
  629.   end
  630.   #==================================================
  631.   #★己方选择结束处理
  632.   #==================================================
  633.   def end_target_actor_selection
  634.     @info_viewport.rect.x -= @target_actor_window.width
  635.     @info_viewport.ox -= @target_actor_window.width
  636.     @target_actor_window.dispose
  637.     @target_actor_window = nil
  638.     #=====================
  639.     #☆减少刷新次数
  640.     #=====================
  641.     @last_index = -1
  642.   end
  643.   #===================================================
  644.   #★己方选择刷新
  645.   #===================================================
  646.   def update_target_actor_selection
  647.     if @last_index != @target_actor_window.index
  648.      @target_actor_window.refresh
  649.      @target_actor_window.draw_actorface($game_party.members[@target_actor_window.index])
  650.      @last_index = @target_actor_window.index
  651.     end
  652.     @target_actor_window.update
  653.     if Input.trigger?(Input::B)
  654.       Sound.play_cancel
  655.       end_target_actor_selection
  656.     elsif Input.trigger?(Input::C)
  657.       Sound.play_decision
  658.       @active_battler.action.target_index = @target_actor_window.index
  659.      
  660.       end_target_actor_selection
  661.       end_skill_selection
  662.       end_item_selection
  663.       next_actor
  664.        @active_battler.cp = 0
  665.     end
  666.   end
  667.   #============================================
  668.   #★特技使用决定  处理
  669.   #===========================================
  670.   
  671.   
  672.   def determine_skill
  673.     @active_battler.action.set_skill(@skill.id)
  674.     @skill_window.active = false
  675.     if @skill.need_selection?
  676.       if @skill.for_opponent?
  677.         start_target_enemy_selection
  678.       else
  679.         start_target_actor_selection
  680.       end
  681.     else
  682.       end_skill_selection
  683.       next_actor
  684.       @active_battler.cp = 0
  685.     end
  686.   end
  687.   #=========================================
  688.   #★物品使用决定  处理
  689.   #=========================================
  690.   
  691.   
  692.   def determine_item
  693.     @active_battler.action.set_item(@item.id)
  694.     @item_window.active = false
  695.     if @item.need_selection?
  696.       if @item.for_opponent?
  697.         start_target_enemy_selection
  698.       else
  699.         start_target_actor_selection
  700.       end
  701.     else
  702.       end_item_selection
  703.       next_actor
  704.        @active_battler.cp = 0
  705.     end
  706.   end
  707.   
  708.   #===============================================
  709.   #★各窗口视口生成
  710.   #===============================================
  711.    def create_info_viewport
  712.     @info_viewport = Viewport.new(0, 288, 544, 256)
  713.     @info_viewport.z = 100
  714.     @status_window = Window_BattleStatus.new
  715.     @actor_command_window = Window_ActorCommand.new
  716.     @status_window.viewport = @info_viewport
  717.     @actor_command_window.viewport = @info_viewport
  718.     @status_window.x = 0
  719.     @actor_command_window.x = 416
  720.     @status_window.y = 128
  721.     @actor_command_window.y = 128
  722.     @info_viewport.visible = false
  723.     #========================
  724.     #☆减少头像刷新用
  725.     #========================
  726.     @now_face = -1
  727.    
  728.   end
  729.   #================================================
  730.   #★视口释放
  731.   #================================================
  732.   def dispose_info_viewport
  733.     @status_window.dispose
  734.     @actor_command_window.dispose
  735.     @info_viewport.dispose
  736.     #========================
  737.     #☆减少头像刷新用
  738.     #========================
  739.     @now_face = -1
  740.     if @window_egi != nil
  741.      @window_egi.dispose
  742.     end
  743.   end
  744.   #======================================================
  745.   #★视口刷新
  746.   #======================================================
  747.   
  748.   
  749.   def update_info_viewport
  750.    
  751.     @actor_command_window.update
  752.    
  753.   
  754.     if @active_battler != nil and @active_battler.is_a?(Game_Actor) and @active_battler.id != @now_face
  755.       @status_window.draw_actorface(@active_battler)
  756.       @now_face = @active_battler.id
  757.     end  
  758.    
  759.    
  760.     @status_window.update
  761.    
  762.    
  763.    
  764.     if @actor_command_window.active and   @actor_command_window.y > 0
  765.      @actor_command_window.y -= 8
  766.      @status_window.y -= 8
  767.    
  768.    
  769.     end
  770.   end
  771.   
  772.   #================================================
  773.   #★战斗开始 处理
  774.   #================================================
  775.   
  776.   def process_battle_start
  777.    
  778.    
  779.     if $game_troop.preemptive
  780.      
  781.       for battler in $game_party.members
  782.          battler.cp = battler.maxcp
  783.        end  
  784.        $game_troop.preemptive = false
  785.     elsif $game_troop.surprise
  786.       
  787.       for battler in $game_troop.members
  788.         battler.cp = battler.maxcp
  789.       end
  790.       $game_troop.surprise = false
  791.     end
  792.    
  793.     make_escape_ratio
  794.     process_battle_event
  795.    
  796.     #===========================================
  797.     @status_window.refresh
  798.     @status_window.index = @actor_index = -1
  799.    
  800.     #=====================
  801.     @cp_battle.stop = false
  802.     #=====================
  803.   
  804.   end
  805.   #==========================================
  806.   #★逃走处理
  807.   #==========================================
  808.   def process_escape
  809.     @info_viewport.visible = false
  810.    
  811.     if $game_troop.preemptive
  812.       success = true
  813.     else
  814.       success = (rand(100) < @escape_ratio)
  815.     end
  816.     Sound.play_escape
  817.     if success
  818.       #=============================
  819.       @cp_battle.dispose
  820.       #=============================
  821.       for battler in $game_party.members
  822.         battler.cp = 0
  823.       end  
  824.      
  825.       
复制代码
回复 支持 反对

使用道具 举报

1

主题

5

帖子

42

积分

②入门

积分
42
 楼主| 发表于 2010-3-26 13:56:08 | 显示全部楼层
  1.    battle_end(1)
  2.     else
  3.       @escape_ratio += 10
  4.      
  5.       @active_battler.cp = 0
  6.       @active_battler.action.clear
  7.       next_actor   
  8.     end
  9.   end
  10.   #========================================
  11.   #★胜利处理
  12.   #========================================
  13.   def process_victory
  14.     @info_viewport.visible = false
  15.    
  16.     RPG::BGM.stop
  17.     $game_system.battle_end_me.play
  18.     for battler in $game_troop.members
  19.       if battler.dead?
  20.          if  @cp_battle.cp_battler.include?(battler)
  21.               @cp_battle.cp_battler[battler].collapse = true
  22.               
  23.               next
  24.           end  
  25.        end     
  26.     end
  27.      @cp_battle.cp_battler.each{|key,value|
  28.       if value.disposed?
  29.         @cp_battler.delete(key)
  30.         next
  31.       end
  32.       value.update}
  33.     #=============================
  34.     @cp_battle.dispose
  35.     #=============================
  36.    for battler in $game_party.members
  37.      battler.cp = 0
  38.     end
  39.     unless $BTEST
  40.       $game_temp.map_bgm.play
  41.       $game_temp.map_bgs.play
  42.     end
  43.     display_exp_and_gold
  44.     display_drop_items
  45.     display_level_up
  46.     battle_end(0)
  47.   end
  48.    
  49.   #=================================
  50.   #★失败处理
  51.   #=================================
  52.   def process_defeat
  53.     @cp_battle.dispose
  54.     for battler in $game_party.members + $game_troop.members
  55.      battler.cp = 0
  56.     end
  57.     @info_viewport.visible = false
  58.    
  59.     battle_end(2)
  60.    
  61.   end
  62.   
  63.   #=============================================================================
  64.   #★CP战斗的主要刷新★
  65.   #=============================================================================
  66.   
  67.    def active_battler_update
  68.    
  69.     #===================================
  70.     @actor_battler = []
  71.     @enemy_battler = []
  72.     $game_party.actor_battler = []
  73.     $game_troop.enemy_battler = []
  74.     #===================================
  75.     @cp_battle.update
  76.     @actor_battler = $game_party.actor_battler
  77.     @enemy_battler = $game_troop.enemy_battler
  78.     #for battler in $game_party.members + $game_troop.members
  79.       
  80.     #end
  81.     if @actor_battler.size != 0
  82.       @cp_battle.stop = true
  83.       next_actor
  84.       Audio.se_play("Audio/SE/Jump2",100,100)
  85.     elsif @enemy_battler.size != 0  
  86.    
  87.     #================
  88.     @cp_battle.stop = true
  89.     start_main
  90.     #================
  91.    
  92.    
  93.      
  94.    end
  95.   
  96. end
  97. #=============================================================
  98. #=============================================================
  99.   #====================================================
  100.   #★战斗主处理
  101.   #====================================================
  102.    def start_main
  103.    
  104.     for i in 0..$game_party.members.size-1
  105.       if $game_party.members[i].act_status != 0
  106.         $game_party.members[i].act_status = 0
  107.       end  
  108.     end
  109.    
  110.    
  111.    
  112.     if @info_viewport.visible
  113.     @info_viewport.visible = false
  114.     @status_window.y = 128
  115.     @actor_command_window.y = 128
  116.     end
  117.    
  118.     @actor_command_window.active = false
  119.     @status_window.index = @actor_index = -1
  120.     @active_battler = nil
  121.   
  122.     make_action_orders
  123.     wait(20)
  124.    #=============================
  125.   
  126.    while @action_battlers.size != 0 and judge_win_loss == false
  127.    process_action
  128.    end
  129.    @cp_battle.stop = false
  130.    #=============================
  131.    
  132. end
  133. #=====================================
  134. #★行动顺序生成
  135. #=====================================
  136. def make_action_orders
  137.     @action_battlers = []
  138.    
  139.     unless $game_troop.surprise
  140.       @action_battlers += @actor_battler if @actor_battler.size != 0
  141.     end
  142.    
  143.    
  144.     unless $game_troop.preemptive
  145.       @action_battlers += @enemy_battler if @enemy_battler.size != 0
  146.     end
  147.     for battler in @action_battlers
  148.       battler.action.make_speed
  149.     end
  150.     @action_battlers.sort! do |a,b|
  151.       b.action.speed - a.action.speed
  152.     end
  153.   end
  154. #====================================
  155. #★战斗行动处理
  156. #====================================
  157. def process_action
  158.     return if judge_win_loss
  159.     return if $game_temp.next_scene != nil
  160.     set_next_active_battler
  161.    
  162.     return if @active_battler == nil
  163.     return if @active_battler.dead?
  164.    
  165.     @active_battler.white_flash = true
  166.     unless @active_battler.action.forcing
  167.       @active_battler.action.prepare
  168.     end
  169.     if @active_battler.action.valid?
  170.       execute_action
  171.     end
  172.     unless @active_battler.action.forcing
  173.      
  174.       remove_states_auto
  175.       display_current_state
  176.     end
  177.     @active_battler.white_flash = false
  178.    
  179.   end
  180.   #=================================
  181.   #★攻击行动 执行
  182.   #=================================
  183.   def execute_action_attack
  184.    
  185.     targets = @active_battler.action.make_targets
  186.     display_attack_animation(targets)
  187.     wait(20)
  188.     for target in targets
  189.       target.attack_effect(@active_battler)
  190.       display_action_effects(target)
  191.     end
  192.     #=====================
  193.     @active_battler.cp = 0
  194.     #=====================
  195.    end
  196.   #===============================
  197.   #★防御行动   执行
  198.   #===============================
  199.    
  200.    
  201.    def execute_action_guard
  202.    
  203.     wait(45)
  204.     #=====================
  205.     @active_battler.cp = 0
  206.     #=====================
  207.   end
  208.    #===============================
  209.    #★逃走  执行
  210.    #===============================
  211.   
  212.   def execute_action_escape
  213.    
  214.     @active_battler.escape
  215.     Sound.play_escape
  216.     wait(45)
  217.     #=====================
  218.     @active_battler.cp = 0
  219.     #=====================
  220.   end
  221.   #====================================
  222.   #★待机  执行
  223.   #====================================
  224.   def execute_action_wait
  225.    
  226.     wait(45)
  227.     #=====================
  228.     @active_battler.cp = 0
  229.     #=====================
  230.   end
  231.   
  232.   #============================
  233.   #★特技   执行
  234.   #============================
  235.   def execute_action_skill
  236.     skill = @active_battler.action.skill
  237.    
  238.     targets = @active_battler.action.make_targets
  239.    
  240.    
  241.     user = @active_battler.action.skill_user
  242.     if skill.animation2_id != 0
  243.       display_animation(user,skill.animation2_id)
  244.     end  
  245.     display_animation(targets, skill.animation_id)
  246.    
  247.     wait_for_animation
  248.    
  249.     @active_battler.mp -= @active_battler.calc_mp_cost(skill)
  250.     $game_temp.common_event_id = skill.common_event_id
  251.     for target in targets
  252.       target.skill_effect(@active_battler, skill)
  253.       display_action_effects(target, skill)
  254.     end
  255.     #=====================
  256.     @active_battler.cp = 0
  257.     #=====================
  258.   end
  259.   
  260.   #==============================
  261.   #★物品行动 执行
  262.   #==============================
  263.   
  264.   def execute_action_item
  265.     item = @active_battler.action.item
  266.    
  267.    
  268.     user = @active_battler.action.skill_user
  269.     if item.animation2_id != 0
  270.       display_animation(user,item.animation2_id)
  271.     end  
  272.    
  273.    
  274.     targets = @active_battler.action.make_targets
  275.     display_animation(targets, item.animation_id)
  276.    
  277.     wait_for_animation
  278.    
  279.     $game_party.consume_item(item)
  280.     $game_temp.common_event_id = item.common_event_id
  281.     for target in targets
  282.       target.item_effect(@active_battler, item)
  283.       display_action_effects(target, item)
  284.     end
  285.     #=====================
  286.     @active_battler.cp = 0
  287.     #=====================
  288.   end
  289.   #===========================
  290.   #★行动动画显示
  291.   #animation_id :-1 为普通攻击
  292.   #===========================
  293.   def display_animation(targets, animation_id)
  294.     if animation_id < 0
  295.       display_attack_animation(targets)
  296.     else
  297.       display_normal_animation(targets, animation_id)
  298.     end
  299.     wait(20)
  300.    
  301.   end
  302.   #====================================
  303.   #★普通攻击的动画显示
  304.   #====================================
  305.   def display_attack_animation(targets)
  306.     if @active_battler.is_a?(Game_Enemy)
  307.         user = @active_battler.action.skill_user
  308.       if @select_input == true
  309.         a1 = 0
  310.         a2 = 0
  311.         eval(@active_battler.note)
  312.         display_normal_animation(user,a1)if   a1 != 0
  313.         display_normal_animation(targets,a2)if  a2 !=0
  314.         Sound.play_enemy_attack if   a1 == 0 and a2 == 0
  315.         wait(15, true) if  a1 == 0 and  a2 == 0
  316.       elsif @active_battler.animation1_id != 0 or @active_battler.animation2_id != 0
  317.             display_normal_animation(user,@active_battler.animation1_id)if @active_battler.animation1_id != 0
  318.             display_normal_animation(targets,@active_battler.animation2_id)if @active_battler.animation2_id != 0
  319.             Sound.play_enemy_attack if  @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
  320.             wait(15, true) if  @active_battler.animation1_id == 0 and @active_battler.animation2_id == 0
  321.        end     
  322.    
  323.    
  324.    else
  325.       aid1 = @active_battler.atk_animation_id
  326.       aid2 = @active_battler.atk_animation_id2
  327.      
  328.       user = @active_battler.action.skill_user
  329.       if @active_battler.act_animation_id != 0
  330.         display_normal_animation(user,@active_battler.act_animation_id)
  331.       end  
  332.      
  333.    
  334.       
  335.       display_normal_animation(targets, aid1, false)
  336.       display_normal_animation(targets, aid2, true)
  337.     end
  338.     wait_for_animation
  339.   end
  340.   
  341.   #========================================
  342.   #★显示行动结果
  343.   #========================================
  344.    def display_action_effects(target, obj = nil)
  345.     unless target.skipped
  346.      
  347.       wait(5)
  348.       #=======================
  349.       target.damage_pop = true
  350.       #=======================
  351.       display_critical(target, obj)
  352.       display_damage(target, obj)
  353.       display_state_changes(target, obj)
  354.    
  355.     end
  356.   end
  357.   
  358.   #======================================
  359.   #★显示HP伤害
  360.   #======================================
  361.   
  362.   
  363.   def display_hp_damage(target, obj = nil)
  364.      
  365.     if target.hp_damage == 0               
  366.       return if obj != nil and obj.damage_to_mp
  367.       return if obj != nil and obj.base_damage == 0
  368.       
  369.     elsif target.absorbed                   # 吸収
  370.      
  371.        #=====================================
  372.       @active_battler.damage_pop = true
  373.       @active_battler.damage = target.hp_damage
  374.      
  375.       target.cp -= target.hp_damage/100
  376.       @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
  377.      if target.dead?
  378.          @cp_battle.cp_battler[target].collapse = true
  379.          target.cp = 0
  380.          @cp_battle.cp_battler[target].update
  381.       end
  382.       
  383.       
  384.    
  385.       #=====================================
  386.     elsif target.hp_damage > 0            
  387.      
  388.       if target.actor?
  389.       
  390.         Sound.play_actor_damage
  391.         $game_troop.screen.start_shake(5, 5, 10)
  392.       else
  393.       
  394.         Sound.play_enemy_damage
  395.         target.blink = true
  396.       end
  397.       #=====================================
  398.       
  399.       target.cp -= target.hp_damage/100
  400.       @cp_battle.cp_battler[target].x = [95 + 300*target.cp/target.maxcp,95].max
  401.       
  402.       if target.dead?
  403.          @cp_battle.cp_battler[target].collapse = true
  404.          target.cp = 0
  405.          @cp_battle.cp_battler[target].update
  406.       end
  407.       
  408.      
  409.       #wait(10)
  410.       #=====================================
  411.     else                                    
  412.      
  413.       Sound.play_recovery
  414.     end
  415.    
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # ● MP 伤害表示
  419.   #--------------------------------------------------------------------------
  420.   def display_mp_damage(target, obj = nil)
  421.     return if target.dead?
  422.     return if target.mp_damage == 0
  423.    
  424.     if target.absorbed                      # 吸收
  425.       
  426.       #=====================================
  427.       @active_battler.damage_pop = true
  428.       @active_battler.damage = - target.mp_damage
  429.      
  430.       
  431.       target.cp -= target.mp_damage/100
  432.       @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
  433.       
  434.       #=====================================
  435.     elsif target.mp_damage > 0              
  436.    
  437.      #=====================================
  438.       target.cp -= target.mp_damage/100
  439.       @cp_battle.cp_battler[target].x = [95+300*target.cp/target.maxcp,95].max
  440.       
  441.       #=====================================
  442.     else                                    
  443.    
  444.       Sound.play_recovery
  445.     end
  446.    
  447.   end
  448.   #=======================================
  449.   #★重定义对话窗口刷新
  450.   #=======================================
  451.   def wait_for_message
  452.    wait(45)
  453.   end
  454.   
  455.   #================================================
  456.   #★经验金钱获得物品提示窗口(原方法重定义)
  457.   #================================================
  458.   def display_exp_and_gold
  459.     exp=$game_troop.exp_total
  460.     gold=$game_troop.gold_total
  461.     $game_party.gain_gold(gold)
  462.     drop_items = $game_troop.make_drop_items
  463.     @window_egi = Window_egi.new(exp,gold,drop_items)
  464.     @window_egi.openness=0
  465.     wait(15)
  466.     loop do
  467.       if @window_egi.openness <= 255
  468.        @window_egi.openness+=48
  469.       end
  470.       if Input.trigger?(Input::C) or Input.trigger?(Input::B)
  471.         break
  472.       end
  473.       Graphics.update
  474.       Input.update
  475.       
  476.       
  477.     end
  478.    
  479.     loop do
  480.       @window_egi.openness -= 48 if @window_egi.openness >= 0
  481.       Graphics.update
  482.       if @window_egi.openness <= 0
  483.         break
  484.       end  
  485.     end #loop
  486.    
  487.   end
  488.   alias oldstart_skill_selection  start_skill_selection
  489.   def start_skill_selection
  490.     oldstart_skill_selection
  491.     @skill_window.z = 3000
  492.     @skill_window.help_window.z = 3000
  493.    
  494.   end  
  495.   alias oldstart_item_selection  start_item_selection
  496.   def start_item_selection
  497.     oldstart_item_selection
  498.     @item_window.z=3000
  499.     @item_window.help_window.z = 3000
  500.   end  
  501.   
  502.   
  503. end #class
  504. #=====================================================
  505. #★战斗状态窗口类
  506. #=====================================================
  507. class Window_BattleStatus < Window_Selectable
  508.   
  509.   
  510.   def draw_item(index)
  511.     rect = item_rect(index)
  512.     rect.x += 4
  513.     rect.width -= 8
  514.     self.contents.clear_rect(rect)
  515.     self.contents.font.color = normal_color
  516.     actor = $game_party.members[index]
  517.     draw_actor_name(actor, 96, rect.y)
  518.     draw_actor_state(actor, 114+48, rect.y, 48)
  519.     draw_actor_hp(actor, 174, rect.y, 120)
  520.     draw_actor_mp(actor, 310, rect.y, 70)
  521.   end
  522.   #=======================================================================
  523.   #★定义角色头像的描绘
  524.   #=======================================================================
  525.    def draw_actorface(actor)
  526.       
  527.     draw_face(actor.face_name, actor.face_index, 5, 5, size = 80)
  528.   end
  529.   #=========================================================================
  530.   
  531.   def update_cursor
  532.      super
  533.      self.cursor_rect.width = self.width - 120
  534.      self.cursor_rect.x = 90
  535.      
  536.   end  
  537.   #========================================================================
  538. end #class
  539. #=================================================
  540. #★战斗图处理的类
  541. #=================================================
  542. class Sprite_Battler < Sprite_Base
  543.   
  544. #=================================
  545. #★刷新
  546. #=================================
  547. def update
  548.     super
  549.     if @battler == nil
  550.       self.bitmap = nil
  551.     else
  552.       @use_sprite = @battler.use_sprite?
  553.       if @use_sprite
  554.         self.x = @battler.screen_x
  555.         self.y = @battler.screen_y
  556.         self.z = @battler.screen_z
  557.         update_battler_bitmap
  558.         if @battler.act_status == 1
  559.          if self.opacity <280
  560.            self.opacity += 20
  561.         end
  562.       elsif @battler.act_status == -1
  563.          if self.opacity > 125
  564.            self.opacity -= 20
  565.          end  
  566.       elsif  (@battler.dead? or   @battler.hidden) and @battler.collapse == false
  567.       
  568.       else
  569.         self.opacity = 255
  570.       end  
  571.       end
  572.       
  573.       setup_new_effect
  574.       update_effect
  575.      
  576.     end
  577.   end  
  578. #===============================
  579. #
  580. #===============================
  581.   def update_battler_bitmap
  582.     if @battler.battler_name != @battler_name or
  583.        @battler.battler_hue != @battler_hue
  584.       @battler_name = @battler.battler_name
  585.       @battler_hue = @battler.battler_hue
  586.       self.bitmap = Cache.battler(@battler_name, @battler_hue)
  587.       @width = bitmap.width
  588.       @height = bitmap.height
  589.       self.ox = @width / 2
  590.       self.oy = @height
  591.       if (@battler.dead? or @battler.hidden) and @battler.collapse == false
  592.         
  593.       end
  594.     end
  595.     if @battler.is_a?(Game_Actor)
  596.       count = 40
  597.     else
  598.       count = 44
  599.     end  
  600.    
  601.    
  602.     if Graphics.frame_count%count <= 19
  603.       self.bitmap = Cache.battler(@battler_name,@battler_hue)
  604.       @width = bitmap.width
  605.       @height = bitmap.height
  606.       self.ox = @width / 2
  607.       self.oy = @height
  608.     else
  609.       b_name = @battler_name + "待"
  610.        if FileTest.exist?("Graphics/Battlers/#{b_name}.png") or FileTest.exist?("Graphics/Battlers/#{b_name}.jpg")  or  FileTest.exist?("Graphics/Battlers/#{b_name}.bmp")
  611.          self.bitmap = Cache.battler(b_name,@battler_hue)
  612.          @width = bitmap.width
  613.          @height = bitmap.height
  614.          self.ox = @width/2
  615.          self.oy = @height
  616.        end
  617.     end      
  618.       
  619.    
  620.   end
  621.   
  622. #==================================
  623. #
  624. #==================================
  625. def setup_new_effect
  626.     if @battler.white_flash
  627.       @effect_type = WHITEN
  628.       @effect_duration = 16
  629.       @battler.white_flash = false
  630.     end
  631.    
  632.     if @battler.blink
  633.       @effect_type = BLINK
  634.       @effect_duration = 20
  635.       @battler.blink = false
  636.     end
  637.     if not @battler_visible and @battler.exist?
  638.       @effect_type = APPEAR
  639.       @effect_duration = 16
  640.       @battler_visible = true
  641.     end
  642.     if @battler.damage_pop and not (@battler.collapse or @battler.hidden)
  643.       if @battler.damage != nil
  644.         s_1 = @battler.damage > 0 ? 0 : 1
  645.         @battler.damage = @battler.damage > 0 ? [email=-@battler.damage]-@battler.damage[/email] : @battler.damage
  646.       end  
  647.       
  648.       damage(@battler.damage,@battler.critical,s_1) if @battler.damage != 0 and @battler.damage != nil
  649.       damage(@battler.hp_damage,@battler.critical,0) if @battler.hp_damage != 0
  650.       damage(@battler.mp_damage,@battler.critical,1) if @battler.mp_damage != 0
  651.       damage("失误",@battler.critical) if @battler.missed
  652.       damage("MISS",@battler.critical) if @battler.evaded
  653.       damage(@battler.slip_damage - @battler.auto_damage,@battler.critical) if @battler.slip_damage != 0 or @battler.auto_damage != 0
  654.       @battler.slip_damage = 0
  655.       @battler.auto_damage = 0
  656.       @battler.damage = nil
  657.       @battler.damage_pop = false
  658.     end
  659.     if @battler_visible and @battler.hidden
  660.       @effect_type = DISAPPEAR
  661.       @effect_duration = 32
  662.       @battler_visible = false
  663.     end
  664.     if @battler.collapse and self.opacity != 0
  665.       @effect_type = COLLAPSE
  666.       @effect_duration = 48
  667.       @battler.collapse = false
  668.       @battler_visible = false
  669.     end
  670.     if @battler.animation_id != 0 and @battler.collapse == false
  671.       self.opacity = 255
  672.       animation = $data_animations[@battler.animation_id]
  673.       mirror = @battler.animation_mirror
  674.       start_animation(animation, mirror)
  675.       @battler.animation_id = 0
  676.     end
  677.    
  678.       
  679.   end
  680. #=========================================
  681. #
  682. #=========================================
  683.   
  684.   
  685.   
  686.   
  687. end #class  
  688. #=================================================
  689. #★处理战斗行动的类
  690. #=================================================
  691. class Game_BattleAction
  692.   def skill_user
  693.     targets = []
  694.     targets.push(battler)
  695.      
  696.      return targets.compact
  697.    end
  698.   
  699.   
  700.    
  701. end#class  
  702. #=======================================================
  703. #★处理敌人的类
  704. #
  705. #=======================================================
  706. class Game_Enemy < Game_Battler
  707. def note
  708.     return $data_enemies[@enemy_id].note
  709. end  
  710.   
  711. end#class
  712. #======================================================
  713. #★角色处理类
  714. #======================================================
  715. class Game_Actor < Game_Battler
  716.   def setup(actor_id)
  717.     actor = $data_actors[actor_id]
  718.     @actor_id = actor_id
  719.     @name = actor.name
  720.     #--------------------------------------------
  721.     #★添加战斗图名称,以便战斗中获取战斗图
  722.     #--------------------------------------------
  723.     @battler_name = actor_id.to_s + "_z"
  724.     @battler_hue = 0
  725.     @flash = false
  726.     @character_name = actor.character_name
  727.     @character_index = actor.character_index
  728.     @face_name = actor.face_name
  729.     @face_index = actor.face_index
  730.     @class_id = actor.class_id
  731.     @weapon_id = actor.weapon_id
  732.     @armor1_id = actor.armor1_id
  733.     @armor2_id = actor.armor2_id
  734.     @armor3_id = actor.armor3_id
  735.     @armor4_id = actor.armor4_id
  736.     @level = actor.initial_level
  737.     @exp_list = Array.new(101)
  738.     make_exp_list
  739.     @exp = @exp_list[@level]
  740.     @skills = []
  741.     for i in self.class.learnings
  742.       learn_skill(i.skill_id) if i.level <= @level
  743.     end
  744.     clear_extra_values
  745.     recover_all
  746.   end
  747.   #--------------------------------------------------------------------------
  748.   # ● 执行自动回复 (回合结束时调用)
  749.   #--------------------------------------------------------------------------
  750.   def do_auto_recovery
  751.     if auto_hp_recover and not dead?
  752.       self.hp += maxhp / 20
  753.       @auto_damage = maxhp / 20
  754.     end
  755.   end
  756.   #==========================================================================
  757.   #★ 定义武器的行动方动画id,默认为第一武器的id
  758.   #==========================================================================
  759.   
  760.   def act_animation_id
  761.     return weapons[0] == nil ? 0 : weapons[0].animation2_id
  762.   end  
  763.   
  764.   #==========================================================================
  765.   #==========================================================================
  766.   #==========================================================================
  767.   #★定义角色战斗图 X 坐标
  768.   #==========================================================================
  769.   def screen_x
  770.    if self.index != nil
  771.     case index
  772.      when 0
  773.       return 460
  774.      when 1
  775.       return 440
  776.      when 2
  777.       return 420
  778.      when 3
  779.       return 400
  780.     end  
  781.   else
  782.    return 0
  783.   end
  784. end
  785.   #========================================================================
  786.   #★定义角色战斗图 Y 坐标
  787.   #========================================================================
  788.   def screen_y
  789.     if self.index != nil
  790.       case index
  791.        when 0
  792.          return 245
  793.        when 1
  794.          return 215
  795.        when 2
  796.          return 185
  797.        when 3
  798.          return 155
  799.        end
  800.     else   
  801.    
  802.     return 230
  803.    end
  804.   end  
  805.   
  806.   #========================================================================
  807.   #★定义角色战斗图 Z 坐标
  808.   #========================================================================   
  809.   def screen_z
  810.      if self.index != nil
  811.       return 4 - self.index
  812.     else
  813.       return 0
  814.     end
  815.   end
  816.   
  817.   
  818.   
  819.   def use_sprite?
  820.     return true
  821.   end
  822.   
  823. end#class
  824. #==========================================================
  825. #★模块定义
  826. #==========================================================
  827.   module RPG
  828.   class BaseItem
  829.     def animation2_id
  830.       return @note != nil ? @note.to_i : 0
  831.     end
  832.   end  
  833.    class Enemy
  834.      def animation1_id
  835.        animation1_id = @note.split(/,/)[0]
  836.        return animation1_id != nil ? animation1_id.to_i : 0
  837.      end
  838.      def animation2_id
  839.        animation2_id = @note.split(/,/)[1]
  840.        return animation2_id != nil ? animation2_id.to_i : 0
  841.      end
  842.     end
  843.    
  844.   end
  845.   
  846.   
  847. #======================================================
  848. #★精灵类主模块_伤害部分的添加
  849. #======================================================
  850. class Sprite_Base < Sprite
  851.   def initialize(viewport = nil)
  852.     super(viewport)
  853.     @use_sprite = true         
  854.     @animation_duration = 0     
  855.     #=============
  856.     @_damage_duration = 0
  857.     #=============
  858.   end
  859. alias oldupdate update
  860.   def update
  861.     oldupdate
  862.     #================
  863.     damge_update
  864.     #================
  865.   end
  866. alias olddispose dispose
  867.    def dispose
  868.      olddispose
  869.      
  870.     #===============
  871.     dispose_damage
  872.     #===============
  873.    end
  874.   
  875. #==========================================================================
  876. #★定义伤害处理
  877. #==========================================================================
  878.    def damage(value, critical,type = 0)
  879.       dispose_damage
  880.       if value.is_a?(Numeric)
  881.         damage_string = value.abs.to_s
  882.       else
  883.         damage_string = value.to_s
  884.       end
  885.       bitmap = Bitmap.new(160, 48)
  886.       bitmap.font.name = "黑体"
  887.       bitmap.font.size = 25
  888.       bitmap.font.color.set(0, 0, 0)
  889.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  890.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  891.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  892.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  893.       if value.is_a?(Numeric) and value < 0
  894.         case type
  895.          when 0
  896.            bitmap.font.color.set(176, 255, 144)
  897.          when 1
  898.            bitmap.font.color.set(0,100,255)
  899.          end  
  900.       else
  901.         case type
  902.         when 0
  903.         bitmap.font.color.set(255, 255, 255)
  904.         when 1
  905.           bitmap.font.color.set(200,0,185)
  906.         end  
  907.       end
  908.       
  909.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  910.       if critical and type == 0
  911.         bitmap.font.size = 18
  912.         bitmap.font.color.set(0, 0, 0)
  913.         bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  914.         bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  915.         bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  916.         bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  917.         bitmap.font.color.set(255, 255, 255)
  918.         bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  919.       end
  920.       @_damage_sprite = ::Sprite.new(self.viewport)
  921.       @_damage_sprite.bitmap = bitmap
  922.       @_damage_sprite.ox = 80
  923.       @_damage_sprite.oy = 20
  924.       @_damage_sprite.x = self.x
  925.       @_damage_sprite.y = self.y - self.oy / 2
  926.       @_damage_sprite.z = 3000
  927.       @_damage_duration = 40
  928.     end
  929.    
  930.     #===================================================
  931.     #
  932.     #===================================================
  933.     def dispose_damage
  934.       if @_damage_sprite != nil
  935.         @_damage_sprite.bitmap.dispose
  936.         @_damage_sprite.dispose
  937.         @_damage_sprite = nil
  938.         @_damage_duration = 0
  939.       end
  940.     end
  941.     #=============================================
  942.     #
  943.     #=============================================
  944.     def damge_update
  945.        if @_damage_duration > 0
  946.         @_damage_duration -= 1
  947.         case @_damage_duration
  948.         when 38..39
  949.           @_damage_sprite.y -= 4
  950.         when 36..37
  951.           @_damage_sprite.y -= 2
  952.         when 34..35
  953.           @_damage_sprite.y += 2
  954.         when 28..33
  955.           @_damage_sprite.y += 4
  956.         end
  957.         @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
  958.         if @_damage_duration == 0
  959.           dispose_damage
  960.         end
  961.       end
  962.    end
  963.   
  964.   
  965. end#class
  966. #=======================================================
  967. #★战斗经验、金钱、物品提示窗口
  968. #=======================================================
  969. class Window_egi<Window_Base
  970. #====================================
  971. #●初始化
  972. #====================================
  973. def initialize(exp, gold,item)
  974.    
  975.    
  976.     @exp=exp
  977.     @gold=gold
  978.     @item=item
  979.     @item_name = {}
  980.     n=0
  981.     m=0
  982.     if @item != nil
  983.      for itn in @item
  984.       if @item_name[itn.name]==nil
  985.          @item_name[itn.name]=0
  986.          m+=1
  987.        end
  988.      end
  989.     end
  990.     if @gold>0
  991.       m+=1
  992.     end  
  993.     super(200,100, 160,32*m+112 )
  994.     self.opacity = 150
  995.    
  996.     refresh
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # ● 刷新
  1000.   #--------------------------------------------------------------------------
  1001. def refresh
  1002.     self.contents.clear
  1003.     self.contents.font.size=19
  1004.     if @exp > 0
  1005.      self.contents.font.color = Color.new(255,255,0,255)
  1006.      self.contents.draw_text(6,8,64,32,"获得经验:")
  1007.      self.contents.font.color = Color.new(255,255,255,255)
  1008.      self.contents.draw_text(80,8,32,32,sprintf("%4s",@exp))
  1009.    
  1010.    elsif @exp == 0
  1011.      self.contents.font.color = Color.new(255,0,0,0)
  1012.      self.contents.draw_text(6,8,32,32,"没有获得经验!")
  1013.      
  1014.    end
  1015.    if @gold>0
  1016.      self.contents.font.color = Color.new(255,255,0,255)
  1017.      self.contents.draw_text(6,40,64,32,"获得金钱:")
  1018.      self.contents.font.color = Color.new(255,255,255,255)
  1019.      self.contents.draw_text(80,40,32,32,sprintf("%4s",@gold)+Vocab::gold)
  1020.    end  
  1021.    if @item_name.size != 0
  1022.    self.contents.font.size = 20
  1023.    self.contents.font.color = Color.new(255,255,0)
  1024.    self.contents.draw_text(25,72,64,32,"获得物品")
  1025.    i=0
  1026.    for itn in @item
  1027.      if @item_name[itn.name] == 0
  1028.        draw_icon(itn.icon_index ,6 ,106+i*32 , true)
  1029.        i+=1
  1030.      end  
  1031.      @item_name[itn.name]+=1
  1032.    end  
  1033.    i=0
  1034.    self.contents.font.size = 18
  1035.    self.contents.font.color = Color.new(255,255,255,255)
  1036.    for itn in @item_name
  1037.      self.contents.draw_text(30,106+i*32,64,32,itn[0].to_s + " × "+itn[1].to_s)
  1038.      i+=1
  1039.    end
  1040.    end
  1041.   
  1042.    
  1043.    
  1044. end
  1045.    
  1046.    
  1047. end#class  
  1048. module Cache
  1049.   def self.battleback(filename)
  1050.      load_bitmap("Graphics/Battlebacks/", filename)
  1051.    end   
  1052. end   
  1053.   
  1054. #=====================================================
  1055. #添加战斗背景的相关定义
  1056. #=====================================================
  1057. class Game_Map
  1058.   attr_accessor :name   
  1059.     def setup(map_id)
  1060.     @map_id = map_id
  1061.     @map = load_data(sprintf("Data/Map%03d.rvdata", @map_id))
  1062.     @mapinfo = load_data("Data/MapInfos.rvdata")
  1063.     #============================
  1064.     @name = @mapinfo[@map_id].name
  1065.     #============================
  1066.     @display_x = 0
  1067.     @display_y = 0
  1068.     @passages = $data_system.passages
  1069.     referesh_vehicles
  1070.     setup_events
  1071.     setup_scroll
  1072.     setup_parallax
  1073.     @need_refresh = false
  1074.    end #class
  1075.   
  1076.   
  1077.    def area(old_name,new_name)
  1078.   
  1079.     for area in  $data_areas.values
  1080.       if area.name == old_name and area.map_id == @map_id
  1081.         area.name == new_name
  1082.       end
  1083.     end
  1084.   end  
  1085. end #class
  1086. class Spriteset_Battle
  1087.   def create_battleback
  1088.      source = $game_temp.background_bitmap
  1089.      bitmap = Bitmap.new(640, 480)
  1090.      bitmap.blt(0,0,source,source.rect)
  1091.      @battleback_sprite = Sprite.new(@viewport1)
  1092.      @battleback_sprite.bitmap = bitmap
  1093.      @battleback_sprite.ox = 272
  1094.      @battleback_sprite.oy = 208
  1095.      @battleback_sprite.x = 260
  1096.      @battleback_sprite.y = 208
  1097.    end
  1098.   alias oldcreate_battlefloor create_battlefloor
  1099.   def create_battlefloor
  1100.    oldcreate_battlefloor
  1101.    @battlefloor_sprite.opacity = 0
  1102.   end
  1103. end#class
复制代码
回复 支持 反对

使用道具 举报

1

主题

5

帖子

42

积分

②入门

积分
42
 楼主| 发表于 2010-3-26 13:56:46 | 显示全部楼层
得失物品
  1. #==============================================================================
  2. # 本腳本來自[url]www.66RPG.com[/url],使用和轉載請保留此信息
  3. #==============================================================================
  4. # 注意!!!在對話後得到物品,請在對話後先用事件等待3幀,否則對話框來不及消失。
  5. # 開關定義:
  6. $noshowgold = 41                        # 不显示金钱得失
  7. $noshowitem = 42                        # 不显示物品得失
  8. $noshowweapon = 43                      # 不显示武器得失
  9. $noshowarmor = 44                       # 不显示防具得失
  10. # 以上開關,當打開的時候,獲得物品將不會提示,比如默認打開41號開關,獲得金錢不再提示
  11. # 不想提示等级升降时,就在事件命令直接选择是否显示就行了。
  12. #——聲效,可以自己改
  13. folder = "Audio/SE/"
  14. $gain_gold_se   = folder +"Shop"      # 获得金钱声效
  15. $loss_gold_se   = folder +"Blow2"     # 失去金钱声效
  16. $gain_item_se   = folder +"Item1"     # 获得物品声效
  17. $loss_item_se   = folder +"Blow2"     # 失去物品声效
  18. $gain_weapon_se = folder +"Item1"     # 获得武器声效
  19. $loss_weapon_se = folder +"Blow2"     # 失去武器声效
  20. $gain_armor_se  = folder +"Item1"     # 获得防具声效
  21. $loss_armor_se  = folder +"Blow2"     # 失去防具声效
  22. $gain_lv_se     = folder +"Item1"     # 提升等级声效
  23. $loss_lv_se     = folder +"Blow2"     # 降低等级声效
  24. # ————————————————————————————————————
  25. class Game_Interpreter
  26.   #--------------------------------------------------------------------------
  27.   # ● 增減金錢
  28.   #--------------------------------------------------------------------------
  29.   def command_125
  30.     value = operate_value(@params[0], @params[1], @params[2])
  31.     $game_party.gain_gold(value)
  32.     if $game_switches[$noshowgold]==false
  33.       show_gain_window(0, value)
  34.     end
  35.     return true
  36.   end
  37.   #--------------------------------------------------------------------------
  38.   # ● 增減物品
  39.   #--------------------------------------------------------------------------
  40.   def command_126
  41.     value = operate_value(@params[1], @params[2], @params[3])
  42.     $game_party.gain_item($data_items[@params[0]], value)
  43.     if $game_switches[$noshowitem]==false
  44.       show_gain_window(1, value)
  45.     end
  46.     $game_map.need_refresh = true
  47.     return true
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 增減武器
  51.   #--------------------------------------------------------------------------
  52.   def command_127
  53.     value = operate_value(@params[1], @params[2], @params[3])
  54.     if @params[1] == 0
  55.       $game_party.gain_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  56.     else
  57.       $game_party.lose_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  58.     end
  59.     if $game_switches[$noshowweapon]==false
  60.       show_gain_window(2, value)
  61.     end
  62.     return true
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ● 增減防具
  66.   #--------------------------------------------------------------------------
  67.   def command_128
  68.     value = operate_value(@params[1], @params[2], @params[3])
  69.     if @params[1] == 0
  70.       $game_party.gain_reini_item($base_armors[@params[0]], value.abs, @params[4])
  71.     else
  72.       $game_party.lose_reini_item($base_armors[@params[0]], value.abs, @params[4])
  73.     end
  74.     if $game_switches[$noshowarmor]==false
  75.       show_gain_window(3, value)
  76.     end
  77.     return true
  78.   end
  79.   
  80.   #--------------------------------------------------------------------------
  81.   # ● 等级増減
  82.   #--------------------------------------------------------------------------
  83.   def command_316
  84.     value = operate_value(@params[1], @params[2], @params[3])
  85.     iterate_actor_id(@params[0]) do |actor|
  86.       actor.change_level(actor.level + value, false)
  87.       if @params[4]
  88.         show_gain_level_window(actor,value)
  89.       end
  90.     end
  91.     return true
  92.   end
  93.   
  94.   def show_gain_window(type, value)
  95.     snstar2006_66rpg_item = $data_armors[@params[0]]
  96.     snstar2006_66rpg = Window_Base.new((640-300)/2,128,200,100)
  97.     snstar2006_66rpg.contents = Bitmap.new(snstar2006_66rpg.width - 32, snstar2006_66rpg.height - 32)
  98.     if value >= 0
  99.       gain_text = "獲得"   
  100.     else
  101.       gain_text = "失去"
  102.     end
  103.    
  104.     case type
  105.     when 0
  106.       gain_type = "金錢"
  107.       if value >=0
  108.         Audio.se_play($gain_gold_se,80,100)
  109.       else
  110.         Audio.se_play("Audio/SE/"+"Item1",80,100)
  111.       end
  112.     when 1
  113.       gain_type = "物品"
  114.       string = $data_items[@params[0]]
  115.       if value >=0
  116.         Audio.se_play($gain_item_se,80,100)
  117.       else
  118.         Audio.se_play($loss_item_se,80,100)
  119.       end
  120.     when 2
  121.       gain_type = "武器"
  122.       string = $base_weapons[@params[0]]
  123.       if value >=0
  124.         Audio.se_play($gain_weapon_se,80,100)
  125.       else
  126.         Audio.se_play($loss_weapon_se,80,100)
  127.       end
  128.     when 3
  129.       gain_type = "防具"
  130.       string = $base_armors[@params[0]]
  131.       if value >=0
  132.         Audio.se_play($gain_armor_se,80,100)
  133.       else
  134.         Audio.se_play($loss_armor_se,80,100)
  135.       end
  136.     end
  137.    
  138.     snstar2006_66rpg.contents.draw_text(0,0,160,32,gain_text+gain_type+":")
  139.    
  140.     unless type == 0
  141.       snstar2006_66rpg.draw_item_name(string, 28, 32, true)
  142.       snstar2006_66rpg.contents.draw_text(0, 32, 150, 32, "×"+value.abs.to_s, 2)
  143.     else
  144.       snstar2006_66rpg.contents.draw_text(32,32,240,32,value.abs.to_s + "  "+ Vocab::gold)
  145.     end
  146.    
  147.     snstar2006_66rpg.opacity = 160
  148.    
  149.     for i in 0..30
  150.       Graphics.update
  151.     end
  152.    
  153.     for i in 0..10
  154.       snstar2006_66rpg.opacity -= 30
  155.       snstar2006_66rpg.contents_opacity -= 30
  156.       Graphics.update
  157.     end
  158.    
  159.     snstar2006_66rpg.dispose
  160.   end
  161.   def show_gain_level_window(actor,value)
  162.     lvstring = Vocab::level
  163.         
  164.     snstar2006_66rpg = Window_Base.new((640-300)/2,128,200,100)
  165.     snstar2006_66rpg.contents = Bitmap.new(snstar2006_66rpg.width - 32, snstar2006_66rpg.height - 32)
  166.    
  167.     if value >= 0
  168.       gain_text = "提升"
  169.       Audio.se_play($gain_lv_se,80,100)
  170.     else
  171.       gain_text = "降低"
  172.       Audio.se_play($loss_lv_se,80,100)
  173.     end
  174.    
  175.    
  176.     snstar2006_66rpg.contents.draw_text(0, 0, 108, 32, actor.name)
  177.     string = lvstring+gain_text+value.abs.to_s+"级"
  178.     snstar2006_66rpg.contents.draw_text(32,32,160,32,string)
  179.     snstar2006_66rpg.opacity = 160
  180.    
  181.     for i in 0..30
  182.       Graphics.update
  183.     end
  184.    
  185.     for i in 0..10
  186.       snstar2006_66rpg.opacity -= 30
  187.       snstar2006_66rpg.contents_opacity -= 30
  188.       Graphics.update
  189.     end
  190.    
  191.     snstar2006_66rpg.dispose
  192.   end
  193. end
复制代码
回复 支持 反对

使用道具 举报

1

主题

5

帖子

42

积分

②入门

积分
42
 楼主| 发表于 2010-3-26 14:00:34 | 显示全部楼层
  1. #=============================================================================
  2. # (测试)vx复杂装备系统之 装备升级功能 by 沉影不器
  3. #-----------------------------------------------------------------------------
  4. # 此版本侧重于捕捉bug,欢迎反馈.
  5. #=============================================================================
  6. # 参数设定如下
  7. #=============================================================================
  8. module Game_Equip
  9.   ## 能力升级基数(倍数)
  10.   BaseAbility = 0.2
  11.   ## 每级价格提高基数(倍数)
  12.   BasePrice = 0.3
  13.   ## 是否保证成功
  14.   UpGrade_Absoluteness = false
  15.   ## 每级成功率基数(百分比,用于逐级下降)
  16.   BaseSucceed = 1
  17.   ## 最大等级
  18.   MaxLevel = 10
  19.   ## 需金钱基数(与本身价格的倍数)
  20.   GoldNeed = 0.8
  21.   ## 需物品id => 数量
  22.   ItemsNeed = {21=>1, 22=>2}
  23. end
  24. #=============================================================================
  25. # 复杂装备模块
  26. #=============================================================================
  27. module Game_Equip
  28.   #--------------------------------------------------------------------------
  29.   # ● 处理价格
  30.   #--------------------------------------------------------------------------
  31.   def self.setup_price(item, price)
  32.     item.price = $base_weapons[item.base_id].price
  33.     item.price += [(item.price * BasePrice).round, 1].max
  34.     item.price += price
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 升级是否成功?
  38.   #--------------------------------------------------------------------------
  39.   def self.upgradesucceed?(lv)
  40.     return true if UpGrade_Absoluteness
  41.     new_lv = lv.nil? ? 1 : lv + 1
  42.     return false if new_lv > MaxLevel
  43.     return BaseSucceed**new_lv > rand(0)
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 装备重生
  47.   #    equip:  装备
  48.   #--------------------------------------------------------------------------
  49.   def self.reini(equip)
  50.     return if equip.nil?
  51.     result = Marshal.load(Marshal.dump(equip))
  52.     result.base_id = equip.id
  53.     setup_price(result, 0)
  54.     case result
  55.     when RPG::Weapon
  56.       result.id = $data_weapons.size
  57.       ##result.name += result.id.to_s
  58.       $data_weapons.push result
  59.     when RPG::Armor
  60.       result.id = $data_armors.size
  61.       ##result.name += result.id.to_s
  62.       $data_armors.push result
  63.     end
  64.     return result
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 直接指定装备等级
  68.   #    equip:  装备
  69.   #    lv:  等级
  70.   #--------------------------------------------------------------------------
  71.   def self.level(equip, lv)
  72.     equip.level = 1 if equip.level.nil?
  73.     n = lv - equip.level
  74.     ## 等级更低时返回
  75.     return if n < 0
  76.     n.times{equip = self.upgrade(equip, true)}
  77.     return equip
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 装备升级
  81.   #    equip:  装备
  82.   #--------------------------------------------------------------------------
  83.   def self.upgrade(equip, abs = false)
  84.     return unless abs || upgradesucceed?(equip.level)
  85.     case equip
  86.     when RPG::Weapon
  87.       return if equip.level == MaxLevel
  88.       equip.level += 1
  89.       if equip.level == 2
  90.         equip.name.concat "(Lv.2)"
  91.       elsif equip.level > 2
  92.         equip.name.sub!(/\\(Lv\\.([0-9]+)\\)/) {"(Lv.#{equip.level})"}
  93.       end
  94.       equip.atk += [(equip.atk * BaseAbility).round, 1].max
  95.       setup_price(equip, 0)
  96.     when RPG::Armor
  97.       return if equip.level == MaxLevel
  98.       equip.level += 1
  99.       if equip.level == 2
  100.         equip.name.concat "(Lv.2)"
  101.       elsif equip.level > 2
  102.         equip.name.sub!(/\\(Lv\\.([0-9]+)\\)/) {"(Lv.#{equip.level})"}
  103.       end
  104.       equip.def += [(equip.def * BaseAbility).round, 1].max
  105.       setup_price(equip, 0)
  106.     end
  107.     return equip
  108.   end
  109. end
  110. #==============================================================================
  111. # ■ RPG::BaseItem
  112. #==============================================================================
  113. module RPG
  114.   class BaseItem
  115.     def initialize
  116.       @id = 0
  117.       @name = ""
  118.       @icon_index = 0
  119.       @description = ""
  120.       @note = ""
  121.       @base_id = 0
  122.       @level = 1
  123.     end
  124.     attr_accessor :id
  125.     attr_accessor :name
  126.     attr_accessor :icon_index
  127.     attr_accessor :description
  128.     attr_accessor :note
  129.     attr_accessor :base_id
  130.     attr_accessor :level
  131.   end
  132. end
  133. #==============================================================================
  134. # ■ Game_Actor
  135. #==============================================================================
  136. class Game_Actor < Game_Battler
  137.   #--------------------------------------------------------------------------
  138.   # ● 设置
  139.   #     actor_id : 角色 ID
  140.   #--------------------------------------------------------------------------
  141.   def setup(actor_id)
  142.     actor = $data_actors[actor_id]
  143.     @actor_id = actor_id
  144.     @name = actor.name
  145.     @character_name = actor.character_name
  146.     @character_index = actor.character_index
  147.     @face_name = actor.face_name
  148.     @face_index = actor.face_index
  149.     @class_id = actor.class_id
  150.     @weapon_id = actor.weapon_id
  151.     @armor1_id = actor.armor1_id
  152.     @armor2_id = actor.armor2_id
  153.     @armor3_id = actor.armor3_id
  154.     @armor4_id = actor.armor4_id
  155.     @level = actor.initial_level
  156.     @exp_list = Array.new(101)
  157.     make_exp_list
  158.     @exp = @exp_list[@level]
  159.     @skills = []
  160.     for i in self.class.learnings
  161.       learn_skill(i.skill_id) if i.level <= @level
  162.     end
  163.     clear_extra_values
  164.     recover_all
  165.     ## 生成新装备id
  166.     reset_equip_id
  167.   end
  168.   
  169.   #--------------------------------------------------------------------------
  170.   # ● 装备重设
  171.   #--------------------------------------------------------------------------
  172.   def reset_equip_id
  173.     if @weapon_id != 0
  174.       item = Game_Equip.reini($base_weapons[@weapon_id])
  175.       unless item.nil?
  176.         $data_weapons.push item
  177.         @weapon_id = item.id
  178.       end
  179.     end
  180.     if @armor1_id != 0
  181.       if two_swords_style####two_hands_legal?
  182.         item = Game_Equip.reini($base_weapons[@armor1_id])
  183.         unless item.nil?
  184.           $data_weapons.push item
  185.           @armor1_id = item.id
  186.         end
  187.       else
  188.         item = Game_Equip.reini($base_armors[@armor1_id])
  189.         unless item.nil?
  190.           $data_armors.push item
  191.           @armor1_id = item.id
  192.         end
  193.       end
  194.     end
  195.     if @armor2_id != 0
  196.       item = $base_armors[@armor2_id]
  197.       unless item.nil?
  198.         item = Game_Equip.reini(item)
  199.         $data_armors.push item
  200.         @armor2_id = item.id
  201.       end
  202.     end
  203.     if @armor3_id != 0
  204.       item = $base_armors[@armor3_id]
  205.       unless item.nil?
  206.         item = Game_Equip.reini(item)
  207.         $data_armors.push item
  208.         @armor3_id = item.id
  209.       end
  210.     end
  211.     if @armor4_id != 0
  212.       item = $base_armors[@armor4_id]
  213.       unless item.nil?
  214.         item = Game_Equip.reini(item)
  215.         $data_armors.push item
  216.         @armor4_id = item.id
  217.       end
  218.     end
  219.   end
  220.   
  221.   #--------------------------------------------------------------------------
  222.   # ● 判断是否可以装备
  223.   #     item : 物品
  224.   #     base : 是否读取母版数据
  225.   #--------------------------------------------------------------------------
  226.   def equippable?(item, base = true)
  227.     id = base ? item.base_id : item.id
  228.     if item.is_a?(RPG::Weapon)
  229.       return self.class.weapon_set.include?(id)
  230.     elsif item.is_a?(RPG::Armor)
  231.       return false if two_swords_style and item.kind == 0
  232.       return self.class.armor_set.include?(id)
  233.     end
  234.     return false
  235.   end
  236. end
  237. #==============================================================================
  238. # ■ Game_Party
  239. #==============================================================================
  240. class Game_Party < Game_Unit
  241.   #--------------------------------------------------------------------------
  242.   # ● 判断持有的物品
  243.   #     item          : 物品
  244.   #     include_equip : 包括装备品
  245.   #--------------------------------------------------------------------------
  246.   def has_item_by_base_id?(item, include_equip = false)
  247.     for i in items
  248.       return true if i.base_id == item.id
  249.     end
  250.     if include_equip
  251.       for actor in members
  252.         for e in actor.equips
  253.           return true if e.base_id == item.id
  254.         end
  255.       end
  256.     end
  257.     return false
  258.   end
  259.   #--------------------------------------------------------------------------
  260.   # ● 获得物品
  261.   #     item          : 物品
  262.   #     n             : 个数
  263.   #--------------------------------------------------------------------------
  264.   def gain_reini_item(item, n, include_equip = false)
  265.     if n < 0
  266.       lose_item(item, -n, include_equip = false)
  267.     else
  268.       case item
  269.       when RPG::Item
  270.         number = item_number(item)
  271.         @items[item.id] = [[number + n, 0].max, 99].min
  272.       when RPG::Weapon
  273.         for i in 0...n
  274.           w = Game_Equip.reini(item)
  275.           @weapons[w.id] = 1
  276.         end
  277.       when RPG::Armor
  278.         for i in 0...n
  279.           a = Game_Equip.reini(item)
  280.           @armors[a.id] = 1
  281.         end
  282.       end
  283.     end
  284.   end
  285.   #--------------------------------------------------------------------------
  286.   # ● 减少物品 (减少)
  287.   #     item          : 物品
  288.   #     n             : 个数
  289.   #     include_equip : 包括装备品
  290.   #--------------------------------------------------------------------------
  291.   def lose_reini_item(item, n, include_equip = false)
  292.     number = item_number(item)
  293.     case item
  294.     when RPG::Item
  295.       @items[item.id] = [[number - n, 0].max, 99].min
  296.     when RPG::Weapon
  297.       @weapons[item.id] = [[number - n, 0].max, 99].min
  298.     when RPG::Armor
  299.       @armors[item.id] = [[number - n, 0].max, 99].min
  300.     end
  301.     n -= number
  302.     if include_equip and n > 0
  303.       for actor in members
  304.         while n > 0 and actor.equips.include?(item)
  305.           actor.discard_equip(item)
  306.           n -= 1
  307.         end
  308.       end
  309.     end
  310.   end
  311. end
  312. #==============================================================================
  313. # ■ Game_Troop
  314. #==============================================================================
  315. class Game_Troop < Game_Unit
  316.   #--------------------------------------------------------------------------
  317.   # ● 敌人角色名称后的文字表
  318.   #--------------------------------------------------------------------------
  319.   LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
  320.                    'K','L','M','N','O','P','Q','R','S','T',
  321.                    'U','V','W','X','Y','Z']
  322.   #--------------------------------------------------------------------------
  323.   # ● 生成掉落物品队列
  324.   #--------------------------------------------------------------------------
  325.   def make_drop_items
  326.     drop_items = []
  327.     for enemy in dead_members
  328.       for di in [enemy.drop_item1, enemy.drop_item2]
  329.         next if di.kind == 0
  330.         next if rand(di.denominator) != 0
  331.         if di.kind == 1
  332.           drop_items.push($data_items[di.item_id])
  333.         elsif di.kind == 2
  334.           drop_items.push($base_weapons[di.weapon_id])
  335.         elsif di.kind == 3
  336.           drop_items.push($base_armors[di.armor_id])
  337.         end
  338.       end
  339.     end
  340.     return drop_items
  341.   end
  342. end
  343. #==============================================================================
  344. # ■ Game_Interpreter
  345. #==============================================================================
  346. class Game_Interpreter
  347.   #--------------------------------------------------------------------------
  348.   # ● 计算操作的值
  349.   #     operation    : 操作 (0:增加 1:减少)
  350.   #     operand_type : 运算域类型 (0:常量 1:变量)
  351.   #     operand      : 运算域 (数值为变量 ID)
  352.   #--------------------------------------------------------------------------
  353.   def operate_value(operation, operand_type, operand)
  354.     if operand_type == 0
  355.       value = operand
  356.     else
  357.       value = $game_variables[operand]
  358.     end
  359.     if operation == 1
  360.       value = -value
  361.     end
  362.     return value
  363.   end
  364.   #--------------------------------------------------------------------------
  365.   # ● 条件分歧
  366.   #--------------------------------------------------------------------------
  367.   def command_111
  368.     result = false
  369.     case @params[0]
  370.     when 0  # 开关
  371.       result = ($game_switches[@params[1]] == (@params[2] == 0))
  372.     when 1  # 变量
  373.       value1 = $game_variables[@params[1]]
  374.       if @params[2] == 0
  375.         value2 = @params[3]
  376.       else
  377.         value2 = $game_variables[@params[3]]
  378.       end
  379.       case @params[4]
  380.       when 0  # 相等
  381.         result = (value1 == value2)
  382.       when 1  # 大于等于
  383.         result = (value1 >= value2)
  384.       when 2  # 小于等于
  385.         result = (value1 <= value2)
  386.       when 3  # 大于
  387.         result = (value1 > value2)
  388.       when 4  # 小于
  389.         result = (value1 < value2)
  390.       when 5  # 不等于
  391.         result = (value1 != value2)
  392.       end
  393.     when 2  # 自我开关
  394.       if @original_event_id > 0
  395.         key = [@map_id, @original_event_id, @params[1]]
  396.         if @params[2] == 0
  397.           result = ($game_self_switches[key] == true)
  398.         else
  399.           result = ($game_self_switches[key] != true)
  400.         end
  401.       end
  402.     when 3  # 计时器
  403.       if $game_system.timer_working
  404.         sec = $game_system.timer / Graphics.frame_rate
  405.         if @params[2] == 0
  406.           result = (sec >= @params[1])
  407.         else
  408.           result = (sec <= @params[1])
  409.         end
  410.       end
  411.     when 4  # 角色
  412.       actor = $game_actors[@params[1]]
  413.       if actor != nil
  414.         case @params[2]
  415.         when 0  # 是同伴
  416.           result = ($game_party.members.include?(actor))
  417.         when 1  # 姓名
  418.           result = (actor.name == @params[3])
  419.         when 2  # 特技
  420.           result = (actor.skill_learn?($data_skills[@params[3]]))
  421.         when 3  # 武器
  422.           ## 判断是否符合母版id
  423.           actor.weapons.each do |weapon|
  424.             if weapon.base_id == @params[3]
  425.               result = true
  426.               break
  427.             end
  428.           end
  429.         when 4  # 防具
  430.           ## 判断是否符合母版id
  431.           actor.armors.each do |armor|
  432.             if armor.base_id == @params[3]
  433.               result = true
  434.               break
  435.             end
  436.           end
  437.         when 5  # 状态
  438.           result = (actor.state?(@params[3]))
  439.         end
  440.       end
  441.     when 5  # 敌方角色
  442.       enemy = $game_troop.members[@params[1]]
  443.       if enemy != nil
  444.         case @params[2]
  445.         when 0  # 出现
  446.           result = (enemy.exist?)
  447.         when 1  # 状态
  448.           result = (enemy.state?(@params[3]))
  449.         end
  450.       end
  451.     when 6  # 角色
  452.       character = get_character(@params[1])
  453.       if character != nil
  454.         result = (character.direction == @params[2])
  455.       end
  456.     when 7  # 金钱
  457.       if @params[2] == 0
  458.         result = ($game_party.gold >= @params[1])
  459.       else
  460.         result = ($game_party.gold <= @params[1])
  461.       end
  462.     when 8  # 物品
  463.       result = $game_party.has_item?($data_items[@params[1]])
  464.     when 9  # 武器
  465.       result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
  466.     when 10  # 防具
  467.       result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
  468.     when 11  # 按钮
  469.       result = Input.press?(@params[1])
  470.     when 12  # 脚本
  471.       result = eval(@params[1])
  472.     when 13  # 交通工具
  473.       result = ($game_player.vehicle_type == @params[1])
  474.     end
  475.     @branch[@indent] = result     # 将判断结果放置在缓存中
  476.     if @branch[@indent] == true
  477.       @branch.delete(@indent)
  478.       return true
  479.     end
  480.     return command_skip
  481.   end
  482.   
  483.   
  484.   #--------------------------------------------------------------------------
  485.   # ● 计算装备操作的值
  486.   #     operand_type : 运算域类型 (0:常量 1:变量)
  487.   #     operand      : 运算域 (数值为变量 ID)
  488.   #--------------------------------------------------------------------------
  489.   def opera_equip_value(operation, operand_type, operand)
  490.     if operand_type == 0
  491.       value = operand
  492.     else
  493.       value = $game_variables[operand]
  494.     end
  495.     return value
  496.   end
  497.   #--------------------------------------------------------------------------
  498.   # ● 增减武器
  499.   #--------------------------------------------------------------------------
  500.   def command_127
  501.     value = operate_value(@params[1], @params[2], @params[3])
  502.     if @params[1] == 0
  503.       $game_party.gain_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  504.     else
  505.       $game_party.lose_reini_item($base_weapons[@params[0]], value.abs, @params[4])
  506.     end
  507.     return true
  508.   end
  509.   #--------------------------------------------------------------------------
  510.   # ● 增减防具
  511.   #--------------------------------------------------------------------------
  512.   def command_128
  513.     value = operate_value(@params[1], @params[2], @params[3])
  514.     if @params[1] == 0
  515.       $game_party.gain_reini_item($base_armors[@params[0]], value.abs, @params[4])
  516.     else
  517.       $game_party.lose_reini_item($base_armors[@params[0]], value.abs, @params[4])
  518.     end
  519.     return true
  520.   end
  521.   #--------------------------------------------------------------------------
  522.   # ● 更改装备
  523.   #--------------------------------------------------------------------------
  524.   def command_319
  525.     actor = $game_actors[@params[0]]
  526.     if actor != nil
  527.       actor.change_equip_by_id(@params[1], @params[2])
  528.     end
  529.     return true
  530.   end
  531. end
  532. #==============================================================================
  533. # ■ Window_ShopBuy
  534. #==============================================================================
  535. class Window_ShopBuy < Window_Selectable
  536.   #--------------------------------------------------------------------------
  537.   # ● 刷新
  538.   #--------------------------------------------------------------------------
  539.   def refresh
  540.     @data = []
  541.     for goods_item in @shop_goods
  542.       case goods_item[0]
  543.       when 0
  544.         item = $base_items[goods_item[1]]
  545.       when 1
  546.         item = $base_weapons[goods_item[1]]
  547.       when 2
  548.         item = $base_armors[goods_item[1]]
  549.       end
  550.       if item != nil
  551.         @data.push(item)
  552.       end
  553.     end
  554.     @item_max = @data.size
  555.     create_contents
  556.     for i in 0...@item_max
  557.       draw_item(i)
  558.     end
  559.   end
  560. end
  561. #==============================================================================
  562. # ■ Window_ShopStatus
  563. #==============================================================================
  564. class Window_ShopStatus < Window_Base
  565.   #--------------------------------------------------------------------------
  566.   # ● 描绘角色现在装备的能力值变化
  567.   #     actor : 角色
  568.   #     x     : 描画目标 X 坐标
  569.   #     y     : 描画目标 Y 坐标
  570.   #--------------------------------------------------------------------------
  571.   def draw_actor_parameter_change(actor, x, y)
  572.     return if @item.is_a?(RPG::Item)
  573.     enabled = actor.equippable?(@item, false)
  574.     self.contents.font.color = normal_color
  575.     self.contents.font.color.alpha = enabled ? 255 : 128
  576.     self.contents.draw_text(x, y, 200, WLH, actor.name)
  577.     if @item.is_a?(RPG::Weapon)
  578.       item1 = weaker_weapon(actor)
  579.     elsif actor.two_swords_style and @item.kind == 0
  580.       item1 = nil
  581.     else
  582.       item1 = actor.equips[1 + @item.kind]
  583.     end
  584.     if enabled
  585.       if @item.is_a?(RPG::Weapon)
  586.         atk1 = item1 == nil ? 0 : item1.atk
  587.         atk2 = @item == nil ? 0 : @item.atk
  588.         change = atk2 - atk1
  589.       else
  590.         def1 = item1 == nil ? 0 : item1.def
  591.         def2 = @item == nil ? 0 : @item.def
  592.         change = def2 - def1
  593.       end
  594.       self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
  595.     end
  596.     draw_item_name(item1, x, y + WLH, enabled)
  597.   end
  598. end
  599. #==============================================================================
  600. # ■ Window_ScrEquip
  601. #==============================================================================
  602. class Window_ScrEquip < Window_Selectable
  603.   attr_accessor :equip_only
  604.   #--------------------------------------------------------------------------
  605.   # ● 初始化对象
  606.   #     x      : 窗口的 X 坐标
  607.   #     y      : 窗口的 Y 坐标
  608.   #     width  : 窗口的宽
  609.   #     height : 窗口的高
  610.   #--------------------------------------------------------------------------
  611.   def initialize(x, y, width, height)
  612.     super(x, y, width, height)
  613.     @column_max = 1
  614.     @equip_only = true
  615.     refresh
  616.   end
  617.   #--------------------------------------------------------------------------
  618.   # ● 取得物品
  619.   #--------------------------------------------------------------------------
  620.   def item
  621.     return @data[self.index]
  622.   end
  623.   #--------------------------------------------------------------------------
  624.   # ● 显示是否可以使用物品
  625.   #     item : 物品
  626.   #--------------------------------------------------------------------------
  627.   def enable?(item)
  628.     return true
  629.   end
  630.   #--------------------------------------------------------------------------
  631.   # ● 列表中包含的物品
  632.   #     item : 物品
  633.   #--------------------------------------------------------------------------
  634.   def include?(item)
  635.     return true if item == nil
  636.     if @equip_only
  637.       return false if item.is_a? RPG::Item
  638.     else
  639.       return false unless item.is_a? RPG::Item
  640.     end
  641.     return true
  642.   end
  643.   #--------------------------------------------------------------------------
  644.   # ● 刷新
  645.   #--------------------------------------------------------------------------
  646.   def refresh
  647.     self.index = 0
  648.     @data = []
  649.     for item in $game_party.items
  650.       next unless include?(item)
  651.       @data.push(item)
  652.     end
  653.     @data.push(nil) if include?(nil)
  654.     @item_max = @data.size
  655.     create_contents
  656.     for i in 0...@item_max
  657.       draw_item(i)
  658.     end
  659.   end
  660.   #--------------------------------------------------------------------------
  661.   # ● 描绘项目
  662.   #     index : 项目编号
  663.   #--------------------------------------------------------------------------
  664.   def draw_item(index)
  665.     rect = item_rect(index)
  666.     self.contents.clear_rect(rect)
  667.     item = @data[index]
  668.     if item != nil
  669.       number = $game_party.item_number(item)
  670.       rect.width -= 4
  671.       draw_item_name(item, rect.x, rect.y)
  672.       self.contents.draw_text(rect, sprintf(":%2d", number), 2)
  673.     end
  674.   end
  675.   #--------------------------------------------------------------------------
  676.   # ● 更新帮助文本
  677.   #--------------------------------------------------------------------------
  678.   def update_help
  679.     @help_window.set_text(item == nil ? "" : item.description)
  680.   end  
  681. end
  682. #==============================================================================
  683. # ■ Window_DestEquip #equip add clear items
  684. #==============================================================================
  685. class Window_DestEquip < Window_Base
  686.   #--------------------------------------------------------------------------
  687.   # ● 定义实例变量
  688.   #--------------------------------------------------------------------------
  689.   attr_reader   :equip
  690.   attr_reader   :items
  691.   #--------------------------------------------------------------------------
  692.   # ● 初始化对象
  693.   #     x      : 窗口的 X 坐标
  694.   #     y      : 窗口的 Y 坐标
  695.   #     width  : 窗口的宽
  696.   #     height : 窗口的高
  697.   #--------------------------------------------------------------------------
  698.   def initialize(x, y, width, height)
  699.     super(x, y, width, height)
  700.     clear
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 添加物品
  704.   #--------------------------------------------------------------------------
  705.   def add(item, n = 1)
  706.     $game_party.lose_item(item, n)
  707.     if @index == -1
  708.       @equip = item
  709.     else
  710.       number = @items[item].to_i
  711.       @items[item] = [[number + n, 0].max, 99].min
  712.     end
  713.     @index += 1
  714.     draw_item(item, n)
  715.   end
  716.   #--------------------------------------------------------------------------
  717.   # ● 清除物品
  718.   #--------------------------------------------------------------------------
  719.   def clear
  720.     @equip = nil
  721.     @items = {}
  722.     @index = -1
  723.     self.contents.clear
  724.     self.contents.font.color = system_color
  725.     self.contents.draw_text(0,0,self.contents.width-16,WLH,"请放入升级装备:")
  726.     self.contents.draw_text(0,WLH*2,self.contents.width-16,WLH,"请放入炼制物品:")
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 归还物品
  730.   #--------------------------------------------------------------------------
  731.   def revert
  732.     $game_party.gain_item(@equip, 1)
  733.     @items.each{|i,n| $game_party.gain_item(i, n)}
  734.     clear
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # ● 描绘项目
  738.   #     index : 项目编号
  739.   #--------------------------------------------------------------------------
  740.   def draw_item(item, n)
  741.     rect = Rect.new(4,WLH+WLH*@index,self.contents.width-8, WLH)
  742.     rect.y += WLH if @index >0
  743.     ##self.contents.clear_rect(rect)
  744.     if item != nil
  745.       ##rect.width -= 4
  746.       draw_item_name(item, rect.x, rect.y)
  747.       self.contents.draw_text(rect, sprintf(":%2d", n), 2)
  748.     end
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 更新帮助文本
  752.   #--------------------------------------------------------------------------
  753.   def update_help
  754.     @help_window.set_text(item == nil ? "" : item.description)
  755.   end
  756. end
  757. #==============================================================================
  758. # ■ Window_EquipNumber
  759. #==============================================================================
  760. class Window_EquipNumber < Window_Base
  761.   #--------------------------------------------------------------------------
  762.   # ● 初始化对象
  763.   #     x : 窗口的 X 坐标
  764.   #     y : 窗口的 Y 坐标
  765.   #--------------------------------------------------------------------------
  766.   def initialize(x, y)
  767.     super(x, y, 272, 304)
  768.     @item = nil
  769.     @max = 1
  770.     @number = 1
  771.   end
  772.   #--------------------------------------------------------------------------
  773.   # ● 设置物品、最大个数
  774.   #--------------------------------------------------------------------------
  775.   def set(item, max)
  776.     @item = item
  777.     @max = max
  778.     @number = 1
  779.     refresh
  780.   end
  781.   #--------------------------------------------------------------------------
  782.   # ● 设置输入个数
  783.   #--------------------------------------------------------------------------
  784.   def number
  785.     return @number
  786.   end
  787.   #--------------------------------------------------------------------------
  788.   # ● 刷新
  789.   #--------------------------------------------------------------------------
  790.   def refresh
  791.     y = 96
  792.     self.contents.clear
  793.     draw_item_name(@item, 0, y)
  794.     self.contents.font.color = normal_color
  795.     self.contents.draw_text(212-32, y, 20, WLH, "×")
  796.     self.contents.draw_text(248-32, y, 20, WLH, @number, 2)
  797.     self.cursor_rect.set(244-32, y, 28, WLH)
  798.   end
  799.   #--------------------------------------------------------------------------
  800.   # ● 更新画面
  801.   #--------------------------------------------------------------------------
  802.   def update
  803.     super
  804.     if self.active
  805.       last_number = @number
  806.       if Input.repeat?(Input::RIGHT) and @number < @max
  807.         @number += 1
  808.       end
  809.       if Input.repeat?(Input::LEFT) and @number > 1
  810.         @number -= 1
  811.       end
  812.       if Input.repeat?(Input::UP) and @number < @max
  813.         @number = [@number + 10, @max].min
  814.       end
  815.       if Input.repeat?(Input::DOWN) and @number > 1
  816.         @number = [@number - 10, 1].max
  817.       end
  818.       if @number != last_number
  819.         Sound.play_cursor
  820.         refresh
  821.       end
  822.     end
  823.   end
  824. end
  825. #==============================================================================
  826. # ■ Scene_UpEquip
  827. #==============================================================================
  828. class Scene_UpEquip < Scene_Base
  829.   include Game_Equip
  830.   #--------------------------------------------------------------------------
  831.   # ● 开始处理
  832.   #--------------------------------------------------------------------------
  833.   def start
  834.     super
  835.     create_menu_background
  836.     create_command_window
  837.     @help_window = Window_Help.new
  838.     @gold_window = Window_Gold.new(96+16, 56)
  839.     @gold_window.opacity = 0
  840.     @scr_window = Window_ScrEquip.new(0,112,272,304)
  841.     @scr_window.active = true
  842.     @scr_window.help_window = @help_window
  843.     @dest_window = Window_DestEquip.new(272,56,272,304+56)
  844.     @number_window = Window_EquipNumber.new(0, 112)
  845.     @number_window.active = false
  846.     @number_window.visible = false
  847.     @result_window = Window_Base.new(56,56,384,80)
  848.     @result_window.active = false
  849.     @result_window.visible = false
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ● 结束处理
  853.   #--------------------------------------------------------------------------
  854.   def terminate
  855.     super
  856.     dispose_menu_background
  857.     dispose_command_window
  858.     @help_window.dispose
  859.     @gold_window.dispose
  860.     @scr_window.dispose
  861.     @dest_window.dispose
  862.     @number_window.dispose
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● 更新画面
  866.   #--------------------------------------------------------------------------
  867.   def update
  868.     super
  869.     update_menu_background
  870.     @help_window.update
  871.     @command_window.update
  872.     @gold_window.update
  873.     @scr_window.update
  874.     @dest_window.update
  875.     @number_window.update
  876.     if @command_window.active
  877.       @scr_window.contents_opacity = 128
  878.       @command_window.contents_opacity = 255
  879.       update_command_selection
  880.     elsif @scr_window.active
  881.       @scr_window.contents_opacity = 255
  882.       @command_window.contents_opacity = 128
  883.       update_item_selection
  884.     elsif @number_window.active
  885.       update_number_input
  886.     elsif @result_window.active
  887.       update_result_window
  888.     end
  889.   end
  890.   #--------------------------------------------------------------------------
  891.   # ● 生成指令窗口
  892.   #--------------------------------------------------------------------------
  893.   def create_command_window
  894.     s1 = "升级"
  895.     s2 = "退出"
  896.     @command_window = Window_Command.new(272, [s1, s2], 4, 0, 8)
  897.     @command_window.y = 56
  898.     @command_window.active = false
  899.     @command_window.contents_opacity = 128
  900.   end
  901.   #--------------------------------------------------------------------------
  902.   # ● 释放指令窗口
  903.   #--------------------------------------------------------------------------
  904.   def dispose_command_window
  905.     @command_window.dispose
  906.   end
  907.   #--------------------------------------------------------------------------
  908.   # ● 是否满足装备升级条件?
  909.   #--------------------------------------------------------------------------
  910.   def upgradeable?(equip)
  911.     return false if equip.nil?
  912.     if equip.is_a?(RPG::Weapon) || equip.is_a?(RPG::Armor) and equip.level.nil?
  913.       equip.level = 1
  914.     end
  915.     price = (equip.price * (GoldNeed ** equip.level)).round
  916.     return false if $game_party.gold < price
  917.     ItemsNeed.each do |id,n|
  918.       return false if @dest_window.items[$data_items[id]].nil?
  919.       return false if @dest_window.items[$data_items[id]] < n
  920.     end
  921.     ## 扣钱
  922.     $game_party.lose_gold(price)
  923.     return true
  924.   end
  925.   #--------------------------------------------------------------------------
  926.   # ● 显示结果(包括处理金钱物品)
  927.   #--------------------------------------------------------------------------
  928.   def show_result
  929.     @result_window.active = true
  930.     @result_window.visible = true
  931.     ###@scr_window.refresh
  932.     unless upgradeable?(@dest_window.equip)
  933.       @result_window.contents.clear
  934.       @result_window.contents.draw_text(0,0,352,24,"材料或金钱不足!", 1)
  935.       @result_window.contents.draw_text(0,24,352,24,"物品已自动归还.", 1)
  936.       @dest_window.revert
  937.       Sound.play_actor_collapse
  938.       ## 直接返回
  939.       return
  940.     end
  941.     msg = Game_Equip.upgrade(@dest_window.equip)
  942.     case msg
  943.     when RPG::Weapon
  944.       s = "攻击力提升到(#{msg.atk})"
  945.       @result_window.contents.clear
  946.       @result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
  947.       @result_window.contents.draw_text(4, 24, 352-4, 24, s)
  948.       $game_party.gain_item(msg, 1)
  949.       Sound.play_shop
  950.     when RPG::Armor
  951.       s = "防御力提升到(#{msg.def})"
  952.       @result_window.contents.clear
  953.       @result_window.contents.draw_text(0, 0, 352, 24, "#{msg.name}升级成功!")
  954.       @result_window.contents.draw_text(4, 24, 352-4, 24, s)
  955.       $game_party.gain_item(msg, 1)
  956.       Sound.play_shop
  957.     else
  958.       @result_window.contents.clear
  959.       @result_window.contents.draw_text(0,0,352,24,"升级失败, 物品已损坏!", 1)
  960.       Sound.play_actor_collapse
  961.     end
  962.     @dest_window.clear
  963.   end
  964.   #--------------------------------------------------------------------------
  965.   # ● 更新帮助文本
  966.   #--------------------------------------------------------------------------
  967.   def update_help(text)
  968.     @help_window.set_text(text)
  969.   end  
  970.   #--------------------------------------------------------------------------
  971.   # ● 更新指令窗口
  972.   #--------------------------------------------------------------------------
  973.   def update_command_selection
  974.     case @command_window.index
  975.     when 0
  976.       update_help("确定键执行装备升级")
  977.     when 1
  978.       update_help("退出升级界面")
  979.     end
  980.     if Input.trigger?(Input::B)
  981.       ## 重来
  982.       Sound.play_cancel
  983.       @scr_window.active = true
  984.       @command_window.active = false
  985.     elsif Input.trigger?(Input::C)
  986.       case @command_window.index
  987.       when 0  # 升级
  988.         Sound.play_decision
  989.         @command_window.active = false
  990.         @scr_window.active = false
  991.         ######### 显示升级结果,归还物品
  992.         show_result
  993.       when 1  # 退出
  994.         Sound.play_decision
  995.         @dest_window.revert
  996.         $scene = Scene_Map.new
  997.       end
  998.     end
  999.   end
  1000.   #--------------------------------------------------------------------------
  1001.   # ● 更新选择物品
  1002.   #--------------------------------------------------------------------------
  1003.   def update_item_selection
  1004.     if Input.trigger?(Input::B)
  1005.       Sound.play_cancel
  1006.       @command_window.active = true
  1007.       @scr_window.active = false
  1008.       ###@help_window.set_text("")
  1009.       return
  1010.     end
  1011.     if Input.trigger?(Input::C)
  1012.       @item = @scr_window.item
  1013.       number = $game_party.item_number(@item)
  1014.       if @item == nil or number == 0
  1015.         Sound.play_buzzer
  1016.       else
  1017.         Sound.play_decision
  1018.         ##### 传递物品给容器栏
  1019.         if number > 1
  1020.           @scr_window.active = false
  1021.           @number_window.set(@item, number)
  1022.           @number_window.active = true
  1023.           @number_window.visible = true
  1024.         else
  1025.           Sound.play_shop
  1026.           @dest_window.add(@scr_window.item, 1)
  1027.           @scr_window.equip_only = false
  1028.           @scr_window.refresh
  1029.         end
  1030.       end
  1031.     end
  1032.   end
  1033.   #--------------------------------------------------------------------------
  1034.   # ● 更新输入个数
  1035.   #--------------------------------------------------------------------------
  1036.   def update_number_input
  1037.     if Input.trigger?(Input::B)
  1038.       cancel_number_input
  1039.     elsif Input.trigger?(Input::C)
  1040.       decide_number_input
  1041.     end
  1042.   end
  1043.   #--------------------------------------------------------------------------
  1044.   # ● 更新结果窗体
  1045.   #--------------------------------------------------------------------------
  1046.   def update_result_window
  1047.     if Input.trigger?(Input::B) or Input.trigger?(Input::C)
  1048.       Sound.play_decision
  1049.       @scr_window.equip_only = true
  1050.       @scr_window.refresh
  1051.       @scr_window.active = true
  1052.       @result_window.active = false
  1053.       @result_window.visible = false
  1054.     end
  1055.   end
  1056.   #--------------------------------------------------------------------------
  1057.   # ● 取消输入个数
  1058.   #--------------------------------------------------------------------------
  1059.   def cancel_number_input
  1060.     Sound.play_cancel
  1061.     @number_window.active = false
  1062.     @number_window.visible = false
  1063.     @scr_window.active = true
  1064.     @scr_window.visible = true
  1065.   end
  1066.   #--------------------------------------------------------------------------
  1067.   # ● 确定输入个数
  1068.   #--------------------------------------------------------------------------
  1069.   def decide_number_input
  1070.     Sound.play_shop
  1071.     @number_window.active = false
  1072.     @number_window.visible = false
  1073.     @dest_window.add(@item, @number_window.number)
  1074.     @scr_window.equip_only = false
  1075.     @scr_window.refresh
  1076.     @scr_window.active = true
  1077.   end
  1078. end
  1079. #==============================================================================
  1080. # ■ Scene_File
  1081. #==============================================================================
  1082. class Scene_File < Scene_Base
  1083.   #--------------------------------------------------------------------------
  1084.   # ● 写入存档数据
  1085.   #     file : 写入文件用对象 (已经打开)
  1086.   #--------------------------------------------------------------------------
  1087.   def write_save_data(file)
  1088.     characters = []
  1089.     for actor in $game_party.members
  1090.       characters.push([actor.character_name, actor.character_index])
  1091.     end
  1092.     $game_system.save_count += 1
  1093.     $game_system.version_id = $data_system.version_id
  1094.     @last_bgm = RPG::BGM::last
  1095.     @last_bgs = RPG::BGS::last
  1096.     Marshal.dump(characters,           file)
  1097.     Marshal.dump(Graphics.frame_count, file)
  1098.     Marshal.dump(@last_bgm,            file)
  1099.     Marshal.dump(@last_bgs,            file)
  1100.     Marshal.dump($game_system,         file)
  1101.     Marshal.dump($game_message,        file)
  1102.     Marshal.dump($game_switches,       file)
  1103.     Marshal.dump($game_variables,      file)
  1104.     Marshal.dump($game_self_switches,  file)
  1105.     Marshal.dump($game_actors,         file)
  1106.     Marshal.dump($game_party,          file)
  1107.     Marshal.dump($game_troop,          file)
  1108.     Marshal.dump($game_map,            file)
  1109.     Marshal.dump($game_player,         file)
  1110.     Marshal.dump($data_weapons,        file)
  1111.     Marshal.dump($data_armors,         file)
  1112.   end
  1113.   #--------------------------------------------------------------------------
  1114.   # ● 读取存档数据
  1115.   #     file : 读取文件用对象 (已经打开)
  1116.   #--------------------------------------------------------------------------
  1117.   def read_save_data(file)
  1118.     characters           = Marshal.load(file)
  1119.     Graphics.frame_count = Marshal.load(file)
  1120.     @last_bgm            = Marshal.load(file)
  1121.     @last_bgs            = Marshal.load(file)
  1122.     $game_system         = Marshal.load(file)
  1123.     $game_message        = Marshal.load(file)
  1124.     $game_switches       = Marshal.load(file)
  1125.     $game_variables      = Marshal.load(file)
  1126.     $game_self_switches  = Marshal.load(file)
  1127.     $game_actors         = Marshal.load(file)
  1128.     $game_party          = Marshal.load(file)
  1129.     $game_troop          = Marshal.load(file)
  1130.     $game_map            = Marshal.load(file)
  1131.     $game_player         = Marshal.load(file)
  1132.     $data_weapons        = Marshal.load(file)
  1133.     $data_armors         = Marshal.load(file)
  1134.     if $game_system.version_id != $data_system.version_id
  1135.       $game_map.setup($game_map.map_id)
  1136.       $game_player.center($game_player.x, $game_player.y)
  1137.     end
  1138.   end
  1139. end
  1140. #==============================================================================
  1141. # ■ Scene_Shop
  1142. #==============================================================================
  1143. class Scene_Shop < Scene_Base
  1144.   #--------------------------------------------------------------------------
  1145.   # ● 确定输入个数
  1146.   #--------------------------------------------------------------------------
  1147.   def decide_number_input
  1148.     Sound.play_shop
  1149.     @number_window.active = false
  1150.     @number_window.visible = false
  1151.     case @command_window.index
  1152.     when 0  # 购买
  1153.       $game_party.lose_gold(@number_window.number * @item.price)
  1154.       $game_party.gain_reini_item(@item, @number_window.number)
  1155.       @gold_window.refresh
  1156.       @buy_window.refresh
  1157.       @status_window.refresh
  1158.       @buy_window.active = true
  1159.       @buy_window.visible = true
  1160.     when 1  # 卖出
  1161.       $game_party.gain_gold(@number_window.number * (@item.price / 2))
  1162.       $game_party.lose_reini_item(@item, @number_window.number)
  1163.       @gold_window.refresh
  1164.       @sell_window.refresh
  1165.       @status_window.refresh
  1166.       @sell_window.active = true
  1167.       @sell_window.visible = true
  1168.       @status_window.visible = false
  1169.     end
  1170.   end
  1171. end
  1172. #==============================================================================
  1173. # ■ Scene_Title
  1174. #==============================================================================
  1175. class Scene_Title < Scene_Base
  1176.   #--------------------------------------------------------------------------
  1177.   # ● 载入数据库
  1178.   #--------------------------------------------------------------------------
  1179.   def load_database
  1180.     $data_actors        = load_data("Data/Actors.rvdata")
  1181.     $data_classes       = load_data("Data/Classes.rvdata")
  1182.     $data_skills        = load_data("Data/Skills.rvdata")
  1183.     $data_items         = load_data("Data/Items.rvdata")
  1184.     $base_weapons       = load_data("Data/Weapons.rvdata")
  1185.     $base_armors        = load_data("Data/Armors.rvdata")
  1186.     $data_enemies       = load_data("Data/Enemies.rvdata")
  1187.     $data_troops        = load_data("Data/Troops.rvdata")
  1188.     $data_states        = load_data("Data/States.rvdata")
  1189.     $data_animations    = load_data("Data/Animations.rvdata")
  1190.     $data_common_events = load_data("Data/CommonEvents.rvdata")
  1191.     $data_system        = load_data("Data/System.rvdata")
  1192.     $data_areas         = load_data("Data/Areas.rvdata")
  1193.     $data_weapons       = [nil]
  1194.     $data_armors        = [nil]
  1195.   end
  1196.   #--------------------------------------------------------------------------
  1197.   # ● 载入战斗测试用的数据库
  1198.   #--------------------------------------------------------------------------
  1199.   def load_bt_database
  1200.     $data_actors        = load_data("Data/BT_Actors.rvdata")
  1201.     $data_classes       = load_data("Data/BT_Classes.rvdata")
  1202.     $data_skills        = load_data("Data/BT_Skills.rvdata")
  1203.     $data_items         = load_data("Data/BT_Items.rvdata")
  1204.     $data_weapons       = load_data("Data/BT_Weapons.rvdata")
  1205.     $data_armors        = load_data("Data/BT_Armors.rvdata")
  1206.     $data_enemies       = load_data("Data/BT_Enemies.rvdata")
  1207.     $data_troops        = load_data("Data/BT_Troops.rvdata")
  1208.     $data_states        = load_data("Data/BT_States.rvdata")
  1209.     $data_animations    = load_data("Data/BT_Animations.rvdata")
  1210.     $data_common_events = load_data("Data/BT_CommonEvents.rvdata")
  1211.     $data_system        = load_data("Data/BT_System.rvdata")
  1212.     $base_weapons       = $data_weapons
  1213.     $base_armors        = $data_armors
  1214.   end
  1215. end
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-5-15 20:45 , Processed in 0.032737 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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