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.

how to tell if actor is in party?

Status
Not open for further replies.
I've been cleaning up some old scripts, and one of the things I never figured out was how to tell if an actor was in the party.

I have an active/reserve party system, and right now, I'm using switches to control everything (bad, i know).

So, does anyone know what conditional or bool indicates whether an actor is in the active party?
 
add in a new script above main

Code:
class Game_Party
  def has_actor?(actor_id)
    # Setup Array
    actor_ids = []
    # Get All Actor IDs
    @actors.each {|actor| actor_ids << actor.id}
    # If All Actors included
    return actor_ids.include?(actor)
  end
end

now you can do

$game_party.has_actor?(actor_id)

where actor_id is the actor's id to check
 
You made that way to difficult Trickster.

Code:
class Game_Party
  def has_actor?(actor_id)
    @actors.each {|a| return true if a.id == actor_id}
    return false
  end
  def has_actors?(*ids)
    i = ids.size
    @actors.each {|a| i -= 1 if ids.include?(a.id)}
    return i == 0
  end
end

:p
 

ccoa

Member

This topic has been resolved. If lambchop 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