Time Analysis, by Aaditya V. Rangan

Version 1.0 -- 2000 October 20

Introduction

Allright. I have discovered a (somewhat) serious flaw in my reasoning. I was wrong about the quick-with-quick-and-countermagic scenario.

I said that if A quicks B, and B counterquicks A, then A gets to go before the resultant mime cycle.

What is actually true is that the first character in the character_list with a quick-flag gets to go before the mime cycle. So if B is before A in the character list, B would get to take a turn before the resultant mime-cycle. (at least, this is what the debug mode does for me today. I could have sworn that I was right before though...). (nevertheless, I am pretty sure that everything else I said about the quick-with-quick-and-countermagic scenario is correct).

At any rate, now I will cover what I believe is a more general case. Namely, quick-turn resolution during SR phases.

Preliminaries

  1. An action (ie, a fast action, or the resolution of a slow-action) will always immediately spawn a reaction. That is, every action will ALWAYS allow for it's targets to react. In other words, nobody can take quick-turns in between an action and it's reactions. I hope I never see an exception to this.
  2. A mime cycle is when the mimes are checked in character_list order, and all the eligible mimes mimick the last_action. After each mime mimicks the last action, their target gets a chance to react. Then the next mime on the list mimicks the last_action, and so on. Mime cycles are always completed. That is, they are never interrupted. Nobody can take a quick-turn (of any type) in the middle of a mime-cycle. I have never seen an exception to this, and I hope I never do. So basically, all a mime-cycle can do (for my purposes) is hand out a bunch of quick-flags all over the place. There is no way anybody can do anything 'funny' in the middle of a mime-cycle, and the mime-cycle is completely determined by the last-action (defined prior to the mime-cycle).
  3. The game sometimes checks for quick-turns in between actions and mime-cycles. The game sometimes checks for quick-turns after mime-cycles. This is why I must introduce the notion of a 'quick safety'. This can be either on or off. The quick-safety is basically some bit toggled somewhere which switches the gameflow between 'safe' mode (no quick turns happening here, no siree) and 'quick' mode (alas! must resolve multiple quickturns). The only reason I am introducing this quick-safety is that quick-turn resolution during SR phases makes NO SENSE without it...
  4. There seems to be 4 different types of quick. There is quick (the spell). There is critical-quick (the reaction). There is mime-quick (when a character gets hit with the quick spell during a mime cycle). And there is mime-critical-quick (when a character critical quicks during a mime-cycle). As far as I can tell, countermagic-quick (the reaction) and quick (the spell) are equivalent (I have tested this every way I know how). So a character can have no quick flag, a quick-spell-flag, a critical-quick-flag, a mime-quick-spell-flag, or a mime-critical-quick-flag. I will denote these by n-flag, qs-flag, cq-flag, mqs-flag and mcq-flag respectively.
  5. As far as I can tell right now, the only observable difference between mqs and mcq is that mqs raises CT to 100, whereas mcq raises CT to 154. (what the hell is that all about???). What is even weirder, is that mcq only raises CT to 154 most of the time. sometimes it only raises CT to 100. (go figure...). qs is definitely different from cq, and I'm pretty sure cq is different from mcq. So I'm guessing that qs is different from mqs. Whatever.
  6. As you probably guessed, the difference between qs and cq has to do with the quick-safety. I'll get into that later.

Enter the Jungle

The standard way events are resolved is:

  1. Resolve the initial basic action (and redefine last_action).
    This step can apply a qs-flag.
  2. Resolve the initial reaction(s).
    This step can apply (several) cq-flags. It can also apply a qs-flag (via countermagic).
  3. Check the character_list for quick-flags.
    If nobody has any quick-flags, head on to step 4. Otherwise give the first quick-flagged character on the list a quick-turn. This character can act, and redefine the last-action. Then allow all appropriate reactions (hence applying cq-flags). After the reactions, ignore the rest of the quick-flagged characters on the character_list, and immediately skip to the...
  4. Mime-cycle.
    Examining the last_action, all eligible mimes do their thing. Each mime is checked in order of the character_list, and the first eligible mime acts (and triggers reactions). Then the next eligible mime acts (and triggers reactions). And so on. This allows the distribution of several mqs-flags or mcq-flags. At the end of the mime-cycle, the last-action is cleared (set to empty).
  5. Check the character_list for quick-flags.
    If nobody has any quick-flags, head on to step 6. Otherwise give the first quick-flagged character on the list a quick-turn. If that character acts, he redefines the last-action. Then allow all appropriate reactions (hence applying cq-flags). After this character's quick-turn is finished, go back to step 4.
  6. Now the initial basic action is considered to have ended.
    The last-action is cleared, and the game moves on. (If we are in an SR phase, the game would check for the next eligible slow-action, and (if it finds one) then head back to step 1). (If we are in a CR phase, the game would check for the next eligible character, and give them an AT).

