Mineral improving gear

Started by Zolnova, September 04, 2012, 09:49:28 pm

Previous topic - Next topic

Zolnova

Hello, I'm trying to make it so that gear you get in game is fixed to your character and so the only way to improve it would be using a certain number of items (lets say iron) on a gear to improve it.

For example lets say, my main characters' falchion can become iron falchion by trading 5 iron and said falchion to the npc.

This part is easy, the only major problem I have is getting the npc to bring up a list of my party, then asking what gear to improve, and how much it will cost (in a certain mineral) to improve.

Can anyone help me please?

Thanks in return :)

KK20

This sounds like something that would be really easy to script and probably look much nicer than by an event. In fact, you can even manipulate this script to fit your needs.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zolnova

Yes this script is perfect! Thank you!
I am still having one small problem.
The script only recognizes weapons (etc) to be in your inventory to use them in a forge.
is there a method I am missing to make it so my items can remain fixed to my characters?

KK20

I believe not. It might be something easy to modify--I'll look into it sometime soon.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zolnova


KK20

Upon looking into the script, I think writing a new script may be necessary. As such, there are some questions that must be asked:
1.) Equipment, you say, is entirely fixed to the characters. These equipments are the default weapon and 4 armor slots, yes? Are these equipment slots all filled up at the start of the game or does the player "earn" new equips to add to their slots?
2.) How does upgrading work? For example, you have a Sword. It can upgrade to Gold Sword and Diamond Sword (diamond being better than gold). Can the Sword be directly upgraded to Diamond or does it have to upgrade through Gold first?
3.) How will the list of available upgrades look like? Will it constantly change from time to time? In other words, will the player have access to ALL the possible upgrade types OR do they have to (for example) beat a certain boss to unlock a potential new upgrade?

If there's anything else you think I'm missing or would like to see, suggest it. I'm not sure how much time I'll have to work on this so it might be a while before I can post a solution.





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zolnova

I see the equipment being one with the characters, so the gear would have to remain on the character right at the start of it joining your team.
Like a werewolf would have claws for weapons, and thick hide for armor.

As for upgrading, its freely selected "tier" order. (example: iron, silver, gold in any order)
All the upgrades become available as the story progresses onward, requiring better materials.

KK20

Huh, I was able to edit the Blacksmith script afterall. Script call instructions are located within the script.
Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Blacksmith Shop
# Author: ForeverZer0
# Type: Custom Shop System
# Date: 4.23.2011
# Version: v.2.0
#
# Editted: KK20
# For: Zolnova
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
#               EDITTED DOCUMENTATION LOCATED FURTHER BELOW
#
# Explanation:
#   Will allow you to create a complete blacksmithing system. The player will be
#   able to forge equipment/items by using combinations of weapons, armors, and
#   items in their possession. Also includes a "Enchantment" feature that will
#   allow the player to use special items to add stats, elementel efficiencies,
#   and state altering to weapons and armor. The extraction feature allows for
#   the breaking down of current equipment and items into other ones.
#
# Features:
#   - Completely configurable item requirements for every item.
#   - Configurable blacksmith 'fees' for every weapon/armor
#   - Can use as many different items, with different quantities for each piece
#     of equipment.
#   - Variable "skill" levels for Blacksmith shops, which lets you decide
#     which features the Blacksmith can do.
#   - Only have to use a single script call to for the Blacksmith's shop.
#   - Can recycle old equipment by extracting items from weapons/armors/items.
#
# Instructions:
#   - Place script below debug and above main
#   - Configuration and instructions for each are below
#   - To call blacksmith shop, this script call:
#
#         w = [ WEAPON_IDS ]    (Use as many as needed, seperate with commas)
#         a = [ ARMOR_IDS ]
#         i = [ ITEM_IDS ]
#         $scene = Scene_BlackSmith.new(w, a, i)
#
#   - All IDs that you included in the script call for items will be be
#     available for forging in that shop.
#   - You can also include a fourth argument to the call to set the Blacksmith's
#     "skill level". Just make an array of true/false elemenets, set up like
#     this:
#
#             [CAN_FORGE?, CAN_EXTRACT?, CAN_ENCHANT?]
#
#     If you are not using the Enchant feature, omit the last option. Just make
#     sure that if you do include this argument that the array has a value for
#     each skill.
#
# Credits/Thanks:
#   - ForeverZer0, for the script.
#   - RoseSkye, huge thanks for beta-testing and demo map.
#
# Author's Notes:
#   Please report any bugs/issues at www.chaos-project.com
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
=begin

