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.

$game_party.actors[]

Hi, first of all sorry I know I have posted here a lot today.

I am making a menu system and... am having a bit of trouble.

This is the Limit Break part, or what is done of it so far:

Code:
class Window_LimitCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(actor)
    super(6, 60, 182, 62)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    @commands = []
    @actor = $game_party.actors[actor].actor_id
    @commands.push("Sonic Slash") if @actor = 1 and $actor1limit <= 0
    @commands.push("Chaotic Fury") if @actor = 1 and $actor1limit <= 1
    @commands.push("Meteora") if @actor = 1 and $actor1limit <= 2
    @commands.push("Final Blow") if @actor = 1 and $actor1limit <= 3
    @commands.push("Heavenly Touch") if @actor = 2 and $actor1limit <= 0
    @commands.push("Blessings") if @actor = 2 and $actor1limit <= 1
    @commands.push("Hell Hath no Fury") if @actor = 2 and $actor1limit <= 2
    @commands.push("Nature's Fury") if @actor = 2 and $actor1limit <= 3
    @commands.push("Triple Slash") if @actor = 3 and $actor1limit <= 0
    @commands.push("Fury Blow") if @actor = 3 and $actor1limit <= 1
    @commands.push("Last Resort") if @actor = 3 and $actor1limit <= 3
    @commands.push("Vow of Silence") if @actor = 3 and $actor1limit <= 2
    @item_max = 4
    @column_max = 2
    self.active = false
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text character color
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Cursor Rectangle Update
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(160 + index * 160, 0, 128, 32)
  end
end

I know I have probably done it all wrong but... oh well. ':|

The bit I am stuck on is this. I need to find out what the ID of a character in the party is.

@actor = $game_party.actors[actor].actor_id

But I get the error "cannot convert Game_Actor into an Integer".

Anyone know what the proper syntax is?
 
$game_party.actors is an array with at maximum 4 elements. You have to take care to not index a nil element inside it. For the sake of an example, try that:
Code:
# The first actor in the party
$game_party.actors[0].id
You can use it for any actor in $game_actors, but it´s somehow pointless (because they´re indexed by their ID´s), unless you´ve got an object from it or simply can´t reach the index you used at a first time. Syntax?
Code:
# Check for Arshes
index = 1
aluxes = $game_actors[index]
print index == aluxes.id     # => true
And avoid to use the $data variables. They´re static, and holds data that can change each time you mess up with the database. Also, $data and $game holds completely different object types, so a method used for one of its objects may not be used for the other.

Is that what you want? If not, just ask.
 
Basically, what I am trying to do is have a selectable command window which has different commands in it depending on what character it is. So I need it to find out the database ID of the character in the party whose party id is "actor". (Actor is defined when it is called).

If you have ever played Final fantasy VII, I am trying to recreate the Limit Break part of that menu system.
 
I´ve never played it ^^

Haven´t got it well... If you want to check the database id of any character in the party, use
Code:
$game_party.actors[<actor_position>].id
Where <actor_position> is the position of the actor in the party.
 