So what's the problem?

Well, often during SR phases, steps 3 and 5 above are SKIPPED. That is, characters who should get quick turns are instead 'passed over' until later. (this is where I get to the quick-safety)... Once I explain this, it should generalize to the CR phases (and all the stuff I explained before in those earlier posts).

(If you think that steps 3 and 5 are basically the same step, then you're right. I am pretty sure that 3 and 5 both involve calling the same subroutine to resolve the first quick-turn on the character_list. The only difference is that skipping 3 leads to 4, whereas skipping 5 leads to 6 (a difference in the function call only, not the subroutine)).

So here are some rules to fix all this wackiness. First assume that the game ONLY looks at step 3 and 5 if the quick-safety is OFF. (that is, steps 3 and 5 are automatically skipped if the game is in 'safe' mode).

  1. At the beginning of step 1, the character_list is checked for quick-flags. If anybody has any quick-flags, the quick-safety is turned OFF (that is, the game enters 'quick' mode). Otherwise, the quick-safety is turned ON (the game falls into 'safe' mode).
  2. If step 1 (or 2) applies a qs-flag, the quick-safety is turned OFF. (note that application of a cq-flag does NOT turn the safety off). So if the initial actor quick-spelled somebody (or got hit by countermagic quick) then the game is put into 'quick' mode.
  3. Now, after step 2, the game will enter step 3 only if it is in 'quick' mode. If the quick-safety is on, the game will skip straight to step 4.
  4. At the beginning of step 4, the character_list is checked for quick-flags. If anybody has any quick-flags, the quick-safety is turned off. Otherwise, the quick-safety is not altered. The quick-safety is not altered during the resolution of the mime cycle. That is, the application of mqs-flags or mcq-flags won't switch the game into 'quick' mode. So unless the quick-safety was OFF to begin with, the game will skip straight to step 6 after the mime-cycle.
  5. During step 6, the quick-safety is turned ON. (and the game is put back into 'safe' mode).

So what did you just fix?

Well, now this explains everything I have observed so far. qs (and countermagic qs) will immediately put the game into quick mode. That means that somebody will get a quick-turn before the resulting mimecycle. cq will NOT put the game into quick-mode, until AFTER step 3 (at the beginning of step 4). That means that cq won't trigger a quick turn until after the resulting mimecycle.

In addition (and this is the most important part), mqs and mcq will NOT switch the game into quick mode. That means that if the game is in safe mode BEFORE the mimecycle, and then some mqs-flags or mcq-flags are applied, those quick-turns get skipped until later. (until the next 'step 3' comes around, to be more precise).

So, what does that really mean?

O.K. first of all, these steps can be rewritten as follows:

  1. Resolution of basic initial action:
    1. If there are any quick-flags, turn quick-safety OFF.
    2. Resolve basic inital action, handing out qs-flags as needed.
    3. Rewrite last_action appropriately. (including information about the action taken, and the team that took that action).
    4. Go on to step 2.
  2. Resolution of basic initial reaction(s):
    1. Resolve basic initial reaction(s) (in character_list order), handing out qs-flags and cq-flags as needed.
    2. If there are any qs-flags, turn quick-safety OFF.
    3. If the quick-safety is off, go to step 3.
    4. If the quick-safety is on, go to step 4.
  3. Resolution of the first quick-turn:
    1. Check the character_list for the first fellow with a quick-flag.
    2. Give that sap a turn.
    3. If he acts, rewrite the last_action appropriately.
    4. If he acted, resolve all the reactions, and hand out the cq-flags as needed.
    5. Go on to step 4.
  4. Mime-cycle:
    1. If there are any quick-flags, turn quick-safety OFF.
    2. Go through the mime-cycle (I won't bore you with the details), handing out mqs-flags and mcq-flags as necessary.
    3. Clear the last_action (rewrite it to empty).
    4. If the quick-safety is off, go to step 5.
    5. If the quick-safety is on, go to step 6.
  5. Resolution of the first quick-turn:
    1. Check the character_list for the first fellow with a quick-flag.
    2. If there aren't any quick-flags, go on to step 6.
    3. Otherwise, give the first character on the charcter_list a quick-turn.
    4. If he acts, rewrite the last_action appropriately.
    5. If he acted, resolve all the reactions, and hand out the cq-flags as needed.
    6. Go back to step 4.
  6. End of action:
    1. If in an SR phase, turn quick-safety on.
    2. If in an SR phase, look for the next slow-action on the character_list.
    3. Once you find it, go back to step 1.

I want an example, smartass

Now here is an easily reproducible example that illustrates the need for the quick-safety.

A,B and C all have CT 100, speed 99, and short-charge.
D and E are mimes.
A starts casting quick (targets an empty panel)
B waits
C waits

(time passes, and every character's CT increments)

A, B, C all wait

(time passes)

A's quick goes off, and misses
D mimes A and hits C
E mimes A and hits B

(every character's CT increments)

Now, during the subsequent CR phase, the turn order is 
B, C, A

As you can see, B and C definitely got quick-flags (mqs-flags, to be exact). But they did not get quick-turns until the following CR phase. In other words, they were ignored during the SR phase. There was a mime-cycle during the SR phase (after A's quick-spell went off). And yet B and C did NOT get quick-turns right after the mime-cycle. The reason is that at the beginning of the mime-cycle, nobody had any quick-flags, and so the game stayed in 'safe' mode.

Here is a slightly different example.

A,B and C all have CT 100, speed 99, and short-charge.
D and E are mimes.
A starts casting quick (targets an empty panel)
B and C wait.

(time passes, and every character's CT increments)

B starts casting haste (targets an empty panel)
C starts casting haste (targets an empty panel)

(time passes)

A's quick spell goes off, missing.
D mimes A, and hits C with a quick spell
E mimes A, and hits B with a quick spell
B's haste spell goes off
B gets a quick turn
B waits
D mimes B, and hits C with a haste spell
E mimes B, and hits C with a haste spell
C gets a quick turn
C waits

(every character's CT increments)

Now, during the subsequent CR phase, the turn order is
A, B, C

Now you can see the effect of the quick-safety. Since there were no quickflags during A's action, the game was left in safe mode. So after the resultant mime-cycle, C and B were ignored. However, at the beginning of B's haste spell, the game switched to 'quick' mode. Then, B got a quick-turn BEFORE the resultant mime-cycle. After B finished, the mime-cycle went off, and then C got a quick-turn. After C finished, every character's CT incremented.

Here's a real example

Now I will go step by step through a complicated example, to illustrate what gets switched when.

AGRias, RAMza, RAD and ALIcia are all on the same team.
AGR has critical quick
RAM has counter magic
RAD is a mime
ALI is a mime

RAFa, MELiadoul, LAVian and REIs are all on the same team.
RAFa has counter magic
MELiadoul has critical quick
LAVian is a mime
REIs has critical quick

The character list is
AGR, RAM, RAD, ALI, RAF, MEL, LAV, REI

Now, AGR,RAM,MEL,REI all charge up quick spells so they will go off in the same SR phase. Here is the SR phase:

(I will put actual observed events on the left. First is the actor, then the action, then the target. I will put reactions below actions, indenting them appropriately, as well as preceding the reactor's name with an 'r'. I will indent mimecycles, and precede the mime's name with an 'm'. My corresponding gameflow theory is on the right, in curly brackets)

AGR - qs - miss       {qsafety ON, since nobody has any quick-flags
                      {so we skip step 3, and go on to the mimecycle
                      {now the mimecycle starts, qsafety still ON
  mRAD - mqs - REI    {REI gets an mqs-flag
  mALI - mqs - miss   {
                      {qsafety is still ON, so step 5 is skipped
                      {now, during step 6, RAM's qs is found
RAM - qs - miss       {qsafety turned OFF, due to REI's mqs-flag
                      {since the qsafety is OFF, we go to step 3
REI - wait            {this is a step 3 quick-turn
                      {now the mimecycle starts, qsafety still OFF
  mRAD - mqs - miss   {
  mALI - mqs - AGR    {AGR gets an mqs-flag
                      {since the qsafety is OFF, we go to step 5
AGR - wait            {this is a step 5 quick-turn
                      {now, during step 6, qsafety is turned back ON
                      {and MEL's qs is found
MEL - qs - miss       {qsafety left ON, since nobody has any quick-flags
                      {skip step 3, and go on to mimecycle
                      {mimecycle starts, qsafety still ON
  mLAV - mqs - RAF    {LAV mimes, giving RAF a mqs-flag
    rRAF - mqs - LAV  {RAF countermagics, giving LAV a mqs-flag
                      {since qsafety is still ON, skip step 5
                      {now, during step 6, qsafety is turned back ON
                      {and REI's qs is found
REI - qs - miss       {qsafety turned OFF, due to RAF's mqs-flag
                      {since qsafety is OFF, we go to step 3
RAF - wait            {this is a step 3 quick-turn
                      {now we go to the mimecycle, qsafety still OFF
  mLAV - mqs - RAF    {LAV mimes, giving RAF a mqs-flag
    rRAF - mqs - LAV  {RAF countermagics, giving LAV a mqs-flag
                      {since qsafety is OFF, we go to step 5
RAF - wait            {this is a step 5 quick-turn
                      {we go back to step 4, then back to step 5
LAV - wait            {this is another step 5 quick-turn

Now the SR phase ends, all characters increment CT, and the next CR phase starts.

Ready for more?

Using the same team, here is another example.

Now AGR,MEL,REI are charging up quick spells, while RAM has a demi spell up his sleeve. They are timed so that they all go off in one SR phase. Here is the SR phase:

(again, actual observed events are on the left. My theory on the right)

AGR - qs - miss         {qsafety ON, since nobody has any quick-flags
                        {so no step 3, and on to the mimecycle
                        {now the mimecycle starts, qsafety left ON
  mRAD - qs - REI       {REI gets a mqs-flag
  mALI - qs - miss      {
                        {qsafety is still ON, so step 5 is skipped
                        {now, during step 6, RAM's demi is found
RAM - demi - miss       {qsafety is turned OFF, due to REI's mqs-flag
                        {since the qsafety is OFF, we go to step 3
REI - wait              {this is a step 3 quick-turn
                        {now the mimecycle starts, qsafety left OFF
  mRAD - demi - MEL,REI {RAD mimes
    rMEL - mcq          {MEL gets an mcq-flag
    rREI - mcq          {REI gets an mcq-flag
  mALI - demi - AGR     {ALI mimes
    rAGR - mcq          {AGR gets an mcq-flag
                        {mimecycle ends, qsafety still OFF
                        {so we go to step 5
AGR - attack - miss     {this is a step 5 quick-turn.  Since AGR
                        {acted, this redefines the last_action, and
                        {so we proceed back to step 4
  mRAD - attack - miss  {
  mALI - attack - AGR   {
    rAGR - mcq          {AGR gets an mcq-flag
                        {mimecycle ends, qsafety still OFF
                        {so we go to step 5
AGR - wait              {this is a step 5 quick turn
                        {we go back to step 4, then back to step 5
MEL - wait              {this is a step 5 quick turn
                        {we go back to step 4, then back to step 5
REI - wait              {this is a step 5 quick turn
                        {no more quickflags, we go to step 6
                        {now in step 6, qsafety turned back ON, and
                        {MEL's qs is found
MEL - qs - RAM          {qsafety ON, since nobody has quickflags (yet)
                        {then RAM gets a qs-flag
  rRAM - qs - MEL       {RAM countermagics, and gives MEL a qs-flag
                        {now, in step 2, the qsafety is turned OFF 
                        {since RAM got a qs-flag
                        {so we proceed to step 3
RAM - attack - miss     {this is a step 3 quick-turn.  note that RAM
                        {rewrote the last_action, and so the mimes will
                        {mimick RAM and not MEL.  this is evidenced as
                        {we pass to the mimecycle (step 4)
                        {mimecycle starts, qsafety left OFF
  mRAD - attack - miss  {
  mALI - attack - AGR   {
    rAGR - mcq          {AGR gets an mcq-flag
                        {mimecycle ends, qsafety still OFF
                        {so we go to step 5
AGR - wait              {this is a step 5 quick turn
                        {we go back to step 4, then back to step 5
MEL - wait              {this is a step 5 quick turn
                        {no more quickflags, we go to step 6
                        {now in step 6, qsafety turned back ON, and
                        {REI's qs is found
REI - qs - miss         {qsafety left ON, since nobody has quickflags
                        {so we skip step 3, and head to the mimecycle
                        {mimecycle starts, qsafety left ON
  mLAV - mqs - RAF      {LAV mimes, RAF gets an mqs flag
    rRAF - mqs - LAV    {RAF countermagics, LAV gets an mqs flag
                        {mimecycle ends, and since the qsafety is still
                        {ON, we skip step 5 and go straight to step 6
                        {now, during step 6, we turn the qsafet ON again
                        {and look for the next slow-action.  There are
                        {no more slow actions, and so the SR phase ends.
                        {we proceed to the C+ phase, and all character's
                        {CT increments.  Then we proceed to the next
                        {CR phase.  Since LAV and RAF still have quick
                        {flags, the turn order in the subsequent CR
                        {phase is RAF,LAV,AGR,RAM,...

Pretty neat, eh? My newfangled gameflow theory covers all the cases I have covered so far, as well as all the complicated examples I have tested so far. (I have a couple more, and they fit the bill too).