Original suggestion: viewtopic.php?f=15&t=29014
A_CheckLOF (state jump, int flags = 0, float range = 0, float minrange = 0, float angle = 0, float pitch = 0, float offsetheight = 0, float offsetwidth = 0, int ptr_target = AAPTR_DEFAULT);
Test a would-be-hitscan/line of fire to see if anything other than the target is encountered along the way. If the target would be hit, jump to the specified state (first parameter). Flags and parameters allow the decision to be a little more involved. A creature will not necessarily want to refrain shooting at one enemy just because it would hit something else; that something could be another enemy, and a good target.
- Parameters -
Jump: Actor state jump, used if the target or another acceptable victim blocks the line of fire.
Flags: Modifies the function in various ways, see separate list.
Minrange: Fail if the line of fire is blocked too near the shooting actor; useful if a monster is contemplating the use of explosives (that are not configured to spare their originator).
Angle: Offset your aim by this angle. Base aim depends on flags; on target by default.
Pitch: Offset your aim by this angle (vertical). Base aim depends on flags; on target by default.
Offsetheight: Offset the line of fire's point of origin by this value. The base height depends on flags; hitscan emulation (around the middle) by default. When pitch is determined by aiming for target, aim is adjusted to correct for this offset.
Offsetwidth: Offset the line of fire's point of origin by this value (horizonal). Aim is not adjusted to correct for this value.
ptr_target: Pick an actor to aim for, AAPTR_DEFAULT picks TARGET (to ensure no actor is targeted, use AAPTR_NULL)
- Flags (CLOFF_...) -
NOAIM_VERT to disable vertical aim.
NOAIM_HORZ to disable horizonal aim.
Point of origin
FROMBASE: Move origin to actor's base
MUL_HEIGHT: Multiply height offset by actor's height. When called by a player, crouching is taken into account (if I succeeded in my coding).
MUL_WIDTH: Multiply width offset by actor's radius.
Additional jump qualifiers (jump if any of these occur)
JUMPENEMY: Enemy breaks line of fire
JUMPFRIEND: Friend breaks line of fire
JUMPOBJECT: Non-monster breaks line of fire
JUMPNONHOSTILE: Non-enemy breaks line of fire (I think "wild" monsters may see eachother as non-enemies unless they're set to fight over everything all the time)
Pretend the following obstacles do not exist, unless they are valid jump qualifiers (the chosen target or additional jump qualifiers)
Exclude actors that conflict with the given criteria (they will cause neither success/jump nor failure); these criteria do not apply to the actor targeted by the line of fire check
MUSTBESHOOTABLE: Ignore actors that are not shootable (checks SHOOTABLE and NONSHOOTABLE)
MUSTBEGHOST: Ignore actors that are not ghosts
IGNOREGHOST: Ignore actors that are ghosts
MUSTBESOLID: Ignore actors that are not solid
SKIPTARGET: Ignore the target actor breaking the ray
-- None of the other filters apply to the target actor, they only apply to intercepting actors
BEYONDTARGET: Trace past the targeted actor (requires SKIPTARGET, and is only useful if you're checking for some of the additional jump qualifiers)
ALLOWNULL: Cast the ray even if target is NULL. When there is no target, caller aim (pitch, angle) is used regardless of aim-flags.
CHECKPARTIAL: Perform the check even if the target itself is actually out of range. Useful if you're still interested in closer intercepting actors.
CLOFF_SKIPOBSTACLES = CLOFF_SKIPENEMY|CLOFF_SKIPFRIEND|CLOFF_SKIPOBJECT|CLOFF_SKIPNONHOSTILE
(You can override some of these with jump-flags, such as CLOFF_SKIPOBSTACLES|CLOFF_JUMPFRIEND)
CLOFF_NOAIM = CLOFF_NOAIM_VERT|CLOFF_NOAIM_HORZ
Other details: Point of origin
Default origin at natural hitscan origin (8 units above half height for monsters, player adjustment using something like attackzoffset * crouchfactor)
Firing from a specific height above actor base (feet)
Include the flag CLOFF_FROMBASE and give an explicit height offset (32 matching the default from a_custommissile)
Check from half height wherever that may be
Include flags: CLOFF_FROMBASE|CLOFF_MUL_HEIGHT
Explicit height offset: 0.5