Get Actor's Index based on dynamic Actor ID in battle

Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Hey guys!


This one seems simple but I just can't figure it out.


How do we store Index of an Actor with Actor ID X in variable? Where X is an another game variable.


It is very easy if the X is constant but how if it isnt?


I dont think $game_actors[$game_variable[55]].index will work....


Please help, thanks!
 

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
219
First Language
English
Primarily Uses
RMVXA
Something like this, I guess.


$game_variables[1] = Actor_ID # ID of actor whose index we want.
$game_variables[2] = Actor_Index # Where we'll store the index.
$game_party.members.each do |member|
$game_variables[2] = member.index if member.id == $game_variables[1]
end


In battle, an actors index will be based on their position in the party, starting from 0.


The problem with using global variables is that they default to 0, so if the Actor ID


isn't present in battle, the index value would default to 0 (the first member).



Its not difficult to get around this drawback, but without some context into what you're


attempting to accomplish, I'm not sure if it's even necessary.
 
Last edited by a moderator:
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Something like this, I guess.



$game_variables[1] = Actor_ID # ID of actor whose index we want.
$game_variables[2] = Actor_Index # Where we'll store the index.
$game_party.members.each do |member|
$game_variables[2] = member.index if member.id == $game_variables[1]
end


In battle, an actors index will be based on their position in the party, starting from 0.


The problem with using global variables is that they default to 0, so if the Actor ID


isn't present in battle, the index value would default to 0 (the first member).



Its not difficult to get around this drawback, but without some context into what you're


attempting to accomplish, I'm not sure if it's even necessary.
Alright, thanks! I got the way around this method actually... But thanks for you reply
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I dont think $game_actors[$game_variable[55]].index will work....


That's actually almost exactly what you do.  Except it's $game_variables (plural) rather than $game_variable.


If your actor ID is in variable 55, that will return the spot in the party lineup that the actor occupies.  Remember the first person / leader is 0, not 1.
 
Joined
Aug 6, 2016
Messages
95
Reaction score
5
First Language
English
Primarily Uses
Alright thanks! (I haven't tried it because I found a better method for my game  than doing  this, but still maybe I'll need that sometime in the future)
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top