It is still not working :(.

(I smartened up the code a bit to see it better) it's like this:

Code:
    @actor = $game_party.actors[actor].id
    @commands.push("Sonic Slash")       if @actor == 1 and $actor1limit <= 0
    @commands.push("Chaotic Fury")      if @actor == 1 and $actor1limit <= 1
    @commands.push("Meteora")           if @actor == 1 and $actor1limit <= 2
    @commands.push("Final Blow")        if @actor == 1 and $actor1limit <= 3
    @commands.push("Heavenly Touch")    if @actor == 2 and $actor2limit <= 0
    @commands.push("Blessings")         if @actor == 2 and $actor2limit <= 1
    @commands.push("Hell Hath no Fury") if @actor == 2 and $actor2limit <= 2
    @commands.push("Nature's Fury")     if @actor == 2 and $actor2limit <= 3
    @commands.push("Triple Slash")      if @actor == 3 and $actor3limit <= 0
    @commands.push("Fury Blow")         if @actor == 3 and $actor3limit <= 1
    @commands.push("Last Resort")       if @actor == 3 and $actor3limit <= 3
    @commands.push("Vow of Silence")    if @actor == 3 and $actor3limit <= 2

Basically, if the actor id is 1 and a variable is 0 or above, it adds "Sonic Slash" to the list of commands. Sonic Slash being a "limit break", or a special attack, which is unique to that character.

It still gets the error that Game_Actor cannot be converted to an integer.
 
I called this method in a map event:
Code:
def test
  @commands = []
  actor = 0
  $actor1limit = 0
  @actor = $game_party.actors[actor].id
  @commands.push("Sonic Slash")       if @actor == 1 and $actor1limit <= 0
  @commands.push("Chaotic Fury")      if @actor == 1 and $actor1limit <= 1
  @commands.push("Meteora")           if @actor == 1 and $actor1limit <= 2
  @commands.push("Final Blow")        if @actor == 1 and $actor1limit <= 3
  @commands.push("Heavenly Touch")    if @actor == 2 and $actor2limit <= 0
  @commands.push("Blessings")         if @actor == 2 and $actor2limit <= 1
  @commands.push("Hell Hath no Fury") if @actor == 2 and $actor2limit <= 2
  @commands.push("Nature's Fury")     if @actor == 2 and $actor2limit <= 3
  @commands.push("Triple Slash")      if @actor == 3 and $actor3limit <= 0
  @commands.push("Fury Blow")         if @actor == 3 and $actor3limit <= 1
  @commands.push("Last Resort")       if @actor == 3 and $actor3limit <= 3
  @commands.push("Vow of Silence")    if @actor == 3 and $actor3limit <= 2
  p @commands
end
And found no errors. Maybe that actor variable you´re trying to use has a Game_Actor object.

OH now i think i got what´s your question... Wait i´ll try out a solution for you...

Try adding this in any script above main and below Game_Party:
Code:
class Game_Party
  # Must pass a Game_Actor object
  # Returns the id of the actor relative to his/her party position
  # If he/she´s not in the party, returns nil
  def actor_in_party?(actor)
    for i in 0...@actors.size
      return i if @actors[i].id == actor.id
    end
  end
  
end
Now, each time you have a Game_Actor and want to know if he´s in the party and the position where he is, just use
Code:
$game_party.actor_in_party?(actor_object)
Where actor_object can be, for example:
Code:
actor_object = $game_actors[1] # For Arshes
Now turning back to my example, we should try:
Code:
def test
  @commands = []
  actor = $game_actors[1] # For Arshes
  index = $game_party.actors[actor]
  return if index.nil?  # If index is equal to nil there´s nothing more to do, RETURN
  @actor = $game_party.actors[index]
  $actor1limit = 0
  @actor = $game_party.actors[actor].id
  @commands.push("Sonic Slash")       if @actor == 1 and $actor1limit <= 0
  @commands.push("Chaotic Fury")      if @actor == 1 and $actor1limit <= 1
  @commands.push("Meteora")           if @actor == 1 and $actor1limit <= 2
  @commands.push("Final Blow")        if @actor == 1 and $actor1limit <= 3
  @commands.push("Heavenly Touch")    if @actor == 2 and $actor2limit <= 0
  @commands.push("Blessings")         if @actor == 2 and $actor2limit <= 1
  @commands.push("Hell Hath no Fury") if @actor == 2 and $actor2limit <= 2
  @commands.push("Nature's Fury")     if @actor == 2 and $actor2limit <= 3
  @commands.push("Triple Slash")      if @actor == 3 and $actor3limit <= 0
  @commands.push("Fury Blow")         if @actor == 3 and $actor3limit <= 1
  @commands.push("Last Resort")       if @actor == 3 and $actor3limit <= 3
  @commands.push("Vow of Silence")    if @actor == 3 and $actor3limit <= 2
  p @commands
end
Hope you got it... Or if i have answered correctly to your question.
 
Sorry i made a mistake on the example ^^
Code:
class Game_Party
  # Must pass a Game_Actor object
  # Returns the id of the actor relative to his/her party position
  # If he/she´s not in the party, returns nil
  def actor_in_party?(actor)
    for i in 0...@actors.size
      return actor.id if @actors[i].id == actor.id
    end
    return nil
  end
  
end

Code:
def test
  @commands = []
  actor = $game_actors[1] # For Arshes
  index = $game_party.actor_in_party?(actor)
  return if index.nil?  # If index is equal to nil there´s nothing more to do, RETURN
  $actor1limit = 0
  @actor = actor.id
  @commands.push("Sonic Slash")       if @actor == 1 and $actor1limit <= 0
  @commands.push("Chaotic Fury")      if @actor == 1 and $actor1limit <= 1
  @commands.push("Meteora")           if @actor == 1 and $actor1limit <= 2
  @commands.push("Final Blow")        if @actor == 1 and $actor1limit <= 3
  @commands.push("Heavenly Touch")    if @actor == 2 and $actor2limit <= 0
  @commands.push("Blessings")         if @actor == 2 and $actor2limit <= 1
  @commands.push("Hell Hath no Fury") if @actor == 2 and $actor2limit <= 2
  @commands.push("Nature's Fury")     if @actor == 2 and $actor2limit <= 3
  @commands.push("Triple Slash")      if @actor == 3 and $actor3limit <= 0
  @commands.push("Fury Blow")         if @actor == 3 and $actor3limit <= 1
  @commands.push("Last Resort")       if @actor == 3 and $actor3limit <= 3
  @commands.push("Vow of Silence")    if @actor == 3 and $actor3limit <= 2
  p @commands
end

I somewhat made that in a rush.
 

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