[Script Calls]
>> To bring up the scene, use the following line:
    $scene = Scene_Blacksmith.new

>> To define the types of equips that the scene will list, use:
    $scene = Scene_Blacksmith.new(weapons_list, armors_list)
  ...where weapons_list and armors_list are arrays containing the equip IDs
     located within the database.

>> To add weapons and armors to the list, use the following line(s):
    Blacksmith.add_weapons(list)
    Blacksmith.add_armors(list)
  ...where list is an array containing the equip IDs located in the database

=end

module Blacksmith
 
#===============================================================================
#                          BEGIN CONFIGURATION
#===============================================================================

  FORGE_SE = ['006-System06', 80, 100]
  # SE played when an item is forged. ['FILENAME', VOLUME, PITCH]
 
  # Define the colors used for the text in the Blacksmith shop.
  PLUS_COLOR = Color.new(128, 255, 128)
  MINUS_COLOR = Color.new(255, 128, 128)
 
  MAP_BACK = true
  # Set to true if you would like slightly opaque windows with the map showing
  # through.
 
 
  # Put the weapon/armor IDs inside to indicate that these equips can be crafted
  # at the start of the game
  STARTING_WEAPONS_LIST = [1,5,9]
  STARTING_ARMORS_LIST = [1,5,9]
 
 
  #-----------------------------------------------------------------------------
  # FORGE DATABASE
  #-----------------------------------------------------------------------------
  # Define the materials used for each weapon/armor/item that can be forged and
  # extracted. They configuration is slightly different than what it was in the
  # first version of the script. You can seperately define materials that are
  # given during extraction if you like, or ignore it and it will simply return
  # the same materials it takes to forge them. It works like this:
  #
  # STEP 1:
  #   Create a new "case" in the appropriate method below for the type of item
  #   you are trying to define. There are three of them, one each for weapons,
  #   armors, and items. Just use this syntax:
  #       
  #          when DATABASE_ID then []
  #
  # STEP 2:
  #   Now you can begin to add materials to forge the item. Each material has
  #   an number which defines what type of item is is. Here is the "key":
  #
  #       0 = Weapon
  #       1 = Armor
  #       2 = Item
  #
  #   To define a material for an item, you simply create a three element array
  #   using this format:
  #                       [ITEM_TYPE, DATABASE_ID, QUANTITY]
  #
  #   ...and add it the appropriate empty array in the case statement you made
  #   in Step 1. You can add as many different items as you please to forge an
  #   weapon/armor/item, simply seperate the material arrays with commas. See
  #   below for a few examples.
  #-----------------------------------------------------------------------------
  def self.weapon_forges(id)
    return case id
    when 1 then [[2, 31, 3], [2, 32, 1]]            # Bronze Sword
    when 2 then [[2, 32, 2], [2, 31, 1]] # Iron Sword
    when 3 then [[2, 30, 10]]            # Steel Sword
    when 4 then [[2, 30, 3], [2, 31, 1]] # Mythril Sword
    when 5 then [[2, 30, 5], [2, 32, 1]]            # Bronze Spear
    when 6 then [[2, 30, 4], [2, 32, 1]] # Iron Spear
    when 7 then [[2, 30, 2], [2, 31, 1]] # Steel Spear
    when 8 then [[2, 31, 8], [2, 32, 1]]            # Mythril Spear
    end
  end
 
  def self.armor_forges(id)
    return case id
    when 1 then [[2, 31, 3], [2, 32, 1]]
    when 2 then [[2, 31, 3], [2, 32, 1]]
    when 3 then [[2, 31, 3], [2, 32, 1]]
    when 4 then [[2, 31, 3], [2, 32, 1]]
    when 5 then [[2, 31, 3], [2, 32, 1]]
    end
  end
 
  #-----------------------------------------------------------------------------
  # GOLD DATABASE
  #-----------------------------------------------------------------------------
  # Here you can define the amount of gold that is required to forge an item,
  # and the amount that is given if extracted. There are three methods, one each
  # for weapons, armors, and items. Simply follow this pattern for each
  # category:
  #
  #     when DATABASE_ID then [FORGE_PRICE, EXTRACT_GOLD,]
  #-----------------------------------------------------------------------------
  def self.weapon_gold(id)
    return case id
    when 1 then [200, 50]
    when 2 then [450, 225]
    when 3 then [1000, 525]
    when 4 then [1200, 200]
    when 5 then [300, 75]
    when 6 then [550, 275]
    when 7 then [1200, 600]
    when 8 then [1500, 650]
    else
      [0, 0]
    end
  end
 
  def self.armor_gold(id)
    return case id
    when 1 then [100, 100]
    when 2 then [200, 200]
    when 3 then [300, 300]
    when 4 then [400, 400]
    when 5 then [500, 500]
    else
      [0, 0]
    end
  end
 
