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.

Today's Problem: Sephiroth Spawn's Materia System in the RTAB

Alright, alright, maybe one of you can help me out with this one. I'm attempting to use Sephiroth Spawn's Materia System in conjunction with the RTAB system that DerVVulfman's been working on. However, Ruby has been getting testy with me. Both scripts modify/add to the Phase 3 Skill Select segment from Scene Battle. Now, the game works fine, materia system and battle system, if I put the Materia script above the RTAB script. However, doing this seems to allow the Phse 3 Skill Select in the Materia script to be overwritten by the RTAB's, as far as I can tell. This effectively negates the scope effects created by the All materia pairing. Bugger.

I can get into the battle just fine, but when I select the "Skills" option, it brings me to this error message:
Script 'Materia System' line 2251: NoMethodError occurred.
undefined method `return_paired_materia' for nil:NilClass

Okay, let's take a look at what it's talking about...
Code:
  def update_phase3_skill_select
    # Orignal Enemy Select Method
    seph_materiasystem_scenebattle_skillselect
    # Gets Active Battlers Paired Mater
    [b]paired_materia_set = @active_battler.return_paired_materia[/b]
    for paired_set in paired_materia_set
      materia = paired_set[2]
      other_materia = paired_set[3]
      if materia.special_effect == 'All'
        for skill_id in other_materia.skills
          if skill_id == @skill.id

I can get the basics and a little bit beyond that of Ruby. I'm more of a graphics/mapping/story/acting guy myself. So any help at all would be greatly appreciated.
 
With what you're describing, it is VERY likely that you'll need to ... SPLIT... the Materia system into two pieces. The first piece covers the basics, including Actors and Windows. BUT.... the 'Scene_Battle' code must certainly be posted BELOW the RTAB code.

RTAB uses very little 'ALIASing' of the battle system as it rewrites certain sections (including the Phase3_item-blah-blah-blah). One of the things you'll notice is that RTAB's defs in many cases have a (battler) argument:

originally...
def update_phase4_step3
vs RTAB's
def update_phase4_step3(battler)

This is to keep each battler's actions separate from the others. Y'see the normal battlesystem goes through a list of battlers and does each one's actions one-at-a-time. Using a value in the system (@active_battler) doesn't have a problem with that. But, RTAB's battlers can perform their own tasks while you're waiting... overlapping each other's actions. So, RTAB uses the battler value and keeps it isolated so no two actor's actions get mixed!

And likewise, you'll be changing lines like
if @active_battler.current_action.basic == 0
to
if battler.current_action.basic == 0 ...

... changing @active_battler to battler or @battler ...

...and values like self.damage
need be changed to self.damage[attacker] in some cases.
 
Hmm... so this is what my code looks like now, with the problem line emboldened:
Code:
#==============================================================================
# ** Scene_Battle (part 3)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_materiasystem_scenebattle_skillselect update_phase3_skill_select
  alias seph_materiasystem_scenebattle_prior_actor phase3_prior_actor
  #--------------------------------------------------------------------------
  # * Go to Command Input of Previous Actor
  #--------------------------------------------------------------------------
  def phase3_prior_actor
    # Orginal Previous Actor Method
    seph_materiasystem_scenebattle_prior_actor
    unless @battler.nil?
      # Checks to See if Skill Was already selected
      if @battler.current_action.skill_id > @data_skill_size - 1
        # Forgets Skill
        @battler.forget_skill(@battler.current_action.skill_id)
        # Deletes Skill From $data_skills
        $data_skills.pop
        # Sets Skill Selection to nil
        @skill = nil
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : skill selection)
  #--------------------------------------------------------------------------
  def update_phase3_skill_select
    # Orignal Enemy Select Method
    seph_materiasystem_scenebattle_skillselect
    # Gets Active Battlers Paired Mater
    [b]paired_materia_set = @battler.return_paired_materia[/b]
    for paired_set in paired_materia_set
      materia = paired_set[2]
      other_materia = paired_set[3]
      if materia.special_effect == 'All'
        for skill_id in other_materia.skills
          if skill_id == @skill.id
            # Duplicates Skill and Changes ID
            new_skill = @skill.dup
            new_skill.scope = 2 if @skill.scope == 1
            new_skill.scope = 4 if @skill.scope == 3 || @skill.scope == 7
            new_skill.scope = 6 if @skill.scope == 5
            new_skill.id = $data_skills.size
            $data_skills << new_skill
            @battler.learn_skill(new_skill.id)
            # Set action
            @battler.current_action.skill_id = new_skill.id
            # End skill selection
            end_skill_select
            # End enemy selection
            end_enemy_select unless @enemy_arrow.nil?
            # End actor selection
            end_actor_select unless @actor_arrow.nil?
            # Go to command input for next actor
            phase3_next_actor
          end
        end
      end
    end
    return
  end
end

I still get the original error message though.
Script 'Materia System' line 2251: NoMethodError occurred.
undefined method `return_paired_materia' for nil:NilClass
Hmm.... this one's really wracking my brain. Oy oy.

