Turn Order Calculations

If you are stuck in the Dunan Unification Wars; or wish for more details on the gameplay systems, this is the place.
Post Reply
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Turn Order Calculations

Post by Omnigamer »

One of the last big mysteries that I've been trying to work out is exactly how turn order works. On the surface, it just selects based on character speed. Things get tricky once magic is introduced, however. For example, some characters will move much earlier than they should when taking part in Rune Unite attacks. Not only that, but the type of magic also seems to play a role. I've had cases of one character going first while casting Thor, for example, but goes third when casting Water Dragon with an otherwise identical team and setup. In that same situation, having Riou cast Battle Oath will almost always let him go first.

So suspect that the actual turn order depends not only on a character's speed, but also some otherwise unmentioned speed constant for particular spells or moves. For example, I think Thor may have an additional speed constant of 41, based on my very limited testing. This is from a unique situation where Flik and Sierra were at 136 and 137 SPD, respectively, and they cast Thor on the same turn as Luc (178 SPD) casts Water Dragon. In this case, casting order is Flik -> Luc -> Sierra. If Luc instead casts Thor as well, he goes first every time. Character speed may also gain 0-3 points in a turn due to the RNG; I'm not entirely sure on this yet, but I'd also like to figure that out.

Pyriel, if you know where to look in regards to figuring out turn order, that would be really helpful. I tried debugging my way through it but couldn't find anything definitive.

Anybody else, I'd appreciate it if you could do some mild testing as well. Even figuring out that Magic A always goes before Magic B for two characters with the same SPD stat is helpful in determining some variety of pecking order.
User avatar
gildedtalon
Posts: 1343
Joined: Thu Mar 18, 2010 12:15 am

Re: Turn Order Calculations

Post by gildedtalon »

SPD plays a part, like Viki, the slowest character, that's why Punkaiser used her for this setup since she always acts last

https://www.youtube.com/watch?v=IGdGSMbI6cg
My GameFAQs account now is SheenavsKilley
I already closed gildedtalon, my old account
Antimatzist
Posts: 2770
Joined: Sat Apr 19, 2008 9:48 am
Location: Germany, yeah baby
Contact:

Re: Turn Order Calculations

Post by Antimatzist »

From my experience (no actual testing), using healing items also lets characters act faster.But it's hard to say as using a medicine is done at the same time as other characters attack.
User avatar
Punkaiser
Posts: 644
Joined: Thu Jan 12, 2012 5:21 am

Re: Turn Order Calculations

Post by Punkaiser »

From what I remember, turn order is determined after all these conditions are checked:

1. Effective SPD = Character SPD * modifier
Modifier:
Support commands (heal/buff) = 1.3
Other actions = 1

2. Highest effective SPD go first

3. If 2 characters have same effective SPD, then turn order is decided by the slot in party they are in, 1 goes first, 6 acts last
1-2-3
4-5-6
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

Thanks for that, Punkaiser. The 1.3 modifier makes sense for the first situation involving Thors, but I don't see why Water Dragon wouldn't also have the modifier since it also heals. Is it an actual floating point multiply or do the remainders get sheared off? How is double beat decided, since there are cases where the character can attack but then have to wait through an enemy attack before going again? Do items have any additional speed modifier? How does Spark play into everything? There's still a bunch to figure out.
KFCrispy
Global Admin
Posts: 6174
Joined: Wed Jun 30, 2004 3:29 pm

Re: Turn Order Calculations

Post by KFCrispy »

it's just how spells are classified. i doubt the magic unites, Forgiver Sign, and Shining Wind are considered heal spells....
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

The Thor I'm referring to is the Unite Spell, not Thor Shot. The Water component to both Water Dragon and Thor gives the same unite effect: HP and status refilled. It might just be an oversight that Water Dragon doesn't get the same treatment, but it's still something I'd like to figure out. All of the other pieces are valid too. Enemy turn order, especially for Bosses with 2+ attacks per turn, are something of an anomaly too.

