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.

Skill learning by party composition

Status
Not open for further replies.
Question from a confused beginner, because I can't find anything in the support or tutorials that quite seems to fix my problem.

Okay, in my project I have a character whose skills change depending on who else is in the party with him. Foolishly thinking "I can do this!", the way I've been trying to implement it is by checking $game_party.actors for actor IDs, like so:

if $game_party.actors.include?(1)

. . . and that's where it snags. I know I'm definitely doing something wrong with the syntax or setup, because that generates a no method error for that line (undefined method 'actors' for nil:NilClass).

I'm more hoping someone can clear up my confusion on this, I thought that the global variables and their related methods could be called from any script at any time? If not, what can I do differently; and if so, where am I farking up royally?

Ta.
 
I'll script this and then edit my post (unless you post before I'm done) but you're probably calling $game_party before it's been created or something.

Edit: I'm really dense sometimes:
if $game_party.actors.include?($game_actors[1])
should work but I'll still script it in a minute.

Edit again:
Ok I scripted it:
Code:
class Game_Actor < Game_Battler
  
  def skills
    unless self.id == 1
      return @skills
    end
    x = @skills.clone
    if $game_party.actors.include?($game_actors[7])
      x.push(1)
    end
    
    x.sort!
    return x
  end
  
  def skill_learn?(skill_id)
    return self.skills.include?(skill_id)
  end
  
end
If you know basic scripting you should understand how to edit it.
If not or you want to ask about anything just ask me ok?
 
Understand most of that, cheers, can see where to put the skills and other actor IDs - just to check one thing, is self.id the ID of the actor who learns the skills? I.e. for actor 3 should I change that to 3?

EDIT: Never mind, I've tried it out and it works like a charm. Many thanks. :D
 
This topic has been resolved. If fortysixand2 or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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