#===============================================================================
#                              END CONFIGURATION
#===============================================================================
 
  def self.add_weapons(list)
    if list.is_a?(Array)
      $game_system.bs_weapons_list |= list
      $game_system.bs_weapons_list.sort!
    else
      $game_system.bs_weapons_list.push(list) unless [list].include?($game_system.bs_weapons_list)
      $game_system.bs_weapons_list.sort!
    end
  end
 
  def self.add_armors(list)
    if list.is_a?(Array)
      $game_system.bs_armors_list |= list
      $game_system.bs_armors_list.sort!
    else
      $game_system.bs_armors_list.push(list) unless [list].include?($game_system.bs_armors_list)
      $game_system.bs_armors_list.sort!
    end
  end
 



  def self.materials?(type, id)
    # Get the required materials for the item
    materials = case type
    when 0 then [self.weapon_forges(id), self.weapon_gold(id)]
    when 1 then [self.armor_forges(id), self.armor_gold(id)]
    end
    materials[0] = [] if materials[0] == nil
    # Check gold, skipping item check if there is not enough.
    if $game_party.gold >= materials[1][0]
      # Iterate all required materials, making sure enough are in inventory.
      materials[0].each {|item|
        # Branch by the type of the item.
        result = case item[0]
        when 0 then ($game_party.weapon_number(item[1]) >= item[2])
        when 1 then ($game_party.armor_number(item[1]) >= item[2])
        when 2 then ($game_party.item_number(item[1]) >= item[2])
        end
        # End iteration and return false immidiately if missing required item.
        return false unless result
      }
      return true
    end
    return false
  end
end

$blacksmith = 2.0



class Game_System
  attr_accessor :bs_weapons_list
  attr_accessor :bs_armors_list
 
  alias init_bs_equip_lists_after initialize
  def initialize
    init_bs_equip_lists_after
    @bs_weapons_list = Blacksmith::STARTING_WEAPONS_LIST
    @bs_armors_list = Blacksmith::STARTING_ARMORS_LIST
  end
end



class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Change Equipment
  #     equip_type : type of equipment
  #     id    : weapon or armor ID (If 0, remove equipment)
  #--------------------------------------------------------------------------
  def equip(equip_type, id, delete_old = false)
    case equip_type
    when 0  # Weapon
      if id == 0 or $game_party.weapon_number(id) > 0
        $game_party.gain_weapon(@weapon_id, 1) unless delete_old
        @weapon_id = id
        $game_party.lose_weapon(id, 1)
      end
    when 1  # Shield
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor1_id], $data_armors[id])
        $game_party.gain_armor(@armor1_id, 1) unless delete_old
        @armor1_id = id
        $game_party.lose_armor(id, 1)
      end
    when 2  # Head
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor2_id], $data_armors[id])
        $game_party.gain_armor(@armor2_id, 1) unless delete_old
        @armor2_id = id
        $game_party.lose_armor(id, 1)
      end
    when 3  # Body
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor3_id], $data_armors[id])
        $game_party.gain_armor(@armor3_id, 1) unless delete_old
        @armor3_id = id
        $game_party.lose_armor(id, 1)
      end
    when 4  # Accessory
      if id == 0 or $game_party.armor_number(id) > 0
        update_auto_state($data_armors[@armor4_id], $data_armors[id])
        $game_party.gain_armor(@armor4_id, 1) unless delete_old
        @armor4_id = id
        $game_party.lose_armor(id, 1)
      end
    end
  end
 
  def equipped?(item)
    case item
    when RPG::Weapon
      return (@weapon_id == item.id)
    when RPG::Armor
      [@armor1_id,@armor2_id,@armor3_id,@armor4_id].each{|arm|
        return true if arm == item.id }
      return false
    end
  end
 
 