EDIT: Just tried out some of the other Rune Unite attacks as well. Apparently Burning Camp, which has no healing to it, gets the boost while Scorched Earth does not. Perhaps it means that the Lightning rune gives it the speed modifier? I tested briefly with some of the other healing spells in Water and the Bright Shield, and they seem to follow the 1.3 modifier as expected.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

I went through and tested all the spells that I have available at the moment. All of the spells below get a speed boost:

Kindness Drops
Protect Mist
Kindness Rain
Silent Lake
Empty World*
Healing Wind
Storm Warning
Shining Wind*
Mother Ocean
Revenge Earth
Canopy Defense
Guardian Earth
Scream
Yell
Great Blessing
Battle Oath
Burning Camp*
Thor*

I have not tested White Saint rune, Black Sword rune, Thunderstorm spell, or Forgiver Sign spell. Most of them follow the pattern of having some party-side effect, usually healing, but there are a few exceptions. A * indicates spells that are unusual. This was all tested assuming the same constant 1.3 modifier, although if there are other potential modifiers then this would require further testing. If I had to guess about the remaining spells, I would say that Forgiver Sign is likely a fast spell as well. It's curious that both Camp and Thor are the Unite Spells that get a speed boost, but not any of the other ones that provide healing effects.
KFCrispy
Global Admin
Posts: 6174
Joined: Wed Jun 30, 2004 3:29 pm

Re: Turn Order Calculations

Post by KFCrispy »

crazy stuff indeed. i hate how there are all these hidden mechanics and the game designers don't think it would be interesting to publish the information.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

I am really unsure of what to think. I have an endgame party where, in one file, the turn order proceeds as follows:

1. Flik uses Blazing Camp
2. Riou uses Scorched Earth
3. Luc uses Earthquake (lvl 3)

In another file with almost the exact same setup, but Flik and Luc having slightly lower speed each, Flik goes last and Luc goes second. The exact SPD values are below:

File 1:
Luc SPD - 178 (163 base, 15 bonus from equip)
Flik SPD - 142
Riou SPD - 183 (158 base, 25 bonus from equip)

File 2:
Luc SPD - 174 (159 base, 15 bonus from equip)
Flik SPD - 148 (138 base, 10 bonus from equip)
Riou SPD - 184 (159 base, 25 bonus from equip)

I have tried all manner of things, but I just can't seem to get the turn order I want with the second file. It's actually pretty critical for a Beast Rune strategy, but I really am not sure why I get the 1.3x bonus in some files but not others. Swapping around all manner of speed items doesn't seem to help until I pass Luc's SPD, which indicates I'm getting no modifier at all. Yet in my prior testing, Blazing Camp does get a modifier. I can go back to the other file and see that it still works every time. So yeah, not sure what to make of it.
KFCrispy
Global Admin
Posts: 6174
Joined: Wed Jun 30, 2004 3:29 pm

Re: Turn Order Calculations

Post by KFCrispy »

what about order within the party? .... are the runes in different slots by any chance?
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

I have since reorganized the strategy so that the boost is not a factor, but that doesn't solve any of the discrepancies above. I have also noticed in some other cases where Thor does not get the speed modifier either, but that is not as common.

Things I had tried to change in order to get the effect back:

-Party member order
-Rune slot order
-Changing specifically the base speed rather than from equipment bonuses
-Specific runes occupying other slots
-Replacing specific prior runes with the current ones
-Changing other member speed values
-Changing equipment for small and large speed differences
-Changing the type of rune used by the Uniter (ie Fire -> Rage)
-Trying users with different affinities for those elements

The last caveat I can consider is that the files where the speed boost is granted were all imported from PS3 PSN version, whereas the file where it does not work was created fresh on Playstation TV PSN version. Both are being executed on the PSTV version, so unless there's a discrepancy in the actual save I'm not sure that they should be different at all. Testing the original PS1 version via emulator also gives the speed boosts every time, so I'm not sure what else might be affecting it.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