EDIT:
I also have the Return_Paired_Materia def here:
Code:
  #--------------------------------------------------------------------------
  # * Return Paired Materia
  #--------------------------------------------------------------------------
  def return_paired_materia
    # Creates Your Return Array
    paired = []
    # Checks Weapon
    unless @weapon_id == 0
      if $data_weapons[@weapon_id].paired_materia > 0
        for i in 0...($data_weapons[@weapon_id].paired_materia * 2)
          materia = @weapon_materia[i]
          if materia.type == 'Support'
            o_i = i + ([0, 2, 4, 6].include?(i) ? 1 : - 1)
            other_materia = @weapon_materia[o_i]
            unless other_materia.nil?
              paired << [0, [i, o_i].min, materia, other_materia]
            end
          end
        end
      end
    end
    # Checks Armors
    for a in 1..4
      unless (eval "@armor#{a}_id") == 0
        if (eval "$data_armors[@armor#{a}_id].paired_materia") > 0
          for i in 0...((eval "$data_armors[@armor#{a}_id].paired_materia") * 2)
            materia = (eval "@armor#{a}_materia")[i]
            if materia.type == 'Support'
              o_i = i + ([0, 2, 4, 6].include?(i) ? 1 : - 1)
              other_materia = (eval "@armor#{a}_materia")[o_i]
              unless other_materia.nil?
                paired << [a, [i, o_i].min, materia, other_materia]
              end
            end
          end
        end
      end
    end
    return paired
  end
end
Does anything seem to stand out glaringly to you?
 
Yes.

Looking at def update_phase3_skill_select in RTAB, I saw that THAT def in RTAB does not have the (battler) parameter. Just by it being RTAB, I expected it to look like:
Code:
def update_phase3_skill_select(battler)
Comparing both script defs is crucial.

Also, the RTAB script references @active_actor for a change, and not battler or @battler, so try @active_actor.return_paired_materia.

And, um, what CLASS is def return_paired_materia within. It's important. Game_Battler? ;)

Trust me, adapting scripts to RTAB is 'FREAKIN' HARD!!!!'

But possible. :D
 
def return_paired_materia is actually in Game_Actor.

Yes, adapting scripts to RTAB is quite difficult. But it's a pretty decent way to learn things for folks like I. ;)

EDIT:
Also, in the RTAB, it seems as if def update_phase3_skill_select does not actually seem to have the (battler) at the end of it. The one that does that I do know for sure is def update_phase4_step3.

EDIT 2:
Good news though. Finally made it into the Skill Selection window. However, as soon as I attempted to use the Fire skill with the All effect attached to it, I got this guy here:
Script 'Materia System' line 2264: NoMethodError occurred.
undefined method `learn_skill' for nil:NilClass
I'm gonna check it out and see if I can discover anything and complain again shortly when I break the system completely again. ;)

EDIT 3:
Okay, so I ended up replacing @battler with @active_actor in the spots it had errors in, and I was finally able to select the skill in the skill select window! Hooray!

But of course, we're not home free yet.

It seems as if what it does is it doesn't actually utilize the skill at all. Instead, when you select the skill with the all materia attached to it, the game acts as if nothing happened. Yet, if you attempt to enter the skill menu again it closes immediately. However, if there's enough delay to catch a quick glimpse at your item choices, you can see many copies of the same skill.
Code:
  def update_phase3_skill_select
    # Orignal Enemy Select Method
    seph_materiasystem_scenebattle_skillselect
    # Gets Active Battlers Paired Mater
    paired_materia_set = @active_actor.return_paired_materia
    for paired_set in paired_materia_set
      materia = paired_set[2]
      other_materia = paired_set[3]
      if materia.special_effect == 'All'
        for skill_id in other_materia.skills
          if skill_id == @skill.id
            # Duplicates Skill and Changes ID
            new_skill = @skill.dup
            new_skill.scope = 2 if @skill.scope == 1
            new_skill.scope = 4 if @skill.scope == 3 || @skill.scope == 7
            new_skill.scope = 6 if @skill.scope == 5
            new_skill.id = $data_skills.size
            $data_skills << new_skill
            @active_actor.learn_skill(new_skill.id)
            # Set action
            @active_actor.current_action.skill_id = new_skill.id
            # End skill selection
            end_skill_select
            # End enemy selection
            end_enemy_select unless @enemy_arrow.nil?
            # End actor selection
            end_actor_select unless @actor_arrow.nil?
            # Go to command input for next actor
            phase3_next_actor
As far as I can gather, what the script does is copy the skill but modifies the scope of the skill so it attacks all the enemies instead of just one, and makes the actor use the new skill instead of the old one. However, what it appears to do in the game is repeatedly copy the same skill over and over and over each time the ATB guage fills up (I think).
 
module RPG
 
  #============================================================================
  # ** Weapon
  #============================================================================
  class Weapon
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :paired_materia
    attr_accessor :single_materia
    #--------------------------------------------------------------------------
    # * Set Materia Slots
    #--------------------------------------------------------------------------
    def set_materia_slots(slots)
=begin
  --> Line 84 =end    @paired_materia, @single_materia = slots[0], slots[1]
    end
  end
 
  #============================================================================
  # ** Armor
  #============================================================================
  class Armor
    #--------------------------------------------------------------------------
    # * 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
end

this is the portion that does not work for me, it says "undefined method '[]' for nil:NilClass Line 84
 

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