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.

Problems with SephirothSpawn's Materia System

Aerif

Member

So I just added Sephiroth Spawn's Materia System to my game. And everything was going fine until I actually play-tested the game and then I recieved the following error:

Script 'Materia System' line 84: NoMethodError occured.
undefined method '[]' for nil:NilClass

Here is the section where the error occurs:

  #============================================================================
  # ** Weapon
  #============================================================================
  class Weapon
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :paired_materia
    attr_accessor :single_materia
    #--------------------------------------------------------------------------
    # * Set Materia Slots
    #--------------------------------------------------------------------------
    def set_materia_slots(slots)
(84)  @paired_materia, @single_materia = slots[0], slots[1]
    end
  end
 

I'm using SDK 2.3 and I really need this error fixed to continue my project
 
hmmm.... give me ten minutes or contact seph

*edit*

ok, so I needed ten seconds

Code:
  #============================================================================
  # ** Weapon
  #============================================================================
  class Weapon
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :paired_materia
    attr_accessor :single_materia
    #--------------------------------------------------------------------------
    # * Set Materia Slots
    #--------------------------------------------------------------------------
    def set_materia_slots(slots)
      @paired_materia, @single_materia = slots[0], slots[1]
    end
  end
this is what that section should look like
 

Aerif

Member

Actually I only put the 84 there to indicate that that was the problematic line. So that doesn't actually help in the slightest seeing as that's what I have already in the script.
 
oh, oh, ohhhhh.
well I tried.
when I get home I'll try and figure this out.
but until then.
does this happen right as you playtest the game?

*edit*
not home  but...
Code:
#==============================================================================
# ** Game_Battler (part 3)
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_materiasystem_gamebattler_skilleffect skill_effect
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #     user  : the one using skills (battler)
  #     skill : skill
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Orginal Skill Effects Method
    seph_materiasystem_gamebattler_skilleffect(user, skill)
    if user.is_a?(Game_Actor)
      # Gets Paired Materia
      materia_set = user.return_paired_materia
      for paired_set in materia_set
        materia = paired_set[2]
        other_materia = paired_set[3]
        # HP Absorb
        if materia.special_effect == 'HP Absorb'
          for skill_id in other_materia.skills
            unless skill_id == 0
              m_skill = $data_skills[skill_id]
              if skill == m_skill
                hp = (user.maxhp * 0.1).to_i
                user.hp += [hp, user.maxhp - hp].min
                user.damage = - [hp, user.maxhp - hp].min
                user.damage_pop = true
              end
            end
          end
        end
        # MP Absorb
        if materia.special_effect == 'MP Absorb'
          for skill_id in other_materia.skills
            unless skill_id == 0
              m_skill = $data_skills[skill_id]
              if skill == m_skill
                sp = (user.maxsp * 0.1).to_i
                user.sp += [sp, user.maxsp - sp].min
                user.damage = - [sp, user.maxsp - sp].min
                user.damage_pop = true
              end
            end
          end
        end
        # MP Turbo
        if materia.special_effect == 'MP Turbo'
          for skill_id in other_materia.skills
            unless skill_id == 0
              m_skill = $data_skills[skill_id]
              if skill == m_skill
                unless user.sp < skill.sp_cost * 2
                  if self.damage > 0
                    self.damage *= 2
                    user.sp -= skill.sp_cost
                    user.damage = 'MP TURBO!'
                    user.damage_pop = true
                  end
                end
              end
            end
          end
        end
        # Steal As Well
        if materia.special_effect == 'Steal as well'
          for skill_id in other_materia.skills
            unless skill_id == 0
              m_skill = $data_skills[skill_id]
              if skill == m_skill
                if self.is_a?(Game_Battler)
                  if (rand(100) < self.treasure_prob)
                    unless self.item_id == 0
                      item = $data_items[self.item_id]
                    end
                    unless self.weapon_id == 0
                      item = $data_weapons[self.weapon_id]
                    end
                    unless self.armor_id == 0
                      item = $data_armors[self.armor_id]
                    end
                    unless item.nil?
                      case item
                      when RPG::Item
                        $game_party.gain_item(self.item_id, 1)
                      when RPG::Weapon
                        $game_party.gain_weapon(self.weapon_id, 1)
                      when RPG::Armor
                        $game_party.gain_armor(self.armor_id, 1)
                      end
                      user.damage = "Stole #{item.name}"
                      user.damage_pop = true
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end
rplace your Game_Battler (part 3) with this one
 

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