Scinaya

Both Hands Style (Aero GP's toolbox)

Apr 28th, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 7.69 KB | None | 0 0
  1. #==============================================================================
  2. # ** ExEquip_BothHanded (AEROGP)
  3. #------------------------------------------------------------------------------
  4. #  This script grants the ability to use a shield, as well as equip it in the
  5. # weapon slot instead of the shield slot, when "two swords style" is enabled.
  6. #==============================================================================
  7.  
  8. class Game_Actor < Game_Battler
  9.   alias _exebthd_initialize initialize unless $@
  10.   #--------------------------------------------------------------------------
  11.   # * Object Initialization
  12.   #     actor_id : actor ID
  13.   #--------------------------------------------------------------------------
  14.   def initialize(actor_id)
  15.     _exebthd_initialize(actor_id)
  16.     @weapon_class = RPG::Weapon
  17.     @armor1_class = two_swords_style ? RPG::Weapon : RPG::Armor
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # * Get Weapon Object Array (Redefined)
  21.   #--------------------------------------------------------------------------
  22.   def weapons
  23.     result = []
  24.     if @weapon_class == RPG::Weapon
  25.       result.push($data_weapons[@weapon_id])
  26.     end
  27.     if @armor1_class == RPG::Weapon
  28.       result.push($data_weapons[@armor1_id])
  29.     end
  30.     return result
  31.   end
  32.   #--------------------------------------------------------------------------
  33.   # * Get Armor Object Array (Redefined)
  34.   #--------------------------------------------------------------------------
  35.   def armors
  36.     result = []
  37.     if @weapon_class == RPG::Armor
  38.       result.push($data_armors[@weapon_id])
  39.     end
  40.     if @armor1_class == RPG::Armor
  41.       result.push($data_armors[@armor1_id])
  42.     end
  43.     result.push($data_armors[@armor2_id])
  44.     result.push($data_armors[@armor3_id])
  45.     result.push($data_armors[@armor4_id])
  46.     return result
  47.   end
  48.   #--------------------------------------------------------------------------
  49.   # * Get Left-Hand Object
  50.   #--------------------------------------------------------------------------
  51.   def left_hand
  52.     result = [nil]
  53.     if @weapon_class == RPG::Weapon
  54.       result = [$data_weapons[@weapon_id]]
  55.     end
  56.     if @weapon_class == RPG::Armor
  57.       result = [$data_armors[@weapon_id]]
  58.     end
  59.     return result
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # * Get Right-Hand Object
  63.   #--------------------------------------------------------------------------
  64.   def right_hand
  65.     result = [nil]
  66.     if @armor1_class == RPG::Weapon
  67.       result = [$data_weapons[@armor1_id]]
  68.     end
  69.     if @armor1_class == RPG::Armor
  70.       result = [$data_armors[@armor1_id]]
  71.     end
  72.     return result
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Get Body Armor Object Array
  76.   #--------------------------------------------------------------------------
  77.   def body_armors
  78.     result = []
  79.     result.push($data_armors[@armor2_id])
  80.     result.push($data_armors[@armor3_id])
  81.     result.push($data_armors[@armor4_id])
  82.     return result
  83.   end
  84.   #--------------------------------------------------------------------------
  85.   # * Get Equipped Item Object Array (Redefined)
  86.   #--------------------------------------------------------------------------
  87.   def equips
  88.     return left_hand + right_hand + body_armors
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Change Equipment (Definition added)
  92.   #     equip_type : Equip region (0..4)
  93.   #     item       : Weapon or armor (nil is used to unequip)
  94.   #     test       : Test flag (for battle test or temporary equipment)
  95.   #--------------------------------------------------------------------------
  96.   def change_equip(equip_type, item, test = false)
  97.     last_item = equips[equip_type]
  98.     unless test
  99.       return if $game_party.item_number(item) == 0 if item != nil
  100.       $game_party.gain_item(last_item, 1)
  101.       $game_party.lose_item(item, 1)
  102.     end
  103.     item_id = item == nil ? 0 : item.id
  104.     case equip_type
  105.     when 0  # Weapon / Weapon 1
  106.       @weapon_id = item_id
  107.       if two_swords_style and item != nil   # If two swords style
  108.         @weapon_class = item.class
  109.         unless shield_legal?                # If shield is not allowed
  110.           change_equip(1, nil, test)        # Unequip from other hand
  111.         end
  112.       end
  113.       unless two_hands_legal?               # If two hands is not allowed
  114.         change_equip(1, nil, test)          # Unequip from other hand
  115.       end
  116.     when 1  # Shield / Weapon 2
  117.       @armor1_id = item_id
  118.       if two_swords_style and item != nil   # If two swords style
  119.         @armor1_class = item.class
  120.         unless shield_legal?                # If shield is not allowed
  121.           change_equip(0, nil, test)        # Unequip from other hand
  122.         end
  123.       end
  124.       unless two_hands_legal?               # If two hands is not allowed
  125.         change_equip(0, nil, test)          # Unequip from other hand
  126.       end
  127.     when 2  # Head
  128.       @armor2_id = item_id
  129.     when 3  # Body
  130.       @armor3_id = item_id
  131.     when 4  # Accessory
  132.       @armor4_id = item_id
  133.     end
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Discard Equipment (Redefined)
  137.   #     item : Weapon or armor to be discarded.
  138.   #    Used when the "Include Equipment" option is enabled.
  139.   #--------------------------------------------------------------------------
  140.   def discard_equip(item)
  141.     if item.is_a?(RPG::Weapon)
  142.       if @weapon_class == item.class and @weapon_id == item.id
  143.         @weapon_id = 0
  144.       elsif @armor1_class == item.class and @armor1_id == item.id
  145.         @armor1_id = 0
  146.       end
  147.     elsif item.is_a?(RPG::Armor)
  148.       if @weapon_class == item.class and @weapon_id == item.id
  149.         @weapon_id = 0
  150.       elsif @armor1_class == item.class and @armor1_id == item.id
  151.         @armor1_id = 0
  152.       elsif @armor2_id == item.id
  153.         @armor2_id = 0
  154.       elsif @armor3_id == item.id
  155.         @armor3_id = 0
  156.       elsif @armor4_id == item.id
  157.         @armor4_id = 0
  158.       end
  159.     end
  160.   end
  161.   #--------------------------------------------------------------------------
  162.   # * Determine if Shield is Usable
  163.   #--------------------------------------------------------------------------
  164.   def shield_legal?
  165.     if @weapon_id != 0 and @weapon_class == RPG::Armor
  166.       return false if @armor1_class == RPG::Armor
  167.     end
  168.     if @armor1_id != 0 and @armor1_class == RPG::Armor
  169.       return false if @weapon_class == RPG::Armor
  170.     end
  171.     return true
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # * Determine if Equippable (Redefined)
  175.   #     item : item
  176.   #--------------------------------------------------------------------------
  177.   def equippable?(item)
  178.     if item.is_a?(RPG::Weapon)
  179.       return self.class.weapon_set.include?(item.id)
  180.     elsif item.is_a?(RPG::Armor)
  181.       return self.class.armor_set.include?(item.id)
  182.     end
  183.     return false
  184.   end
  185. end
  186.  
  187. class Window_EquipItem < Window_Item
  188.   #--------------------------------------------------------------------------
  189.   # * Whether to include item in list (Redefined)
  190.   #     item : item
  191.   #--------------------------------------------------------------------------
  192.   def include?(item)
  193.     return true if item == nil
  194.     if @equip_type == 0
  195.       if @actor.two_swords_style
  196.         return false if item.is_a?(RPG::Armor) and item.kind > 0
  197.       else
  198.         return false unless item.is_a?(RPG::Weapon)
  199.       end
  200.     else
  201.       return false unless item.is_a?(RPG::Armor)
  202.       return false unless item.kind == @equip_type - 1
  203.     end
  204.     return @actor.equippable?(item)
  205.   end
  206. end
Advertisement
Add Comment
Please, Sign In to add comment