Theo - Smithing: Cost Edit

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
Hello!

I was wondering if someone could help me with a small edit to Theo's Smithing script.

As it stands, it costs gold to upgrade your weapons. Would it be possible to change the cost to an item instead (or better yet, both?)
 

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
By both do you mean the price to upgrade and the price to sell the weapon?
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
By both do you mean the price to upgrade and the price to sell the weapon?
I was just referring the price to upgrade the weapon, the sell price can stay as is.

By both, I just meant that when upgrading your weapon, you could set both an item cost, and a gold cost. (Ex. Instead of costing 100 gold to upgrade, I could have it cost 1 grindstone plus 100 gold.)
 

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
I wrote an edit script that lets you use these kind of prices.
Haven't tested much, but a simple test of 2 and 3 item prices (one of those was gold) worked.
Check the instructions on how to apply the price.
Paste below the original script.
Code:
module THEO
  module Smith
      W_Upgrade_Table = { # <-- Do not touch this at all cost!
   
    # ------------------------------------------------------------------------
    # Upgrade tree format.
    # ------------------------------------------------------------------------
    # ID => [ <-- opening
    #
    #       [{:symbol => num}, icon_index, name, description, sell_price, [[item_id, sum], [item_id, sum]]],  # Level 2
    #       [{:symbol => num}, icon_index, name, description, sell_price],  # Level 3
    #       [ <add more here for the next level> ],             # Level 4
    #
    #       ], <-- ending (do not forget to add comma!)
    # ------------------------------------------------------------------------
    # Just a quick guide won't kill yourself :)
    # ------------------------------------------------------------------------
    # ID                = Weapon ID in database.
    #
    # {:symbol => num } = Once you've upgrade your weapon, the parameter will
    #                     change whether it's up or down. Use the symbol to
    #                     represent the status. Here's the list:
    #                     ---------------------------------------------------
    #                     :atk = attack     || :def = defense
    #                     :mat = magic atk  || :mdf = magic defense
    #                     :agi = agility    || :luk = luck
    #                     :mhp = Max HP     || :mmp = Max MP
    #                     ---------------------------------------------------
    #                     And "num" is a number represent to parameter change
    #
    # icon_index        = Represent as icon index. You may look the icon
    #                     index when you open the icon window dialog box and
    #                     see to the bottom left of that window. Use -1 if you
    #                     don't want to change weapon's icon once upgraded.
    #
    # name              = The new name of upgraded weapon. Leave it blank ("")
    #                     if you wanna keep the original name
    #
    # description       = The new description of upgraded weapon. Leave it
    #                     blank ("") if you wanna keep the original description
    #
    #===========================================================================
    # EDIT (by vFoggy):
    # upgrade_price      = A list with pairs of item_id and sum of item. Use
    #                      0 for the item_id for gold price
    #
    # if you want gold instead of an item then use 0 for the item_id
    #===========================================================================
    # Here's the example :
    # ------------------------------------------------------------------------
      1  => [
            [{:atk => 2,:luk => 2},-1,"","", 500, [[1, 10], [0, 100]]], # dont forget comma
            [{:atk => 2},-1,"Iron Ax","Upgrade version of Hand ax", [[5, 3], [0, 200]]],
            [{:atk => 2},-1,"Silver Ax","", [[5, 50], [0, 500], [6, 2]]],
            ] # dont forget comma
   
    # add more here if it's necessary
   
    # ------------------------------------------------------------------------
    }
  end
end

class Game_Party < Game_Unit
  # New method: checks if item can be upgraded
  def upgradable?(price)
    price.each do |id, count|
      if id == 0
        return false if @gold < count
      else
        return false if item_number($data_items[id]) < count
      end
    end
    return true
  end
 
end

class Window_SmithMenu < Window_Selectable
  def enable?(index)
    actor = $game_party.members[index]
    return false if actor.equips[0].nil?
    # EDIT: check if it is enabled
    return actor.equips[0].next_weapon_exist? &&
      $game_party.upgradable?(actor.equips[0].next_weapon.upgrade_price)
  end
end