end

#===============================================================================
# ** Window_BlacksmithForge
#===============================================================================
class Window_BlacksmithForge < Window_Selectable

  def initialize(shop_goods)
    super(0, 64, 368, 416)
    # Initialize window and create instance variable to store available goods.
    @shop_goods = shop_goods
    self.active = true
    refresh
    self.index = 0
  end
  #-----------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #-----------------------------------------------------------------------------
  def refresh(enchanting = false)
    # Dispose bitmap and set to nil if not already.
    if self.contents != nil
      self.contents = self.contents.dispose
    end
    # Set flag for enchanting
    @enchanting = enchanting
    # Create array of equipment, depending on flag
    if @enchanting
      @data = []
      # Add weapons
      ($data_weapons - [nil]).each {|weapon|
        if $game_party.weapon_number(weapon.id) > 0 &&
            !Blacksmith::NO_ENCHANT_WEAPONS.include?(weapon.id)
          @data.push(weapon)
        end
      }
      # Add Armor
      ($data_armors - [nil]).each {|armor|
        if $game_party.armor_number(armor.id) > 0 &&
            !Blacksmith::NO_ENCHANT_ARMORS.include?(armor.id)
          @data.push(armor)
        end
      }
    else
      @data = @shop_goods
    end
    # Create a new bitmap, sized for available items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      (0...@item_max).each {|i| draw_item(i) }
    end
  end
  #-----------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    # Set a few local variables depending on the type of item.
    case item
    when RPG::Weapon
      quantity = $game_party.weapon_number(item.id)
      price, type = Blacksmith.weapon_gold(item.id)[0], 0
    when RPG::Armor
      quantity = $game_party.armor_number(item.id)
      price, type = Blacksmith.armor_gold(item.id)[0], 1
    when RPG::Item
      quantity = $game_party.item_number(item.id)
      price, type = Blacksmith.item_gold(item.id)[0], 2
    end
    # Don't check material requirments for forging wjen enchanting
    result = @enchanting ? true : Blacksmith.materials?(type, item.id)
    # Determine the color to use for drawing the item name.
    if quantity < 99 && result
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    # Draw the item name, icon, and price.
    x, y = 4, index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    if !@enchanting
      self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
    end
  end
  #-----------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? '' : self.item.description)
  end
end

