Actor pointers are used to keep track of an actor's relationships with others, such as which one spawned them, or which ones they spawned.
There are three actor pointers that are generally used:
Some additional pointers also exist, such as lastenemy, but are not normally exposed to modders.
Depending on the type of actor, different pointers are used.
- target: A projectile's target is not the actor that it will seek after. Instead, this is the actor who fired the projectile (though a little counter-intuitive at that).
- tracer: This is used only if the projectile has the +SEEKERMISSILE flag. It will lock onto an enemy and seek towards whoever is in this field.
- master: Unused.
- master: This refers to the monster that spawns them using A_SpawnItemEx with the SXF_SETMASTER flag, or is transferred over with the SXF_TRANSFERPOINTERS flag.
- target: This refers to whom the monster is chasing and will attack when called upon with A_Chase.
- tracer: Unused.
Many special actors have different handling for these pointers which do not fit in the generic categories above. They include:
- Anything that explodes will use its target as the source responsible for damage inflicted by the explosion.
- SpawnShot (A_SpawnFly and A_SpawnSound will move it towards its target, not its tracer as with other projectiles).
- Archvile (A_VileTarget assigns its tracer to the spawned ArchvileFire, and A_VileAttack detonates the fire)
- MinotaurFriend uses the tracer pointer to keep track of the player who summoned it.
- HolyTail (A_CHolyTail uses the tracer pointer to manage its trail).
- Lightning and derived classes use the tracer, target and lastenemy pointers to manage cohesion between the various components of the lightning column.
- Dragon (its dedicated movement functions use the tracer fields as path nodes for its navigation)
- TeleportFog uses the actor who teleported as the target.
This list is not exhaustive.
All pointers are automatically supported by all implementing functions, unless the function documentation specifies otherwise.
The following set of named values all indicate ways of retrieving an actor pointer from a source actor or a static context. The values are divided into categories, and the first selector applicable to the source actor is used. Selectors from different categories may be combined using BITWISE OR. (SELECTOR_A | SELECTOR_B)
Selector category 1: Player-only selectors
Players will use a pointer in this category if one is specified. Otherwise, a pointer from another applicable category will be used.
- AAPTR_PLAYER_GETTARGET: Get the actor in the player's line of sight. Most target-specific functions use this approach to determining the player's target. This only works if the actor has the SHOOTABLE and SOLID flags, and also lacks the NOBLOCKMAP flag, much like A_JumpIfTargetInLOS.
- AAPTR_PLAYER_GETCONVERSATION: Get the actor currently talking to the player. Best used from a Strife dialogue that gives a custom inventory item, or starts a script with ACS_ExecuteWithResult (as it processes immediately).
Selector category 2: Generic context selectors
Any actor (non-null) will use a pointer in this category if one is specified. Otherwise, a pointer from another applicable category will be used.
- AAPTR_MASTER: Access the actor's MASTER pointer. (Players normally do not have masters.)
- AAPTR_TARGET: Access the actor's TARGET pointer. (Players normally do not use this.)
- AAPTR_TRACER: Access the actor's TRACER pointer.
- AAPTR_FRIENDPLAYER: Access the actor's FRIENDPLAYER pointer.
- AAPTR_GET_LINETARGET: Get the actor in the line of sight. This is similar to AAPTR_PLAYER_GETTARGET above, except it is used for non-player actors.
Note that AAPTR_GET_LINETARGET is identified as AAPTR_LINETARGET in DECORATE.
Note on retrieving TARGET information: Most functions use a special approach to find the target of a player; checking what they are aiming/looking at. This corresponds to AAPTR_PLAYER_GETTARGET. To make a single function that conforms to this standard, use the selector combination AAPTR_TARGET|AAPTR_PLAYER_GETTARGET. The most applicable method will be used (AAPTR_PLAYER_GETTARGET for any player).
Selector category 3: Static context selectors
Any specified pointer in this category will be used.
- AAPTR_NULL: Return NULL.
- AAPTR_PLAYER# (where # is a number in the range 1 - 8):
- A static pointer to the player of that number. NULL if the player does not exist.
Scripting tip: AAPTR_PLAYER1 points to player 1. AAPTR_PLAYER1<<X (shift bits X up) points to player (1 + X). This fact can be applied in ACS loops if you need to reference each active player in sequence.
Selector category 4: Default
This selection is always implied, and applies if no other selection was made. To fully disable this, specify one static selection (as they always apply when specified), such as AAPTR_NULL.
- AAPTR_DEFAULT: Returns the source actor itself (null if there is no source actor).
The following selectors expose fields for manipulation: AAPTR_MASTER, AAPTR_TARGET and AAPTR_TRACER.
Assignment operations will often, but not necessarily, prevent some assignments from occuring. Examples of such events are:
- An actor pointing to itself
- An infinite chain of references (two actors referencing eachother as master or target)
Prevention may involve cancelling the operation, or setting the pointer to NULL. Details on this should be included in the documentation of the individual function.
Revision information - assigning to pointers: Significant changes to this functionality are unlikely. Functions that support a set of selectors different from AAPTR_MASTER, AAPTR_TARGET, AAPTR_TRACER should list the supported features, along with any needed revision information.