As dumb as this may sound, I'm thinking it might be related to save slot. I will investigate it a bit more soon, but my evidence thus far is this:

-I was doing a playthrough of L'Ren. Saved immediately before Seed & Culgan, and then entered battle. In the battle, I set up 4 Blazing Camps. The first 3 executed from chars with SPD > 155. Then Shin attacks (SPD = 150), followed by Seed attack, then Sierra (SPD = 138) casting the last Camp. I reset and reloaded the save. Repeated the exact same things in the battle, and this time around all 4 Camps executed first, followed by Shin. The only way this would be possible is if Sierra also received a speed modifier so she could go before Shin.

I need to see about offloading some of my saves and then I can fool with trying out different slots. I'll report back if I find anything.

EDIT: Save slots (thankfully) do not affect it at all. I've been digging into the code to help me solve it, but those subroutines use a lot of register operations that make it difficult to source from the main memory. At the very least, I have some of the main culprits nailed down, but I still haven't figured out when or where the bug comes in. One thing I can confirm though is that the speed modifier can likely be applied to any Rune Unite so long as things are set up correctly for it. I had one case where Blazing Camps would not get the boost but Scorched Earth did, which further threw things into disarray. In most other saves and circumstances I have not been able to get Scorched Earth to get the boost; so it's likely the result of some persistent battle values.
Metsu
Posts: 66
Joined: Wed Apr 15, 2015 9:27 am

Re: Turn Order Calculations

Post by Metsu »

I would like to help you, as I've been able to debug assembly to figure out all the questions one community had in game mechanics. My time is pretty limited at the moment but hoping to free some up soon.

I did have a question on your debugging methods. I've been using the psxfin debugger which is great except that it can only do memory read/write breakpoints and not execution breakpoints. Sometimes a pain, but I've always found a way to get around that. After skimming a couple articles, it seems everyone's method of choice is IDA Pro? Does it have some sort of decompiling feature where it names some methods for you or is that everyone's own comments? XD 'cause that would be nice and I would have to switch.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: Turn Order Calculations

Post by Omnigamer »

Much appreciated Metsu! I've been using psxfin as well. It can do execution breakpoints, but you have to be careful about setting them; they will no longer work if the currently loaded module changes. If you set one for battle events within battle, it should work in my experience.

Below is a copy+paste of some more detailed information I sent to Pyriel.
Not sure if you've seen my thread about turn order calculations, but the basic gist of what I'm dealing with now is this: sometimes Unite Attacks get the "healing" speed modifier of 1.3x, other times they do not. When it is active, it seems to be active per spell, as in if Blazing Camp gets the boost, then all users of Blazing Camp will get the boost. I've been doing what I can to trace through the code and figure out why it's occurring, but I'm somewhat limited in my static analysis tools. I know at least when it happens and the end memory address that holds the flags for a particular spell, but I've been having difficulty sourcing it beyond that.

What I have so far (first round of battle only):

-Spell properties get stored to character base + 0x58 in memory for a single frame. I've been working off of the character in position 2, so it's 0x00145C78.
-If the above address has the 0x10000000 bit set, then the current spell gets a speed boost. The speed calculations occur at 0x4D5E8 of BP0_FST.BIN.
-The set of instructions that actually set this are at 0x4D5A4 in what I'm assuming is the BP0_FST.BIN module. It uses some constant that I assume is based on the spell (stored in r6) and then uses that to find the appropriate flag to apply to the spell.
-There are some 59 instances in the module that jump directly to this code block, but I'm having trouble determining how the game ends up in any particular path. I assume there's some check against the spell's identifier or something like that, but I don't have a means to find that with what I've got.

That said, do you think you could be able to help out with digging a little further? The actual bug is the inconsistency with which Unite Attacks get the speed modifier. I have some save files where it works on some spells every time, and others where it never works. I assume it's something where there's some leftover setting from prior spells by one of the casters, but in playing around with it I haven't found anything that directly affects whether the boost occurs or not.
Post Reply