#===============================================================================
# ** Window_BlacksmithMaterials
#===============================================================================
class Window_BlacksmithMaterials < Window_Base
 
  attr_accessor :active
 
  def initialize
    # Initialize window size and coordinates.
    super(0, 64, 368, 416)
    @active = true
  end
  #-----------------------------------------------------------------------------
  def refresh(item, type = 0)
    # Clear the bitmap and set the new materials.
    if self.contents != nil
      self.contents = self.contents.dispose
    end
    set_materials(item, type)
    # Create a new bitmap, based off the amount of materials
    if @materials != nil && @materials.size > 0
      self.contents = Bitmap.new(self.width - 32, 64 + (@materials.size * 32))
      # Draw each material and quantity required.
      self.contents.font.color = system_color
      word = type == 0 ? 'Cost' : ($data_system.words.gold + ':')
      self.contents.draw_text(4, 0, 212, 32, word, 0)
      text = type == 0 ? 'Required Materials:' : 'Extractable Materials:'
      self.contents.draw_text(4, 32, 368, 32, text, 0)
      self.contents.font.color = normal_color
      self.contents.draw_text(244, 0, 88, 32, @price.to_s, 2)
      # Enumerate through each material.
      @materials.each_index {|i|
        # Set local variable to current item, depending on type.
        case @materials[i][0]
        when 0
          item = $data_weapons[@materials[i][1]]
          enough = $game_party.weapon_number(item.id) >= @materials[i][2]
          amount = $game_party.weapon_number(item.id)
        when 1
          item = $data_armors[@materials[i][1]]
          enough = $game_party.armor_number(item.id) >= @materials[i][2]
          amount = $game_party.armor_number(item.id)
        when 2
          item = $data_items[@materials[i][1]]
          enough = $game_party.item_number(item.id) >= @materials[i][2]
          amount = $game_party.item_number(item.id)
        end
        next if item == nil
        # Set local variable to store required amount of this item.
        required = @materials[i][2]
        # Set color of text, draw grayed if out if forging and not enough.
        self.contents.font.color = normal_color
        if type == 0 && !enough
          self.contents.font.color = disabled_color
        end
        # Set coordinates of current line.
        x, y = 4, 64 + (i * 32)
        # Draw item name, icon, and required amount.
        rect = Rect.new(x, y, self.width - 32, 32)
        self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
        bitmap = RPG::Cache.icon(item.icon_name)
        opacity = self.contents.font.color == normal_color ? 255 : 128
        self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
        self.contents.draw_text(x + 28, y, 212, 32, item.name)
        self.contents.draw_text(x + 220, y, 48, 32, amount.to_s, 2)
        self.contents.draw_text(x + 272, y, 48, 32, '/', 0)
        self.contents.draw_text(x + 272, y, 48, 32, required.to_s, 2)
      }
    elsif @price > 0
      self.contents = Bitmap.new(self.width - 32, 64)
      self.contents.font.color = system_color
      self.contents.draw_text(4, 0, 212, 32, $data_system.words.gold + ':')
      self.contents.font.color = normal_color
      self.contents.draw_text(244, 0, 88, 32, @price.to_s, 2)
      self.contents.draw_text(4, 32, 368, 32, 'No Materials')
    end
  end
  #-----------------------------------------------------------------------------
  def set_materials(item, type)
    # Sets the required/extractable items for the passed item.
    id = item.id
    if item.is_a?(RPG::Weapon)
      @materials = type == 0 ? Blacksmith.weapon_forges(id) :
        Blacksmith.weapon_extractions(id)
      @price = Blacksmith.weapon_gold(id)[type]
    elsif item.is_a?(RPG::Armor)
      @materials = type == 0 ? Blacksmith.armor_forges(id) :
        Blacksmith.armor_extractions(id)
      @price = Blacksmith.armor_gold(id)[type]
    else
      if @materials != 2
        @materials = type == 0 ? Blacksmith.item_forges(id) :
          Blacksmith.item_extractions(id)
        @price = Blacksmith.item_gold(id)[type]
      end
    end
  end
  #-----------------------------------------------------------------------------
  def update
    # Allow scrolling of bitmap if materials don't fit in window.
    if @active && self.contents != nil && self.contents.height > 320
      if Input.trigger?(Input::UP)
        if self.oy > 0
          self.oy -= 32
          $game_system.se_play($data_system.cursor_se)
        end
      elsif Input.trigger?(Input::DOWN)
        if (self.oy + 320) < self.contents.height
          self.oy += 32
          $game_system.se_play($data_system.cursor_se)
        end
      end
    end
  end
end




