Unidentified modifier 'index' (Earthbound-ish Battle System Sprite Add-on)

Joined
May 30, 2014
Messages
23
Reaction score
1
First Language
English
Primarily Uses
Hey there! So when I add more than 5 characters for use with YanFly's party system, but when I do and enter a battle it shows me this:

Script 'Sprite Addon' line 131: NoMethodError occured.
undefined method 'index' for nil:NilClass
 

self.x = @battler.index * 128 + sx / 2 + 60 + 32 * (4 - $game_party.members.size)This is a weird error because this line determines the sprite's position. Any idea on how to fix this?

 

Code:
#==============================================================================# ** Earthbound-Ish Sprite Display#------------------------------------------------------------------------------# Version: 1.0# Author: cozziekuns # Date: February 17, 2013#==============================================================================# Description:#------------------------------------------------------------------------------# This script attempts to emulate the battle system of the Earthbound/Mother # series; most notably Earthbound and Earthbound 2 (Mother 2 and 3). This # certain addon addresses the character sprite movements found in Mother 3, # where active actors bobbed up and down the screen.#==============================================================================# Instructions:#------------------------------------------------------------------------------# Paste this script into its own slot in the Script Editor, above Main but # below Materials. #==============================================================================#==============================================================================# ** BattleManager#==============================================================================class << BattleManager    alias coz_ebishspd_btlmngr_init_members init_members  def init_members(*args)    coz_ebishspd_btlmngr_init_members(*args)    @dummy_battler = nil  end    def dummy_battler    @dummy_battler  end    def next_subject    loop do      battler = @action_battlers.shift      unless battler        @dummy_battler = nil        return nil      end      next unless battler.index && battler.alive?      @dummy_battler = battler      return battler    end  end  end#==============================================================================# ** Game_Actor#==============================================================================class Game_Actor    def use_sprite?    true  end  end#==============================================================================# ** Sprite_BattlerCharacter#==============================================================================class Sprite_BattlerCharacter < Sprite_Battler    def initialize(viewport, battler = nil)    super(viewport, battler)    @y_offset = 0  end    def make_animation_sprites    @ani_sprites = []    @ani_duplicated = @@ani_checker.include?(@animation)    if !@ani_duplicated && @animation.position == 3      @@ani_checker.push(@animation)    end  end    def update    super    update_position    update_zoom    update_y_offset  end    def update_bitmap    new_bitmap = set_character_bitmap    if bitmap != new_bitmap      self.bitmap = new_bitmap      init_visibility    end    update_src_rect  end    def set_character_bitmap    bitmap = Cache.character(@battler.character_name)    sign = @battler.character_name[/^[\!\$]./]    if sign && sign.include?('$')      @cw = bitmap.width / 3      @ch = bitmap.height / 4    else      @cw = bitmap.width / 12      @ch = bitmap.height / 8    end    self.ox = @cw / 2    self.oy = @ch    bitmap  end    def update_origin    if bitmap      self.ox = @cw / 2      self.oy = 0    end  end    def update_src_rect    index = @battler.character_index    sx = (index % 4 * 3 + 1) * @cw    sy = (index / 4 * 4) * @ch     self.src_rect.set(sx, sy, @cw, @y_offset)  end    def update_position    width = Graphics.width / ( 4 / $game_party.members.size.to_f )    sx = (Graphics.width - width) / 2 + 128    self.x = @battler.index * 128 + sx / 2 + 60 + 32 * (4 - $game_party.members.size)    self.y = 363 - @y_offset * 2   end    def update_zoom    self.zoom_x = 2.0    self.zoom_y = 2.0  end    def update_y_offset    if BattleManager.actor == @battler or BattleManager.dummy_battler == @battler      @y_offset = [@y_offset + 4, 32].min    else      @y_offset = [@y_offset - 4, 0].max    end  end  end#==============================================================================# ** Spriteset_Battle#==============================================================================class Spriteset_Battle    def create_actors    @actor_sprites = $game_party.members.collect { |actor|      Sprite_BattlerCharacter.new(@viewport3, actor)     }  end  end
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Can you take a look at this value in YanFly's Script?

module YEA    module PARTY        MAX_BATTLE_MEMBERS   = 5        <...>    endend
If it's higher than 5, see if this is higher than 0:

Code:
MAX_MEMBERS_VARIABLE = 0
 
Joined
May 30, 2014
Messages
23
Reaction score
1
First Language
English
Primarily Uses
I made sure to set MAX_BATTLE_MEMBERS to 4, but I will look at the MAX_MEMBERS_VARIABLE when I get a chance.

EDIT: MAX_MEMBERS_VARIABLE is set to 0
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
You should set it to 6 or higher (whatever the number of actors is you can have in combat). If that number changes during gameplay, use the variable and modify it accordingly.
 
Last edited by a moderator:
Joined
May 30, 2014
Messages
23
Reaction score
1
First Language
English
Primarily Uses
I want to have only 4 actors in combat, does it have to be 6+?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
I want to have only 4 actors in combat, does it have to be 6+?
The problem is that the error you reported usually indicates that you have more than 4 battlers, because the sprites for the first four battlers are regular for the script.

And at the beginning you were talking about adding five characters...

If you have max battler set to four and still get the error, then most probably it's an incompatibility between the scripts - that the party system changes the way how the indices for the battle members are handled (automatically 1-4 in default), and that the sprite addon doesn't expect the way the party system handles the indices.
 
Joined
May 30, 2014
Messages
23
Reaction score
1
First Language
English
Primarily Uses
Ah I see how I was unclear. My plan was to have many actors that can be switched out, but you can only have 4 in a battle at a time. I think you're right about the scripts not being compatible though, thanks Andar!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top