A_Tracer

From ZDoom Wiki
Jump to navigation Jump to search

A_Tracer

DoomWiki.org
For more information on this article, visit the A_Tracer page on the Doom Wiki.


(no parameters)


The seeking function for the Revenant's missile. This seeks very aggressively and spawns both a puff and a smoke behind the missile. This only works for missiles with the SEEKERMISSILE flag.

Note: This function is written so that it only performs its action if the global time counter is a multiple of 4, so it may have some side effects — for instance, Revenant rockets, which call this function every two tics, only home in if they were spawned during an even tic; if they were spawned during an odd tic the function will never be called during a tic that is a multiple of 4, and the tracer will not home in. The frequency at which A_Tracer is called is thus very important for its behavior:

  • If the interval is odd, the homing behavior will happen every interval × 4 tics.
  • If it is a multiple of four, it will happen every interval tics, but only if it was spawned during a tic that is a multiple of four.
  • If it is an even number that is not a multiple of four, it will happen every interval × 2 tics only if it was spawned during an even tic.

See examples below.

Examples

The original example is RevenantTracer. It only homes every four tics if it were spawned during an even tic. The following table underlines at which gametic the function will have an effect, depending on the gametic-modulo-four at which the RevenantTracer actor was spawned:

0: 02 04 06 08 10 12 14 16 etc.
1: 03 05 07 09 11 13 15 17 etc.
2: 04 06 08 10 12 14 16 18 etc.
3: 05 07 09 11 13 15 17 19 etc.
actor RevenantTracer
{
  // See RevenantTracer for the full definition!
  States
  {
  Spawn:
    FATB AB 2 bright A_Tracer   // See RevenantTracerSmoke
    loop
  }
}

This “Tracer1” variant will home in very aggressively every four tics, no matter when it was spawned.

0: 01 02 03 04 05 06 07 08 09 10 11 12 etc.
1: 02 03 04 05 06 07 08 09 10 11 12 13 etc.
2: 03 04 05 06 07 08 09 10 11 12 13 14 etc.
3: 04 05 06 07 08 09 10 11 12 13 14 15 etc.
Actor Tracer1 : RevenantTracer
{
  States
  {
  Spawn:
    FATB AB 1 bright A_Tracer
    loop
  }
}

This “Tracer3” variant will home in on the target every time, but only steer towards it once every 12 tics.

0: 03 06 09 12 15 18 21 24 27 30 33 36 etc.
1: 04 07 10 13 16 19 22 25 28 31 34 37 etc.
2: 05 08 11 14 17 20 23 26 29 32 35 38 etc.
3: 06 09 12 15 18 21 24 27 30 33 36 39 etc.
Actor Tracer3 : RevenantTracer
{
  States
  {
  Spawn:
    FATB AB 3 bright A_Tracer
    loop
  }
}

This “Tracer4” variant will only home in if it was spawned during a gametic that is a multiple of 4, as shown by the table below:

0: 04 08 12 16 20 etc.
1: 05 09 13 17 21 etc.
2: 06 10 14 18 22 etc.
3: 07 11 15 19 23 etc.
Actor Tracer4 : RevenantTracer
{
  States
  {
  Spawn:
    FATB AB 4 bright A_Tracer
    loop
  }
}

This “Tracer5” variant will home in every twenty tics.

0: 05 10 15 20 25 30 35 40 etc.
1: 06 11 16 21 26 31 36 41 etc.
2: 07 12 17 22 27 32 37 42 etc.
3: 08 13 18 23 28 33 38 43 etc.
Actor Tracer5 : RevenantTracer
{
  States
  {
  Spawn:
    FATB AB 5 bright A_Tracer
    loop
  }
}


Likewise, a “Tracer6” variant would home every 12 rounds only if it were spawned during an even tic; a “Tracer7” would home every 28 tics, a “Tracer8” variant would home every eight rounds only if it were spawned during a tic that is a multiple of four, and so on.