#===============================================================================
# ** Window_BlacksmithStatus
#===============================================================================
class Window_BlacksmithStatus < Window_Base
 
  def initialize
    super(368, 128, 272, 352)
    self.contents = Bitmap.new(width - 32, height - 32)
    # Create array of sprites same size as party
    @sprites = [Sprite.new, Sprite.new, Sprite.new, Sprite.new]
    #@sprites = Array.new($game_party.actors.size, Sprite.new)
    # Set coordinates of each sprite
    @sprites.each_index {|i|
      @sprites[i].x, @sprites[i].y = 380, 194 + (i * 64)#(i * 34)
      @sprites[i].z = self.z + 10
    }
    self.visible = true
    # Array of flags for walking
    @walk = Array.new($game_party.actors.size, false)
    @count, @item = 0, nil
    refresh
  end
  #-----------------------------------------------------------------------------
  def refresh
    # Clear bitmap and turn off visiblity of each sprite.
    self.contents.clear
    @sprites.each {|sprite| sprite.visible = false }
    # Return if selected item index is undefined.
    return if @item == nil
    self.contents.font.size = Font.default_size + 2
    quantity = case @item
    when RPG::Item then $game_party.item_number(@item.id)
    when RPG::Weapon then $game_party.weapon_number(@item.id)
    when RPG::Armor then $game_party.armor_number(@item.id)
    end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 200, 32, 'Possessed:')
    self.contents.font.color = normal_color
    self.contents.draw_text(204, 0, 32, 32, quantity.to_s, 2)
    # Disable walking animation and end method if selected item is a normal item
    if @item.is_a?(RPG::Item)
      @walk.collect! {|value| false }
      return
    end
    # Change the font size.
    self.contents.font.size = Font.default_size - 1
    # Iterate each actor...
    $game_party.actors.each_index {|i|
      chr = $game_party.actors[i]
      # Set local variable to highlighted piece of equipment.
      if @item.is_a?(RPG::Weapon)
        eqp = $data_weapons[chr.weapon_id]
      else
        armors = [chr.armor1_id, chr.armor2_id, chr.armor3_id, chr.armor4_id]
        eqp = $data_armors[armors[@item.kind]]
      end
      # Draw the actor sprite.
      draw_actor_graphic(i, chr.equippable?(@item))
      # Draw message and return if unequippable.
      unless chr.equippable?(@item)
        self.contents.font.color = normal_color
        self.contents.draw_text(32, 54 + (i * 64), 150, 32, 'Cannot Equip')
        next
      else
        # Create array of stat changes.
        # [str, dex, agi, int, pdef, mdef, (atk || eva)]
        stats = [
          (@item == nil ? 0 : @item.str_plus) - (eqp == nil ? 0 : eqp.str_plus),
          (@item == nil ? 0 : @item.dex_plus) - (eqp == nil ? 0 : eqp.dex_plus),
          (@item == nil ? 0 : @item.agi_plus) - (eqp == nil ? 0 : eqp.agi_plus),
          (@item == nil ? 0 : @item.int_plus) - (eqp == nil ? 0 : eqp.int_plus),
          (@item == nil ? 0 : @item.pdef) - (eqp == nil ? 0 : eqp.pdef),
          (@item == nil ? 0 : @item.mdef) - (eqp == nil ? 0 : eqp.mdef)
        ]
        if @item.is_a?(RPG::Weapon)
          stats.push(
            (@item == nil ? 0 : @item.atk) - (eqp == nil ? 0 : eqp.atk))
        elsif @item.is_a?(RPG::Armor)
          stats.push(
            (@item == nil ? 0 : @item.eva) - (eqp == nil ? 0 : eqp.eva))
        end
        # Set local variable to each piece of equipments' name
        current_name = eqp == nil ? '' : eqp.name
        new_name = @item == nil ? '' : @item.name
        # If stats are all equal, show message and end method.
        if stats.all? {|stat| stat == 0 }
          self.contents.font.color = normal_color
          if current_name != new_name
            self.contents.draw_text(32, 54 + (i * 64), 150, 32, 'No Change')
          else
            self.contents.draw_text(32, 54 + (i * 64), 150, 32, 'Equipped')
          end
          next
        end
        # Draw any stat changes, using colors to show plus/minus changes
        self.contents.font.size = (Font.default_size - 1)
        self.contents.font.color = normal_color
        self.contents.draw_text(104, 42 + (64*i), 32, 32, 'STR ') if stats[0] != 0
        self.contents.draw_text(104, 58 + (64*i), 32, 32, 'DEX ') if stats[1] != 0
        self.contents.draw_text(104, 74 + (64*i), 32, 32, 'AGI ') if stats[2] != 0
        self.contents.draw_text(176, 42 + (64*i), 32, 32, 'INT ') if stats[3] != 0
        self.contents.draw_text(32, 58 + (64*i), 32, 32, 'PDF ') if stats[4] != 0
        self.contents.draw_text(32, 74 + (64*i), 32, 32, 'MDF ') if stats[5] != 0
        if stats[-1] != 0
          # Show stats changes for atk/eva, depending on the equipment type
          stat = @item.is_a?(RPG::Weapon) ? 'ATK ' : 'EVA '
          self.contents.draw_text(32, 42 + (64 * i), 32, 32, stat) if stat != 0
        end
        # Show any stat changes
        stats.each_index {|j|
          next if stats[j] == 0
          xy = case j
          when 0 then [132, 42 + (64 * i)]
          when 1 then [132, 58 + (64 * i)]
          when 2 then [132, 74 + (64 * i)]
          when 3 then [198, 42 + (64 * i)]
          when 4 then [60, 58 + (64 * i)]
          when 5 then [60, 74 + (64 * i)]
          when 6 then [60, 42 + (64 * i)]
          end
          # Set color and operator depending on value
          if stats[j] < 0
            self.contents.font.color, sign = Blacksmith::MINUS_COLOR, '-'
          else
            self.contents.font.color, sign = Blacksmith::PLUS_COLOR, '+'
          end
          self.contents.draw_text(xy[0], xy[1], 8, 32, sign, 1)
          self.contents.draw_text(xy[0] + 10, xy[1], 24, 32, stats[j].abs.to_s)
        }
      end
    }
  end
  #-----------------------------------------------------------------------------
  def item=(item)
    if @item != item
      # Change the item variable and refresh.
      @item = item
      refresh
    end
  end
  #-----------------------------------------------------------------------------
  def draw_actor_graphic(id, equipable)
    # Draws the actor graphic
    actor = $game_party.actors[id]
    @sprites[id].bitmap = RPG::Cache.character(actor.character_name,
      actor.character_hue)
    @sprites[id].src_rect.set(0, 0, @sprites[id].bitmap.width / 4,
    @sprites[id].bitmap.height / 4)
    # Set walking animation if item is equippable.
    @walk[id] = equipable
    @sprites[id].tone = Tone.new(0, 0, 0, equipable ? 0 : 255)
    @sprites[id].visible = true
  end
  #-----------------------------------------------------------------------------
  def update
    super
    # Update the walking animation.
    @count = (@count + 1) % 40
    $game_party.actors.each_index {|i|
      next unless @walk[i]
      if @sprites[i].bitmap != nil
        w = @sprites[i].bitmap.width / 4
        h = @sprites[i].bitmap.height / 4
        x = (@count / 10) * w
        @sprites[i].src_rect.set(x, 0, w, h)
      end
    }
  end
  #-----------------------------------------------------------------------------
  def visible=(bool)
    super
    # Set visible to the actor sprites as well.
    @sprites.each {|sprite| sprite.visible = bool }
  end
  #-----------------------------------------------------------------------------
  def dispose
    super
    # Dispose the actor sprites as well.
    @sprites.each {|sprite| sprite.dispose }
  end