class Scene_Smith < Scene_MenuBase
  def craft_weapon
    @confirm.close
    @confirm.deactivate
    $game_party.gain_item(next_weapon,1)
    # EDIT: remove each item that is needed
    next_weapon.upgrade_price.each do |id, count|
      if id == 0
        $game_party.lose_gold(count)
      else
        $game_party.lose_item($data_items[id], count)
      end
    end
    last_equip = item_to_lose
    @notif_smith.show_weapon(last_equip)
    actor.change_equip(0,next_weapon)
    $game_party.lose_item(last_equip,1)
    @menu_actor.update_help
    @menu_actor.activate
    @menu_actor.refresh
    @gold_window.refresh
  end
end


class Window_SmithResult < Window_Base
  include THEO::Smith
 
  def draw_price_text(rect, price)
    y = rect.y
    x = rect.x
    price.each_with_index do |req, index|
      id = req[0]
      count = req[1]
      draw_text_ex(x, y, count)
      x += text_size(count).width
      if id == 0
        draw_text_ex(x, y, "G ")
        x += text_size("G ").width
      else
        draw_icon($data_items[id].icon_index, x, y, true)
        x += 25
      end
      draw_text_ex(x, y, " + ") unless index == price.length-1
      x += text_size(" + ").width
    end
  end
 
  def draw_next_weapon
    ypos = 28
    rect = Rect.new(0,ypos,contents.width,line_height)
    contents.font.size -= 4
    change_color(text_color(Colour::Upgradable))
    draw_text(rect,SVocab::Upgradable,2)
    change_color(system_color)
    draw_text(rect,SVocab::Cost)
    rect.x += text_size(SVocab::Cost).width
    change_color(normal_color)
    # EDIT: draw_price_text instead of draw_text
    draw_price_text(rect, @weapon.next_weapon.upgrade_price)
    texts = obtain_params_change
    ypos += line_height
    texts.each do |txt|
      draw_text_ex(0,ypos,txt)
      ypos += line_height
    end
  end
end

class RPG::UpgradedWeapon < RPG::Weapon
  # EDIT: takes parameter price [[item_id, count], [item_id, count]]
  def make_price(price)
    item_price = @price
    base_price = THEO::Smith::PriceBase
    @price = eval(THEO::Smith::PriceTrade)
    @upgrade_price = price
  end
end

class << DataManager
  def init_upgraded_weapons
    $upgraded_weapons = {}
    THEO::Smith::W_Upgrade_Table.each do |id, table|
      table.each_with_index do |data,level|
        gen_id = (id*100) + (level+1) # Generated ID
        weapon_check = $upgraded_weapons[gen_id]
        result = nil
        if (level + 1) != 1 && !weapon_check.nil?
          result = weapon_check.clone_data
        else
          result = $data_weapons[id].clone_data
        end
        result.level = level+2
        data[0].each do |param,value|
          param_id = THEO::Smith::Key[param]
          result.params[param_id] += value
        end
        if data[1] > -1
          result.icon_index = data[1]
        end
        result.name = data[2].empty? ? result.name : data[2]
        result.description = data[3].empty? ? result.description : data[3]
        result.ori_id = id
        # EDIT: call to make_price
        result.make_price(data[-1])
        gen_id = (id*100) + (level+2)
        result.id = gen_id # Generated ID
        $upgraded_weapons[gen_id] = result
      end
    end
  end
end
Let me know if you want anything changed.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
574
Reaction score
196
First Language
English
Primarily Uses
RMMV
I wrote an edit script that lets you use these kind of prices.
Haven't tested much, but a simple test of 2 and 3 item prices (one of those was gold) worked.
Check the instructions on how to apply the price.
Paste below the original script.
Thanks a bunch, it works great!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I should realize that error was produced by a outdated version of MZ so that's why it pop up like that
Ami
i can't wait to drink some ice after struggling with my illness in 9 days. 9 days is really bad for me,i can't focus with my shop and even can't do something with my project
How many hours have you got in mz so far?

A bit of a "sparkle" update to the lower portion of the world map. :LZSexcite:
attack on titan final season is airing tomorrow, I'm excited and scared at the same time!

Forum statistics

Threads
105,882
Messages
1,017,230
Members
137,607
Latest member
Maddo
Top