Advertisement
dsiver144

DSI Equipment Set v1.2

May 18th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 21.15 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Equipment Set v1.2
  3. # -- Last Updated: 2017.05.18
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-EquipSet"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.05.15 - Finish first version.
  14. # 2017.05.16 - Fix some bugs.
  15. # 2017.05.18 - Fix more bugs.
  16. #==============================================================================
  17. # + Instructions
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # To install this script, open up your script editor and copy/paste this script
  20. # to an open slot below �� Materials/�f�� but above �� Main. Remember to save.
  21. #==============================================================================
  22.   module DSIVER144
  23.     module Equipment_Set
  24.       Equipments = {}
  25.       #-------------------------------------------------------------------------
  26.       Equipments[1] = {}
  27.       Equipments[1][:name] = "Earth Mage Set"
  28.       Equipments[1][:items] = ["w13","a12","a36","a1","a2"] # weapon 13, armor 12, armor 36, ...
  29.       Equipments[1][:set] = []
  30.       Equipments[1][:set][1] = {}
  31.       Equipments[1][:set][1][:skill_id] = [[28,22]] # Replace 28 with 169
  32.                                                      # [[28,169],[29,169],[x,y],...] You can enhance more than 1 skill
  33.       Equipments[1][:set][1][:info] = ["DMG + 1 when using Earth Mage card."]
  34.       Equipments[1][:set][3] = {}
  35.       Equipments[1][:set][3][:skill_id] = [[28,23]] # Place 28 with 170
  36.       Equipments[1][:set][3][:info] = ["DMG + 2 when using Earth Mage card.", "20% chance to poison the chosen target when using X Skilllllll."]
  37.       Equipments[1][:set][5] = {}
  38.       Equipments[1][:set][5][:skill_id] = [[28,24]] # Place 28 with 171
  39.       Equipments[1][:set][5][:info] = ["HP barrier is projected on the caster for 1 turn.","+5 HP restored. Cure certain status effects"]
  40.      
  41.       Equipments[2] = {}
  42.       Equipments[2][:name] = "Grand Gaia Set"
  43.       Equipments[2][:items] = ["w89","a521","a523","a522","a524"] # weapon 13, armor 12, armor 36, ...
  44.       Equipments[2][:set] = []
  45.       Equipments[2][:set][1] = {}
  46.       Equipments[2][:set][1][:skill_id] = [[30,18]] # Replace 28 with 169
  47.       Equipments[2][:set][1][:info] = ["Stalagmite Dmg +1."]
  48.       Equipments[2][:set][3] = {}
  49.       Equipments[2][:set][3][:skill_id] = [[29,19]] # Place 28 with 170
  50.       Equipments[2][:set][3][:info] = ["Wood Hammer Dmg +2", "20% chance to stun enemies for 1 turn."]
  51.       Equipments[2][:set][5] = {}
  52.       Equipments[2][:set][5][:skill_id] = [[30,20]] # Place 28 with 171
  53.       Equipments[2][:set][5][:info] = ["Stalagmite Dmg +3", "30% chance to Vanquish on hit", "Healing Effect Removed", "Mp cost +2."]
  54.       #------------------------------------------------------------------------
  55.       # * new method: convert_to_equipdata
  56.       #------------------------------------------------------------------------
  57.       def self.convert_to_equipdata(string_array)
  58.         equip_data = []
  59.         string_array.each do |str|
  60.           if str =~ /w(\d+)/i
  61.             equip_data
  62.           end
  63.         end
  64.       end
  65.       #------------------------------------------------------------------------
  66.       # * new method: convert_equipdata_to_str
  67.       #------------------------------------------------------------------------
  68.       def self.convert_equipdata_to_str(equips)
  69.         str_array = []
  70.         equips.each do |equip|
  71.           if equip.is_a?(RPG::Weapon)
  72.             str_array << "w#{equip.id}"
  73.           end
  74.           if equip.is_a?(RPG::Armor)
  75.             str_array << "a#{equip.id}"
  76.           end
  77.         end
  78.         return str_array
  79.       end
  80.       #------------------------------------------------------------------------
  81.       # * new method: check_for_set
  82.       #------------------------------------------------------------------------
  83.       def self.check_for_set(equips)
  84.         $game_system.set_effect.clear
  85.         Equipments.each_pair do |set_id, equip_set|
  86.           a = convert_equipdata_to_str(equips).sort
  87.           b = equip_set[:items].sort
  88.           c = a - (a - b) # Get Same Equip
  89.           if c.size == 0
  90.             next
  91.           end
  92.           set_type = c.size
  93.           if [2,4].include?(set_type)
  94.             set_type -= 1
  95.           end
  96.           new_set = {}
  97.           new_set[:set_id] = set_id
  98.           new_set[:have_item] = c
  99.           new_set[:have_noitem] = a - b
  100.           [1,3,5].each do |set_index|
  101.             break if set_type < set_index
  102.             new_set[:skill_id] ||= []
  103.             new_set[:skill_id] << equip_set[:set][set_index][:skill_id]
  104.           end
  105.           new_set[:skill_id].uniq!
  106.           $game_system.set_effect << new_set
  107.         end
  108.       end
  109.     end # Equipment_Set
  110.   end # DSIVER144
  111.   #==============================================================================
  112.   # DataManager
  113.   #==============================================================================
  114.   module DataManager
  115.     include DSIVER144::Equipment_Set
  116.     #--------------------------------------------------------------------------
  117.     # alias method: load_database
  118.     #--------------------------------------------------------------------------
  119.     class <<self; alias load_database_equipment_set load_database; end
  120.     def self.load_database
  121.       load_database_equipment_set
  122.       init_equiment_set
  123.     end
  124.     #--------------------------------------------------------------------------
  125.     # Load Notetag Rental Weapons
  126.     #--------------------------------------------------------------------------
  127.     def self.init_equiment_set
  128.       Equipments.each_pair do |set_id, equipment_set|
  129.         equipment_set[:items].each do |str|
  130.           if str =~ /(w|a)(\d+)/i
  131.             item = $1 == "w" ? $data_weapons[$2.to_i] : $data_armors[$2.to_i]
  132.             next if item.nil?
  133.             item.eqset_id = set_id
  134.             p [item.name, set_id]
  135.           end
  136.         end
  137.       end
  138.     end
  139.   end # DataManager
  140.   class RPG::EquipItem
  141.     attr_accessor :eqset_id
  142.   end
  143.   #=============================================================================
  144.   # ** Game_System
  145.   #=============================================================================
  146.   class Game_System
  147.     attr_accessor :set_effect
  148.     alias_method(:dsi_equipment_set_effect_initialize, :initialize)
  149.     #------------------------------------------------------------------------
  150.     # * new method: initialize
  151.     #------------------------------------------------------------------------
  152.     def initialize
  153.       @set_effect = []
  154.       dsi_equipment_set_effect_initialize
  155.     end
  156.   end # Game_System
  157.   #=============================================================================
  158.   # ** Scene_Battle
  159.   #=============================================================================
  160.   class Scene_Battle
  161.     #--------------------------------------------------------------------------
  162.     # Handles card costs
  163.     #--------------------------------------------------------------------------
  164.     def invoke_card_cost(effect_name)
  165.       effect_array = PC27::CG::CARD_EFFECT[effect_name]
  166.       if effect_array[0] == :draw
  167.         card_effect_draw_cards(effect_array[1], effect_array[2], effect_array[3])
  168.         new_skill_id = @skill.id
  169.         $game_system.set_effect.each do |eq_set|
  170.           if eq_set[:skill_id]
  171.             eq_set[:skill_id].each do |replacer|
  172.               replacer.each do |pair|
  173.                 if @skill.id == pair[0]
  174.                   new_skill_id = pair[1]
  175.                 end
  176.               end
  177.             end
  178.           end
  179.         end
  180.         BattleManager.actor.input.set_skill(new_skill_id)
  181.         BattleManager.actor.last_skill.object = @skill
  182.         if !@skill.need_selection?
  183.           @skill_window.hide
  184.           next_command
  185.         elsif @skill.for_opponent?
  186.           select_enemy_selection
  187.         else
  188.           select_actor_selection
  189.         end
  190.       else
  191.         $game_message.background = 1
  192.         $game_message.position   = 1
  193.         $game_message.add(PC27::CG::CARD_EFF_TEXT)
  194.         wait_for_message
  195.         prepare_select_window(:cost, effect_array[0])
  196.         @temp_effect_data = [] unless @temp_effect_data
  197.         @temp_effect_data[0] = :cost
  198.         process_select_cards(effect_name)
  199.       end
  200.     end
  201.     #--------------------------------------------------------------------------
  202.     # On Skill Ok checks for card costs
  203.     #--------------------------------------------------------------------------
  204.     alias pc27_cardgame_scene_battle_on_skill_ok on_skill_ok
  205.     def on_skill_ok
  206.       @skill = @skill_window.item
  207.       BattleManager.actor.card_to_stack?(@skill.id)
  208.       if @skill.cost
  209.         invoke_card_cost(@skill.cost)
  210.         @skill_window.hide
  211.       else
  212.         new_skill_id = @skill.id
  213.         $game_system.set_effect.each do |eq_set|
  214.           if eq_set[:skill_id]
  215.             eq_set[:skill_id].each do |replacer|
  216.               replacer.each do |pair|
  217.                 if @skill.id == pair[0]
  218.                   new_skill_id = pair[1]
  219.                 end
  220.               end
  221.             end
  222.           end
  223.         end
  224.         BattleManager.actor.input.set_skill(new_skill_id)
  225.         BattleManager.actor.last_skill.object = @skill
  226.         if !@skill.need_selection?
  227.           @skill_window.hide
  228.           next_command
  229.         elsif @skill.for_opponent?
  230.           select_enemy_selection
  231.         else
  232.           select_actor_selection
  233.         end
  234.       end
  235.     end
  236.   end # Scene_Battle
  237.   class Game_Interpreter
  238.     #--------------------------------------------------------------------------
  239.     # * Change Equipment
  240.     #--------------------------------------------------------------------------
  241.     alias_method(:dsi_change_equipment_command_319, :command_319)
  242.     def command_319
  243.       dsi_change_equipment_command_319
  244.       actor = $game_actors[@params[0]]
  245.       DSIVER144::Equipment_Set.check_for_set(actor.equips)
  246.     end
  247.   end
  248.   #==============================================================================
  249.   # ** Scene_Equip
  250.   #==============================================================================
  251.   class Scene_Equip
  252.     include DSIVER144::Equipment_Set
  253.     alias_method(:dsi_equipment_set_info_window_creation, :start)
  254.     #--------------------------------------------------------------------------
  255.     # * Start Processing
  256.     #--------------------------------------------------------------------------
  257.     def start
  258.       dsi_equipment_set_info_window_creation # Call original method
  259.       create_equipment_set_info_window
  260.       create_equipment_set_skill_info_window
  261.     end
  262.     #--------------------------------------------------------------------------
  263.     # * Update All Windows
  264.     #--------------------------------------------------------------------------
  265.     alias_method(:dsi_equipment_set_update_all_windows, :update_all_windows)
  266.     def update_all_windows
  267.       return if @equipment_set_skill_info_window.visible
  268.       dsi_equipment_set_update_all_windows
  269.     end
  270.     #-------------------------------------------------------------------------
  271.     # * new method: easeInOutQuad
  272.     #-------------------------------------------------------------------------
  273.     def easeInOutQuad(t, b, c, d)
  274.       t = t / (d/2.0)
  275.       if (t < 1)
  276.         return c/2*t*t + b
  277.       end
  278.       t -= 1
  279.       return -c/2.0 * (t*(t-2) - 1) + b
  280.     end
  281.     #-------------------------------------------------------------------------
  282.     # * new method: update
  283.     #-------------------------------------------------------------------------
  284.     alias_method(:dsi_update_equipment_set, :update)
  285.     def update
  286.       dsi_update_equipment_set
  287.       if Input.trigger?(:X) && $game_system.set_effect.size > 0
  288.         if @slot_window.item
  289.           if @slot_window.item.eqset_id
  290.             @equipment_set_skill_info_window.show_skill_info(@slot_window.item.eqset_id)
  291.             @equipment_set_skill_info_window.visible = !@equipment_set_skill_info_window.visible
  292.             @equipment_set_skill_info_window.update
  293.           end
  294.         end
  295.       end
  296.       if @equipment_set_skill_info_window.visible && Input.trigger?(:B)
  297.         @equipment_set_skill_info_window.visible = false
  298.         @equipment_set_skill_info_window.update
  299.       end
  300.       if @slot_window_index != @slot_window.index
  301.         @slot_window_index = @slot_window.index
  302.         if @slot_window.item && @slot_window.item.eqset_id
  303.           @equipment_set_info_window.show_info(@slot_window.item.eqset_id)
  304.           if @equipment_set_info_window.x > @equipment_info_x_ori
  305.             show_set_info_window
  306.           end
  307.         else
  308.           hide_set_info_window
  309.         end
  310.       end
  311.     end
  312.     #--------------------------------------------------------------------------
  313.     # * new method: create_equipment_set_info_window
  314.     #--------------------------------------------------------------------------
  315.     def create_equipment_set_skill_info_window
  316.       ww = Graphics.width - 90
  317.       wh = Graphics.height - 100
  318.       wx = (Graphics.width - ww) * 0.5
  319.       wy = (Graphics.height - wh) * 0.5
  320.       @equipment_set_skill_info_window = Window_EquipmentSetSkillInfo.new(wx,wy,ww,wh)
  321.       @equipment_set_skill_info_window.z = 200
  322.       DSIVER144::Equipment_Set.check_for_set(@actor.equips)
  323.       @equipment_set_skill_info_window.visible = false
  324.     end
  325.     #--------------------------------------------------------------------------
  326.     # * new method: create_equipment_set_info_window
  327.     #--------------------------------------------------------------------------
  328.     def create_equipment_set_info_window
  329.       wx = @slot_window.x + @slot_window.width
  330.       wy = @command_window.y
  331.       ww = Graphics.width - @slot_window.width
  332.       wh = @slot_window.height + @command_window.height
  333.       @equipment_set_info_window = Window_EquipmentSetInfo.new(wx,wy,ww,wh)
  334.       @equipment_info_x_ori = @equipment_set_info_window.x
  335.       @equipment_set_info_window.x = Graphics.width
  336.       @slot_window_index = @slot_window.index
  337.       DSIVER144::Equipment_Set.check_for_set(@actor.equips)
  338.     end
  339.     #--------------------------------------------------------------------------
  340.     # * new method: show_set_info_window
  341.     #--------------------------------------------------------------------------
  342.     def show_set_info_window
  343.       return if @equipment_set_info_window.x == @equipment_info_x_ori
  344.       start_time = Graphics.frame_count
  345.       start_x = Graphics.width
  346.       change_x = @equipment_info_x_ori - start_x
  347.       while (current_time = Graphics.frame_count - start_time) < 45
  348.         @equipment_set_info_window.x = easeInOutQuad(current_time, start_x, change_x, 45)
  349.         Graphics.update
  350.       end
  351.       @equipment_set_info_window.x = @equipment_info_x_ori
  352.     end
  353.     #--------------------------------------------------------------------------
  354.     # * new method: hide_set_info_window
  355.     #--------------------------------------------------------------------------
  356.     def hide_set_info_window
  357.       return if @equipment_set_info_window.x == Graphics.width
  358.       start_time = Graphics.frame_count
  359.       start_x = @equipment_info_x_ori
  360.       change_x = Graphics.width - start_x
  361.       while (current_time = Graphics.frame_count - start_time) < 45
  362.         @equipment_set_info_window.x = easeInOutQuad(current_time, start_x, change_x, 45)
  363.         Graphics.update
  364.       end
  365.       @equipment_set_info_window.x = Graphics.width
  366.     end
  367.     #--------------------------------------------------------------------------
  368.     # * new method: check_for_equipment_set
  369.     #--------------------------------------------------------------------------
  370.     def check_for_equipment_set
  371.       DSIVER144::Equipment_Set.check_for_set(@actor.equips)
  372.       if $game_system.set_effect.size > 0
  373.         @equipment_set_info_window.show
  374.         if @slot_window.item
  375.           if @slot_window.item.eqset_id
  376.             @equipment_set_info_window.show_info(@slot_window.item.eqset_id)
  377.             show_set_info_window
  378.           else
  379.             hide_set_info_window
  380.           end
  381.         else
  382.           hide_set_info_window
  383.         end
  384.       else
  385.         hide_set_info_window
  386.       end
  387.     end
  388.     #--------------------------------------------------------------------------
  389.     # * new method: command_clear
  390.     #--------------------------------------------------------------------------
  391.     alias_method(:dsi_command_clear_equipment_set, :command_clear)
  392.     def command_clear
  393.       dsi_command_clear_equipment_set # Call original method
  394.       check_for_equipment_set
  395.     end
  396.     #--------------------------------------------------------------------------
  397.     # * new method: on_item_ok
  398.     #--------------------------------------------------------------------------
  399.     alias_method(:dsi_on_item_ok_equipment_set, :on_item_ok)
  400.     def on_item_ok
  401.       dsi_on_item_ok_equipment_set # Call original method
  402.       check_for_equipment_set
  403.     end
  404.   end # Scene_Equip
  405. #==============================================================================
  406. # ** Window_EquipmentSetSkillInfo
  407. #==============================================================================
  408. class Window_EquipmentSetSkillInfo < Window_Base
  409.   include DSIVER144::Equipment_Set
  410.   #-------------------------------------------------------------------------
  411.   # * new method: show_skill_info
  412.   #-------------------------------------------------------------------------
  413.   def show_skill_info(set_id)
  414.     contents.clear
  415.     contents.turn_on_wordwraping
  416.     x = 0; y = 0
  417.     change_color(text_color(20))
  418.     contents.font.size = 20
  419.     draw_text(x,y,contents_width,line_height,"Equipment Set Effect",1)
  420.     equip_set = Equipments[set_id]
  421.     check_set = $game_system.set_effect.select {|set| set[:set_id] == set_id}[0]
  422.     reset_font_settings
  423.     y += 24
  424.     info = ""
  425.     [1,3,5].each do |set_type|
  426.       change_color(text_color(11), true)
  427.       enable_color = check_set[:have_item].size >= set_type ? 11 : 10
  428.       txt_color = check_set[:have_item].size >= set_type ? 7 : 0
  429.       info << "\\c[#{enable_color}][#{set_type}] Set Effect" + "\n"
  430.       equip_set[:set][set_type][:info].each do |text|
  431.         info << "\\c[#{txt_color}] + " + text + "\n"
  432.       end
  433.     end
  434.     contents.draw_text_ex(x,y,info,false,18)
  435.   end
  436. end # Window_EquipmentSetSkillInfo
  437. #==============================================================================
  438. # ** Window_EquipmentSetInfo
  439. #==============================================================================
  440. class Window_EquipmentSetInfo < Window_Base
  441.   include DSIVER144::Equipment_Set
  442.   attr_accessor :last_set_id
  443.   #-------------------------------------------------------------------------
  444.   # * new method: show_info
  445.   #-------------------------------------------------------------------------
  446.   def show_info(set_id)
  447.     contents.clear
  448.     equip_set = Equipments[set_id]
  449.     check_set = $game_system.set_effect.select {|set| set[:set_id] == set_id}[0]
  450.     x = 0; y = 0
  451.     change_color(normal_color, true)
  452.     draw_text(x,y,contents.width,line_height,equip_set[:name],1)
  453.     y += 24;
  454.     equip_set[:items].each do |str_data|
  455.       if check_set[:have_item].include?(str_data)
  456.         change_color(text_color(11), true)
  457.       else
  458.         change_color(normal_color, false)
  459.       end
  460.       if str_data =~ /(w|a)(\d+)/i
  461.         name = $1 == "a" ? $data_armors[$2.to_i].name : $data_weapons[$2.to_i].name
  462.       end
  463.       draw_text(x,y,contents.width,line_height," - " + name)
  464.       y += 16;
  465.     end
  466.     y += 16
  467.     draw_text_ex(x,y,"Press [A] for more info.")
  468.     @last_set_id = set_id
  469.   end
  470. end # Window_EquipmentSetInfo
  471. #==============================================================================
  472. # ** Window_EquipCommand
  473. #------------------------------------------------------------------------------
  474. #  This window is for selecting commands (change equipment/ultimate equipment
  475. # etc.) on the skill screen.
  476. #==============================================================================
  477. class Window_EquipCommand < Window_HorzCommand
  478.   #--------------------------------------------------------------------------
  479.   # * Get Window Width
  480.   #--------------------------------------------------------------------------
  481.   def window_width
  482.     @window_width
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # * Get Digit Count
  486.   #--------------------------------------------------------------------------
  487.   def col_max
  488.     return 2
  489.   end
  490.   #--------------------------------------------------------------------------
  491.   # * Create Command List
  492.   #--------------------------------------------------------------------------
  493.   def make_command_list
  494.     add_command(Vocab::equip2,   :equip)
  495.     add_command(Vocab::clear,    :clear)
  496.   end
  497. end # Window_EquipCommand
  498. #===============================================================================
  499. # * END OF FILE
  500. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement