SHARE
TWEET

richter_h's smithing

richter_h Jun 5th, 2013 1,897 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # ==============================================================================
  2. # richter_h's Smithing -- Simply Upgrade Your Weapon
  3. # v1.0 - June 5, 2013
  4. # Type: Actor Customization, Equipments
  5. # Level: Medium
  6. # ==============================================================================
  7. # Ever played Suikoden? That game has some blacksmithes that provide weapon
  8. # upgrades and some enchantments, making your fights would be easier than
  9. # using a simple stick to the brawl.
  10. # And based on that reason, I made this script.
  11. #
  12. # Here in this rather-simple-to-use script, you can add a simple upgrade
  13. # path for every assigned weapon below. Also, you can:
  14. #    -> Add parameter in every weapon's level. So you can add some ATKs in
  15. #       first levels, then add it more PLUS some SPI. Just for your pleasure.
  16. #    -> Change your favorite weapon's name from simple "Longsword" into
  17. #       "Longersword", "Cloudcleaver", or "Titan's Toothpick" or even
  18. #       "Sword of the Dark Flame Master"? No problem.
  19. #       You can set weapon's name in every level as you want.
  20. #    -> Changing only the name won't impress you? You can change the icon
  21. #       of the weapon as you desire. Just put the certain number and you'll
  22. #       have a totally-epic-looking sword's icon once you upgrade them.
  23. #       And for you Enu SBS a.k.a. Tankentai user, you'll be rejoiced by this,
  24. #       if you know what I mean.
  25. #    -> Not only the name, the description of assigned weapon can be changed
  26. #       and whatever the "Longsword"'s description when upgraded is at your
  27. #       hand.
  28. #    -> The blacksmith can has lines to speak! It's highly customizable
  29. #       as you want, however, only one kind of quote lines could be added;
  30. #       A generic quote would work.
  31. #
  32. # There is another feature that I leave it behind for now. The 'Socket'ing
  33. # feature is in development. In different of your daily 'socket'ing and
  34. # all things 'socket'ery, I planned to just implying the feature brought
  35. # from the first Suikoden series; single-slot socketable in every weapon
  36. # that every Fragment socketed into it could be removed. For now, let's
  37. # don't talk about that 'socket'ery, kay? :D
  38. #
  39. # How to use this script?
  40. # Simply put this below Material and above Main in Script Editor. Don't ask me
  41. # how to put scripts on. Ask other for assistance.
  42. # (implying whoever has a use of this knows how to put scripts in Script Editor)
  43. #
  44. # Credits if you wanna. Don't claim as your own.
  45. # Also credit maximusPrime, since I worked this script based on his.
  46. #
  47. # Oh, don't forget to say a mention to Konami, since they'd made the
  48. # well-made traditional RPG back in 90s. (Not to mention that I only regard
  49. # those first two series, though.)
  50. # ==============================================================================
  51. # New Scene:
  52. # - Scene_Smith
  53. # New Windows:
  54. # - Window_SmithList
  55. # - Window_SmithList_Detail
  56. # Aliased:
  57. # - Scene_Title: load_database
  58. # Altered:
  59. # - RPG::Weapon
  60. #   new methods: add_levels, get_next_cost, get_next_weapon, clone_data
  61. #   new attributes: level, cost, upgrade_balance, next_weapon_id
  62. # ==============================================================================
  63.  
  64. # ==============================================================================
  65. # This is just to make sure the script is recognized in system.
  66. # A "scripter"'s stuff.
  67. # ==============================================================================
  68. $imported = {} if $imported == nil
  69. $imported["richter_h's Smithing"] = true
  70.  
  71. module Smithery
  72.   # ============================================================================
  73.   # So if you planned to set base price and inflation costs in every upgrades,
  74.   # change those numbers below. Their name are self-explanatory.
  75.   # ============================================================================
  76.   module Pricing
  77.     Base_Upgrade_Price = 10
  78.     Inflation_Price = 2
  79.   end
  80.  
  81.   # ============================================================================
  82.   # These variables are for some SEs when the upgrading is in progress.
  83.   # A simple cosmetic, based on what the Suikoden's blacksmithes ever do.
  84.   # ============================================================================
  85.   SMITH_SE = RPG::SE.new("Sword1", 80, 100)
  86.   SMITH_DONE_SE = RPG::SE.new("Sword2", 80, 100)
  87.  
  88.  
  89.   # ============================================================================
  90.   # Here's the main course of this script.
  91.   # You can see what's happened below. Those lines are what I called the
  92.   # 'upgrade tree.'
  93.   # You must follow the rules of adding the tree to make sure the script will
  94.   # work. Ready to follow the instruction? Here we go.
  95.   # ============================================================================
  96.   Upgrade_Table = { # Don't touch this, in the name of King Stout.
  97.       # ========================================================================
  98.       # The rule is simple; just add the weapon ID based on the Weapon tab in
  99.       # database, add some lines, add certain numbers, set the name and
  100.       # description for certain weapon's level, and you're on.
  101.       # Here's the quick guide:
  102.       #
  103.       # ID => [ { parameters }, icon_index, name, description ],
  104.       #
  105.       #     where:
  106.       #                ID = ID of the weapon.
  107.       #                     Look at the Database > Weapons and see the number
  108.       #                     that followed by weapon's name.
  109.       #    { parameters } = What parameter will be up (or down) once you
  110.       #                     upgrade your weapon.
  111.       #                     You can use these symbols to represent the stats:
  112.       #                     ----------------------------------------------------
  113.       #                     |   :atk or :str   <--- this one for weapon's ATK  |
  114.       #                     |   :spi or :int   <--- this one for weapon's SPI  |
  115.       #                     |   :agi           <--- this one for weapon's AGI  |
  116.       #                     |   :def           <--- this one for weapon's DEF  |
  117.       #                     ----------------------------------------------------
  118.       #                     And to assign the growth of assigned stats, follow
  119.       #                     this rule:
  120.       #                     ----------------------------------------------------
  121.       #                     |   :atk => 5, :spi => 2                           |
  122.       #                     ----------------------------------------------------
  123.       #                     It means when upgraded, it'll has ATK+5 and SPI+2
  124.       #                     up.
  125.       #                     You can add multiple stats, of course.
  126.       #        icon_index = The icon's index in Graphics/Iconset.png
  127.       #                     It starts from 0, and it's limitless.
  128.       #                     Use -1 if you don't want to change weapon's icon
  129.       #                     once upgraded.
  130.       #              name = The new name for upgraded weapon. Once it reaches
  131.       #                     that level, the name changes by it.
  132.       #       description = The new description for upgraded weapon.
  133.       #                     Once it reaches that level, the description
  134.       #                     changes by it.
  135.       #                     (Am I heard an echo?)
  136.       # ========================================================================
  137.      
  138.       1 => [   # The Weapon ID #1. Don't forget to add '=>' and '[' as example.
  139.              # These line below is for the weapon level 2.
  140.              # Let me explain this once again.
  141.              [ # It's started from this bracket... Don't touch this!
  142.              {:atk => 8, :agi => 2, :spi => 1}, # The parameter growth once
  143.                                                  # it's upgraded to this level.
  144.                -1,  # The icon index of weapon if upgraded to this level.
  145.                "Heavy Club",  # The name of weapon if upgraded to this level.
  146.                "Upgraded version of your daily clubs." # And the description of
  147.                                                        # weapon if upgraded to
  148.                                                        # this level.
  149.              ], # It's started from this bracket and coma... Don't touch this!
  150.              
  151.              # And in short, your upgrade tree will be like these below.
  152.              # This line below is for the weapon level 3.
  153.              [{:atk => 2, :agi => 1, :spi => 4}, -1, "", ""],
  154.              # This line below is for the weapon level 4.
  155.              [{:atk => 10, :agi => 2, :spi => 0}, 15,
  156.                "Flail", "Your everyday clubs won't be as cool as this!"],
  157.              
  158.              # And so on...
  159.            ], # End of Weapon ID #1's upgrade tree. Don't forget to add '],'
  160.            
  161.       # ========================================================================
  162.       # For the joyment of Pilsner Lord, I added some examples of the upgrade
  163.       # paths. Feel free to alter or delete as you want.
  164.       # ========================================================================
  165.            
  166.       2 => [ # The beginning of upgrade tree
  167.              [{:atk => 3 }, -1, "", ""],
  168.              [{:atk => 3 },  2, "Longsword",
  169.                  "As described on the sword's label..."],
  170.              [{:atk => 5 },  2, "Bastard Sword",
  171.                  "Not to mention whoever wield this sword is bastard..."],
  172.              [{:atk => 3, :agi => 5 }, -1, "", ""],
  173.              [{:atk => 10, :agi => 10, :def => 10, :spi => 10 }, 26,
  174.                  "Sword of Dark Flame Master",
  175.                  "Once wielded by a boy who claims himself as the sword says."],
  176.            ], # The ending of upgrade tree
  177.       3 => [ # The beginning of upgrade tree
  178.              [{:atk => 3 }, -1, "", ""],
  179.              [{:atk => 3 }, -1, "", ""],
  180.              [{:atk => 3 }, -1, "", ""],
  181.            ], # The ending of upgrade tree
  182.            
  183.     } # End of Upgrade Table. Don't touch this, in the name of King Stout.
  184.    
  185.   # ============================================================================
  186.   # And here, for the joyment of smithing.
  187.   # These lines are quotes for some of choice that would be made when accessing
  188.   # a blacksmith.
  189.   # Figure it out once if you want to change it.
  190.   # ========================================================================
  191.   module Smith_Quote
  192.     Decide_service = "What can I do for you?"
  193.     Select_weapon = "Whose weapon will be upgraded?"
  194.     Decide_weapon = "Upgrade this weapon?"
  195.     Upgrade_complete = "It's done."
  196.     Refuse_upgrade = "Not enough money to upgrade."
  197.   end
  198.  
  199. # ==============================================================================
  200. # Touching anything below is not good for our Dark Flame Master himself and
  201. # even for our drunken brawler Vent McGraves.
  202. # For whatever reason, don't change everything below unless you know what
  203. # you're doing below there.
  204. # ==============================================================================
  205.  
  206.   module Weapon_Table
  207.    
  208.     def self.set_class_weaponset(ori, adder)
  209.       for data in $data_classes
  210.         if(data != nil && data.weapon_set.include?(ori))
  211.           data.weapon_set.push(adder)
  212.         end
  213.       end
  214.     end
  215.    
  216.     def self.initialize_weapons
  217.       ori_weapon_table = []
  218.       $data_weapons.each do |i|
  219.         if i.nil?
  220.           ori_weapon_table.push(i)
  221.         else
  222.           ori_weapon_table.push(i.clone_data)
  223.         end
  224.       end
  225.      
  226.       temp_table2 = {}
  227.       for item in Upgrade_Table
  228.         next_weapon = nil
  229.         temp_table = []
  230.         for wep_lv in 0..item[1].size - 1
  231.           prop = item[1][wep_lv]
  232.           if(next_weapon == nil)
  233.             next_weapon = ori_weapon_table[item[0]].clone_data
  234.             next_weapon.next_weapon_id = item[1].size
  235.             next_weapon.level = 1
  236.           end
  237.           if prop[0] != {}
  238.             prop[0].each do |stat|
  239.               case stat[0]
  240.                 when :atk, :str
  241.                   next_weapon.atk += stat[1]
  242.                 when :agi
  243.                   next_weapon.agi += stat[1]
  244.                 when :spi, :int
  245.                   next_weapon.spi += stat[1]
  246.                 when :def
  247.                   next_weapon.def += stat[1]
  248.               end
  249.             end
  250.           end
  251.           if prop[1] != -1
  252.             next_weapon.icon_index = prop[1]
  253.           end
  254.           if prop[2] != ""
  255.             next_weapon.name = prop[2]
  256.           end
  257.           if prop[3] != ""
  258.             next_weapon.description = prop[3]
  259.           end
  260.           next_weapon.cost = next_weapon.get_next_cost(next_weapon)
  261.           next_weapon.next_weapon_id -= 1
  262.           next_weapon.level += 1
  263.           temp_table.push(next_weapon.clone_data)
  264.         end
  265.         temp_table2[item[0]] = []
  266.         for i in 0..temp_table.size - 1
  267.           temp_table2[item[0]].push(temp_table[i])
  268.         end
  269.       end
  270.       preprocess = []
  271.       reprocess = []
  272.       ori_weapon_table.each do |i|
  273.         if i != nil
  274.           i.add_levels
  275.         end
  276.         if temp_table2.has_key?(i.id)
  277.           preprocess.push(nil)
  278.           reprocess.push(i)
  279.         else
  280.           preprocess.push(i)
  281.         end
  282.       end
  283.       reprocess.each do |i|
  284.         maxUpgrade = temp_table2[i.id].size
  285.         currentSize = preprocess.size
  286.         oriNextUpgrade = 0
  287.         temp_table2[i.id].each do |z|
  288.           actualCurrentID = preprocess.size
  289.           if(z.next_weapon_id > 0)
  290.             z.next_weapon_id = currentSize + (maxUpgrade - z.next_weapon_id)
  291.           end
  292.           z.id = actualCurrentID
  293.           if(oriNextUpgrade == 0)
  294.             oriNextUpgrade = z.id
  295.           end
  296.           preprocess.push(z.clone_data)
  297.           set_class_weaponset(i.id, z.id)
  298.         end
  299.         i.next_weapon_id = oriNextUpgrade
  300.         preprocess[i.id] = i.clone_data
  301.       end
  302.       reprocess.clear
  303.       reprocess = nil
  304.       $data_weapons = preprocess
  305.       preprocess = nil
  306.       temp_table2 = nil
  307.       temp_table = nil
  308.     end
  309.   end
  310. end
  311.  
  312. module RPG
  313.   class Weapon < BaseItem
  314.     include Smithery::Pricing
  315.    
  316.     attr_accessor :level
  317.     attr_accessor :cost
  318.     attr_accessor :upgrade_balance
  319.     attr_accessor :next_weapon_id
  320.     attr_accessor :socket
  321.    
  322.     def add_levels
  323.       @level = 1
  324.       @cost = Base_Upgrade_Price
  325.       @upgrade_balance = Inflation_Price
  326.       @next_weapon_id = 0
  327.       @socket = []
  328.     end
  329.    
  330.     def get_next_cost(weapon)
  331.       if(weapon.level == nil)
  332.         @level = 2
  333.       end
  334.       @cost = ((Base_Upgrade_Price+Inflation_Price)*@level)
  335.       return @cost
  336.     end
  337.    
  338.     def get_next_weapon
  339.       return $data_weapons[@next_weapon_id]
  340.     end
  341.    
  342.     def upgrade_cost
  343.       return Base_Upgrade_Price if @cost.nil?
  344.       return @cost + ((Base_Upgrade_Price+Inflation_Price)*@level)
  345.     end
  346.    
  347.     def clone_data
  348.       originalData = self
  349.       if(originalData.is_a?(RPG::Weapon))
  350.         clonedData = RPG::Weapon.new
  351.         clonedData.id = originalData.id
  352.         clonedData.name = originalData.name
  353.         clonedData.icon_index = originalData.icon_index
  354.         clonedData.description = originalData.description
  355.         clonedData.note = originalData.note
  356.         clonedData.animation_id = originalData.animation_id
  357.         clonedData.price = originalData.price
  358.         clonedData.hit = originalData.hit
  359.         clonedData.atk = originalData.atk
  360.         clonedData.def = originalData.def
  361.         clonedData.spi = originalData.spi
  362.         clonedData.agi = originalData.agi
  363.         clonedData.two_handed = originalData.two_handed
  364.         clonedData.fast_attack = originalData.fast_attack
  365.         clonedData.dual_attack = originalData.dual_attack
  366.         clonedData.critical_bonus = originalData.critical_bonus
  367.         clonedData.element_set = originalData.element_set.clone
  368.         clonedData.state_set = originalData.state_set.clone
  369.         clonedData.level = originalData.level
  370.         clonedData.cost = originalData.cost
  371.         clonedData.upgrade_balance = originalData.upgrade_balance
  372.         clonedData.next_weapon_id = originalData.next_weapon_id
  373.         clonedData.socket = originalData.socket
  374.         return clonedData
  375.       end
  376.       return nil
  377.     end
  378.   end
  379. end
  380.  
  381. class Scene_Title < Scene_Base
  382.   alias load_database_smithery load_database
  383.   def load_database
  384.     load_database_smithery
  385.     Smithery::Weapon_Table.initialize_weapons
  386.   end
  387. end
  388.  
  389. class Window_SmithList < Window_Selectable
  390.   def initialize(x,y,w,h)
  391.     super(x,y,w,h)
  392.     @column_max = 1
  393.     self.index = 0
  394.     self.back_opacity = 192
  395.     refresh
  396.   end
  397.  
  398.   def item
  399.     return @data[self.index]
  400.   end
  401.  
  402.   def include?(item)
  403.     return false if item == nil
  404.     return true
  405.   end
  406.  
  407.   def enable?(item)
  408.     if(item.next_weapon_id > 0 &&
  409.         $game_party.gold >= item.upgrade_cost)
  410.       return true
  411.     end
  412.     return false
  413.   end
  414.  
  415.   def refresh
  416.     @data = []
  417.     for member in $game_party.members
  418.       @data.push(member)
  419.     end
  420.     @data.push(nil) if include?(nil)
  421.     @item_max = @data.size
  422.     create_contents
  423.     for i in 0...@item_max
  424.       draw_item(i)
  425.     end
  426.   end
  427.  
  428.   def draw_item(index)
  429.     rect = item_rect(index)
  430.     self.contents.clear_rect(rect)
  431.     item = @data[index]
  432.     if item != nil
  433.       enabled = enable?(item.equips[0])
  434.       rect.width -= 4
  435.       self.contents.font.color.alpha = enabled ? 255 : 128
  436.       self.contents.draw_text(rect, item.name)
  437.     end
  438.   end
  439. end
  440.  
  441. class Window_SmithList_Detail < Window_Base
  442.   def initialize(x,y,w,h,member)
  443.     super(x,y,w,h)
  444.     refresh(member)
  445.   end
  446.  
  447.   def refresh(actor)
  448.     create_contents
  449.     weapon = actor.equips[0]
  450.     self.contents.font.color = normal_color
  451.     self.contents.font.size = 22
  452.     dY = 0
  453.     dWidth = self.width - 20
  454.     pad = 40
  455.     draw_item_name(weapon, 0, 0, true)
  456.     dY += 30
  457.     self.contents.font.size = 18
  458.     self.contents.font.bold = false
  459.     self.contents.fill_rect(0, dY, dWidth, 2, normal_color)
  460.     if(weapon.next_weapon_id > 0)
  461.       dY += 4
  462.       self.contents.draw_text(0, dY, dWidth-16, self.contents.font.size,
  463.             "Cost: " + weapon.upgrade_cost.to_s, 0)
  464.       self.contents.font.color = crisis_color
  465.       self.contents.draw_text(0, dY, dWidth-16, self.contents.font.size,
  466.             "Upgradeable", 2)
  467.       self.contents.font.bold = true
  468.       self.contents.draw_text(0, dY + self.contents.font.size + 4, dWidth-16, self.contents.font.size,
  469.           "Lv." + weapon.level.to_s, 2)
  470.       self.contents.font.bold = false
  471.       self.contents.font.color = normal_color
  472.       if weapon.get_next_weapon.atk - weapon.atk > 0 and (weapon.next_weapon_id > 0)
  473.         dY += self.contents.font.size + 4
  474.         self.contents.font.size = 20
  475.         self.contents.font.color = system_color
  476.         self.contents.draw_text(0, dY, pad, self.contents.font.size,
  477.             Vocab.atk)
  478.         self.contents.font.color = normal_color
  479.         self.contents.draw_text(pad, dY, dWidth - pad, self.contents.font.size,
  480.               ": " + weapon.atk.to_s + " > " + weapon.get_next_weapon.atk.to_s)
  481.       end
  482.       if weapon.get_next_weapon.agi - weapon.agi > 0 and (weapon.next_weapon_id > 0)
  483.         dY += self.contents.font.size + 4
  484.         self.contents.font.size = 20
  485.         self.contents.font.color = system_color
  486.         self.contents.draw_text(0, dY, pad, self.contents.font.size,
  487.             Vocab.agi)
  488.         self.contents.font.color = normal_color
  489.         self.contents.draw_text(pad, dY, dWidth - pad, self.contents.font.size,
  490.               ": " + weapon.agi.to_s + " > " + weapon.get_next_weapon.agi.to_s)
  491.       end
  492.       if weapon.get_next_weapon.spi - weapon.spi > 0 and (weapon.next_weapon_id > 0)
  493.         dY += self.contents.font.size + 4
  494.         self.contents.font.size = 20
  495.         self.contents.font.color = system_color
  496.         self.contents.draw_text(0, dY, pad, self.contents.font.size,
  497.             Vocab.spi)
  498.         self.contents.font.color = normal_color
  499.         self.contents.draw_text(pad, dY, dWidth - pad, self.contents.font.size,
  500.               ": " + weapon.spi.to_s + " > " + weapon.get_next_weapon.spi.to_s)
  501.       end
  502.       if weapon.get_next_weapon.def - weapon.def > 0 and (weapon.next_weapon_id > 0)
  503.         dY += self.contents.font.size + 4
  504.         self.contents.font.size = 20
  505.         self.contents.font.color = system_color
  506.         self.contents.draw_text(0, dY, pad, self.contents.font.size,
  507.             Vocab.def)
  508.         self.contents.font.color = normal_color
  509.         self.contents.draw_text(pad, dY, dWidth - pad, self.contents.font.size,
  510.               ": " + weapon.def.to_s + " > " + weapon.get_next_weapon.def.to_s)
  511.       end
  512.     else
  513.       dY += 4
  514.       self.contents.font.color = crisis_color
  515.       self.contents.font.bold = true
  516.       self.contents.draw_text(0, dY, dWidth-16, self.contents.font.size,
  517.           "Lv." + weapon.level.to_s, 2)
  518.       self.contents.font.color = normal_color
  519.       self.contents.font.bold = false
  520.       self.contents.draw_text(0, dY, dWidth-16, self.contents.font.size,
  521.             "Maxed Out", 0)
  522.     end
  523.   end
  524. end
  525.  
  526. class Window_Notification < Window_Base
  527.   def initialize
  528.     super(0, 0, 400, WLH*2 + 32)
  529.     self.back_opacity = 255
  530.   end
  531.   def set_text(text, weapon=nil, align = 0)
  532.     text2 = ""
  533.     if weapon != nil
  534.       weapon2 = weapon.get_next_weapon
  535.       text = "The weapon turned into " + weapon2.name if weapon.name != weapon2.name
  536.       text2 += Vocab.atk + " +" + (weapon2.atk - weapon.atk).to_s + " " if weapon2.atk > weapon.atk
  537.       text2 += Vocab.spi + " +" + (weapon2.spi - weapon.spi).to_s + " " if weapon2.spi > weapon.spi
  538.       text2 += Vocab.agi + " +" + (weapon2.agi - weapon.agi).to_s + " " if weapon2.agi > weapon.agi
  539.       text2 += Vocab.def + " +" + (weapon2.def - weapon.def).to_s + " " if weapon2.def > weapon.def
  540.     end
  541.     if text != @text or align != @align
  542.       self.contents.clear
  543.       self.contents.font.color = normal_color
  544.       self.contents.draw_text(4,   0, self.width - 40, WLH, text, align)
  545.       if text2 != ""
  546.         self.contents.font.color = text_color(4)
  547.         self.contents.draw_text(4, WLH, self.width - 40, WLH, text2, align)
  548.       end
  549.       @text = text
  550.       @align = align
  551.     end
  552.   end
  553. end
  554.  
  555.  
  556. class Scene_Smith < Scene_Base
  557.   #--------------------------------------------------------------------------
  558.   # * Start processing
  559.   #--------------------------------------------------------------------------
  560.   def start
  561.     super
  562.     create_menu_background
  563.     @viewport = Viewport.new(0, 0, 544, 416)
  564.     @gold_window = Window_Gold.new(384, 56)
  565.     @help_window = Window_Help.new
  566.     @help_window.viewport = @viewport
  567.     create_notification_window
  568.     create_party_list_window
  569.     create_detail_window
  570.     create_choice_box
  571.     create_confirmation_box
  572.     @choice_box.active = true
  573.     arrange_windows
  574.     smith_quote_list("Decide service")
  575.   end
  576.  
  577.   def create_notification_window
  578.     @notification_window = Window_Notification.new
  579.     @notification_window.x = Graphics.width/2 - @notification_window.width/2
  580.     @notification_window.y = Graphics.height/2 - @notification_window.height/2
  581.     @notification_window.visible = false
  582.     @notification_window.z = 200
  583.   end
  584.  
  585.   def create_choice_box
  586. #~     s1 = "Sharpen"
  587. #~     s2 = "Fragment Socket"
  588. #~     s3 = "Exit"
  589. #~     @choice_box = Window_Command.new(160, [s1, s2, s3])
  590.     menu = []
  591.     menu.push("Sharpen")
  592.     menu.push("Socket")
  593.     menu.push("Exit")
  594.     @choice_box = Window_Command.new(384, menu, menu.length, 1)
  595.     @choice_box.index = 0
  596.     @choice_box.viewport = @viewport
  597.   end
  598.  
  599.   def create_party_list_window
  600.     @list_window = Window_SmithList.new(0, 56, 128,
  601.       ($game_party.members.size*24)+32)
  602.     @list_window.viewport = @viewport
  603.     @list_window.visible = false
  604.   end
  605.  
  606.   def create_detail_window
  607.     @smith_detail_window = Window_SmithList_Detail.new(0,0,256,180,
  608.       $game_party.members[@list_window.index])
  609.     @smith_detail_window.viewport = @viewport
  610.     @smith_detail_window.visible = false
  611.   end
  612.  
  613.   def create_confirmation_box
  614.     s1 = "Yes"
  615.     s2 = "No"
  616.     @confirmation_box = Window_Command.new(80, [s1, s2])
  617.     @confirmation_box.visible = false
  618.   end
  619.  
  620.   def arrange_windows
  621.     @choice_box.y = @help_window.height
  622.     @list_window.y = @choice_box.y + @choice_box.height
  623.     @smith_detail_window.x = @list_window.width
  624.     @smith_detail_window.y = @gold_window.y + @gold_window.height
  625.     @confirmation_box.x = @smith_detail_window.x + @smith_detail_window.width - @confirmation_box.width
  626.     @confirmation_box.y = @smith_detail_window.y + @smith_detail_window.height - @confirmation_box.height
  627.   end
  628.  
  629.   def terminate
  630.     super
  631.     dispose_menu_background
  632.     @viewport.dispose
  633.     @gold_window.dispose
  634.     @help_window.dispose
  635.     @list_window.dispose
  636.     @smith_detail_window.dispose
  637.     @choice_box.dispose
  638.     @confirmation_box.dispose
  639.   end
  640.  
  641.   def refresh
  642.     @choice_box.refresh
  643.     @list_window.refresh
  644.     if(@current_item != nil)
  645.       @smith_detail_window.refresh(@current_item)
  646.     end
  647.   end
  648.  
  649.   def return_scene
  650.     $scene = Scene_Map.new
  651.   end
  652.  
  653.   def update
  654.     super
  655.     update_menu_background
  656.     @gold_window.update
  657.     @help_window.update
  658.     if @choice_box.active
  659.       update_choice_box
  660.     elsif @list_window.active
  661.       update_smithing_window
  662.     elsif @confirmation_box.active
  663.       @confirmation_box.update
  664.       update_confirmation_box
  665.     end
  666.   end
  667.  
  668.   def update_choice_box
  669.     @choice_box.update
  670.     if Input.trigger?(Input::C)
  671.       case @choice_box.index
  672.       when 0
  673.         Sound.play_decision
  674.         smith_quote_list("Choose weapon")
  675.         select_party
  676.       when 1
  677.         Sound.play_buzzer
  678.         @notification_window.visible = true
  679.         @notification_window.set_text("Socketing isn't available for now.")
  680.         smith_quote_list("Socketing weapon")
  681.         for i in 0...150
  682.           Graphics.update
  683.         end
  684.         @notification_window.visible = false
  685.         smith_quote_list("Decide service")
  686.       when 2
  687.         Sound.play_cancel
  688.         return_scene
  689.       end
  690.     elsif Input.trigger?(Input::B)
  691.       Sound.play_cancel
  692.       return_scene
  693.     end
  694.   end
  695.  
  696.   def update_confirmation_box
  697.     if Input.trigger?(Input::C)
  698.       case @confirmation_box.index
  699.       when 0
  700.         Sound.play_decision
  701.         itema = @list_window.item
  702.         weapon = itema.equips[0]
  703.         wait_for_smithing(weapon)
  704.         $game_party.lose_gold(weapon.upgrade_cost)
  705.         $game_party.gain_item(weapon.get_next_weapon.clone_data, 1)
  706.         $game_party.members[@list_window.index].change_equip(0, weapon.get_next_weapon.clone_data)
  707.         $game_party.lose_item(weapon, 1)
  708.         @gold_window.refresh
  709.         confirm
  710.       when 1
  711.         Sound.play_cancel
  712.         confirm
  713.         smith_quote_list("Choose weapon")
  714.       end
  715.     elsif Input.trigger?(Input::B)
  716.       Sound.play_cancel
  717.       confirm
  718.       smith_quote_list("Choose weapon")
  719.     end
  720.   end
  721.  
  722.   def update_smithing_window
  723.     @list_window.update
  724.     @smith_detail_window.update
  725.     item = @list_window.item
  726.     weapon = item.equips[0]
  727.     if(@current_item != item)
  728.       @current_item = item
  729.       @smith_detail_window.refresh(@current_item)
  730.     end
  731.     if Input.trigger?(Input::B)
  732.       Sound.play_cancel
  733.       hide_party
  734.       smith_quote_list("Decide service")
  735.     elsif Input.trigger?(Input::C)
  736.       if(weapon != nil &&
  737.           weapon.next_weapon_id > 0 && weapon.get_next_weapon != nil &&
  738.           $game_party.gold >= weapon.upgrade_cost)
  739.         Sound.play_decision
  740.         smith_quote_list("Decide weapon")
  741.         confirmation
  742.       end
  743.     end
  744.   end
  745.  
  746.   def wait_for_smithing(weapon)
  747.     for i in 0...300
  748.       Graphics.update
  749.       Smithery::SMITH_SE.play if i%60 == 0 and i < 150
  750.       if i == 180
  751.         Smithery::SMITH_DONE_SE.play
  752.         @notification_window.visible = true
  753.         @notification_window.set_text("Weapon improved.", weapon)
  754.         smith_quote_list("Upgrade complete")
  755.       end
  756.     end
  757.     @notification_window.visible = false
  758.     smith_quote_list("Choose weapon")
  759.   end
  760.  
  761.   def confirmation
  762.     @confirmation_box.active = true
  763.     @confirmation_box.visible = true
  764.     @list_window.active = false
  765.   end
  766.  
  767.   def confirm
  768.     @confirmation_box.active = false
  769.     @confirmation_box.visible = false
  770.     @list_window.active = true
  771.     refresh
  772.   end
  773.  
  774.   def select_party
  775.     refresh
  776.     @choice_box.active = false
  777.     @list_window.active = true
  778.     @list_window.visible = true
  779.     @smith_detail_window.active = true
  780.     @smith_detail_window.visible = true
  781.   end
  782.  
  783.   def hide_party
  784.     @choice_box.active = true
  785.     @list_window.active = false
  786.     @list_window.visible = false
  787.     @smith_detail_window.active = false
  788.     @smith_detail_window.visible = false
  789.     refresh
  790.   end
  791.  
  792.   def smith_quote_list(response = "")
  793.     case response
  794.     when "Decide service"
  795.       @help_window.set_text(Smithery::Smith_Quote::Decide_service)
  796.     when "Choose weapon"
  797.       @help_window.set_text(Smithery::Smith_Quote::Select_weapon)
  798.     when "Decide weapon"
  799.       @help_window.set_text(Smithery::Smith_Quote::Decide_weapon)
  800.     when "Upgrade complete"
  801.       @help_window.set_text(Smithery::Smith_Quote::Upgrade_complete)
  802.     when "Not enough money"
  803.       @help_window.set_text(Smithery::Smith_Quote::Refuse_upgrade)
  804.     when "Socketing weapon"
  805.       @help_window.set_text("Maybe not now, mate.")
  806.     end
  807.   end
  808. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top