Script that grabs a skill users Actor ID?

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
153
Reaction score
57
First Language
English
Primarily Uses
RMMV
Hello! I'm implementing a "win quote" screen similar to something you'd see in a KOF game. The way these screens usually work, is that you pick a team of three characters and whichever of those three characters wins the match, gets their unique quote shown at the end of a fight.

My theorized way of going about this, was to simply make a single common event that sets the chosen variable to the actors ID, and apply it to every player skill. That way, whoever ended the fight, would have the variable set to them. However, I have no idea how to go about grabbing the ID of a skills user.

Anyone got any insight for this? Thank you in advance!
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
341
Reaction score
252
First Language
English
Primarily Uses
RMMZ
What you're proposing (checking the actor ID after each skill use and presumably updating a variable continually) would work. But since it sounds like you only care about checking that information when you win the battle, you can do so when you actually win. BattleManager still knows the current subject when the victory stuff gets processed.

JavaScript:
_BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
    var actorId = BattleManager._subject._actorId;
    _BattleManager_processVictory.call(this);
};
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
153
Reaction score
57
First Language
English
Primarily Uses
RMMV
What you're proposing (checking the actor ID after each skill use and presumably updating a variable continually) would work. But since it sounds like you only care about checking that information when you win the battle, you can do so when you actually win. BattleManager still knows the current subject when the victory stuff gets processed.

JavaScript:
_BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
    var actorId = BattleManager._subject._actorId;
    _BattleManager_processVictory.call(this);
};
Thanks for the reply! I'm still pretty new to javascript so I'm not exactly sure how to apply the code.

Is the actual ID being stored in actorId or _BattleManager_processVictory in this result? I tried using either and my variable either turns into a "function" or stays at zero.

I put the script in the win condition of a battle process, but perhaps when you mean "win the battle" am I supposed to apply it in the actual troop menu for it to count?
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
341
Reaction score
252
First Language
English
Primarily Uses
RMMZ
BattleManager.processVictory is the JavaScript function that the game runs by default when you win a battle. The code I posted hooks into that function and checks the actor ID of the current subject. From there, you can do whatever you want with that information.

In terms of application, you could copy the following code to a text editor, save it as a .js file, and install it as a plugin:
JavaScript:
_BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
    var actorId = BattleManager._subject._actorId;
    $gameVariables.setValue(1, actorId);
    _BattleManager_processVictory.call(this);
};
Each time you win a battle, the 1st game variable will be updated with the ID of the acting actor. Which, if I'm understanding your OP correctly, is what you're trying to accomplish.

You can change the 1 in $gameVariables.setValue(1, actorId) to whatever number variable you would like to use to store the actor ID.

You could then use that stored actor ID to do other things with events or other plugins.
 

KingKraken

Veteran
Veteran
Joined
Apr 2, 2015
Messages
153
Reaction score
57
First Language
English
Primarily Uses
RMMV
BattleManager.processVictory is the JavaScript function that the game runs by default when you win a battle. The code I posted hooks into that function and checks the actor ID of the current subject. From there, you can do whatever you want with that information.

In terms of application, you could copy the following code to a text editor, save it as a .js file, and install it as a plugin:
JavaScript:
_BattleManager_processVictory = BattleManager.processVictory;
BattleManager.processVictory = function() {
    var actorId = BattleManager._subject._actorId;
    $gameVariables.setValue(1, actorId);
    _BattleManager_processVictory.call(this);
};
Each time you win a battle, the 1st game variable will be updated with the ID of the acting actor. Which, if I'm understanding your OP correctly, is what you're trying to accomplish.

You can change the 1 in $gameVariables.setValue(1, actorId) to whatever number variable you would like to use to store the actor ID.

You could then use that stored actor ID to do other things with events or other plugins.
Ah, I was overthinking it by a large margin, haha. This works straight out of the box!
Thanks for the patience and efforts!
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
341
Reaction score
252
First Language
English
Primarily Uses
RMMZ
You’re welcome!
 

Latest Threads

Latest Posts

Latest Profile Posts

I have made 60 new skills! ''after test'' I have made 3 new skills!

Made a new battleback this week! How's it look?
"This is the real secret to life - To be completely engaged with what you are doing in the here and now. And instead of calling it work, realize it is play."
Me: "I don't to use other engines because I'd have to do a lot of coding."

Also my desktop right now....
mycurrentdesktop.jpg

...I literally spend more time using VS Code than MZ. :kaoswt:

Forum statistics

Threads
113,813
Messages
1,077,661
Members
147,869
Latest member
asdfd
Top