A_RearrangePointers

From ZDoom Wiki
Jump to: navigation, search

A_RearrangePointers (pointer target, pointer master, pointer tracer, int flags)

The calling actor swaps its actor pointers.

  • target corresponds to the value to store in the target field.
  • master corresponds to the value to store in the master field.
  • tracer corresponds to the value to store in the tracer field.

The pointers can be any of the following:

  • AAPTR_DEFAULT: no change is performed.
  • AAPTR_NULL: no actor at all.
  • AAPTR_TARGET: the calling actor's target, if any.
  • AAPTR_MASTER: the calling actor's master, if any.
  • AAPTR_TRACER: the calling actor's tracer, if any.

Remember that the nature of these pointers depend on the actor type and is not always intuitive.

By default master and target become NULL if values are assigned that would cause infinite relationships, such as missiles targeting each other, masters mastering each other. The following flags can manipulate and disable the safe guards to allow for more complex relationships:

  • PTROP_UNSAFETARGET (1) — do not nullify assignments that result in an infinite chain of missiles referencing each other.
  • PTROP_UNSAFEMASTER (2) — do not nullify assignments that result in an infinite chain of actors referencing each other.
  • PTROP_NOSAFEGUARDS (4) — same as putting in PTROP_UNSAFETARGET|PTROP_UNSAFEMASTER.

Note that setting a target to AAPTR_NULL with this function does not perform all actions of A_ClearTarget, that clears other related fields.

Examples

This imp has a 4/256 chance to "forget" its master and its target.

ACTOR AmnesiacImp : DoomImp
{
  States
  {
  See:
    TROO A 0 A_Jump(252, 2)
    TROO A 0 A_RearrangePointers(AAPTR_NULL, AAPTR_NULL, AAPTR_DEFAULT)
    TROO AABBCCDD 3 A_Chase
    Loop
  }
}

See also