Advertisement
Fomar0153

Fomar0153 - Duel Wield -> Free Hands 1.1

Mar 27th, 2012
3,173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.57 KB | None | 0 0
  1. =begin
  2. Duel Wield -> Free Hands
  3. by Fomar0153
  4. Version 1.1
  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. Change Log
  20. ----------------------
  21. 1.0 -> 1.1 Fixed a bug where the equip item in the second hand could
  22.            overwrite the main hand's equip item.
  23. ----------------------
  24. Known bugs
  25. ----------------------
  26. None
  27. =end
  28. class Game_Actor
  29.  
  30.   def equip_slots
  31.     return [0,1,2,3,4]
  32.   end
  33.  
  34.   def change_equip(slot_id, item)
  35.     return unless trade_item_with_party(item, equips[slot_id])
  36.     return if (item && equip_slots[slot_id] != item.etype_id) and
  37.       not (dual_wield? and (equip_slots[slot_id] == 1 and item.etype_id == 0))
  38.     @equips[slot_id].object = item
  39.     refresh
  40.   end
  41.  
  42.   def release_unequippable_items(item_gain = true)
  43.     @equips.each_with_index do |item, i|
  44.       if !equippable?(item.object,equip_slots[i]) || (item.object.etype_id != equip_slots[i] and
  45.           not (dual_wield? and (equip_slots[i] == 1 and item.object.etype_id == 0)))
  46.         trade_item_with_party(nil, item.object) if item_gain
  47.         item.object = nil
  48.       end
  49.     end
  50.   end
  51.  
  52.   def equippable?(item, slot = nil)
  53.     unless slot.nil?
  54.       if slot == 1 and dual_wield?
  55.         return (super(item) and not equip_type_sealed?(1)) if item.is_a?(RPG::Weapon)
  56.       end
  57.     end
  58.     return super(item)
  59.   end
  60.  
  61.   def slot_list(etype_id)
  62.     result = []
  63.     equip_slots.each_with_index {|e, i| result.push(i) if e == etype_id or ((e == 1 and etype_id == 0) and dual_wield?) }
  64.     result
  65.   end
  66. end
  67.  
  68. class RPG::Weapon
  69.  
  70.   def two_handed?
  71.     return self.note.include?("<two-handed>")
  72.   end
  73.  
  74. end
  75.  
  76. class Window_EquipItem < Window_ItemList
  77.  
  78.   def include?(item)
  79.     return true if item == nil
  80.     return false unless item.is_a?(RPG::EquipItem)
  81.     return false if @slot_id < 0
  82.     return false if @actor.equip_slots[@slot_id] == 1 and
  83.       (item.is_a?(RPG::Weapon) and item.two_handed?)
  84.     return false if (item.etype_id != @actor.equip_slots[@slot_id]) and
  85.       not (@actor.dual_wield? and (@actor.equip_slots[@slot_id] == 1 and item.etype_id == 0))
  86.     return @actor.equippable?(item,@actor.equip_slots[@slot_id])
  87.   end
  88.  
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement