Fomar0153

Fomar0153 - Dual Wielding -> Free Hands 1.0

Jan 30th, 2012
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.21 KB | None | 0 0
  1. =begin
  2. Duel Wield -> Free Hands
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. No requirements
  9. Changes dual wielding to allow characters to equip shield or one handed
  10. weapons in the shield slot. Also allows for two handed weapons.
  11. ----------------------
  12. Instructions
  13. ----------------------
  14. Notetag two handed weapon with <two-handed> and have them
  15. disable the shield slot.
  16. I would reccomend changing the slot name to Main Hand and Off Hand
  17. or something similiar
  18. ----------------------
  19. Known bugs
  20. ----------------------
  21. None
  22. =end
  23. class Game_Actor
  24.  
  25.   def equip_slots
  26.     return [0,1,2,3,4]
  27.   end
  28.  
  29.   def change_equip(slot_id, item)
  30.     return unless trade_item_with_party(item, equips[slot_id])
  31.     return if (item && equip_slots[slot_id] != item.etype_id) and
  32.       not (dual_wield? and (equip_slots[slot_id] == 1 and item.etype_id == 0))
  33.     @equips[slot_id].object = item
  34.     refresh
  35.   end
  36.  
  37.   def release_unequippable_items(item_gain = true)
  38.     @equips.each_with_index do |item, i|
  39.       if !equippable?(item.object,equip_slots[i]) || (item.object.etype_id != equip_slots[i] and
  40.           not (dual_wield? and (equip_slots[i] == 1 and item.object.etype_id == 0)))
  41.         trade_item_with_party(nil, item.object) if item_gain
  42.         item.object = nil
  43.       end
  44.     end
  45.   end
  46.  
  47.   def equippable?(item, slot = nil)
  48.     unless slot.nil?
  49.       if slot == 1 and dual_wield?
  50.         return (super(item) and not equip_type_sealed?(1)) if item.is_a?(RPG::Weapon)
  51.       end
  52.     end
  53.     return super(item)
  54.   end
  55.  
  56. end
  57.  
  58. class RPG::Weapon
  59.  
  60.   def two_handed?
  61.     return self.note.include?("<two-handed>")
  62.   end
  63.  
  64. end
  65.  
  66. class Window_EquipItem < Window_ItemList
  67.  
  68.   def include?(item)
  69.     return true if item == nil
  70.     return false unless item.is_a?(RPG::EquipItem)
  71.     return false if @slot_id < 0
  72.     return false if @actor.equip_slots[@slot_id] == 1 and
  73.       (item.is_a?(RPG::Weapon) and item.two_handed?)
  74.     return false if (item.etype_id != @actor.equip_slots[@slot_id]) and
  75.       not (@actor.dual_wield? and (@actor.equip_slots[@slot_id] == 1 and item.etype_id == 0))
  76.     return @actor.equippable?(item,@actor.equip_slots[@slot_id])
  77.   end
  78.  
  79. end
Add Comment
Please, Sign In to add comment