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!
Conditional branch: If First turn of battle..
● ARCHIVED · READ-ONLY
-
-
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. -
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? -
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 -
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 >.< -
= is setting.
=== is comparing.
This
Code:should be a part of it, but there's obviously more.$gameTroop._turnCount === 1
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. -
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 :)
-
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.