Project1

标题: Dual_Wield 轻量级二刀流脚本 [打印本页]

作者: SailCat    时间: 2012-3-21 23:33
标题: Dual_Wield 轻量级二刀流脚本
闲话不多说,看注释,插到main前面就可以了
轻量级,只附带二刀流功能(盾当武器),不夹带任何私货等,标准新建工程测试通过

  1. #==============================================================================
  2. # ★ Dual_Wield 轻量级二刀流脚本
  3. #------------------------------------------------------------------------------
  4. #  本脚本#不使用#任何alias,避免冲突
  5. #  本脚本#不追加定义#任何实例变量,避免冲突和制作中途加入带来的存档不兼容问题
  6. #  本脚本未实现二刀流双次动画或双次攻击功能,有意者可自行实现,难度很低
  7. #  二刀流实现原理:当盾的ID小于0时,为双持的武器,否则为盾
  8. #  默认攻击力、属性、状态等为二手直接相加,可以修改base_atk之类定义来进行修改
  9. #  常量DUAL_WIELDER_CLASSES为可以双持武器的职业ID组,请在下面修改
  10. #==============================================================================
  11. # ■ Game_Actor
  12. #------------------------------------------------------------------------------
  13. #  处理角色的类。本类在 Game_Actors 类 ($game_actors)
  14. # 的内部使用、Game_Party 类请参考 ($game_party) 。
  15. #==============================================================================

  16. class Game_Actor < Game_Battler
  17.   #--------------------------------------------------------------------------
  18.   # ● 常量
  19.   #--------------------------------------------------------------------------
  20.   DUAL_WIELDER_CLASSES = [3, 4]               # 可以双持武器的职业 ID 组
  21.   #--------------------------------------------------------------------------
  22.   # ● 双持武器判定
  23.   #--------------------------------------------------------------------------
  24.   def dual_wield?
  25.     return DUAL_WIELDER_CLASSES.include?(@class_id)
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 取得属性修正值
  29.   #     element_id : 属性 ID
  30.   #--------------------------------------------------------------------------
  31.   def element_rate(element_id)
  32.     # 获取对应属性有效度的数值
  33.     table = [0,200,150,100,50,0,-100]
  34.     result = table[$data_classes[@class_id].element_ranks[element_id]]
  35.     # 防具能防御本属性的情况下效果减半
  36.     for i in [[@armor1_id, 0].max, @armor2_id, @armor3_id, @armor4_id]
  37.       armor = $data_armors[i]
  38.       if armor != nil and armor.guard_element_set.include?(element_id)
  39.         result /= 2
  40.       end
  41.     end
  42.     # 状态能防御本属性的情况下效果减半
  43.     for i in @states
  44.       if $data_states[i].guard_element_set.include?(element_id)
  45.         result /= 2
  46.       end
  47.     end
  48.     # 过程结束
  49.     return result
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 判定防御属性
  53.   #     state_id : 属性 ID
  54.   #--------------------------------------------------------------------------
  55.   def state_guard?(state_id)
  56.     for i in [[@armor1_id, 0].max, @armor2_id, @armor3_id, @armor4_id]
  57.       armor = $data_armors[i]
  58.       if armor != nil
  59.         if armor.guard_state_set.include?(state_id)
  60.           return true
  61.         end
  62.       end
  63.     end
  64.     return false
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● 获取普通攻击属性
  68.   #--------------------------------------------------------------------------
  69.   def element_set
  70.     elements = []
  71.     weapon1 = $data_weapons[@weapon_id]
  72.     weapon2 = @armor1_id < 0 ? $data_weapons[-@armor1_id] : nil
  73.     elements |= weapon1.element_set if weapon1 != nil
  74.     elements |= weapon2.element_set if weapon2 != nil
  75.     return elements
  76.   end
  77.   #--------------------------------------------------------------------------
  78.   # ● 获取普通攻击状态变化 (+)
  79.   #--------------------------------------------------------------------------
  80.   def plus_state_set
  81.     plus_states = []
  82.     weapon1 = $data_weapons[@weapon_id]
  83.     weapon2 = @armor1_id < 0 ? $data_weapons[-@armor1_id] : nil
  84.     plus_states |= weapon1.plus_state_set if weapon1 != nil
  85.     plus_states |= weapon2.plus_state_set if weapon2 != nil
  86.     return plus_states
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 获取普通攻击状态变化 (-)
  90.   #--------------------------------------------------------------------------
  91.   def minus_state_set
  92.     minus_states = []
  93.     weapon1 = $data_weapons[@weapon_id]
  94.     weapon2 = @armor1_id < 0 ? $data_weapons[-@armor1_id] : nil
  95.     minus_states |= weapon1.minus_state_set if weapon1 != nil
  96.     minus_states |= weapon2.minus_state_set if weapon2 != nil
  97.     return minus_states
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # ● 获取基本力量
  101.   #--------------------------------------------------------------------------
  102.   def base_str
  103.     n = $data_actors[@actor_id].parameters[2, @level]
  104.     weapon = $data_weapons[@weapon_id]
  105.     if @armor1_id >= 0
  106.       armor1 = $data_armors[@armor1_id]
  107.     else
  108.       armor1 = $data_weapons[-@armor1_id]
  109.     end
  110.     armor2 = $data_armors[@armor2_id]
  111.     armor3 = $data_armors[@armor3_id]
  112.     armor4 = $data_armors[@armor4_id]
  113.     n += weapon != nil ? weapon.str_plus : 0
  114.     n += armor1 != nil ? armor1.str_plus : 0
  115.     n += armor2 != nil ? armor2.str_plus : 0
  116.     n += armor3 != nil ? armor3.str_plus : 0
  117.     n += armor4 != nil ? armor4.str_plus : 0
  118.     return [[n, 1].max, 999].min
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● 获取基本灵巧
  122.   #--------------------------------------------------------------------------
  123.   def base_dex
  124.     n = $data_actors[@actor_id].parameters[3, @level]
  125.     weapon = $data_weapons[@weapon_id]
  126.     if @armor1_id >= 0
  127.       armor1 = $data_armors[@armor1_id]
  128.     else
  129.       armor1 = $data_weapons[-@armor1_id]
  130.     end
  131.     armor2 = $data_armors[@armor2_id]
  132.     armor3 = $data_armors[@armor3_id]
  133.     armor4 = $data_armors[@armor4_id]
  134.     n += weapon != nil ? weapon.dex_plus : 0
  135.     n += armor1 != nil ? armor1.dex_plus : 0
  136.     n += armor2 != nil ? armor2.dex_plus : 0
  137.     n += armor3 != nil ? armor3.dex_plus : 0
  138.     n += armor4 != nil ? armor4.dex_plus : 0
  139.     return [[n, 1].max, 999].min
  140.   end
  141.   #--------------------------------------------------------------------------
  142.   # ● 获取基本速度
  143.   #--------------------------------------------------------------------------
  144.   def base_agi
  145.     n = $data_actors[@actor_id].parameters[4, @level]
  146.     weapon = $data_weapons[@weapon_id]
  147.     if @armor1_id >= 0
  148.       armor1 = $data_armors[@armor1_id]
  149.     else
  150.       armor1 = $data_weapons[-@armor1_id]
  151.     end
  152.     armor2 = $data_armors[@armor2_id]
  153.     armor3 = $data_armors[@armor3_id]
  154.     armor4 = $data_armors[@armor4_id]
  155.     n += weapon != nil ? weapon.agi_plus : 0
  156.     n += armor1 != nil ? armor1.agi_plus : 0
  157.     n += armor2 != nil ? armor2.agi_plus : 0
  158.     n += armor3 != nil ? armor3.agi_plus : 0
  159.     n += armor4 != nil ? armor4.agi_plus : 0
  160.     return [[n, 1].max, 999].min
  161.   end
  162.   #--------------------------------------------------------------------------
  163.   # ● 获取基本魔力
  164.   #--------------------------------------------------------------------------
  165.   def base_int
  166.     n = $data_actors[@actor_id].parameters[5, @level]
  167.     weapon = $data_weapons[@weapon_id]
  168.     if @armor1_id >= 0
  169.       armor1 = $data_armors[@armor1_id]
  170.     else
  171.       armor1 = $data_weapons[-@armor1_id]
  172.     end
  173.     armor2 = $data_armors[@armor2_id]
  174.     armor3 = $data_armors[@armor3_id]
  175.     armor4 = $data_armors[@armor4_id]
  176.     n += weapon != nil ? weapon.int_plus : 0
  177.     n += armor1 != nil ? armor1.int_plus : 0
  178.     n += armor2 != nil ? armor2.int_plus : 0
  179.     n += armor3 != nil ? armor3.int_plus : 0
  180.     n += armor4 != nil ? armor4.int_plus : 0
  181.     return [[n, 1].max, 999].min
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 获取基本攻击力
  185.   #--------------------------------------------------------------------------
  186.   def base_atk
  187.     atk = 0
  188.     weapon = $data_weapons[@weapon_id]
  189.     atk += weapon.atk if weapon != nil
  190.     if @armor1_id < 0
  191.       weapon = $data_weapons[-@armor1_id]
  192.       atk += weapon.atk if weapon != nil
  193.     end
  194.     return atk
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # ● 获取基本物理防御
  198.   #--------------------------------------------------------------------------
  199.   def base_pdef
  200.     weapon = $data_weapons[@weapon_id]
  201.     if @armor1_id >= 0
  202.       armor1 = $data_armors[@armor1_id]
  203.     else
  204.       armor1 = $data_weapons[-@armor1_id]
  205.     end
  206.     armor2 = $data_armors[@armor2_id]
  207.     armor3 = $data_armors[@armor3_id]
  208.     armor4 = $data_armors[@armor4_id]
  209.     pdef1 = weapon != nil ? weapon.pdef : 0
  210.     pdef2 = armor1 != nil ? armor1.pdef : 0
  211.     pdef3 = armor2 != nil ? armor2.pdef : 0
  212.     pdef4 = armor3 != nil ? armor3.pdef : 0
  213.     pdef5 = armor4 != nil ? armor4.pdef : 0
  214.     return pdef1 + pdef2 + pdef3 + pdef4 + pdef5
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 获取基本魔法防御
  218.   #--------------------------------------------------------------------------
  219.   def base_mdef
  220.     weapon = $data_weapons[@weapon_id]
  221.     if @armor1_id >= 0
  222.       armor1 = $data_armors[@armor1_id]
  223.     else
  224.       armor1 = $data_weapons[-@armor1_id]
  225.     end
  226.     armor2 = $data_armors[@armor2_id]
  227.     armor3 = $data_armors[@armor3_id]
  228.     armor4 = $data_armors[@armor4_id]
  229.     mdef1 = weapon != nil ? weapon.mdef : 0
  230.     mdef2 = armor1 != nil ? armor1.mdef : 0
  231.     mdef3 = armor2 != nil ? armor2.mdef : 0
  232.     mdef4 = armor3 != nil ? armor3.mdef : 0
  233.     mdef5 = armor4 != nil ? armor4.mdef : 0
  234.     return mdef1 + mdef2 + mdef3 + mdef4 + mdef5
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 获取基本回避修正
  238.   #--------------------------------------------------------------------------
  239.   def base_eva
  240.     armor1 = @armor1_id >= 0 ? $data_armors[@armor1_id] : nil
  241.     armor2 = $data_armors[@armor2_id]
  242.     armor3 = $data_armors[@armor3_id]
  243.     armor4 = $data_armors[@armor4_id]
  244.     eva1 = armor1 != nil ? armor1.eva : 0
  245.     eva2 = armor2 != nil ? armor2.eva : 0
  246.     eva3 = armor3 != nil ? armor3.eva : 0
  247.     eva4 = armor4 != nil ? armor4.eva : 0
  248.     return eva1 + eva2 + eva3 + eva4
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● 变更装备
  252.   #     equip_type : 装备类型
  253.   #     id    : 武器 or 防具 ID  (0 为解除装备)
  254.   #--------------------------------------------------------------------------
  255.   def equip(equip_type, id)
  256.     case equip_type
  257.     when 0  # 武器
  258.       if id == 0 or $game_party.weapon_number(id) > 0
  259.         $game_party.gain_weapon(@weapon_id, 1)
  260.         @weapon_id = id
  261.         $game_party.lose_weapon(id, 1)
  262.       end
  263.     when 1  # 盾
  264.       if id == 0 or (id > 0 and $game_party.armor_number(id) > 0) or
  265.         (id < 0 and $game_party.weapon_number(-id) > 0)
  266.         old_shield = @armor1_id > 0 ? $data_armors[@armor1_id] : nil
  267.         new_shield = id > 0 ? $data_armors[id] : nil
  268.         update_auto_state(old_shield, new_shield)
  269.         if @armor1_id > 0
  270.           $game_party.gain_armor(@armor1_id, 1)
  271.         elsif @armor1_id < 0
  272.           $game_party.gain_weapon(-@armor1_id, 1)
  273.         end
  274.         @armor1_id = id
  275.         if id > 0
  276.           $game_party.lose_armor(id, 1)
  277.         elsif id < 0
  278.           $game_party.lose_weapon(-id, 1)
  279.         end
  280.       end
  281.     when 2  # 头
  282.       if id == 0 or $game_party.armor_number(id) > 0
  283.         update_auto_state($data_armors[@armor2_id], $data_armors[id])
  284.         $game_party.gain_armor(@armor2_id, 1)
  285.         @armor2_id = id
  286.         $game_party.lose_armor(id, 1)
  287.       end
  288.     when 3  # 身体
  289.       if id == 0 or $game_party.armor_number(id) > 0
  290.         update_auto_state($data_armors[@armor3_id], $data_armors[id])
  291.         $game_party.gain_armor(@armor3_id, 1)
  292.         @armor3_id = id
  293.         $game_party.lose_armor(id, 1)
  294.       end
  295.     when 4  # 装饰品
  296.       if id == 0 or $game_party.armor_number(id) > 0
  297.         update_auto_state($data_armors[@armor4_id], $data_armors[id])
  298.         $game_party.gain_armor(@armor4_id, 1)
  299.         @armor4_id = id
  300.         $game_party.lose_armor(id, 1)
  301.       end
  302.     end
  303.   end
  304.   #--------------------------------------------------------------------------
  305.   # ● 更改职业 ID
  306.   #     class_id : 新的职业 ID
  307.   #--------------------------------------------------------------------------
  308.   def class_id=(class_id)
  309.     if $data_classes[class_id] != nil
  310.       @class_id = class_id
  311.       # 避开无法装备的物品
  312.       unless equippable?($data_weapons[@weapon_id])
  313.         equip(0, 0)
  314.       end
  315.       unless (@armor1_id > 0 and equippable?($data_armors[@armor1_id])) or
  316.         (@armor1_id < 0 and equippable?($data_weapons[-@armor1_id]) and
  317.         dual_wield?)
  318.         equip(1, 0)
  319.       end
  320.       unless equippable?($data_armors[@armor2_id])
  321.         equip(2, 0)
  322.       end
  323.       unless equippable?($data_armors[@armor3_id])
  324.         equip(3, 0)
  325.       end
  326.       unless equippable?($data_armors[@armor4_id])
  327.         equip(4, 0)
  328.       end
  329.     end
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 普通攻击 获取攻击方动画 ID
  333.   #--------------------------------------------------------------------------
  334.   def animation1_id
  335.     weapon = $data_weapons[@weapon_id]
  336.     if weapon == nil and dual_wield? and @armor1_id < 0
  337.       weapon = $data_weapons[-@armor1_id]
  338.     end
  339.     return weapon != nil ? weapon.animation1_id : 0
  340.   end
  341.   #--------------------------------------------------------------------------
  342.   # ● 普通攻击 获取对像方动画 ID
  343.   #--------------------------------------------------------------------------
  344.   def animation2_id
  345.     weapon = $data_weapons[@weapon_id]
  346.     if weapon == nil and dual_wield? and @armor1_id < 0
  347.       weapon = $data_weapons[-@armor1_id]
  348.     end
  349.     return weapon != nil ? weapon.animation2_id : 0
  350.   end
  351. end

  352. #==============================================================================
  353. # ■ Window_EquipRight
  354. #------------------------------------------------------------------------------
  355. #  装备画面、显示角色现在装备的物品的窗口。
  356. #==============================================================================

  357. class Window_EquipRight < Window_Selectable
  358.   #--------------------------------------------------------------------------
  359.   # ● 刷新
  360.   #--------------------------------------------------------------------------
  361.   def refresh
  362.     self.contents.clear
  363.     @data = []
  364.     @data.push($data_weapons[@actor.weapon_id])
  365.     if @actor.armor1_id >= 0
  366.       @data.push($data_armors[@actor.armor1_id])
  367.     else
  368.       @data.push($data_weapons[[email protected]_id])
  369.     end
  370.     @data.push($data_armors[@actor.armor2_id])
  371.     @data.push($data_armors[@actor.armor3_id])
  372.     @data.push($data_armors[@actor.armor4_id])
  373.     @item_max = @data.size
  374.     self.contents.font.color = system_color
  375.     if @actor.dual_wield?
  376.       text1 = "右手"
  377.       text2 = "左手"
  378.     else
  379.       text1 = $data_system.words.weapon
  380.       text2 = $data_system.words.armor1
  381.     end
  382.     self.contents.draw_text(4, 32 * 0, 92, 32, text1)
  383.     self.contents.draw_text(4, 32 * 1, 92, 32, text2)
  384.     self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
  385.     self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
  386.     self.contents.draw_text(4, 32 * 4, 92, 32, $data_system.words.armor4)
  387.     draw_item_name(@data[0], 92, 32 * 0)
  388.     draw_item_name(@data[1], 92, 32 * 1)
  389.     draw_item_name(@data[2], 92, 32 * 2)
  390.     draw_item_name(@data[3], 92, 32 * 3)
  391.     draw_item_name(@data[4], 92, 32 * 4)
  392.   end
  393. end

  394. #==============================================================================
  395. # ■ Window_EquipItem
  396. #------------------------------------------------------------------------------
  397. #  装备画面、显示浏览变更装备的候补物品的窗口。
  398. #==============================================================================

  399. class Window_EquipItem < Window_Selectable
  400.   #--------------------------------------------------------------------------
  401.   # ● 刷新
  402.   #--------------------------------------------------------------------------
  403.   def refresh
  404.     if self.contents != nil
  405.       self.contents.dispose
  406.       self.contents = nil
  407.     end
  408.     @data = []
  409.     # 添加可以装备的武器
  410.     if @equip_type == 0 or (@equip_type == 1 and @actor.dual_wield?)
  411.       weapon_set = $data_classes[@actor.class_id].weapon_set
  412.       for i in 1...$data_weapons.size
  413.         if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
  414.           @data.push($data_weapons[i])
  415.         end
  416.       end
  417.     end
  418.     # 添加可以装备的防具
  419.     if @equip_type != 0
  420.       armor_set = $data_classes[@actor.class_id].armor_set
  421.       for i in 1...$data_armors.size
  422.         if $game_party.armor_number(i) > 0 and armor_set.include?(i)
  423.           if $data_armors[i].kind == @equip_type-1
  424.             @data.push($data_armors[i])
  425.           end
  426.         end
  427.       end
  428.     end
  429.     # 添加空白
  430.     @data.push(nil)
  431.     # 生成位图、描绘全部项目
  432.     @item_max = @data.size
  433.     self.contents = Bitmap.new(width - 32, row_max * 32)
  434.     for i in 0...@item_max-1
  435.       draw_item(i)
  436.     end
  437.   end
  438. end

  439. #==============================================================================
  440. # ■ Scene_Equip
  441. #------------------------------------------------------------------------------
  442. #  处理装备画面的类。
  443. #==============================================================================

  444. class Scene_Equip
  445.   #--------------------------------------------------------------------------
  446.   # ● 刷新画面 (物品窗口被激活的情况下)
  447.   #--------------------------------------------------------------------------
  448.   def update_item
  449.     # 按下 B 键的情况下
  450.     if Input.trigger?(Input::B)
  451.       # 演奏取消 SE
  452.       $game_system.se_play($data_system.cancel_se)
  453.       # 激活右侧窗口
  454.       @right_window.active = true
  455.       @item_window.active = false
  456.       @item_window.index = -1
  457.       return
  458.     end
  459.     # 按下 C 键的情况下
  460.     if Input.trigger?(Input::C)
  461.       # 演奏装备 SE
  462.       $game_system.se_play($data_system.equip_se)
  463.       # 获取物品窗口现在选择的装备数据
  464.       item = @item_window.item
  465.       # 变更装备
  466.       if @right_window.index == 1 and item.is_a?(RPG::Weapon)
  467.         @actor.equip(@right_window.index, -item.id)
  468.         @item_window1.refresh
  469.       else
  470.         @actor.equip(@right_window.index, item == nil ? 0 : item.id)
  471.         @item_window2.refresh if @right_window.index == 0 and @actor.dual_wield?
  472.         @item_window1.refresh if @right_window.index == 1 and @actor.dual_wield?
  473.       end
  474.       # 激活右侧窗口
  475.       @right_window.active = true
  476.       @item_window.active = false
  477.       @item_window.index = -1
  478.       # 再生成右侧窗口、物品窗口的内容
  479.       @right_window.refresh
  480.       @item_window.refresh
  481.       return
  482.     end
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 刷新
  486.   #--------------------------------------------------------------------------
  487.   def refresh
  488.     # 设置物品窗口的可视状态
  489.     @item_window1.visible = (@right_window.index == 0)
  490.     @item_window2.visible = (@right_window.index == 1)
  491.     @item_window3.visible = (@right_window.index == 2)
  492.     @item_window4.visible = (@right_window.index == 3)
  493.     @item_window5.visible = (@right_window.index == 4)
  494.     # 获取当前装备中的物品
  495.     item1 = @right_window.item
  496.     # 设置当前的物品窗口到 @item_window
  497.     case @right_window.index
  498.     when 0
  499.       @item_window = @item_window1
  500.     when 1
  501.       @item_window = @item_window2
  502.     when 2
  503.       @item_window = @item_window3
  504.     when 3
  505.       @item_window = @item_window4
  506.     when 4
  507.       @item_window = @item_window5
  508.     end
  509.     # 右窗口被激活的情况下
  510.     if @right_window.active
  511.       # 删除变更装备后的能力
  512.       @left_window.set_new_parameters(nil, nil, nil)
  513.     end
  514.     # 物品窗口被激活的情况下
  515.     if @item_window.active
  516.       # 获取现在选中的物品
  517.       item2 = @item_window.item
  518.       # 变更装备
  519.       last_hp = @actor.hp
  520.       last_sp = @actor.sp
  521.       if @right_window.index == 1 and item2.is_a?(RPG::Weapon)
  522.         @actor.equip(@right_window.index, -item2.id)
  523.       else
  524.         @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  525.       end
  526.       # 获取变更装备后的能力值
  527.       new_atk = @actor.atk
  528.       new_pdef = @actor.pdef
  529.       new_mdef = @actor.mdef
  530.       # 返回到装备
  531.       if @right_window.index == 1 and item1.is_a?(RPG::Weapon)
  532.         @actor.equip(@right_window.index, -item1.id)
  533.       else
  534.         @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  535.       end
  536.       @actor.hp = last_hp
  537.       @actor.sp = last_sp
  538.       # 描画左窗口
  539.       @left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
  540.     end
  541.   end
  542. end

  543. #==============================================================================
  544. # ■ Window_ShopStatus
  545. #------------------------------------------------------------------------------
  546. #  商店画面、显示物品所持数与角色装备的窗口。
  547. #==============================================================================

  548. class Window_ShopStatus < Window_Base
  549.   #--------------------------------------------------------------------------
  550.   # ● 刷新
  551.   #--------------------------------------------------------------------------
  552.   def refresh
  553.     self.contents.clear
  554.     if @item == nil
  555.       return
  556.     end
  557.     case @item
  558.     when RPG::Item
  559.       number = $game_party.item_number(@item.id)
  560.     when RPG::Weapon
  561.       number = $game_party.weapon_number(@item.id)
  562.     when RPG::Armor
  563.       number = $game_party.armor_number(@item.id)
  564.     end
  565.     self.contents.font.color = system_color
  566.     self.contents.draw_text(4, 0, 200, 32, "所持数")
  567.     self.contents.font.color = normal_color
  568.     self.contents.draw_text(204, 0, 32, 32, number.to_s, 2)
  569.     if @item.is_a?(RPG::Item)
  570.       return
  571.     end
  572.     # 添加装备品信息
  573.     for i in 0...$game_party.actors.size
  574.       # 获取角色
  575.       actor = $game_party.actors[i]
  576.       # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  577.       if actor.equippable?(@item)
  578.         self.contents.font.color = normal_color
  579.       else
  580.         self.contents.font.color = disabled_color
  581.       end
  582.       # 描绘角色名字
  583.       self.contents.draw_text(4, 64 + 64 * i, 120, 32, actor.name)
  584.       # 获取当前的装备品
  585.       if @item.is_a?(RPG::Weapon)
  586.         item1 = $data_weapons[actor.weapon_id]
  587.       elsif @item.kind == 0
  588.         item1 = actor.armor1_id > 0 ? $data_armors[actor.armor1_id] : nil
  589.       elsif @item.kind == 1
  590.         item1 = $data_armors[actor.armor2_id]
  591.       elsif @item.kind == 2
  592.         item1 = $data_armors[actor.armor3_id]
  593.       else
  594.         item1 = $data_armors[actor.armor4_id]
  595.       end
  596.       # 可以装备的情况
  597.       if actor.equippable?(@item)
  598.         # 武器的情况
  599.         if @item.is_a?(RPG::Weapon)
  600.           atk1 = item1 != nil ? item1.atk : 0
  601.           atk2 = @item != nil ? @item.atk : 0
  602.           change = atk2 - atk1
  603.         end
  604.         # 防具的情况
  605.         if @item.is_a?(RPG::Armor)
  606.           pdef1 = item1 != nil ? item1.pdef : 0
  607.           mdef1 = item1 != nil ? item1.mdef : 0
  608.           pdef2 = @item != nil ? @item.pdef : 0
  609.           mdef2 = @item != nil ? @item.mdef : 0
  610.           change = pdef2 - pdef1 + mdef2 - mdef1
  611.         end
  612.         # 描绘能力值变化
  613.         self.contents.draw_text(124, 64 + 64 * i, 112, 32,
  614.           sprintf("%+d", change), 2)
  615.       end
  616.       # 描绘物品
  617.       if item1 != nil
  618.         x = 4
  619.         y = 64 + 64 * i + 32
  620.         bitmap = RPG::Cache.icon(item1.icon_name)
  621.         opacity = self.contents.font.color == normal_color ? 255 : 128
  622.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  623.         self.contents.draw_text(x + 28, y, 212, 32, item1.name)
  624.       end
  625.     end
  626.   end
  627. end

  628. #==============================================================================
  629. # ■ Window_Status
  630. #------------------------------------------------------------------------------
  631. #  显示状态画面、完全规格的状态窗口。
  632. #==============================================================================

  633. class Window_Status < Window_Base
  634.   #--------------------------------------------------------------------------
  635.   # ● 刷新
  636.   #--------------------------------------------------------------------------
  637.   def refresh
  638.     self.contents.clear
  639.     draw_actor_graphic(@actor, 40, 112)
  640.     draw_actor_name(@actor, 4, 0)
  641.     draw_actor_class(@actor, 4 + 144, 0)
  642.     draw_actor_level(@actor, 96, 32)
  643.     draw_actor_state(@actor, 96, 64)
  644.     draw_actor_hp(@actor, 96, 112, 172)
  645.     draw_actor_sp(@actor, 96, 144, 172)
  646.     draw_actor_parameter(@actor, 96, 192, 0)
  647.     draw_actor_parameter(@actor, 96, 224, 1)
  648.     draw_actor_parameter(@actor, 96, 256, 2)
  649.     draw_actor_parameter(@actor, 96, 304, 3)
  650.     draw_actor_parameter(@actor, 96, 336, 4)
  651.     draw_actor_parameter(@actor, 96, 368, 5)
  652.     draw_actor_parameter(@actor, 96, 400, 6)
  653.     self.contents.font.color = system_color
  654.     self.contents.draw_text(320, 48, 80, 32, "EXP")
  655.     self.contents.draw_text(320, 80, 80, 32, "NEXT")
  656.     self.contents.font.color = normal_color
  657.     self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
  658.     self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
  659.     self.contents.font.color = system_color
  660.     self.contents.draw_text(320, 160, 96, 32, "装备")
  661.     draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
  662.     if @actor.armor1_id >= 0
  663.       draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
  664.     else
  665.       draw_item_name($data_weapons[[email protected]_id], 320 + 16, 256)
  666.     end
  667.     draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
  668.     draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
  669.     draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
  670.   end
  671. end
复制代码

作者: 小传子    时间: 2012-3-25 21:21
宝刀不老= =,转战ACE去吧猫




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