Advertisement
dsiver144

DSI Equipment Set

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