Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

error?? on script have no idea what it means

so i copied and pasted a script from a site and have no idea how it works, anyways when i use it its ok as long as i have the 2 of the items but when i only have 1 of them i get an error....

'weapon creation'?661???no method error??????????
undefined method `[]' for nil:nilclass

anyways i didnt copy that error message so i dont think its correct word for word, but its very close anyways heres the script....

Code:
#============================================================
#  Weapon Augmentation
#   v. 1.0
#------------------------------------------------------------------------------------------------------------------------
#  Features:
#    Create your own weapons and customize them to your own liking.
#    Add gems for elemental attacks and stat enhancements
#    Add charms to enhance status effects.
#    Temper your weapon and make it stronger... for a fee.
#    Preset weapons that are already assembled.*
#    Disassemble your weapons and rebuild them.  Granted, the tempering you did on your weapon is now gone.
#    
#  Instructions:
#    Place the 6 scripts and Multi-Slot equipment script all under the other scripts, but above Main.
#    In the module below is the tricky part.
#
#  To use this script, follow this checklist:
#    1.  Create item renditions of the Grips, Blades, Gems, and Charms.
#    2.  Below, in the module, place the information in each segment 
#    3.  Be sure to count each space, for example, with grips you need 11 spots, and in order according
#         to what is above it.
#    4.  If you have any errors, make certain it isnt from the module segment before posting the error.
#
#  NOTES:
#    1.  Do not sell weapons in shops.  This setup isnt compatabile with having more than 1 weapon with
#         the same ID.  If anyone can give me ideas on how to fix this, please tell me.
#
#    2.  You MUST use the multislot equipment with it for use with 2-handed weapons and attackx2.
#
#    3.  To specify which grips go with which blades, go into Grip_Types and Blade_Types in the module.
#         0 = hilt (for swords, great swords, and knives)
#         1 = shaft (for Mace, Axe, and Staves)
#         2 = pole (for lances)
#         3 = stock (for guns and crossbows)
#         4 = bow (for bows, of course)
#
#    *This is found in the module at 'Weapon_Initialize'.  You set most settings in the database, and the
#      added stuff such as gems, the grip, blade, etc... are in the module of the script.
#
#
#------------------------------------------------------------------------------------------------------------------------
#  Sword:  Hilt + Blade
#  Great Sword:  Hilt + Lg. Blade
#  Axe:  Shaft + axe head
#  Knife:  Hilt + Sm. Blade
#  Mace:  Shaft + head
#  Lance:  Pole + Tip
#  C-Bow:  Stock + Bolt
#  Bow:  Wood + String
#  Staff:  Shaft + Head
#  Bun:  Stock + Lock
#------------------------------------------------------------------------------------------------------------------------
#  Grips:
#    Hilt
#    Shaft
#    Pole
#    Stock
#    Bow
#
#  Blades:
#    Blade
#    Lg. Blade
#    Sm. Blade
#    Axe Head
#    Mace Head
#    Tip
#    Bolt
#    String
#    Staff Head
#    Lock
#============================================================
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  * module RPG
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module RPG
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  * class Weapon
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  class Weapon
    
    alias leon_rpg_weaponaug_weapon_initialize initialize
    
    def initialize
      leon_rpg_weaponaug_weapon_initialize
      @hilt_id = 0
      @blade_id = 0
      @gems = [0, 0, 0]
      @temper = 0
      @charm = 0
    end
    
    attr_accessor :hilt_id
    attr_accessor :blade_id
    attr_accessor :gems
    attr_accessor :temper
    attr_accessor :charm
  end
end


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  * module Weapon_Augment
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module Weapon_Augment
  #----------------------------------------------------------------------------------------------------------------------
  #  Grips = {item.id => [+price, +atk, +pdef, +mdef, +str, +dex, +agi, +int, attributes, plus stats, minus stats,],...
  #----------------------------------------------------------------------------------------------------------------------
  Grips = {
  35 => [30, 2, 2, 0, 2, 1, 0, 0, [], [], []],
  36 => [50, 0, 4, 0, 0, 2, 0, 0, [7], [], []],
  37 => [75, 5, 0, 2, 3, 0, 0, 0, [], [], []],
  39 => [30, 0, 0, 2, 0, 0, 0, 3, [], [], []],
  40 => [50, 6, 2, 0, 2, -1, -2, -1, [], [], []],
  41 => [75, 2, 2, 0, 1, 2, 3, 0, [], [], []],
  43 => [30, -1, 0, 1, 2, 1, 0, 1, [],[], []],
  44 => [50, 3, 3, 3, 1, 3, 2, 1, [6], [], []],
  45 => [75, 2, 2, 2, 1, 0, 1, 1, [], [], []],
  47 => [30, 1, 1, 2, 1, 2, 3, 0, [], [], []],
  48 => [50, 2, 1, 1, 2, 1, 1, 2, [], [], []],
  49 => [75, 4, 2, -2, 4, -1, -2, 0, [], [], []],
  51 => [30, 1, 0, 3, 0, 1, 1, 2, [], [], []],
  52 => [50, 3, 1, 2, 1, 0, 0, 0, [], [], []],
  53 => [75, 5, 3, 0, 3, -2, -2, 0, [], [], []]
  }
  #----------------------------------------------------------------------------------------------------------------------
  #  Blades= {item.id => [+price, +atk, +pdef, +mdef, +str, +dex, +agi, +int, attributes, plus stats, minus stats, animation2_id],...
  #----------------------------------------------------------------------------------------------------------------------
  Blades = {
  55 => [80, 110, 0, 0, 0, 0, 0, 0, [], [], [], 7],
  56 => [125, 132, 2, 0, 2, 2, 1, 0, [], [], [], 7],
  57 => [175, 157, 0, 2, 0, 1, 2, 0, [], [], [], 7],
  59 => [80, 122, 0, 1, 1, 0, -1, 0, [17], [], [], 7],
  60 => [125, 135, 3, 0, 2, 0, -1, 0, [17], [], [], 7],
  61 => [175, 154, 1, 2, 0, 0, -1, 0, [17], [], [], 7],
  63 => [80, 92, 0, 0, 0, 0, 1, 0, [18], [], [], 7],
  64 => [125, 121, 0, 3, 0, 0, 1, 0, [18], [], [], 7],
  65 => [175, 144, 3, 0, 0, 0, 1, 2, [18], [], [], 7],
  67 => [80, 112, 0, 0, 0, 1, 1, 0, [], [], [], 9],
  68 => [125, 133, 0, 0, 1, 0, 0, 0, [], [], [], 9],
  69 => [175, 156, 2, 0, 1, -1, -2, 0, [], [], [], 9],
  71 => [80, 108, 2, 0, 1, 0, 0, 0, [], [], [], 13],
  72 => [125, 129, 0, 0, 0, 1, 1, 0, [], [], [], 13],
  73 => [175, 151, 0, 0, 1, 0, 0, 0, [8], [], [], 13],
  75 => [80, 121, 2, 0, 2, 0, -1, 0, [17], [], [], 8],
  76 => [125, 130, 0, 4, 0, 0, -2, 1, [1, 17], [], [], 8],
  77 => [175, 152, 3, 0, 3, -1, -2, 0, [10, 17], [], [], 8],
  79 => [80, 110, 2, 0, 0, 0, -1, 0, [17], [], [], 11],
  80 => [125, 131, 1, 0, 2, -1, -1, 0, [17], [], [], 11],
  81 => [175, 149, 0, 2, 0, -1, -1, 2, [3, 17], [], [], 11],
  83 => [80, 109, 0, 0, 0, 0, -1, 0, [17], [], [], 11],
  84 => [125, 129, 1, 0, 0, 1, -1, 0, [17], [], [], 11],
  85 => [175, 147, 0, 1, 0, 0, -1, 2, [17], [], [], 11],
  87 => [80, 109, 0, 1, 0, 0, 0, 2, [7], [], [], 14],
  88 => [125, 138, 2, 0, 0, 0, 0, 2, [], [], [], 14],
  89 => [175, 148, 0, 2, 0, 0, 0, 4, [2], [], [], 14],
  91 => [125, 125, 1, 0, 0, 0, -1, 0, [17], [], [], 12],
  92 => [175, 155, 2, 0, 0, -1, -2, 0, [17], [], [], 12]
  }
  #--------------------------------------------------------------------
  #  Grip_Type = {item.id => grip_id, ...etc
  #  0 = hilt, 1 = shaft, 2 = pole, 3 = stock, 4 = bow
  #--------------------------------------------------------------------
  Grip_Type = {
  35 => 0,
  36 => 0,
  37 => 0,
  39 => 1,
  40 => 1,
  41 => 1,
  43 => 2,
  44 => 2,
  45 => 2,
  47 => 3,
  48 => 3,
  49 => 3,
  51 => 4,
  52 => 4,
  53 => 4
  }
  #--------------------------------------------------------------------
  #  Blade_Type = {item.id => weapon_id...etc
  #  0 = hilt, 1 = shaft, 2 = pole, 3 = stock, 4 = bow
  #--------------------------------------------------------------------
  Blade_Type = {
  55 => 0,
  56 => 0,
  57 => 0,
  59 => 0,
  60 => 0,
  61 => 0,
  63 => 0,
  64 => 0,
  65 => 0,
  67 => 1,
  68 => 1,
  69 => 1,
  71 => 1,
  72 => 1,
  73 => 1,
  75 => 2,
  76 => 2,
  77 => 2,
  79 => 3,
  80 => 3,
  81 => 3,
  83 => 4,
  84 => 4,
  85 => 4,
  87 => 1,
  88 => 1,
  89 => 1,
  91 => 3,
  92 => 3,
  }
  #--------------------------------------------------------------------
  #  Weapon_Type = {blade_id => weapon_type...etc
  #  0 = sword, 1 = lg. sword, 2 = dagger, 3 = axe
  #  4 = mace, 5 = lance, 6 = crossbow, 7 = bow, 
  #  8 = staff, 9 = gun
  #--------------------------------------------------------------------
  Weapon_Type = {
  55 => 0,
  56 => 0,
  57 => 0,
  59 => 1,
  60 => 1,
  61 => 1,
  63 => 2,
  64 => 2,
  65 => 2,
  67 => 3,
  68 => 3,
  69 => 3,
  71 => 4,
  72 => 4,
  73 => 4,
  75 => 5,
  76 => 5,
  77 => 5,
  79 => 6,
  80 => 6,
  81 => 6,
  83 => 7,
  84 => 7,
  85 => 7,
  87 => 8,
  88 => 8,
  89 => 8,
  91 => 9,
  92 => 9,
  }
  #--------------------------------------------------------------------
  #  Blade_Id = { blade_id => [ temper_%, temper_limit],...etc
  #--------------------------------------------------------------------
  Blade_Id = {
  55 => [4, 1],
  56 => [5, 2],
  57 => [5, 3],
  59 => [4, 1],
  60 => [5, 2],
  61 => [5, 3],
  63 => [4, 1],
  64 => [5, 2],
  65 => [5, 3],
  67 => [4, 1],
  68 => [5, 2],
  69 => [5, 3],
  71 => [4, 1],
  72 => [5, 2],
  73 => [5, 3],
  75 => [4, 1],
  76 => [5, 2],
  77 => [5, 3],
  79 => [4, 1],
  80 => [5, 2],
  81 => [5, 3],
  83 => [4, 1],
  84 => [5, 2],
  85 => [5, 3],
  87 => [4, 1],
  88 => [5, 2],
  89 => [5, 3],
  91 => [4, 2],
  92 => [5, 3],
  }  
  #--------------------------------------------------------------------
  #  Hilt_Id = {hilt_id => [gem_amt]
  #--------------------------------------------------------------------
  Hilt_Id = {
  35 => 1,
  36 => 2,
  37 => 3,
  39 => 2,
  40 => 1,
  41 => 3,
  43 => 2,
  44 => 2,
  45 => 2,
  47 => 1,
  48 => 2,
  49 => 3,
  51 => 2,
  52 => 3,
  53 => 3
  }
  #--------------------------------------------------------------------
  #  Price to temper a sword
  #--------------------------------------------------------------------
  Price = 1500
  #--------------------------------------------------------------------
  #  Weapon_Initialize = {weapon.id => [hilt_id, blade_id, gems
  #  temper}
  #--------------------------------------------------------------------
  Weapon_Initialize = {
  }
  #--------------------------------------------------------------------
  #  Gems = { gem_id => [atk, pdef, mdef, str, dex, agi, int, [elem set], price]
  #--------------------------------------------------------------------
  Gems = {
  95 => [2, 2, 1, 2, 1, 1, 1, [], 50],
  96 => [0, 0, 1, 1, 2, 1, 2, [1], 50],
  97 => [0, 0, 2, 2, 0, 0, 2, [5], 50],
  98 => [0, 0, 3, 1, 2, 1, 2, [2], 50],
  99 => [0, 0, 2, 0, 1, 2, 2, [4], 50],
  100 => [0, 0, 3, 2, 0, 0, 2, [6], 50],
  101 => [0, 0, 2, 0, 1, 2, 2, [3], 50],
  102 => [0, 0, 4, 1, 2, 2, 3, [8], 50],
  103 => [0, 0, 4, 1, 2, 2, 3, [7], 50],
  104 => [7, 3, 2, 3, 0, 0, 3, [], 50],
  105 => [10, 0, 0, 2, 2, 2, 0, [], 50]
  }
  #--------------------------------------------------------------------
  #  Charms = { charm_id => [[plus stats], [minus stats], price]
  #--------------------------------------------------------------------
  Charms = {
  108 => [[7], [], 30],
  109 =>[[3], [], 40],
  110 =>[[5], [], 40],
  111 =>[[8], [14], 40],
  112 =>[[1], [], 40]
  }
end

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Game_System
  
  alias leon_weaponaugment_game_system_initialize initialize
  
  def initialize
    leon_weaponaugment_game_system_initialize
    wa = Weapon_Augment
    for i in 1...$data_weapons.size
      if wa::Weapon_Initialize.keys.include?(i)
        $data_weapons[i].hilt_id = wa::Weapon_Initialize[i][0]
        $data_weapons[i].blade_id = wa::Weapon_Initialize[i][1]
        $data_weapons[i].gems = wa::Weapon_Initialize[i][2]
        $data_weapons[i].temper = wa::Weapon_Initialize[i][3]
        $data_weapons[i].charm = wa::Weapon_Initialize[i][4]
        hilt = $data_weapons[i].hilt_id
        blade = $data_weapons[i].blade_id
        $data_weapons[i].animation1_id = 0
        $data_weapons[i].animation2_id = wa::Blades[blade][11]
        $data_weapons[i].price = wa::Grips[hilt][0] + wa::Blades[blade][0]
        $data_weapons[i].atk = wa::Grips[hilt][1] + wa::Blades[blade][1]
        $data_weapons[i].pdef = wa::Grips[hilt][2] + wa::Blades[blade][2]
        $data_weapons[i].mdef = wa::Grips[hilt][3] + wa::Blades[blade][3]
        $data_weapons[i].str_plus = wa::Grips[hilt][4] + wa::Blades[blade][4]
        $data_weapons[i].dex_plus = wa::Grips[hilt][5] + wa::Blades[blade][5]
        $data_weapons[i].agi_plus = wa::Grips[hilt][6] + wa::Blades[blade][6]
        $data_weapons[i].int_plus = wa::Grips[hilt][7] + wa::Blades[blade][7]
        $data_weapons[i].element_set = wa::Grips[hilt][8] + wa::Blades[blade][8]
        $data_weapons[i].element_set.uniq
        charm = wa::Charms[$data_weapons[i].charm]
        if charm != nil
          $data_weapons[i].plus_state_set = wa::Grips[hilt][9] + wa::Blades[blade][9] + charm[0]
          $data_weapons[i].minus_state_set = wa::Grips[hilt][10] + wa::Blades[blade][10] + charm[1]
        else
          $data_weapons[i].plus_state_set = wa::Grips[hilt][9] + wa::Blades[blade][9]
          $data_weapons[i].minus_state_set = wa::Grips[hilt][10] + wa::Blades[blade][10]
        end
        $data_weapons[i].plus_state_set.uniq
        $data_weapons[i].minus_state_set.uniq
        $data_weapons[i].temper = 0
        for j in 0...$data_weapons[i].gems.size
          if $data_weapons[i].gems[j] != 0
            gems = $data_weapons[i].gems
            $data_weapons[i].price = wa::Gems[gems[j]][8] + $data_weapons[i].price
            $data_weapons[i].atk = wa::Gems[gems[j]][0] + $data_weapons[i].atk
            $data_weapons[i].pdef = wa::Gems[gems[j]][1] + $data_weapons[i].pdef
            $data_weapons[i].mdef = wa::Gems[gems[j]][2] + $data_weapons[i].mdef
            $data_weapons[i].str_plus = wa::Gems[gems[j]][3] + $data_weapons[i].str_plus
            $data_weapons[i].dex_plus = wa::Gems[gems[j]][4] + $data_weapons[i].dex_plus
            $data_weapons[i].agi_plus = wa::Gems[gems[j]][5] + $data_weapons[i].agi_plus
            $data_weapons[i].int_plus = wa::Gems[gems[j]][6] + $data_weapons[i].int_plus
            $data_weapons[i].element_set = wa::Gems[gems[j]][7] + $data_weapons[i].element_set
            $data_weapons[i].element_set.uniq
          end
        end
      end
    end
  end
end

      

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  * Scene_Save
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Save < Scene_File
  
  alias leon_weaponaug_scene_save_wsd write_save_data
  
  def write_save_data(file)
    save_data($data_weapons, "Data/Weapons#{@file_index + 1}.rxdata")
    leon_weaponaug_scene_save_wsd(file)
  end
end

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  * Scene_Load
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Scene_Load < Scene_File
  
  alias leon_weaponaug_scene_load_rsd read_save_data
  
  def read_save_data(file)
    $data_weapons = load_data("Data/Weapons#{@file_index + 1}.rxdata")
    leon_weaponaug_scene_load_rsd(file)
  end
end

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  * Game_Party
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Game_Party
  
  alias leon_weaponcreation_gp_initialize initialize
  
  attr_accessor :weapon_array
  attr_accessor :items
  attr_accessor :weapons
  attr_accessor :armors
  
  def initialize
    @weapon_array = []
    for i in 1...$data_weapons.size
      if $data_weapons[i].name ==""
        @weapon_array.push($data_weapons[i].id)
      end
    end
    leon_weaponcreation_gp_initialize
    RPG::Weapon
  end
  
end

#------------------------------------------------------------------------------------------------------------------------
#  * Window_Weapon_Info
#------------------------------------------------------------------------------------------------------------------------
class Window_Weapon_Info < Window_Base
  def initialize
    super(0, 0, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
  end
  
  def update(help_text)
    self.contents.clear
    self.contents.draw_text(0, 0, 600, 32, help_text)
  end
end

#------------------------------------------------------------------------------------------------------------------------
#  * Window_Weapon_Hilts
#------------------------------------------------------------------------------------------------------------------------
class Window_Weapon_Hilts < Window_Selectable
  def initialize
    super(0, 64, 290, 192)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    self.index = 0
    self.active = true
    refresh
  end
  
  def hilts
    if @data != nil
      return @data[index]
    end
  end
  
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    wa = Weapon_Augment
    for i in 1...$data_items.size
      if wa::Grips.keys.include?(i)
        if $game_party.item_number(i) > 0
          @data.push($data_items[i])
        end
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $defaultfonttype
      self.contents.font.size = $defaultfontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  
  def draw_item(index)
    hilt = @data[index]
    x = 4
    y = index * 32
    number = $game_party.item_number(hilt.id)
    bitmap = RPG::Cache.icon(hilt.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, hilt.name, 0)
    self.contents.draw_text(x + 210, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 226, y, 24, 32, number.to_s, 2)
  end
end
#------------------------------------------------------------------------------------------------------------------------
#  * END Window_Weapon_Hilts
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
#  * Window_Weapon_Blades
#------------------------------------------------------------------------------------------------------------------------
class Window_Weapon_Blades < Window_Selectable
  def initialize(hilt_type)
    super(0, 256, 290, 224)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    self.index = -1
    self.visible = false
    self.active = false
    wa = Weapon_Augment
    refresh(hilt_type)
  end
    
  def blades
    if @data != nil
      return @data[index]
    end
  end

  def refresh(hilt_type)
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    wa = Weapon_Augment
    for i in 1...$data_items.size
      if wa::Blades.keys.include?(i)
        if wa::Blade_Type[i] == hilt_type
          if $game_party.item_number(i) > 0
            @data.push($data_items[i])
          end
        end
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $defaultfonttype
      self.contents.font.size = $defaultfontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  def draw_item(index)
    blade = @data[index]
    x = 4
    y = index * 32
    number = $game_party.item_number(blade.id)
    bitmap = RPG::Cache.icon(blade.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, blade.name, 0)
    self.contents.draw_text(x + 210, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 226, y, 24, 32, number.to_s, 2)
  end
end
#------------------------------------------------------------------------------------------------------------------------
#  * END Window_Weapon_Blades
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
#  * Window_Weapon_Stats
#------------------------------------------------------------------------------------------------------------------------
class Window_Weapon_Stats < Window_Base
  def initialize(hilt, blade, blade_index)
    super(290, 64, 350, 416)
    @stats = ["Attack:", "P-Defense", "M-Defense:", "Str:", "Dex:", "Agi:", "Int:"]
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh(hilt, blade, blade_index)
  end
  
  def refresh(hilt, blade, blade_index)
    @hilt_id = hilt.id
    @blade_id = blade.id
    @blade_index = blade_index
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.font.size = $defaultfontsize
    self.contents.draw_text(95, 0, 120, 32, "Grip:")
    self.contents.draw_text(160, 0, 120, 32, "Blade:")
    self.contents.draw_text(235, 0, 120, 32, "Weapon:")
    self.contents.font.size = 18
    for i in 0...@stats.size
      y = i * 20 + 30
      self.contents.draw_text(0, y, 120, 32, @stats[i])
    end
    self.contents.draw_text(0, 170, 120, 32, "E-Attack:")
    self.contents.draw_text(0, 230, 120, 32, "S-Inflict:")
    self.contents.draw_text(0, 290, 120, 32, "S-Cancel:")
    wa = Weapon_Augment
    self.contents.font.color = normal_color
    #----------------------GRIP STATS------------------------------
    if wa::Grips[@hilt_id] != nil
      for i in 1...8
        y = i * 20 + 10
        self.contents.draw_text(95, y, 35, 32, wa::Grips[@hilt_id][i].to_s, 2)
      end
      for i in 0...wa::Grips[@hilt_id][8].size
        y = i * 20 + 170
        elem = wa::Grips[@hilt_id][8][i]
        self.contents.draw_text(72, y, 120, 32, $data_system.elements[elem])
      end
      for i in 0...wa::Grips[@hilt_id][9].size
        y = i * 20 + 230
        state = wa::Grips[@hilt_id][9][i]
        self.contents.draw_text(72, y, 120, 32, $data_states[state].name)
      end
      for i in 0...wa::Grips[@hilt_id][10].size
        y = i * 20 + 290
        state = wa::Grips[@hilt_id][10][i]
        self.contents.draw_text(72, y, 120, 32, $data_states[state].name)
      end
    end
    #----------------------BLADE STATS------------------------------
    if @blade_index > -1
      for i in 1...8
        y = i * 20 + 10
        self.contents.draw_text(160, y, 35, 32, wa::Blades[@blade_id][i].to_s, 2)
      end
      for i in 0...wa::Blades[@blade_id][8].size
        y = i * 20 + 170
        elem = wa::Blades[@blade_id][8][i]
        self.contents.draw_text(137, y, 120, 32, $data_system.elements[elem])
      end
      for i in 0...wa::Blades[@blade_id][9].size
        y = i * 20 + 230
        state = wa::Blades[@blade_id][9][i]
        self.contents.draw_text(137, y, 120, 32, $data_states[state].name)
      end
      for i in 0...wa::Blades[@blade_id][10].size
        y = i * 20 + 290
        state = wa::Blades[@blade_id][10][i]
        self.contents.draw_text(137, y, 120, 32, $data_states[state].name)
      end
      for i in 0...wa::Grips[@hilt_id][8].size
        y = i * 20 + 170
        elem = wa::Grips[@hilt_id][8][i]
        self.contents.draw_text(72, y, 120, 32, $data_system.elements[elem])
      end
      for i in 0...wa::Grips[@hilt_id][9].size
        y = i * 20 + 230
        state = wa::Grips[@hilt_id][9][i]
        self.contents.draw_text(72, y, 120, 32, $data_states[state].name)
      end
      for i in 0...wa::Grips[@hilt_id][10].size
        y = i * 20 + 290
        state = wa::Grips[@hilt_id][10][i]
        self.contents.draw_text(72, y, 120, 32, $data_states[state].name)
      end
    end
    #----------------------WEAPON STATS------------------------------
    if @blade_index > -1
      for i in 1...8
        y = i * 20 + 10
        self.contents.draw_text(235, y, 35, 32, (wa::Grips[@hilt_id][i] + wa::Blades[@blade_id][i]).to_s, 2)
      end
    end
    for i in 0...7
      y = i * 20 + 30
      self.contents.draw_text(140, y, 120, 32, "+")
      self.contents.draw_text(215, y, 120, 32, "=")
    end
  end
  
end
#------------------------------------------------------------------------------------------------------------------------
#  * END Window_Weapon_Stats
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
#  * Window_Weapon_Error
#------------------------------------------------------------------------------------------------------------------------
class Window_Weapon_Error < Window_Base
  def initialize
    super(125, 208, 390, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    self.visible = false
    self.z += 100
    refresh
  end
  
  def refresh
    self.contents.clear
    self.contents.draw_text(0, 0, 400, 32, "Too many weapons, please disassemble one.")
  end
end

#------------------------------------------------------------------------------------------------------------------------
#  * END Window_Weapon_Error
#------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------
#  * Scene_Weapon_Create
#------------------------------------------------------------------------------------------------------------------------
class Scene_Weapon_Create
  def main
    @info_window = Window_Weapon_Info.new
    @hilt_window  = Window_Weapon_Hilts.new
    @blade_window = Window_Weapon_Blades.new(Weapon_Augment::Grip_Type[@hilt_window.hilts.id])
    @stats_window = Window_Weapon_Stats.new(@hilt_window.hilts, @blade_window.blades, @blade_window.index)
    @error_window = Window_Weapon_Error.new
    @counter = 0
    
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    
    @info_window.dispose
    @hilt_window.dispose
    @blade_window.dispose
    @stats_window.dispose
    @error_window.dispose
  end
  
  def update
    @info_window.update("This is only a test!")
    @hilt_window.update
    @error_window.update

    if @hilt_window.active
      hilt_update
      return
    end
    if @blade_window.active
      blade_update
      return
    end
    if @error_window.visible
      update_error
      return
    end
  end
  
  def hilt_update

    wa = Weapon_Augment
    if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
      @counter = 0
    end
    if @counter != 1
      @stats_window.refresh(@hilt_window.hilts, @blade_window.blades, @blade_window.index)
      @counter = 1
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if @hilt_window.hilts != nil
        $game_system.se_play($data_system.decision_se)
        @hilt_window.active = false
        @blade_window.refresh(Weapon_Augment::Grip_Type[@hilt_window.hilts.id])
        @counter = 1
        @blade_window.visible = true
        @blade_window.active = true
        @blade_window.index = 0
      else
        $game_system.se_play($data_system.buzzer_se)
      end
    end
  end
  
  def blade_update
    if @counter >= 1
      @stats_window.refresh(@hilt_window.hilts, @blade_window.blades, @blade_window.index)
      @blade_window.refresh(Weapon_Augment::Grip_Type[@hilt_window.hilts.id])
      @counter = -1
    end
    if Input.trigger?(Input::UP) or Input.trigger?(Input::DOWN)
      @counter = 1
    end
    @blade_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @blade_window.index = -1
      @blade_window.active = false
      @blade_window.visible = false
      @hilt_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      if @blade_window.blades != nil
        wni = $game_party.weapon_array[0]
        if wni == nil
          $game_system.se_play($data_system.buzzer_se)
          @error_window.visible = true
          @blade_window.active = false
        else  
          wa = Weapon_Augment
          hilt = @hilt_window.hilts.id
          blade = @blade_window.blades.id
          $data_weapons[wni].name = $data_items[blade].name
          $data_weapons[wni].animation1_id = 0
          $data_weapons[wni].animation2_id = wa::Blades[blade][11]
          $data_weapons[wni].price = wa::Grips[hilt][0] + wa::Blades[blade][0]
          $data_weapons[wni].atk = wa::Grips[hilt][1] + wa::Blades[blade][1]
          $data_weapons[wni].pdef = wa::Grips[hilt][2] + wa::Blades[blade][2]
          $data_weapons[wni].mdef = wa::Grips[hilt][3] + wa::Blades[blade][3]
          $data_weapons[wni].str_plus = wa::Grips[hilt][4] + wa::Blades[blade][4]
          $data_weapons[wni].dex_plus = wa::Grips[hilt][5] + wa::Blades[blade][5]
          $data_weapons[wni].agi_plus = wa::Grips[hilt][6] + wa::Blades[blade][6]
          $data_weapons[wni].int_plus = wa::Grips[hilt][7] + wa::Blades[blade][7]
          $data_weapons[wni].element_set = wa::Grips[hilt][8] + wa::Blades[blade][8]
          $data_weapons[wni].element_set.uniq
          $data_weapons[wni].plus_state_set = wa::Grips[hilt][9] + wa::Blades[blade][9]
          $data_weapons[wni].plus_state_set.uniq
          $data_weapons[wni].minus_state_set = wa::Grips[hilt][10] + wa::Blades[blade][10]
          $data_weapons[wni].minus_state_set.uniq
          $data_weapons[wni].hilt_id = hilt
          $data_weapons[wni].blade_id = blade
          $data_weapons[wni].gems = [0, 0, 0]
          $data_weapons[wni].temper = 0
          $data_weapons[wni].charm = 0
          $game_party.weapon_array = []
          $game_party.weapons[wni] = 1
          $game_party.items[hilt] -= 1
          $game_party.items[blade] -= 1
          case wa::Weapon_Type[blade]
          when 0
            $data_weapons[wni].icon_name = "001-Weapon01"
          when 1
            $data_weapons[wni].icon_name = "001-Weapon01"
          when 2
            $data_weapons[wni].icon_name = "004-Weapon04"
          when 3
            $data_weapons[wni].icon_name = "003-Weapon03"
          when 4
            $data_weapons[wni].icon_name = "007-Weapon07"
          when 5
            $data_weapons[wni].icon_name = "002-Weapon02"
          when 6
            $data_weapons[wni].icon_name = "005-Weapon05"
          when 7
            $data_weapons[wni].icon_name = "005-Weapon05"
          when 8
            $data_weapons[wni].icon_name = "008-Weapon08"
          when 9
            $data_weapons[wni].icon_name = "006-Weapon06"
          end
          for i in 1...$data_weapons.size
            if $data_weapons[i].name == ""
              $game_party.weapon_array.push($data_weapons[i].id)
            end
          end
          $scene = Scene_Weapon_Naming.new(wni)
          return
        end
      else
        $data_system.se_play($data_system.buzzer_se)
      end
    end
  end
  
  def update_error
    @error_window.update
    if Input.trigger?(Input::B)
        $data_system.se_play($data_system.cancel_se)
      @error_window.visible = false
      @blade_window.active = true
      return
    end
  end
end

oh yeah just in case you didnt understand how the error occurs, it happens when i have a hilt, but no blade and i call scene once i click on the hilt the error comes up, but if i have the hilt and blade then it seems ok.

khmp: Code in code tags. And please just edit the first post rather than double post.
 
I might be able to help, but I need a little more information. First, when you get the error message and open up the script editor; the indicator should be right at where the problem is. Highlight it and post it up.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top