Conditional branch: If First turn of battle..

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
I'm trying to make a check through a common event if it's the first turn in the battle or not.
However, I have no clue where I can find the script to say that.

Doing it through the battle pages is not really an option, since this event needs to be triggered through an attack(If that attack happens on the first turn AND if the hero has 30 TP or less, THEN)(Oh, and some switches need to be on as well to work, so you know.).

And.. for future reference: how can I find these kinds of lines myself? I am aware of the script call list's existence, but I often find myself looking for scripts calls I can't find in there. Usually google does the trick, but this time, I'm having a really hard time finding the answer..

Thanks in advance!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
Do you have a plugin that allows common events to run during battle? By default, they do not.

I don't have MV with me so can't attempt to look it up for you, but I don't think this one would be easy to find online. If you're comfortable with Javascript, head to the rpg_objects.js or maybe the rpg_managers.js scripts and see if you can find the logic where it processes troop event pages. That will have the code behind the Turn X condition, which you should be able to copy & modify to suit your needs.
 

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
Thanks for responding!
I call the common event through the use of an attack, so I don't need a plugin for that luckily.

Okay, with your help, I think I found the code but how do I use it?

I got this from the rpg_managers.js
Code:
BattleManager.isInTurn = function() {
    return this._phase === 'turn';
};
I did not know how to use the code properly, so I tried a few things..

http://prntscr.com/lip56j

Which does activate in battle, whenever I use attack. Only all three options activate at all turns, instead of just turn one, so I'm figuring I am making a silly mistake somewhere?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
No, I don't think that's what you're after.

Take a look in rpg_objects.js at Game_Troop.prototype.meetsConditions. It looks like it might have something to do with $gameTroop._turnCount
 

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
Hm.. I've tried it, but I keep getting the same issue: it works the first round, but also for round 2/3/4 etc..

I tried

$gameTroop._turnCount = 1
$gameTroop.turnCount = 1
$gameTroop._turnCount == 1
$gameTroop.turnCount == 1
$gameTroop._turnCount === 1
$gameTroop.turnCount === 1

But nothing seems to work >.<
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
= is setting.
=== is comparing.

This
Code:
$gameTroop._turnCount === 1
should be a part of it, but there's obviously more.

I'm afraid I don't have time to look into it any further. Compare what is on a troop event page, in the conditions, and see what parts of that function are involved:
Code:
    if (c.turnValid) {
        var n = this._turnCount;
        var a = c.turnA;
        var b = c.turnB;
        if ((b === 0 && n !== a)) {
            return false;
        }
        if ((b > 0 && (n < 1 || n < a || n % b !== a % b))) {
            return false;
        }
    }
Maybe go to the trouble of setting it up IN a troop event first, to make sure it triggers when you want it to. Then see what's in those variables and what you have to add to your test to get it working via script.
 
  • Like
Reactions: MrB

MrB

Veteran
Veteran
Joined
Nov 7, 2018
Messages
58
Reaction score
52
First Language
C#
Primarily Uses
RMMV
Thank you for your time Shaz, you've been a huge help already. I'll see if I can pick it up from this point on :)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
The other option is checking Yanfly's battle plugins. I really have zero knowledge of them, apart from the fact that they're really flexible. There might be something there that will allow you to do it, but it would require adding the battle core and potentially extra plugins if you find one with the required functionality.
 
  • Like
Reactions: MrB

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top