end

#===============================================================================
# ** Scene_Blacksmith
#===============================================================================
class Scene_Blacksmith
 
  def initialize(weapons = [], armors = [])
    weapons = $game_system.bs_weapons_list if weapons == []
    armors = $game_system.bs_armors_list if armors == []
    # Set available goods for this shop based off passed argument.
    @goods = []
    @goods += weapons.collect {|id| $data_weapons[id] }
    @goods += armors.collect {|id| $data_armors[id] }
    @goods.uniq!
  end
  #-----------------------------------------------------------------------------
  def main
    # Create a Proc to handle confirmation of choices
    @confirm_proc = Proc.new {
      @help_window.set_text('So who\'s getting this equipment upgrade?')
     
      window = Window_Command.new(160, @character_list + ['Cancel'])
      window.x, window.y, window.z = 224, 192, 9999
      loop { Graphics.update; Input.update; window.update
        if Input.trigger?(Input::C) and window.index != @character_list.size
          actor = nil
          actor = @actor_list[window.index]
          unless actor.nil?
            case @item
            when RPG::Weapon
              $game_party.gain_weapon(@item.id, 1)
              actor.equip(0, @item.id, true)
            when RPG::Armor
              $game_party.gain_armor(@item.id, 1)
              actor.equip(@item.kind+1, @item.id, true)
            end
          end
          window.dispose
          break(true)
        elsif Input.trigger?(Input::B) or (Input.trigger?(Input::C) and window.index == @character_list.size)
          $game_system.se_play($data_system.cancel_se)
          window.dispose
          break(false)
        end
      }
    }
   
    # Initialize the needed windows.
    @forge_window = Window_BlacksmithForge.new(@goods)
    @materials_window = Window_BlacksmithMaterials.new
    @status_window = Window_BlacksmithStatus.new
    @gold_window = Window_Gold.new
    @gold_window.x, @gold_window.y = 480, 64 
    @help_window = Window_Help.new
    # Bind the help window to the other windows.
    @forge_window.help_window = @help_window
    # Set a windows array for easier handling of all windows.
    @windows = [@forge_window, @help_window,
      @materials_window, @status_window, @gold_window]
    # Create map sprite if configured to do so, and set window opacity
    if Blacksmith::MAP_BACK
      @spriteset = Spriteset_Map.new
      @windows.each {|window| window.opacity = 160 }
    end
    # Execute the transition and start the main loop.
    Graphics.transition
    loop {Graphics.update; Input.update; update; break if $scene != self }
    # Freeze the Graphics and dispose the windows
    Graphics.freeze
    @windows.each {|window| window.dispose }
    if Blacksmith::MAP_BACK && @spriteset != nil
      @spriteset.dispose
    end
  end
  #-----------------------------------------------------------------------------
  def update
    # Update the windows
    @windows.each {|window| window.update }
    # Branch method depending on current action.
    if @forge_window.active
      update_forge
    elsif @materials_window.active
      update_materials
    end
  end
  #-----------------------------------------------------------------------------
  def back_to_map
    # Play SE and return to the map.
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
  end
  #-----------------------------------------------------------------------------
  def update_forge
    # Update for input when forge window is active.
    @item = @status_window.item = @forge_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @forge_window.active = @forge_window.visible = false
      @status_window.visible = false
      back_to_map
    elsif Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @forge_window.active = @forge_window.visible = false
      @materials_window.refresh(@item, 0)
      @materials_window.visible = @materials_window.active = true
    end
  end
  #-----------------------------------------------------------------------------
  def update_materials
    # Show help text.
    text = 'Press the Action Button to proceed. Press Cancel to go back.'
    @help_window.set_text(text)
    if Input.trigger?(Input::B)
      # Return to previous screen if cancel button is pressed.
      $game_system.se_play($data_system.cancel_se)
      @materials_window.visible = @materials_window.active = false
      @forge_window.active = @forge_window.visible = true
    elsif Input.trigger?(Input::C)
      type = case @item
      when RPG::Weapon then 0
      when RPG::Armor then 1
      end
      @character_list = []
      @actor_list = []
      $game_party.actors.each{|actor|
        if !actor.equipped?(@item) and actor.equippable?(@item)
          @character_list.push(actor.name)
          @actor_list.push(actor)
        end
      }
     
      if !Blacksmith.materials?(type, @item.id) or @character_list.size == 0
        $game_system.se_play($data_system.buzzer_se)
      elsif @confirm_proc.call
        forge_item
      end
    end
  end
  #-----------------------------------------------------------------------------
  def forge_item
    # Set local variables depending on item type.
    case @item
    when RPG::Weapon
      quantity, type = $game_party.weapon_number(@item.id), 0
      materials = Blacksmith.weapon_forges(@item.id)
      price = Blacksmith.weapon_gold(@item.id)[0]
    when RPG::Armor
      quantity, type = $game_party.armor_number(@item.id), 1
      materials = Blacksmith.armor_forges(@item.id)
      price = Blacksmith.armor_gold(@item.id)[0]
    end
    # End method and play buzzer if inventory is full.
    return $game_system.se_play($data_system.buzzer_se) if quantity == 99
    # Play the defined SE used when forging.
    $game_system.se_play(RPG::AudioFile.new(*Blacksmith::FORGE_SE))
    # Remove required materials from inventory and subtract gold cost.
    if materials != nil
      materials.each {|material|
        case material[0]
        when 0 then $game_party.lose_weapon(material[1], material[2])
        when 1 then $game_party.lose_armor(material[1], material[2])
        when 2 then $game_party.lose_item(material[1], material[2])
        end
      }
    end
    $game_party.lose_gold(price)
    # Reset windows.
    @materials_window.visible = @materials_window.active = false
    @forge_window.active = @forge_window.visible = true
    # Refresh any windows that may have changed
    [@status_window, @gold_window, @forge_window].each{|window| window.refresh }
  end
end
Now to focus on my school work again :P





   


   
   


   
   

Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!



Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Zolnova