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.

Change leader of party

Status
Not open for further replies.

Jason

Awesome Bro

I've seen this somewhere before but cannot find it when I search, what it is, is when you change the party formation, whoever is first in the party, is the one who walks around on the map.
 

poccil

Sponsor

The actor located at index 0 of $game_party.actors is considered the "leader" of the party.  Therefore, the idea here is to move the actor to index 0 of the party. Here's how you can change the leader:
Code:
def makeLeader(actorID) # Makes the actor with ID _actorID_ the leader
 added=false
 for i in 0...$game_party.actors.size
  if $game_party.actors[i].id==actorID
   actor=$game_party.actors.delete_at(i)
   $game_party.actors.unshift(actor)
   added=true
  end
 end
 if !added
  # Add actor to party
  $game_party.actors.unshift($game_actors[actorID])
  # Maximum 4 party members
  while $game_party.actors.length>4
   $game_party.actors.delete_at(4)
  end
 end
 # Refresh player
 $game_player.refresh
end

The example below changes the first actor to actor 2 (which, by default, is Basil):
Code:
makeLeader(2)
 

poccil

Sponsor

You must have misunderstood.  The big block of code above is meant to be placed in a new script section just before the last one. 
The example, "makeLeader(2)", is meant to be placed in a Script event command.  You should edit the number contained in "makeLeader(2)" within that Script event command.
 
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