Advertisement
Szyu

IC Equipment Enhanced

Sep 20th, 2013
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.64 KB | None | 0 0
  1. #==============================================================================
  2. # IC Equipment Enhanced
  3. # Version 1.0
  4. # By Szyu
  5. #
  6. # About:
  7. # Enhance weapons and armors of a kind. Increase stats of a type and every
  8. # equipment from the same type will be enhanced.
  9. # You gain Equipment Points by level ups or by script command.
  10. #
  11. # Instructions:
  12. # - Place below "▼ Materials" but above "▼ Main Process".
  13. #
  14. # How to Use:
  15. # - <no_enhancing> in equipment's tag for disable function for certain armors
  16. #                   and weapons.
  17. #
  18. # - set LEVEL_UP_MESSAGE to nil or "" if you don't want to show a message on
  19. #   level up.
  20. #
  21. # - Press the "A"-Button on Equip Menu or Item Menu while selecting a weapon
  22. #   or armor to enhance it.
  23. #   BEWARE: Each action costs Equipment Points. So enhance your items carefully.
  24. #
  25. # - You can allow and disallow the player to use Equipment Enhancing on certain
  26. #   moments with the following commands:
  27. #     * $game_party.enable_eq_enhancing
  28. #     * $game_party.disable_eq_enhancing
  29. #     * $game_party.toggle_eq_enhancing
  30. #
  31. # Requires:
  32. # - RPG Maker VX Ace
  33. #
  34. # Terms of Use:
  35. # - Free for commercal and non-commercial use. Please list me
  36. #   in the credits to support my work.
  37. #
  38. # Pastebin:
  39. # http://adf.ly/W58jj
  40. #
  41. #==============================================================
  42. #   * Configuration
  43. #==============================================================
  44.  
  45. # Term in the Enhancing Menu
  46. EQUIPMENT_POINTS_TERM = "Equipment Points"
  47.  
  48. # Message on level up
  49. LEVEL_UP_MESSAGE = "Equipment Points increased!"
  50.  
  51. # Equipment Points gained on level up
  52. EQP_PER_LEVEL_UP = 1
  53.  
  54. # Equipment Points needed for enhance parameters.
  55. EQP_ENHANCING_VALUE = 1
  56.  
  57. # Enables Equipment Enhancing on startup
  58. EQENH_ENABLED_START = true
  59.  
  60. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  61. #==============================================================
  62. #   * Game_Party
  63. #==============================================================
  64. class Game_Party < Game_Unit
  65.   attr_accessor :eqp # Equipment Points
  66.   attr_reader :eq_enhancing_enabled
  67.  
  68.   alias :ic_eqp_init :initialize
  69.   def initialize
  70.     ic_eqp_init
  71.     @eqp = 0
  72.     @eq_enhancing_enabled = EQENH_ENABLED_START
  73.   end
  74.  
  75.   def toggle_eq_enhancing
  76.     @eq_enhancing_enabled = !@eq_enhancing_enabled
  77.   end
  78.  
  79.   def enable_eq_enhancing
  80.     @eq_enhancing_enabled = true
  81.   end
  82.  
  83.   def disable_eq_enhancing
  84.     @eq_enhancing_enabled = false
  85.   end
  86.  
  87.   def gain_eqp(val=1)
  88.     @eqp += val
  89.   end
  90. end
  91.  
  92. #==============================================================
  93. #   * Game_Actor
  94. #==============================================================
  95. class Game_Actor < Game_Battler
  96.  
  97.   alias :ic_eqp_change_level :change_level
  98.   def change_level(level, show)
  99.     ic_eqp_change_level(level, show)
  100.     $game_party.eqp += EQP_PER_LEVEL_UP
  101.   end
  102.  
  103.   alias :ic_eqp_message :display_level_up
  104.   def display_level_up(new_skills)
  105.     ic_eqp_message(new_skills)
  106.     $game_message.add(LEVEL_UP_MESSAGE) if LEVEL_UP_MESSAGE && LEVEL_UP_MESSAGE != ""
  107.   end
  108. end
  109.  
  110. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111. #==============================================================
  112. #   * Scene_Equip
  113. #==============================================================
  114. class Scene_Equip < Scene_MenuBase
  115.  
  116.   alias :ic_eqp_sceq_start :start
  117.   def start
  118.     ic_eqp_sceq_start
  119.     @enhance_window = Window_EnhanceEquipment.new
  120.     @enhance_window.set_handler(:cancel, method(:on_enhancing_cancel))
  121.     @enhance_base_window = Window_EquipmentItemBase.new
  122.     @eqpoints_window = Window_EquipmentPoints.new
  123.     @enhance_window.points_window = @eqpoints_window
  124.   end
  125.  
  126.   alias :ic_eqp_sceq_itwin :create_item_window
  127.   def create_item_window
  128.     ic_eqp_sceq_itwin
  129.     @item_window.set_handler(:enhance_item,     method(:on_enhance_item))
  130.   end
  131.  
  132.   def on_enhance_item
  133.     return unless @item_window.item
  134.     show_equipment_enhance_windows
  135.     @enhance_window.item = @item_window.item
  136.     @enhance_base_window.item = @item_window.item
  137.   end
  138.  
  139.   def show_equipment_enhance_windows
  140.     @viewport.rect.x = @viewport.ox = 0
  141.     @viewport.rect.width = 0
  142.     @enhance_window.show.activate
  143.     @enhance_base_window.show.activate
  144.     @eqpoints_window.show.activate
  145.   end
  146.  
  147.   def hide_equipment_enhance_windows
  148.     @viewport.rect.x = @viewport.ox = 0
  149.     @viewport.rect.width = Graphics.width
  150.     @enhance_window.hide.deactivate
  151.     @enhance_base_window.hide.deactivate
  152.     @eqpoints_window.hide.deactivate
  153.     @item_window.refresh
  154.     @item_window.activate
  155.   end
  156.  
  157.   def on_enhancing_cancel
  158.     hide_equipment_enhance_windows
  159.   end
  160. end
  161.  
  162. #==============================================================
  163. #   * Scene_Item
  164. #==============================================================
  165. class Scene_Item < Scene_ItemBase
  166.   alias :ic_eqp_scit_start :start
  167.   def start
  168.     ic_eqp_scit_start
  169.     @enhance_window = Window_EnhanceEquipment.new
  170.     @enhance_window.set_handler(:cancel, method(:on_enhancing_cancel))
  171.     @enhance_base_window = Window_EquipmentItemBase.new
  172.     @eqpoints_window = Window_EquipmentPoints.new
  173.     @enhance_window.points_window = @eqpoints_window
  174.   end
  175.  
  176.   alias :ic_eqp_scit_itwin :create_item_window
  177.   def create_item_window
  178.     ic_eqp_scit_itwin
  179.     @item_window.set_handler(:enhance_item,     method(:on_enhance_item))
  180.   end
  181.  
  182.   def on_enhance_item
  183.     return unless @item_window.item
  184.     return unless @item_window.item.is_a?(RPG::Weapon) || @item_window.item.is_a?(RPG::Armor)
  185.     show_equipment_enhance_windows
  186.     @enhance_window.item = @item_window.item
  187.     @enhance_base_window.item = @item_window.item
  188.   end
  189.  
  190.   def show_equipment_enhance_windows
  191.     @viewport.rect.x = @viewport.ox = 0
  192.     @viewport.rect.width = 0
  193.     @enhance_window.show.activate
  194.     @enhance_base_window.show.activate
  195.     @eqpoints_window.show.activate
  196.   end
  197.  
  198.   def hide_equipment_enhance_windows
  199.     @viewport.rect.x = @viewport.ox = 0
  200.     @viewport.rect.width = Graphics.width
  201.     @enhance_window.hide.deactivate
  202.     @enhance_base_window.hide.deactivate
  203.     @eqpoints_window.hide.deactivate
  204.     @item_window.refresh
  205.     @item_window.activate
  206.   end
  207.  
  208.   def on_enhancing_cancel
  209.     hide_equipment_enhance_windows
  210.   end
  211. end
  212.  
  213. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214. #==============================================================
  215. #   * Window_ItemList
  216. #==============================================================
  217. class Window_ItemList < Window_Selectable
  218.  
  219.   alias :ic_eqp_winsel_prohan :process_handling
  220.   def process_handling
  221.     ic_eqp_winsel_prohan
  222.     return process_enhance_item if handle?(:enhance_item) && Input.trigger?(:X) && $game_party.eq_enhancing_enabled
  223.   end
  224.  
  225.   def process_enhance_item
  226.     return if item == nil || (!item.is_a?(RPG::Weapon) && !item.is_a?(RPG::Armor))
  227.     return if item.no_enhancing
  228.     Sound.play_cursor
  229.     Input.update
  230.     deactivate
  231.     call_handler(:enhance_item)
  232.   end
  233. end
  234.  
  235. #==============================================================
  236. #   * Window_EnhanceEquipment
  237. #==============================================================
  238. class Window_EnhanceEquipment < Window_Selectable
  239.  
  240.   attr_reader :item
  241.   attr_accessor :points_window
  242.  
  243.   def initialize
  244.     super(0, line_height*5, Graphics.width/3+8, line_height*9)
  245.     self.visible = false
  246.     @points_window = nil
  247.     @item = nil
  248.     @param = 0
  249.   end
  250.  
  251.   def item=(it)
  252.     @item = it
  253.     select(0)
  254.     refresh
  255.   end
  256.  
  257.   def make_item_list
  258.     @data = @item.params
  259.   end
  260.  
  261.   def item_max
  262.     @data ? @data.size : 1
  263.   end
  264.  
  265.   def draw_item(index)
  266.     param = @data[index]
  267.     if $data_system.terms.params[index]
  268.       rect = item_rect(index)
  269.       rect.width -= 4
  270.       draw_text(rect, $data_system.terms.params[index])
  271.       draw_text(rect, param.to_s,2)
  272.     end
  273.   end
  274.  
  275.   def refresh
  276.     make_item_list
  277.     create_contents
  278.     draw_all_items
  279.     @points_window.refresh
  280.   end
  281.  
  282.   def update
  283.     super
  284.     if active
  285.       last_param = @param
  286.       update_params
  287.       if @param != last_param
  288.         Sound.play_cursor
  289.         refresh
  290.       end
  291.     end
  292.   end
  293.  
  294.   def update_params
  295.     if Input.trigger?(:LEFT)
  296.       if $game_party.eqp > 0
  297.         @item.params[@index] -= (@index == 0 ||  @index == 1) ? 10 : 1
  298.         $game_party.eqp -= EQP_ENHANCING_VALUE
  299.         refresh
  300.         Sound.play_cursor
  301.       else
  302.         Sound.play_buzzer
  303.       end
  304.     elsif Input.trigger?(:RIGHT)
  305.       if $game_party.eqp > 0
  306.         @item.params[@index] += (@index == 0 ||  @index == 1) ? 10 : 1
  307.         $game_party.eqp -= EQP_ENHANCING_VALUE
  308.         refresh
  309.         Sound.play_cursor
  310.       else
  311.         Sound.play_buzzer
  312.       end
  313.     end
  314.   end
  315. end
  316.  
  317. #==============================================================
  318. #   * Window_EquipmentItemBase
  319. #==============================================================
  320. class Window_EquipmentItemBase < Window_Selectable
  321.  
  322.   attr_reader :item
  323.  
  324.   def initialize
  325.     super(0,0,Graphics.width, line_height*5)
  326.     self.visible = false
  327.     @item = nil
  328.   end
  329.  
  330.   def item=(it)
  331.     @item = it
  332.     refresh
  333.   end
  334.  
  335.   def draw_horz_line(y)
  336.     line_y = y + line_height / 2 - 1
  337.     contents.fill_rect(0, line_y, contents_width, 2, line_color)
  338.   end
  339.   def line_color
  340.     color = normal_color
  341.     color.alpha = 48
  342.     color
  343.   end
  344.  
  345.   def refresh
  346.     contents.clear
  347.     xx = contents.text_size(@item.name).width
  348.     draw_icon(@item.icon_index, (width-xx)/2-32,0)
  349.     change_color(system_color)
  350.     draw_text(0,0,width,line_height,@item.name,1)
  351.     change_color(normal_color)
  352.     draw_horz_line(line_height*1)
  353.     draw_text_ex(0,line_height*2,@item.description)
  354.   end
  355.  
  356. end
  357.  
  358. #==============================================================
  359. #   * Window_EquipmentPoints
  360. #==============================================================
  361. class Window_EquipmentPoints < Window_Selectable
  362.  
  363.   def initialize
  364.     super(0,line_height*14,Graphics.width/3+8, Graphics.height-line_height*14)
  365.     self.visible = false
  366.   end
  367.  
  368.   def refresh
  369.     contents.clear
  370.     change_color(system_color)
  371.     draw_text(0,0,width,line_height, EQUIPMENT_POINTS_TERM)
  372.     change_color(normal_color)
  373.     draw_text_ex(0,line_height,$game_party.eqp)
  374.   end
  375. end
  376.  
  377. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  378. #==============================================================
  379. #   * RPG::BaseItem
  380. #==============================================================
  381. class RPG::BaseItem
  382.  
  383.   def no_enhancing
  384.     return self.note.include?("<no_enhancing>")
  385.   end
  386.  
  387. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement