Definition: A_CheckFlag(string flagname, state label, int check_actor = AAPTR_DEFAULT);
Optional rename: A_JumpIfFlag
Effect: Check the selected actor's flag. Default selection is the caller, but TARGET|MASTER|TRACER can also be used. Will not jump if the flag is missing. Counterpart to A_ChangeFlag, and a more flexible alternative to features otherwise considered for A_JumpInTargetLOS.
Current backward compatibility requirements: None, as this is a new feature.
Future backward compatibility: Flags that are valid in the revision where this is introduced, need to be supported for backward compatibility.
Implemented handling of deprecated flags:
Currently deprecated flags are supported for read in the same way they were already supported for write; with a dedicated function. "bool CheckDeprecatedFlags(AActor *actor, FActorInfo *info, int index)" is inserted immediately after "HandleDeprecatedFlags". The function checks that the data matches that which HandleDeprecatedFlags would have set if the flag was to be enabled. (The code may speak more clearly than I do on that matter.)
Drawback: Whenever a change is made to HandleDeprecatedFlags (this is not frequent, is it?), a corresponding change should be made to CheckDeprecatedFlags.
Merit: Both I and other modders have encountered situations where it would be nice to toggle or verify a flag value somehow; both of which require the engine to measure the current value of that flag. It has most recently come up during the discussion of another feature suggestion I have made. We already have ways to make jumps and judgements based on many other properties and conditions, so the code pointer seems to fit well in its context.
Testing: Jumps have been tested and verified with FRIENDLY, LOWGRAVITY, ISMONSTER, FRIGHTENED.
Example use: A weapon checking properties of the actor under crosshair. Particularly, if I wanted the backstab dagger from my other suggestion to be useful only against human-typed enemies, the fire state would include:
- Code: Select all • Expand view
SPRT A 0 A_CheckFlag("ISMONSTER", "FireAtMonster", AAPTR_TARGET)
SPRT A 2 A_CheckFlag("NOBLOOD", "InvalidTarget", AAPTR_TARGET)
// More fire-state
EDIT: Added a version which uses my recently submitted player-target code. (From Final inventory actor pointer)
You can now OR (|) your target selection with AAPTR_PLAYER_GETTARGET. If executed with a player caller, the function will then use the player's current linetarget instead of any stored pointer. Players usually have null pointers. This would be especially relevant in weapon definitions where properties of the current target need to be tested. To have it work only for the player, specify AAPTR_PLAYER_GETTARGET|AAPTR_NULL. To have it get any of the other pointers (DEFAULT - which means self, MASTER, TRACER, TARGET), just combine it with that particular pointer instead. AAPTR_DEFAULT is 0, so if you specify AAPTR_PLAYER_GETTARGET alone, DEFAULT is automatically implied for non-players.
EDIT: Attachments removed; they have served their purpose.