Guest User

Untitled

a guest
Aug 10th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.51 KB | None | 0 0
  1. #===============================================================================
  2. #                     N.A.S.T.Y. Extra Equip Slots
  3. #                   Nelderson's Awesome Scripts To You
  4. # By: Nelderson
  5. # Made On: 5/15/2012
  6. #===============================================================================
  7. # Update History:
  8. # - Version 1.0  - Initial release
  9. #===============================================================================
  10. # *Notes:
  11. # - This script let's you add custom equip slots, and also changes
  12. #   the equip screen a little when you move around.
  13. #===============================================================================
  14. # *Usage:
  15. # - To add an extra slot, use the CUSTOM_SLOTS section in the NEL module.
  16. #
  17. # - Put this notetag in an armor's note section for the armor to
  18. #   be a specific equip type:
  19. #            
  20. #      <EQUIP_TYPE: X>  - Where X is the EQUIP_TYPE_ID
  21. #
  22. # - DUAL_ORDER and NON_DUAL_ORDER are the way in which the equip screen will
  23. #   show your equip slots.  Put this in any order you feel like.  You can also
  24. #   use multiple slots of the same slot id for multiple things of the same type.
  25. #===============================================================================
  26. # Credits:
  27. # -Nelderson
  28. #===============================================================================
  29.  
  30.  
  31. module NEL
  32.   #EQUIP_TYPE_ID => "Name"
  33.   CUSTOM_SLOTS = {
  34.   5 => "Boots",
  35.   6 => "Neck",
  36.   7 => "Ring",
  37.   8 => "Tatoo",
  38.   }
  39.  
  40.   #EQUIP_TYPE_IDs already in place
  41.   #0 = Weapon
  42.   #1 = Shield
  43.   #2 = Head
  44.   #3 = Body
  45.   #4 = Accessory
  46.  
  47.   #Used for the order of equip types with Dual Weapon actors
  48.   DUAL_ORDER = [0,0,2,3,4,4,5,6,7,8]
  49.  
  50.   #Used for the order of equip types with Sword/Shield actors
  51.   NON_DUAL_ORDER = [0,1,2,3,4,4,5,8,7,6]
  52.  
  53. end
  54. #==============================================================================#
  55. #                        End Of Customization Section                          #
  56. #==============================================================================#
  57.  
  58. class Game_Actor < Game_Battler
  59. def equip_slots
  60.     return NEL::DUAL_ORDER if dual_wield?    
  61.     return NEL::NON_DUAL_ORDER              
  62.   end
  63. end
  64.  
  65. module Vocab
  66.   class << Vocab
  67.     alias nel_etype etype
  68.     def etype(etype_id)
  69.       if etype_id >= 5
  70.         return NEL::CUSTOM_SLOTS[etype_id]
  71.       else
  72.         $data_system.terms.etypes[etype_id]
  73.       end
  74.     end
  75.   end
  76. end
  77.  
  78. module DataManager
  79.   class << DataManager
  80.     alias nel_item_slot_inita_loadf load_database
  81.     def load_database
  82.       nel_item_slot_inita_loadf
  83.       for a in 0..$data_armors.size
  84.         next if $data_armors[a] == nil
  85.         if /<(?:EQUIP_TYPE:|equip_type:)[ ](\d+)>/i =~ $data_armors[a].note
  86.           $data_armors[a].etype_id = $1.to_i
  87.         end
  88.       end
  89.     end
  90.   end
  91. end
  92.  
  93. class Window_EquipSlot < Window_Selectable
  94.  
  95.   def col_max
  96.     return 2
  97.   end
  98.  
  99. def update
  100.     super
  101.     if index % 2 == 0
  102.       SceneManager.scene.steady_infoview if SceneManager.scene_is?(Scene_Equip)
  103.       @item_window.slot_id = index if @item_window
  104.     else
  105.       SceneManager.scene.reverse_infoview if SceneManager.scene_is?(Scene_Equip)
  106.       @item_window.slot_id = index if @item_window
  107.     end
  108.   end
  109. end
  110.  
  111. #==============================================================================
  112. # ■ Scene_Equip
  113. #------------------------------------------------------------------------------
  114. #==============================================================================
  115. class Scene_Equip < Scene_MenuBase
  116.   def start
  117.     super
  118.     create_help_window
  119.     create_status_window
  120.     create_info_viewport
  121.     create_command_window
  122.     create_slot_window
  123.     create_item_window
  124.   end
  125.  
  126.   def create_info_viewport
  127.     @info_viewport = Viewport.new
  128.     @info_viewport.rect.y = @help_window.height
  129.     @info_viewport.rect.height = @status_window.height + 416
  130.     @info_viewport.z = 100
  131.     @info_viewport.ox = 0
  132.     @status_window.viewport = @info_viewport
  133.   end
  134.  
  135.   alias nel_updt update
  136.   def update
  137.     nel_updt
  138.     update_info_viewport
  139.   end
  140.  
  141.   def reverse_infoview
  142.    return if !@slot_window.active
  143.    @status_window.x = @slot_window.width
  144.    move_info_viewport(208)
  145.  end
  146.  
  147.  def steady_infoview
  148.    return if !@slot_window.active
  149.    @status_window.x = -208
  150.    move_info_viewport(-208)
  151.  end
  152.  
  153.   def create_status_window
  154.     @status_window = Window_EquipStatus.new(-208, 0)
  155.     @status_window.actor = @actor
  156.   end
  157.  
  158.   def update_info_viewport
  159.     if @info_viewport.ox != 0
  160.       move_info_viewport(0) if !@slot_window.active && !@item_window.active
  161.     end
  162.   end
  163.  
  164.   def move_info_viewport(ox)
  165.     current_ox = @info_viewport.ox
  166.     @info_viewport.ox = [ox, current_ox + 48].min if current_ox < ox
  167.     @info_viewport.ox = [ox, current_ox - 48].max if current_ox > ox
  168.   end
  169.  
  170.   def create_command_window
  171.     wx = @status_window.width/2
  172.     wy = @help_window.height
  173.     ww = Graphics.width - @status_window.width
  174.     @command_window = Window_EquipCommand.new(wx, 0, ww)
  175.     @command_window.viewport = @info_viewport
  176.     @command_window.help_window = @help_window
  177.     @command_window.set_handler(:equip,    method(:command_equip))
  178.     @command_window.set_handler(:optimize, method(:command_optimize))
  179.     @command_window.set_handler(:clear,    method(:command_clear))
  180.     @command_window.set_handler(:cancel,   method(:return_scene))
  181.     @command_window.set_handler(:pagedown, method(:next_actor))
  182.     @command_window.set_handler(:pageup,   method(:prev_actor))
  183.   end
  184.  
  185.   def create_slot_window
  186.     wx = @status_window.width
  187.     wy = @command_window.height
  188.     ww = Graphics.width
  189.     @slot_window = Window_EquipSlot.new(0, wy, ww)
  190.     @slot_window.viewport = @info_viewport
  191.     @slot_window.help_window = @help_window
  192.     @slot_window.status_window = @status_window
  193.     @slot_window.actor = @actor
  194.     @slot_window.set_handler(:ok,       method(:on_slot_ok))
  195.     @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  196.   end
  197.  
  198.   def create_item_window
  199.     wx = 0
  200.     wy = @slot_window.y + @help_window.height + @slot_window.height
  201.     ww = Graphics.width
  202.     wh = Graphics.height - wy
  203.     @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  204.     @item_window.viewport = @viewport
  205.     @item_window.help_window = @help_window
  206.     @item_window.status_window = @status_window
  207.     @item_window.actor = @actor
  208.     @item_window.set_handler(:ok,     method(:on_item_ok))
  209.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  210.     @slot_window.item_window = @item_window
  211.   end
  212. end
Add Comment
Please, Sign In to add comment