-
Notifications
You must be signed in to change notification settings - Fork 0
KAI_LOFRaycast
Parent class: LineTracer
Child classes:
KAI_LOFRaycast is the base LineTracer class for making custom line of fire/sight checks. Its purpose is to allow for easily making custom checks, such as a check for a unique attack an actor might have. Custom casts can be made and used by non KAI_Actor NPCs as well, of course.
- A foundation for making custom line tracers more easily, instead of having to start from scratch with LineTracer.
- Includes the KAI_CheckFunctions mixin, allowing custom raycasts to use all the actor checks the mixin includes.
- Contains functions of its' own for checks on any actors or level geometry the trace hits.
Type: Boolean
This variable is used to return if the line of fire check successfully reached its' destination or not. If it's true, then the check failed, if false, then it succeeded.
Type: Actor pointer
Stores a pointer to the actor that shot the raycast (Usually the actor doing the LOF check), useful for raycasts that need to do comparison tests between the shooter and an actor the trace hit, like checking if an actor that was hit is an enemy of the shooter.
Type: Actor pointer
The actor that trace is looking for, if any, in the case of line of fire checks this is usually the _Shooter's target.
Type: Dynamic array
Used to store pointers to each actor that was hit by the trace, if such info is needed. This doesn't work automatically, so you need to do it manually with AddToMobjList(). It might also be good to null the HitActor variable of the TraceResults field, particularly for ripper checks. And instead use this array, where the last actor in it will be the value of Results.HitActor.
Note: Tracers also have access to all the KAI_CheckFunctions functions by default.
Note: This function is static, so it can be called from everywhere.
- OriginPos: The Vector3 coordinate from which the line starts.
- FinalPos: The Vector3 coordinate at which the line ends.
- Distance: The distance for the line to cover, in map units.
- Spacing: How far apart each particle is, default is 4 map units.
- Params: The optional FSpawnParticleParams struct to pass to the particles spawned.
- None
A debug function which draws a line of white particles from OriginPos to FinalPos. Useful for seeing what direction traces are going, what stopped them, etc.
- Other: The actor to add to the Mobjs array.
- None
Adds Other to the Mobjs array, so that the code that create the trace can then access the array once the trace finishes, and see what actors it hit.
- Other: The prop to check.
- HealthThreshold: The amount of health the props needs to be at or below for the check to return true.
- Returns true if the prop is weak enough for the prop that the trace hit to not count as an obstacle, false otherwise.
Checks if the Other actor is a destructible prop, and its' health is at or below HealthThreshold. This can be useful to make an actor whose LOF check prevents it from shooting at actors it can't fire through, but still allows it to fire through them if the actor is weak enough to be destroyed quickly. The basic projectile LOF check makes use of it for that purpose.
- Other: The actor to check.
- Returns true if Other is dead, but still collidable.
Checks if the Other actor is a dead prop, NPC, or player. But their corpse can still be collided. This is useful for making LOF checks still return true for blocking non-props that are in the way. Such as the wrecks of dead vehicles. KAI_LOFProjectileCheck uses this as well.
- Other: The actor to check.
- RipLevel: The rip level to check for.
- NoBossRip: Does the projectile the check is for have +NOBOSSRIP ? If yes, return true if Other is a +BOSS.
- Returns true if the specified RipLevel CAN'T rip Other, and false if it CAN rip.
Checks if the specified rip level this check is practically necessary if you are making a line of fire check for a ripper projectile attack. As it allows the check to return false of an actor that the projectile won't be able to rip through is standing in the way.
- Blocking: The linedef to check for.
- Flags: The flags to use for the check.
- BLITW_HitscansToo: Check for hitscan blocking lines as well.
- BLITW_HitscansOnly: ONLY check for hitscan blocking lines, useful if you are doing LOF checks for hitscan attacks, obviously.
- Returns true if Blocking would stop the attack the raycast is doing a LOF check for. False if it wouldn't.
Checks if the Blocking line would stop the attack the raycast is being used for, remember, this function assumes a projectile attack by default. So use one of the Flags if you want to make a LOF check for a hitscan attack.
NOTE: There is a bug where this function does not work well with single plane 3D floors, this is a problem with GZDoom, and I don't know how to fix it.
- Results: The TraceResults struct of the line tracer. Needed to check all hit data to see if in the current callback, the trace hit any actor and hitscan blocking level geometry.
- Returns true if the trace hit level geometry, false otherwise.
Checks if the trace hit any level geometry whatsoever, this function is useful for nearly all raycasts, unless you have an attack that goes through level geometry.
- Caller: The actor to check if Other is an enemy of.
- Other: The actor to check if they are an enemy of Caller.
- Returns true if Other is hostile to Caller. False otherwise.
Checks if two actors are enemies of each other, if the Caller is a KAI NPC it calls their IsActorHostile() virtual. If it's not a descendant of KAI_Actor it calls IsHostile() instead. Normally this will be a check between the Shooter and the actor the trace hit. Useful for behaviors like making enemies of the shooter not count as obstacles for an attack, or making LOF checks for attacks that can't do friendly fire.
- Origin: The actor to do the sight check from.
- Other: The actor to check if Origin can see.
- Range: The range of the sight check.
- NoBlockSight: Ignore sight blocking lines, false by default.
- Returns true if Origin can see Other within the specified Range, false otherwise.
Checks if Origin can see Other. This exists because the LineTracer class KAI_LOFRaycast is based on is data scoped, and for some reason GZDooms' object scope considers CheckSight() to modify actors, instead of being purely an informational function.
- Home
- Features
- Classes
- Functions
- Guides