Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Randomization Addon by Venka & Sixth (v.1.1d) ----------------
- # - Go nuts with random crafted items! | Updated:
- # REQUIRES Venka's Multiple Crafting Script! | 13/09/2014
- # REQUIRES Vlue's Weapon/Armor Randomization! ----------------
- #==============================================================================
- #------------------------------------------------------------------------------
- # Change Log:
- #------------------------------------------------------------------------------
- # 13/09/2014 - Removed something that is not needed anymore.
- # Updated the instructions part, as it turns out, placement is
- # important for the Crafting Shop Recipes addon.
- # 19/08/2014 - Updated the addon to account for the changes in the main script.
- # - The issue with the Actor Stat Changes Add On is fixed as well.
- # 15/08/2014 - Added $imported tag. Mostly for debugging purposes.
- # 13/08/2014 - Added some script calls to check the number of the total
- # recipes learned by craft types. Might help with some eventing.
- # 10/08/2014 - Restructured the code of the box version of the result window.
- # 09/08/2014 - Added color settings for the borders of the boxes.
- # Added stack size limit options.
- # Added shorter script calls to toggle randomization on and off.
- # Added non-boxed version of the result window.
- # 08/08/2014 - Initial release.
- #------------------------------------------------------------------------------
- # Introduction:
- #------------------------------------------------------------------------------
- # This script will allow you to craft equips and items with a chance of
- # random attributes on them.
- # This addon makes use of Vlue's Weapon/Armor Randomization to make the
- # boosted item. The result window will scale to it's contents and show off
- # the rarity colors and affixes of the items.
- # The addon also changes the way the result popup window appears to suit
- # the possibility of crafting random items in stacks and show their names.
- # A new option is also available for limiting the maximum size of crafting
- # stacks or the maximum amount of items crafted at once.
- #------------------------------------------------------------------------------
- # Important Notes:
- #------------------------------------------------------------------------------
- # Randomized items cannot be used as components in crafting recipes.
- # You can set if you want weapons, armors or items to be randomized. I'd
- # suggest setting Random_Items to false if you plan on crafted items to be
- # components for other recipes, but the choice is yours.
- #
- # Item randomization is different than equip randomization!
- # Items can NOT gain any bonus effects with randomization, but they can be
- # colored and they can get random affix names as well.
- #
- # At the moment, failed/prefailed items will not get randomized but it is easy
- # to make them random too. I don't need this function for now, but if anyone is
- # interested in it, I could post the solution to this little "problem" too.
- # Or I could even implement this as an optional function too. But later. :P
- #
- # The result popup window is NOT scroll-able! Keep this in mind if you allow
- # crafting in stacks with random items!
- # Limiting the maximum number of items crafted is possible, so use that to
- # prevent the information from being cut vertically.
- # You can also use that to prevent players from crafting excessive amount of
- # items while being 'afk'.
- #------------------------------------------------------------------------------
- # Instructions:
- #------------------------------------------------------------------------------
- # Place this add on below Venka's Crafting Script and below Vlue's Weapon/Armor
- # Randomization but above Main.
- #
- # If you are using the 'Actor Stat Changes Add on' for the Crafting Script,
- # place this addon below that one!
- #
- # If you are using the 'Shop Recipes Add on' for the Crafting Script,
- # place that addon below Vlue's Randomization script!
- #
- # Set up both of the above mentioned scripts to your preference.
- # To set up Venka's Crafting Script, refer to the instructions in that script!
- # To set up Vlue's Randomization Script, refer to the instruction in that script!
- # This addon is plug-and-play. Configure the settings below if needed.
- #------------------------------------------------------------------------------
- # Script Calls:
- #------------------------------------------------------------------------------
- # To switch off the randomization during the game, use the following script calls:
- #
- # $craft.rand_weapons = true/false
- # $craft.rand_armor = true/false
- # $craft.rand_items = true/false
- #
- # NOTE: When you change the randomization in the game, it will stay the way
- # you set it until you change it again! Keep that in mind while eventing!
- #
- # To check for the number of the total recipes (learned), use these script calls
- # in conditional branches:
- #
- # $craft.known_recipes_check(ID) # This will check the number of already
- # learned recipes!
- # $craft.total_recipes_check(ID) # This will check the number of all of the
- # recipes from the database of that type!
- #
- # Replace 'ID' with your craft ID number.
- #
- # Some examples for the default sample craft types:
- # $craft.known_recipes_check(1) >= 4 # This will return true if the player has
- # learned 4 or more recipes from the
- # craft type of Cooking.
- # $craft.total_recipes_check(3) # This will get the amount of all of the
- # recipes from the craft type of Alchemy.
- # The only purpose of ever using this
- # call is for displaying it in a message
- # or window, I guess.
- # Replacing the 'ID' with 0 will get you the amount of recipes from all craft
- # types at once.
- #------------------------------------------------------------------------------
- # Extra Tips:
- #------------------------------------------------------------------------------
- # For weapons and armors, using this randomized method, you can make a pretty
- # nice crafting system, which rewards timing (aka good crafting).
- # Make the timer window for success something very small.
- # Now make the success reward and the failed/prefailed item rewards the very
- # same item. What will this do? If you press the button in time, you will get
- # a randomized (usually better, right?) item with cool affixes, and if you
- # miss the timing, you will get a normal item without any bonus stats.
- # Because regular items can not gain any bonus effects from randomization,
- # the good timing reward could be more items crafted at once, for example.
- # This is just a suggestion by me.
- #------------------------------------------------------------------------------
- # Updates In Plan:
- #------------------------------------------------------------------------------
- # None at the moment.
- #------------------------------------------------------------------------------
- # Terms of use:
- #------------------------------------------------------------------------------
- # Do whatever you want with this addon.
- # If you, by any chance, credit me for this, you must also credit Venka and Vlue!
- #------------------------------------------------------------------------------
- # Extra Credits and Thanks:
- #------------------------------------------------------------------------------
- # Venka - For making the awesome Crafting Script - obviously! :P
- # For giving me tips to make this snippet standalone.
- # For giving me info about the font types used to display the arrow symbols.
- # For enhancing this add-on to a whole new level! Even more!
- # For always being helpful!
- # Vlue - For making his Equip Randomizer script - Yay!
- # For giving the basic compatibility patch for this add-on!
- # For making other scripts from which I learned a lot about scaling
- # windows depending on the contents in them.
- # For always being helpful!
- # Bloodmorphed - For making me add the colored items function to the popup window.
- # Without him asking, I wouldn't even bothered with it! :P
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["RandomizationAddon"] = true
- ###############################################################################
- #
- # The "Big" Setup part - edit until you drop!
- #
- ###############################################################################
- module Venka
- module Crafting
- #----------------------------------------------------------------------------
- # Randomization Settings
- #----------------------------------------------------------------------------
- # You can set which items would you like to be randomized in the crafting
- # scenes here. "True" turns randomization ON, while "false" will turn it OFF.
- # You can change these settings on the go in the game too with the provided
- # script calls at the "Script Calls" section.
- #----------------------------------------------------------------------------
- Random_Weapons = true # Craft weapons with random attributes
- Random_Armor = true # Craft armor with random attributes
- Random_Items = false # Craft items with random names and color
- #----------------------------------------------------------------------------
- # Craft Stack Limit Settings
- #----------------------------------------------------------------------------
- # You can set the maximum amount of items crafted at once with the settings
- # below. These settings will not affect anything if the 'Craft_Stacks' settings
- # is set to 'false' in the main customization script of Venka's Crafting Script.
- #----------------------------------------------------------------------------
- Max_Crafting = 10 # Max number of items you can craft in one sitting
- # This won't stop going over the specified number if
- # the recipe got more than 1 crafted_item in the settings.
- # Ex: A recipe giving out 2 potions on success can be
- # crafted 10 times in a stack with the 'Max_Crafting'
- # setting set to 10 but the amount of items crafted
- # in the end will be 20.
- # Setting this to 'nil' will disable this option.
- Max_Total = true # This setting will limit the stack craft entirely.
- # Setting this to 'false' will produce the same effect
- # as in the above example with the potion recipe.
- # Setting it to 'true' will make the max number of
- # items crafted in one sitting no more than the
- # 'Max_Crafting' number, regardless of how many items
- # the recipe gives on success in the recipe settings.
- # Ex: A recipe giving out 2 potions on success can be
- # crafted 5 times in a stack if the 'Max_Crafting'
- # setting is set to 10 and if 'Max_Total' is set to
- # 'true', so in the end the amount of crafted items
- # will be 10 at max.
- # This setting won't affect anything if 'Max_Crafting'
- # is set to 'nil'.
- #----------------------------------------------------------------------------
- # Result Window Appearance Settings
- #----------------------------------------------------------------------------
- # This setting will enable or disable the box version of the result window.
- # Setting it to false will make the result window to the non-boxed version.
- # The boxed version demands more height, while the non-boxed version
- # demands more width to display the information on the screen.
- #----------------------------------------------------------------------------
- Box_Version = true
- #----------------------------------------------------------------------------
- # Arrow Settings (used only for the non-boxed version of the result window)
- #----------------------------------------------------------------------------
- # These settings adjust the position and font type of the arrow symbols used
- # in the result popup window.
- # Not many font types can display the arrow symbol, but "Arial" can surely do.
- # Color can be a window skin color number or an array - [Red, Blue, Green, Alpha].
- #----------------------------------------------------------------------------
- # [[ Font Types Array ], Size, Bold, Color]
- Fonts[:arrows] = [["Monotype Corsiva", "Arial"], 24, true, 13]
- Arrow_x_Item = 0 # The horizontal offset for the arrow displayed
- # after the 'Result_Msg' text
- Arrow_x_Exp = 0 # The horizontal offset for the arrow displayed
- # after the 'Exp_Earned' text
- Arrow_x_Rec = 0 # The horizontal offset for the arrow displayed
- # after the 'Learn_Text' text
- #----------------------------------------------------------------------------
- # Box Settings (used only for the boxed version of the result window)
- #----------------------------------------------------------------------------
- # These settings adjust the colors of the boxes and borders in the result window.
- # Setting the alpha to 0 will make them fully transparent/invisible.
- #----------------------------------------------------------------------------
- #----------------------------------------------------------------------------
- # Box Color Settings
- #----------------------------------------------------------------------------
- # [ R, G, B, A ] # [Red, Green, Blue, Alpha]
- Results_Box = [ 22, 88, 88, 150] # The color of the "Result_Msg" Box
- Failed_Box = [200, 10, 10, 150] # The color of the "Failed_Msg" Box
- Crafted_Items_Box = [ 88, 88, 44, 150] # The color of the "Crafted Items" Box
- Exp_Text_Box = [ 22, 22, 88, 150] # The color of the "Exp_Earned" Box
- Level_Up_Box = [ 22, 88, 44, 150] # The color of the "Lv_Gain" Box
- Recipe_Text_Box = [ 22, 88, 88, 150] # The color of the "Learn_Text" Box
- Learned_Recipes_Box = [ 22, 88, 22, 150] # The color of the "Learned Recipes" Box
- #----------------------------------------------------------------------------
- # Box Border Color Settings
- #----------------------------------------------------------------------------
- # [ R, G, B, A ] # [Red, Green, Blue, Alpha]
- Item_Border_Out = [200,200, 0, 255] # Outside border color of the "Item" Box.
- Item_Border_In = [ 22, 22,222, 255] # Inside border color of the "Item" Box.
- Exp_Border_Out = [ 0,200, 0, 255] # Outside border color of the "Exp" Box.
- Exp_Border_In = [ 22, 22, 22, 255] # Inside border color of the "Exp" Box.
- Recipe_Border_Out = [200, 20, 20, 255] # Outside border color of the "Recipe" Box.
- Recipe_Border_In = [ 22, 22, 22, 255] # Inside border color of the "Recipe" Box.
- end
- end
- ###############################################################################
- #
- # End of the "Big" Setup part - editing below may lead to flying dragons!
- #
- ###############################################################################
- begin
- if AFFIXES
- #==========================================================================
- # ■ Game_Crafting
- #==========================================================================
- class Game_Crafting
- #------------------------------------------------------------------------
- # ♦ Public Instance Variables
- #------------------------------------------------------------------------
- attr_accessor :rand_weapons, :rand_armor, :rand_items
- attr_reader :known_recipes_check, :total_recipes_check
- #------------------------------------------------------------------------
- # ● alias method: initialize
- #------------------------------------------------------------------------
- alias sixth_stored_variables_ini initialize
- def initialize
- sixth_stored_variables_ini
- @rand_weapons = Venka::Crafting::Random_Weapons
- @rand_armor = Venka::Crafting::Random_Armor
- @rand_items = Venka::Crafting::Random_Items
- end
- #------------------------------------------------------------------------
- # ● new method: known_recipe_check
- #------------------------------------------------------------------------
- def known_recipes_check(type)
- return if type == nil
- total = []
- Venka::Crafting::Craft_Info.each_key do |craft_id|
- print "Craft ID: "; p craft_id
- total[craft_id] = 0
- $craft.known_recipes.each do |recipe_id|
- print "recipe ID: "; p recipe_id
- next unless ($recipe[recipe_id].recipe_type == craft_id && $recipe[recipe_id].recipe_type == type) || ($recipe[recipe_id].recipe_type == craft_id && type == 0)
- p "Adding to the total"
- total[craft_id] += 1
- end
- end
- print "Final totals: "; p total
- grand_total = total.compact.inject{|sum, x| sum + x }
- print "Grand Total: "; p grand_total
- end
- #------------------------------------------------------------------------
- # ● new method: total_recipe_check
- #------------------------------------------------------------------------
- def total_recipes_check(type)
- return if type == nil
- total = []
- Venka::Crafting::Craft_Info.each_key do |craft_id|
- print "Craft ID: "; p craft_id
- total[craft_id] = 0
- Venka::Crafting::Recipes.each_key do |recipe_id|
- print "recipe ID: "; p recipe_id
- next unless ($recipe[recipe_id].recipe_type == craft_id && $recipe[recipe_id].recipe_type == type) || ($recipe[recipe_id].recipe_type == craft_id && type == 0)
- p "Adding to the total"
- total[craft_id] += 1
- end
- end
- print "Final totals: "; p total
- grand_total = total.compact.inject{|sum, x| sum + x }
- print "Grand Total: "; p grand_total
- end
- end
- #==========================================================================
- # ■ Crafting_Details_Window
- #==========================================================================
- class Crafting_Details_Window
- #------------------------------------------------------------------------
- # ○ new method: draw_ingredients
- #------------------------------------------------------------------------
- alias sixth_max_items_crafted draw_ingredients
- def draw_ingredients
- sixth_max_items_crafted
- @max = [@max, Venka::Crafting::Max_Crafting].min if Venka::Crafting::Max_Crafting != nil
- @max = @max / @recipe.crafted_amount if Venka::Crafting::Max_Total && Venka::Crafting::Max_Crafting != nil
- end
- #------------------------------------------------------------------------
- # ○ new method: get_random_item
- #------------------------------------------------------------------------
- def get_random_item
- item = []
- @result_amount.times do |i|
- if @recipe.crafted_item.is_a?(RPG::Weapon) && $craft.rand_weapons
- item[i] = $game_party.add_weapon(@recipe.crafted_item.id, 1)
- elsif @recipe.crafted_item.is_a?(RPG::Armor) && $craft.rand_armor
- item[i] = $game_party.add_armor(@recipe.crafted_item.id, 1)
- elsif @recipe.crafted_item.is_a?(RPG::Item) && $craft.rand_items
- item[i] = $game_party.add_item(@recipe.crafted_item.id, 1)
- end
- end
- $game_party.gain_item(@recipe.crafted_item, @result_amount) if item == []
- item = (item == []) ? @recipe.crafted_item : item
- return item
- end
- #------------------------------------------------------------------------
- # ● overwrite method: success_rewards
- #------------------------------------------------------------------------
- def success_rewards
- RPG::SE.new(*Success_Sound).play
- unless SceneManager.scene_is?(Scene_Shop)
- @result_exp = @recipe.earned_exp * @number
- @result_message = Result_Msg
- $craft[@craft_id].gain_exp(@result_exp) if SceneManager.scene_is?(Scene_Crafting)
- end
- @result_amount = @recipe.crafted_amount * @number
- @result_item = get_random_item
- end
- end
- end
- if Venka::Crafting::Box_Version
- #==============================================================================
- # ■ Crafting_Results_Window
- #==============================================================================
- class Crafting_Results_Window < Window_Base
- #----------------------------------------------------------------------------
- # ○ new method: font_height
- #----------------------------------------------------------------------------
- def font_height
- [contents.font.size, 24].max
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: refresh
- #----------------------------------------------------------------------------
- def refresh
- contents.clear
- return if $craft.results == []
- result_info
- resize_window
- draw_box_item
- draw_header
- draw_items_received
- draw_box_exp if @exp > 0
- draw_exp_received if @exp > 0
- draw_level_up if @leveled
- draw_box_recipe if @learned
- draw_new_recipes if @learned
- wait_to_close
- #$craft.clear_results
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: win_width
- #----------------------------------------------------------------------------
- def win_width
- set_font(:other_text)
- # Checking the first box width with every possible conditions
- case @message
- when Venka::Crafting::Result_Msg
- items = @item.is_a?(Array) ? @item.size : 1
- widthi = 0
- if @item.is_a?(Array)
- @item.each do |item|
- size = text_size(item.name).width
- widthi = size if size > widthi
- text = item.name
- end
- else
- widthi = text_size(@item.name).width
- end
- if widthi < text_size(Venka::Crafting::Result_Msg).width
- widthi = text_size(Venka::Crafting::Result_Msg).width
- end
- @width111 = widthi + text_size(" x#{@amount}").width + 14
- when Venka::Crafting::Failed_Msg
- @width111 = text_size(Venka::Crafting::Failed_Msg).width + 7
- end
- # Checking the second box with every possible conditions
- if $craft[@craft_id].max_level?
- text = Venka::Crafting::Max_Exp
- else
- text = Venka::Crafting::Exp_Earned + " #{@exp} Exp!"
- end
- width_xp = text_size(text).width
- set_font(:button_text)
- text2 = Venka::Crafting::Lv_Gain
- width_lvl = text_size(text2).width
- set_font(:other_text)
- if @leveled
- @width112 = [width_xp, width_lvl].max - 6
- else
- @width112 = text_size(text).width - 6
- end
- @width112 = 0 if @exp == 0
- # Checking the third box with every possible conditions
- if @learned && @learned != []
- if @learned
- widthr = 0
- @learned.each do |recipe_id|
- recipe = $recipe[recipe_id]
- size = text_size(recipe.display_name).width
- widthr = size if size > widthr
- end
- if widthr < text_size(Venka::Crafting::Learn_Text).width
- widthr = text_size(Venka::Crafting::Learn_Text).width
- end
- @width113 = widthr + 32
- width113 = @width113 - 18
- end
- else
- @width113 = 0
- width113 = 0
- end
- # Calculating the final width of the window
- return ([[[@width111, @width112].max, width113].max + 120, Graphics.width].min)
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: win_height
- #----------------------------------------------------------------------------
- def win_height
- h1 = Venka::Crafting::Fonts[:recipe_name][1] + standard_padding * 2
- h2 = [Venka::Crafting::Fonts[:other_text][1], 24].max
- set_font(:other_text)
- height = h1 + h2
- # Adding to height depending on the fisrt box height
- if @message == Venka::Crafting::Result_Msg
- items = @item.is_a?(Array) ? @item.size : 1
- height += h2 * items
- elsif @message == Venka::Crafting::Failed_Msg
- height += -7
- end
- # Adding height if leveled
- if @leveled
- height += h2 + 7
- end
- # Adding height depending on the third box height
- if @learned && @learned != []
- height2 = 0
- if @learned
- @learned.each do |recipe_id|
- recipe = $recipe[recipe_id]
- end
- height2 = h2 * @learned.size
- end
- height += height2 + h2 + 17
- end
- height -= 34 if @exp == 0
- # Adding constant height needed
- return height += 53
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_box_frames
- #----------------------------------------------------------------------------
- def draw_box_frames(x, y, width, height, color1, color2, header = 0)
- # top line - horizontal
- contents.fill_rect(x - 15, y, width + 30, 1, color1)
- contents.fill_rect(x - 14, y + 1, width + 28, 2, color2)
- # adjust height if header box is used
- height += header + ((header > 0) ? 8 : 3)
- if header > 0
- # middle line - horizontal
- contents.fill_rect(x - 14, y + header + 3, width + 28, 2, color2)
- contents.fill_rect(x - 15, y + header + 5, width + 30, 1, color1)
- contents.fill_rect(x - 14, y + header + 6, width + 28, 2, color2)
- end
- # bottom line - horizontal
- contents.fill_rect(x - 15, y + height + 2, width + 30, 1, color1)
- contents.fill_rect(x - 14, y + height, width + 28, 2, color2)
- # left line - vertical
- contents.fill_rect(x - 15, y, 1, height + 2, color1)
- contents.fill_rect(x - 14, y + 1, 2, height, color2)
- # right line - vertical
- contents.fill_rect(x + width + 14, y, 1, height + 2, color1)
- contents.fill_rect(x + width + 12, y + 1, 2, height, color2)
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_box_item
- #----------------------------------------------------------------------------
- def draw_box_item
- header_height = [[Venka::Crafting::Fonts[:recipe_name][1], 26].max, 26].min
- set_font(:other_text)
- color1 = Color.new(*Venka::Crafting::Item_Border_Out)
- color2 = Color.new(*Venka::Crafting::Item_Border_In)
- color_result = Color.new(*Venka::Crafting::Results_Box)
- color_failed = Color.new(*Venka::Crafting::Failed_Box)
- color_items = Color.new(*Venka::Crafting::Crafted_Items_Box)
- @width111 += 18
- x = (contents_width - @width111) / 2
- case @message
- when Venka::Crafting::Result_Msg
- items = @item.is_a?(Array) ? @item.size : 1
- box_height = (font_height * items) + 2
- # filler message
- contents.fill_rect(x - 12, 30, @width111 + 24, header_height, color_result)
- # filler item
- contents.fill_rect(x - 12, 61, @width111 + 24, box_height, color_items)
- draw_box_frames(x, 27, @width111, box_height, color1, color2, header_height)
- when Venka::Crafting::Failed_Msg
- # filler message
- contents.fill_rect(x - 12, 30, @width111 + 24, header_height, color_failed)
- draw_box_frames(x, 27, @width111, header_height, color1, color2)
- end
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_header
- #----------------------------------------------------------------------------
- def draw_header
- set_font(:recipe_name)
- height = contents.font.size
- draw_text(0, 0, contents.width, height, Venka::Crafting::Results_Text, 1)
- @y = height
- color = normal_color
- contents.fill_rect(0, height - 2, contents_width, 1, color)
- color.alpha = 90
- contents.fill_rect(0, height - 1, contents_width, 1, color)
- set_font(:other_text)
- case @message
- when Venka::Crafting::Result_Msg
- draw_text(0, @y + 6, contents.width, font_height, @message, 1)
- @y += 32
- when Venka::Crafting::Failed_Msg
- @y += 1
- end
- @y += 5
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_items_received
- #----------------------------------------------------------------------------
- def draw_items_received
- set_font(:other_text)
- case @message
- when Venka::Crafting::Result_Msg
- @item.is_a?(Array) ? @item.each {|item| draw_item(item)} : draw_item(@item, @amount)
- when Venka::Crafting::Failed_Msg
- draw_text(0, @y, contents.width, font_height, @message, 1)
- @y += font_height
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_item
- #----------------------------------------------------------------------------
- def draw_item(item, amount = 1)
- set_font(:other_text)
- text = item.name + " x#{amount}"
- item_width = text_size(text).width + 30
- x1 = (contents.width - text_size(item.name).width) / 2 - 27
- if $imported[:MAIcon_Hue]
- draw_icon_with_hue(item.icon_index, item.icon_hue, x1, @y)
- else
- draw_icon(item.icon_index, x1, @y)
- end
- change_color(item.color)
- draw_text(-5, @y, contents.width + 10, font_height, item.name, 1)
- set_font(:other_text)
- x2 = contents.width - ((contents.width - text_size(item.name).width) / 2 ) + 1
- draw_text(x2, @y, contents.width + 10, font_height, " x#{amount}")
- @y += font_height
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_box_exp
- #----------------------------------------------------------------------------
- def draw_box_exp
- set_font(:other_text)
- color1 = Color.new(*Venka::Crafting::Exp_Border_Out)
- color2 = Color.new(*Venka::Crafting::Exp_Border_In)
- color_exp = Color.new(*Venka::Crafting::Exp_Text_Box)
- color_level = Color.new(*Venka::Crafting::Level_Up_Box)
- @width112 += 12
- x = (contents_width - @width112) / 2
- h2 = [[font_height, 26].max, 26].min
- # filler exp message
- contents.fill_rect(x - 12, @y + 9, @width112 + 24, h2, color_exp)
- if @leveled && Venka::Crafting::Level_Up_Box
- h = [[Venka::Crafting::Fonts[:button_text][1], 26].max, 26].min
- # filler lvl message
- contents.fill_rect(x - 12, @y + h + 14, @width112 + 24, h, color_level)
- draw_box_frames(x, @y + 6, @width112, h2, color1, color2, h)
- else
- draw_box_frames(x, @y + 6, @width112, h2, color1, color2)
- end
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_exp_received
- #----------------------------------------------------------------------------
- def draw_exp_received
- set_font(:other_text)
- @y += 10
- if $craft[@craft_id].max_level?
- text = Venka::Crafting::Max_Exp
- else
- text = Venka::Crafting::Exp_Earned + " #{@exp} Exp!"
- end
- draw_text(- 5, @y, contents.width + 10, font_height, text, 1)
- @y += font_height
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_level_up
- #----------------------------------------------------------------------------
- def draw_level_up
- set_font(:button_text)
- height = contents.font.size
- draw_text(0, @y + 6, contents.width, height, Venka::Crafting::Lv_Gain, 1)
- @y += height
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_box_recipe
- #----------------------------------------------------------------------------
- def draw_box_recipe
- set_font(:other_text)
- color1 = Color.new(*Venka::Crafting::Recipe_Border_Out)
- color2 = Color.new(*Venka::Crafting::Recipe_Border_In)
- color_recipe = Color.new(*Venka::Crafting::Learned_Recipes_Box)
- color_text = Color.new(*Venka::Crafting::Recipe_Text_Box)
- @width113 += 18
- x = (contents_width - @width113) / 2
- return unless @learned && @learned != []
- h = (@learned.size * font_height) + 2
- h2 = [[font_height, 26].max, 26].min
- # filler recipe message
- contents.fill_rect(x - 3, @y + 16, @width113 + 6, h2, color_text)
- # filler recipes
- contents.fill_rect(x - 3, @y + h2 + 21, @width113 + 6, h, color_recipe)
- draw_box_frames(x + 9, @y + 13, @width113 - 18, h, color1, color2, h2)
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_new_recipes
- #----------------------------------------------------------------------------
- def draw_new_recipes
- @y += 48
- set_font(:other_text)
- prefix = Venka::Crafting::Learn_Text
- draw_text(-5, @y - 31, contents.width + 10, font_height, prefix, 1) if @learned && @learned != []
- @learned.each do |recipe_id|
- recipe = $recipe[recipe_id]
- name_width = text_size(recipe.display_name).width + 5
- x = (contents.width - name_width - 25) / 2
- if $imported[:MAIcon_Hue]
- draw_icon_with_hue(recipe.crafted_item.icon_index, @item.icon_hue, x, @y)
- else
- draw_icon(recipe.crafted_item.icon_index, x, @y)
- end
- draw_text(x + 25, @y, contents.width + 10, font_height, recipe.display_name)
- @y += font_height
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_arrow (!!not used for now!!)
- #----------------------------------------------------------------------------
- def draw_arrow(x, y, width, height)
- set_font(:arrows)
- draw_text(0, y, contents.width, height, "→", 1)
- set_font(:other_text)
- end
- end
- else
- #==============================================================================
- # ■ Crafting_Results_Window
- #==============================================================================
- class Crafting_Results_Window < Window_Base
- #----------------------------------------------------------------------------
- # ○ new method: font_height
- #----------------------------------------------------------------------------
- def font_height
- [contents.font.size, 24].max
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: win_width
- # ----------------------------------------------------------------------------
- def win_width
- set_font(:other_text)
- # Items crafted width
- width = 0
- if @message == Venka::Crafting::Result_Msg
- if @item.is_a?(Array)
- @item.each do |item|
- size = text_size(item.name).width
- width = size if size > width
- end
- text = @message + "x#{@amount}"
- else
- text = @message + "x#{@amount}" + @item.name
- end
- width1 = text_size(text).width + 50 + standard_padding * 2 + 10
- width1 += width if @item.is_a?(Array)
- else
- width1 = text_size(@message).width + 10 + standard_padding * 2
- end
- # Recipes learned width
- width2 = 50 + standard_padding * 2
- if @learned
- @learned.each do |recipe_id|
- recipe = $recipe[recipe_id]
- size = text_size(recipe.display_name).width
- width = size if size > width
- end
- width2 += text_size(Venka::Crafting::Learn_Text).width + width
- end
- # Exp message & level up width
- if $craft[@craft_id].max_level?
- text = Venka::Crafting::Max_Exp
- else
- text = Venka::Crafting::Exp_Earned + " #{@exp} Exp!"
- end
- width_xp = text_size(text).width
- set_font(:button_text)
- text2 = Venka::Crafting::Lv_Gain
- width_lvl = text_size(text2).width
- set_font(:other_text)
- if @leveled
- width3 = [width_xp, width_lvl].max + 50
- else
- width3 = text_size(text).width + 50
- end
- width3 = 0 if @exp == 0
- return ([[[width1, width2].max, width3].max + 30, Graphics.width].min)
- end
- #----------------------------------------------------------------------------
- # ○ new method: win_height
- #----------------------------------------------------------------------------
- def win_height
- h1 = Venka::Crafting::Fonts[:recipe_name][1] + standard_padding * 2
- h2 = [Venka::Crafting::Fonts[:other_text][1], 24].max
- height = h1 + h2 + (h2 * (@learned ? @learned.size : 0)) + 3
- height += [Venka::Crafting::Fonts[:button_text][1], 24].max + 4 if @leveled
- items = @item.is_a?(Array) ? @item.size : 1
- height += h2 * items
- height -= h2 if @exp == 0
- return height
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_items_received
- #----------------------------------------------------------------------------
- def draw_items_received
- set_font(:other_text)
- case @message
- when Venka::Crafting::Result_Msg
- items = @item.is_a?(Array) ? @item.size : 1
- h1 = font_height * items
- x = text_size(@message).width + text_size("→").width + 20
- color = normal_color
- contents.fill_rect(x, @y + 1, 1, h1, color)
- color.alpha = 90
- contents.fill_rect(x + 1, @y + 1, 1, h1, color)
- @item.is_a?(Array) ? @item.each {|item| draw_item(item)} : draw_item(@item, @amount)
- draw_text(0, @y/2, contents.width, font_height, @message)
- x = text_size(@message).width + 5
- draw_arrow(x + Venka::Crafting::Arrow_x_Item, @y/2, text_size("→").width + 15, font_height)
- if @exp > 0
- color = normal_color
- contents.fill_rect(0, @y + 2, contents_width, 1, color)
- color.alpha = 90
- contents.fill_rect(0, @y + 3, contents_width, 1, color)
- end
- @y += font_height - (font_height - 3)
- when Venka::Crafting::Failed_Msg
- draw_text(0, @y, contents.width, font_height, @message, 1)
- @y += font_height
- if @exp > 0
- color = normal_color
- contents.fill_rect(0, @y + 2, contents_width, 1, color)
- color.alpha = 90
- contents.fill_rect(0, @y + 3, contents_width, 1, color)
- end
- @y += font_height - (font_height - 3)
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_item
- #----------------------------------------------------------------------------
- def draw_item(item, amount = 1)
- set_font(:other_text)
- x = 0
- x += text_size(@message).width + 5
- x += text_size("→").width + 15
- width = contents.width - x
- text = item.name + " x#{amount}"
- item_width = text_size(text).width + 40
- x = x + (width - item_width) * 0.5 + 5
- if $imported[:MAIcon_Hue]
- draw_icon_with_hue(item.icon_index, item.icon_hue, x, @y)
- else
- draw_icon(item.icon_index, x, @y)
- end
- x += 25
- change_color(item.color)
- draw_text(x, @y, contents.width - x, font_height, item.name)
- set_font(:other_text)
- x += text_size(item.name).width + 5
- draw_text(x, @y, contents.width - x, font_height, " x#{amount}")
- @y += font_height
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_exp_received
- #----------------------------------------------------------------------------
- def draw_exp_received
- set_font(:other_text)
- text = $craft[@craft_id].max_level? ? Venka::Crafting::Max_Exp : "#{@exp} Exp"
- total_text = Venka::Crafting::Exp_Earned + "→" + text
- text_width = text_size(total_text).width + 25
- x = (contents.width - text_width) * 0.5
- draw_text(x, @y, contents.width, font_height, Venka::Crafting::Exp_Earned)
- x += text_size(Venka::Crafting::Exp_Earned).width + 5
- draw_arrow(x + Venka::Crafting::Arrow_x_Exp, @y, text_size("→").width + 15, font_height)
- x += text_size("→").width + 15
- draw_text(x, @y, contents.width, font_height, text)
- @y += font_height
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_level_up
- #----------------------------------------------------------------------------
- def draw_level_up
- set_font(:button_text)
- height = contents.font.size
- draw_text(0, @y, contents.width, height, Venka::Crafting::Lv_Gain, 1)
- @y += height
- if @learned && @learned != []
- color = normal_color
- contents.fill_rect(0, @y + 2, contents_width, 1, color)
- color.alpha = 90
- contents.fill_rect(0, @y + 3, contents_width, 1, color)
- @y += font_height - (font_height - 4)
- end
- end
- #----------------------------------------------------------------------------
- # ○ overwrite method: draw_new_recipes
- #----------------------------------------------------------------------------
- def draw_new_recipes
- set_font(:other_text)
- prefix = Venka::Crafting::Learn_Text
- widthr = 0
- @learned.each do |recipe_id|
- recipe = $recipe[recipe_id]
- size = text_size(recipe.display_name).width
- widthr = size if size > widthr
- widthrx = contents.width - widthr
- x = 0
- x += text_size(prefix).width + 5
- x += text_size("→").width + 15
- width = contents.width - x + 10
- widthx = contents.width - width + 19
- iconx = (width - text_size(recipe.display_name).width) / 2 + widthx - 28
- if $imported[:MAIcon_Hue]
- draw_icon_with_hue(recipe.crafted_item.icon_index, @item.icon_hue, iconx, @y)
- else
- draw_icon(recipe.crafted_item.icon_index, iconx, @y)
- end
- draw_text(widthx - 5, @y, width + 10, font_height, recipe.display_name, 1)
- @y += font_height
- end
- h2 = font_height * @learned.size + 6
- x2 = text_size(prefix).width + 5 + text_size("→").width + 15
- y2 = @y - font_height * @learned.size
- if @learned && @learned != []
- color = normal_color
- contents.fill_rect(x2 + Venka::Crafting::Arrow_x_Rec, y2 + 1, 1, h2, color)
- color.alpha = 90
- contents.fill_rect(x2 + 1 + Venka::Crafting::Arrow_x_Rec, y2 + 1, 1, h2, color)
- end
- x = text_size(prefix).width + 5
- y1 = @y - font_height/2 - (@learned.size * font_height)/2
- draw_text(0, y1, contents.width, font_height, prefix) if @learned && @learned != []
- draw_arrow(x + Venka::Crafting::Arrow_x_Rec, y1, text_size("→").width + 15, font_height) if @learned && @learned != []
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_arrow
- #----------------------------------------------------------------------------
- def draw_arrow(x, y, width, height)
- set_font(:arrows)
- draw_text(x, y, width, height, "→", 1)
- set_font(:other_text)
- end
- end
- end
- rescue
- msgbox("The Randomization Addon for the crafting script requires that you use Vlue's Weapon/Armor Randomization Script!")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement