Script call for the currently active battler

Daemoshiin

Villager
Member
Joined
Aug 2, 2017
Messages
17
Reaction score
2
First Language
English
Primarily Uses
N/A
Done a quick scan for this, doesn't seem to be on the big script call page so here it is.
I'm trying to get information from an enemy before it begins any attacks and add it to a variable, in particular its Luck stat.
The call I'm using at the moment is this:

$gameTroop.members()[0].luk

However that only takes the luck stat of whoever the first enemy listed in the troop is.
I need to find out how to only add the luck of the currently active enemy (The one about to attack) so that I can change this variable to different things depending on the enemy.

Am I missing something super obvious again?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,190
Reaction score
1,167
First Language
Spanish
Primarily Uses
RMVXA
the active battler at moment level is handled by the battle manager.
I don't remember specifically the code, but look into the battle manager, and you'll see it's written as always "battler vs target", regardless of which is which.
to find the *battler* at any moment, read the main loop, because it changes depending on the attacking side, and since it changes, it's *assigned*, and you can spot that assignment.

I'm sure it can be pulled via a simple call, and that call must be defined as a subroutine, so it has to be it's own section there.
 

Daemoshiin

Villager
Member
Joined
Aug 2, 2017
Messages
17
Reaction score
2
First Language
English
Primarily Uses
N/A
Had a good old scrape through the Battle Manager, as well as the multitude of plugins I have that are interacting with it, but can't find anything that specifically refers to the enemy who is doing stuff.
Or if it does, i just have no idea how to make it a script call in a variable increase event.

Sticking .luk on the end of random script snippets doesn't seem to be working either, hah
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
The order in which battlers will act is calculated when the turn starts based on random number generation and influenced by agi, so you'd need to insert something in there.

Code:
BattleManager.makeActionOrders = function() {
    var battlers = [];
    if (!this._surprise) {
        battlers = battlers.concat($gameParty.members());
    }
    if (!this._preemptive) {
        battlers = battlers.concat($gameTroop.members());
    }
    battlers.forEach(function(battler) {
        battler.makeSpeed();
    });
    battlers.sort(function(a, b) {
        return b.speed() - a.speed();
    });
    this._actionBattlers = battlers;
};
This is the point at which BattleManager knows the order of battlers for the turn.
 
Last edited:

Daemoshiin

Villager
Member
Joined
Aug 2, 2017
Messages
17
Reaction score
2
First Language
English
Primarily Uses
N/A
I realise now how awkward this is, if only due to the fact that it's randomly and dynamically decided, and thus the base system doesn't really know whose turn it is - At least not in a way that you can actually see without running the game first.

Not sure if this information will help anyone, but I eventually dropped the following into one of the plugins I had, one that drew windows for each battler to display their health and whatnot, as I figured that plugin would understand how to check the current battler.

Code:
$gameVariables.setValue(133, this._entity.battler().luk);
Sets a variable to their luck stat, and then I can just add the two together after calculations.
Thanks for the help anyways!
 
Last edited:

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,190
Reaction score
1,167
First Language
Spanish
Primarily Uses
RMVXA
but can't find anything that specifically refers to the enemy who is doing stuff.
because *the enemy doing stuff* is at times *the attacker*.
that's why you need to read the thing and find the mentions to *the attacker*, and find the point at which *the attacker* becomes *Enemy nº X*
that's *the assignment* I was talking about.... that assignment happens at some point, so that's the event I'd use to find my way in.
you have a number of ways in: that event, the checking for "moment" through the battle event system, the calculation of damage, the checking of skills, etc.
since the battle system is written as a collection of comparisons between "attacker" and "defender", once you find that comparison, you can track both attacker and defender through the code and spot where the actual character from either the party or the troop becomes an attacker or defender.
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,343
Reaction score
1,226
First Language
English
Primarily Uses
RMMV
Depending on what you're trying to do and when, try either of these:

Code:
BattleManager._subject
BattleManager.getNextSubject()
To make sure it doesn't throw any errors due to null values:

Code:
BattleManager._subject ? BattleManager._subject.luk : 0
// or
BattleManager.getNextSubject() ? BattleManager.getNextSubject().luk : 0
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
because *the enemy doing stuff* is at times *the attacker*.
that's why you need to read the thing and find the mentions to *the attacker*, and find the point at which *the attacker* becomes *Enemy nº X*
that's *the assignment* I was talking about.... that assignment happens at some point, so that's the event I'd use to find my way in.
you have a number of ways in: that event, the checking for "moment" through the battle event system, the calculation of damage, the checking of skills, etc.
since the battle system is written as a collection of comparisons between "attacker" and "defender", once you find that comparison, you can track both attacker and defender through the code and spot where the actual character from either the party or the troop becomes an attacker or defender.
The system doesn't track turn order in a way other code can reference, though. So there isn't really a concept of "the first enemy to be doing stuff" unless you code in an assignment for it.

Edit: Actually Aesica's suggestion would work (though you'd have to iterate through _actionBattlers until you find the first enemy)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
503
Reaction score
220
First Language
English
Primarily Uses
RMMV
I think you misunderstood something, Trihan? I don't think he was asking for the first enemy in the turn order...
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,382
Reaction score
1,567
First Language
English
Primarily Uses
RMMV
Ohh, the original post made it sound like this was just meant to be an effect that differed depending on which enemy attacked first.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How do you cure sleep problem? It has been 7 months and it's 3 AM now..
Darn you, Seals! Why do you gotta be so cute when on land?:kaoluv:
So dragonbones getting laggy xD
I even removed the fingers armatures.

Have to remake this guy after crashing ( corrupted file).
:rtear:

Although limited to only this shop for room decorations, I like this aspect for previewing items.
So yesterday I got a follower (follow my NSFW art account) who dmed me and said to me :
if you continue to be friends with [name of the artists] which make me uncomfortable I will have to unfollow and I am like :
... do it?

Forum statistics

Threads
100,837
Messages
980,115
Members
132,485
Latest member
jenifer027
Top