[XP] Blacksmith System (New Configuration Program!)

Started by ForeverZer0, April 21, 2010, 04:50:15 pm

Previous topic - Next topic

Xuroth

can you use this to create multiple recipes for an item?
for example:
to make a chaos sword (no enchantments) you need:
1 chaos essence
1 mithril sword
but if you dont have a mithril sword but you have its reqs:
3 mithril ores
1 wrapped hilt
You should be able to use:
3 mithril ores
1 wrapped hilt
1 chaos essence
For not having all the specific items (and because the smith will "forge" the sword then add the essence) you should have to pay the fee of both making the mithril sword and the chaos sword together.

Just curious...

KK20

Quote from: Xuroth on October 12, 2011, 03:52:59 am
can you use this to create multiple recipes for an item?
for example:
to make a chaos sword (no enchantments) you need:
1 chaos essence
1 mithril sword
but if you dont have a mithril sword but you have its reqs:
3 mithril ores
1 wrapped hilt
You should be able to use:
3 mithril ores
1 wrapped hilt
1 chaos essence
For not having all the specific items (and because the smith will "forge" the sword then add the essence) you should have to pay the fee of both making the mithril sword and the chaos sword together.

Just curious...
I'm not sure if it works exactly like that. I'm assuming it doesn't. But that doesn't mean you can't just forge a mithril sword and then use that sword to make a chaos sword.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

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

Join the CP Discord Server!

Xuroth

that was a poor example of what I was asking, so I apologize. I meant more like having two separate methods to create the same thing.

KK20

According to the setup, each item/weapon/armor has only one recipe. I'm sure it's more than possible to edit the script to satisfy your needs, but at the current state of the script, no, it's not possible. (Anyone correct me if I'm wrong)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

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

Join the CP Discord Server!

ForeverZer0

Currently their is only support for one combination per item. You could work around this by creating copies of the same item, but that would look kinda strange in the inventory screen.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Xuroth


ForeverZer0

No, it really doesn't work like that. There isn't any really quick edit that will change it, the configuration and all the calls to it would need to be altered to support it.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Magus

Oh, I never followed up. But without this script, I think a chunk of my game would die... D: (Simply because the use of forging to get a stronger weapon is where its at.)
LEVEL ME DOWN. THE ANTI-BLIZZ GROUP IS AMONG YOU... Do it for the chick below...She watches..<br />

ForeverZer0

Glad you like it.

When I was making it, I had dreams of creating a Vagrant Story type system. Sadly, I never got around to creating it. :'(
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

xxo60

Great script.

only one problem. I downloaded the program and went to the cache script. I pasted it in the script editor and put the file created on the anvil. Then I copied the blacksmith event from the example in my game. Also i put all the new icons (like ores) in my game folder. I added some recipes. When i try to use the blacksmith i get a pop-up box with the following text: 'NameError occured while running script. uninitialized constant Interpreter::Scene_Blacksmith'. Then Rpg-maker closes.

Could you help me solve this problem?

ForeverZer0

I think there may be a bug with the name. Do a search and replace of Scene_Blacksmith and change it to Scene_BlackSmith, with a capital "S".
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

chaucer

I know its a weird question but is it possible to only show the Weapons/Items/Armors you can make when you have all the required Materials?
like here would be the setup as an example
w = [ 12, 21 ]
a = [ 14 ]
i = [ 11 ]
$scene = Scene_Blacksmith.new(w, a, i)
and when you talk to the blacksmith without any of the required items for these recipes it will not show them on the Forge Screen?
just wondering.

ForeverZer0

It would likely be a pretty minor edit. I don't script for RMXP anymore, and I barely even still offer support on scripts I wrote. It should not be very difficult if someone else were to decide to help you out, though.

* Stares at the remaining scripters of the forum *
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

KK20

*casually walks in*
Window_BlacksmithForge: ShowHide
#===============================================================================
# ** Window_BlacksmithForge
#===============================================================================

class Window_BlacksmithForge < Window_Selectable

  def initialize(shop_goods)
    super(0, 128, 368, 352)
    # Initialize window and create instance variable to store available goods.
    @shop_goods = shop_goods
    self.active = self.visible = false
    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
    # Keep only items that you have materials for
    @new_data = []
    @data.each{|i|
      case i
      when RPG::Weapon
        type = 0
      when RPG::Armor
        type = 1
      when RPG::Item
        type = 2
      end
      @new_data.push(i) if Blacksmith.materials?(type, i.id)
    }
    @data = @new_data
    # 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
CTRL + F for "Window_BlacksmithForge" and replace with this. It's been a while since I've looked at any programming, so I threw this together pretty quick. Obviously someone can find a way to hack this down a few lines shorter.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

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

Join the CP Discord Server!

chaucer


michaelsan

January 17, 2012, 12:28:34 am #115 Last Edit: January 17, 2012, 12:30:39 am by game_guy
Hi ForeverZer0 Thankz for the excellent script :) I´m sure using this on my project :) But can i ask If you could add a new feature to it? If yes then i would like (and i think many people too) If you could have an option for using an Image as layout instead of the windowskin like the mog menu or something like that :)

Thkz for the script I love it :D Hope you can make the feature :)

Re-Edited Subject to avoid confusion. ~ G_G

RPGamer5

Hi, i would really like to include this in my project (with proper credit of course), but i get an argument error if i call the Scene_BlackSmith.new:
"line 349: comparison of Fixnum with nil failed"
# Check gold, skipping item check if there is not enough.
if $game_party.gold >= materials[1][0]

Since i have no scripting knowledge, any help would be appreciated.
Btw, i also use Blizz-ABS if it matters

And i'm sorry if i dug up an old thread

Skwig

Hello, i have a problem with this script.. I did everything and copied it and such, and it says Syntax error which means i did something wrong with events
soo.. Also i use the version 2.0
Here you have the event window thing

Thanks

Taiine

Question.
Can the shop be split? As in, a call for just the forging,and another for taking things apart? I'd like to split it between two npc's, one being the smith that will forge items from parts, and another that will take items apart into their base items.

ForeverZer0

@Skwig:
Try putting the arguments on the same line: 
$scene = Scene_Blacksmith.new(w,a,i,l)


or at least the leading parenthesis:

$scene = Scene_Blacksmith.new(
w,a,i,l)


@Taiine:
Yes, it could be. It would be a relatively simple edit to the scene to change the options. 
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.