Help - Search - Members - Calendar
Full Version: Actor Position in Party?
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
FunkyPurpleDuck
So I'm trying to set up a common event with a conditional branch that depends upon a certain actors position in the party. That is to say, whether the actor is the in the first, second, third, or forth slot in the party's formation. Trouble is, there's no such condition in conditional branches, and I can't find a way to set a variable to match an actors position, either. Is there any way to do this?

The reason, if it matters, is because I'm setting up a skill that basically makes the character attack twice in a row. I'm doing that by having it set off a common event that uses Force Action to have him attack a random target twice. But since Force Action identifies the actor by position, and the character may not always be in the same position (I have a script for party changing), I need some way to set up a variable or something.
Callista
I'm not sure what you want exactly, but if you want to check which position your actor is in, paste this above Main:
CODE
class Game_Actor
  attr_reader :actor_id
end

class Game_Party
  def get_actor_position(actor_id)
    for i in actors
      return i.index if i.actor_id == actor_id
    end
  end
end


get_actor_position(actor_id) will return the party position of actor with database ID actor_id, possible values being 0, 1, 2 or 3. You can call it in a Conditional Branch with the Script option, like so:

CODE
@>Conditional Branch: Script: $game_party.get_actor_position(1) == 0
will check if Aluxes is in the first position of the party.
FunkyPurpleDuck
I must be doing something wrong, as it doesn't seem to be doing anything. Is there something I have to do to call the script before I start the conditional branch, or should the value inside "get_actor_position(actor_id)" already be set by the script?
Callista
It's working for me. You can test it out with a simple event, like this:



That will make the event speak if Aluxes is in the first party position.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.