Skip to content

KAI_CheckFunctions

inkoalawetrust edited this page Oct 14, 2023 · 6 revisions

KAI_CheckFunctions

This is a mixin class that contains loads of simple check functions that can check certain attributes of an actor, like if it can fly or is patrolling. All of the functions contained in this mixin are clearscoped unless otherwise specified. Allowing them to be used by data scoped classes like KAI_LOFRaycast.

Also, unless otherwise specified, all these functions include exactly 1 parameter: Other, which is a pointer to the actor to check.

CheckActorExists()

Parameters:

  • ActorClass: A string to the actor class to check the existence of.

Function:

Returns true if there is an actor class that matches the string passed to ActorClass. If no such class exists (e.g it's part of a mod that is not currently loaded). It will return false.

IsDead()

Returns true if the Other actor is dead, false otherwise.

IsIndestructible()

Returns true if the Other actor is indestructible, false otherwise.

HasBuddha()

Parameters:

  • Other: The actor to check.
  • NoPlayerCheck: If on, the function will not return true if the Other actor is a player that has the buddha mode 1 or 2 cheats enabled.

Function:

Returns true if the Other actor has one of the buddha flags or cheats on. Meaning that they can be harmed, but will never have their health reach 0.

HasGodmode()

Parameters:

  • Other: The actor to check.
  • NoPlayerCheck: If on, the check just flat out returns false.

Function:

Returns true if the Other actor is a player, and has one of the god mode 1 or 2 cheats on. This does nothing for unkillable NPCs, so use IsIndestructible() for those instead.

IsInanimateObject()

Returns true if the Other actor is an inanimate object instead of a player or NPC. Returns false otherwise.

IsCollidable()

Parameters:

  • Other: The actor to check.
  • Caller: The actor to check the collision groups of, this can be kept null if not needed

Function:

Returns true if the other actor can be collided. If a Caller is also specified, the function will also check if they have +ALLOWTHRUBITS on, and if they do, will also account for the thrubits property.

IsPatrolling()

Returns true if the Other actor is currently patrolling, false otherwise.

IsFrightening()

Returns true if the Other actor is a frightening actor or player. This is different from the threat assessment system, it just checks if the +FRIGHTENING flag or cheat is on.

IsFlying()

Returns true if the Other actor is a flying actor or player, false otherwise.

IsInState()

Parameters:

  • Other: The actor to check.
  • CheckFor: The state label to check if Other is within. Default state label is Spawn.

Function:

Returns true if Other is within the specified state sequence, false otherwise. This is basically a wrapper for using InStateSequence().

CanBeTargeted()

Parameters:

  • Caller: The other actor whose target to check.
  • Other: The actor to check.

Function:

Returns true if the Other actor can be targeted. If they have NOTARGET, but the Caller is already targeting them, it will still return true unless they have +NEVERTARGET.

IsFast()

Returns true if Other is fast, false otherwise.

IsNecromancer()

Returns true if Other is a necromancer-type enemy that resurrects corpses. Like vanilla Doom's Archvile.

IsTeleportingMonster()

Returns true if Other is a monster that mainly moves by teleporting from one point to the other, instead of actually moving with momentum, like players do. This is all monsters by default, however, monsters not based on KAI_Actor can be marked as moving with real momentum using KAI_DataToken, KAI NPCs are marked with the +MOVESWITHVELOCITY flag. Used by the Target prediction code to determine how to estimate the targets' trajectory.

Explanation:

TryMove, which is the function that functions like A_Chase(), A_Wander(), and KAI_MoveTowards() call to move. Works by teleporting the monster from point A to B, as opposed applying actual momentum to move it there. This is unlike players (And monsters marked as such as specified above), who move how you would actually expect, by applying thrust in their direction of movement, and moving there from tick to tick. This is also why GZDoom has an option for interpolating the movement of monsters.

IsTargetingAllies()

Parameters:

  • Caller: This is the actor that the function checks if one of their allies is being attacked.
  • Other: The actor to check if it is attacking one of the Callers' allies.

Function:

Returns true if Other is targeting an ally of Caller, otherwise returns false. For friendly monsters, it only checks if the Others' target is also friendly. For hostile monsters, it checks if Other is targeting them. If Caller is a vehicle/turret then it checks if Other is targeting its' hull or turret. If the Caller has +NOINFIGHTSPECIES, it will consider actors of the same species as Caller being targeted by Other to be allies.

CheckHitboxIntersection()

Parameters:

  • A: The first actor to check.
  • B: The second actor to check.

Function:

Checks if the hitbox of A is intersecting with the hitbox of B.

GetHitboxBoundaries()

Parameters:

  • Mo: The actor to get the hitbox boundaries of.

Function:

Gets the minimum and maximum boundaries of an actors' hitbox, and returns them as 2 vector3s.

Return:

  • A vector3 with the minimum XYZ coordinates of the hitbox.
  • A vector3 with the maximum XYZ coordinates of the hitbox.

KAI_GetSpriteAngle()

Parameters:

  • Other: The actor to get the sprite angle to.
  • ViewAngle: The angle at which Other is being looked at from.
  • TicFrac: What tick fraction to use when account for actors with +INTERPOLATEANGLES. Doesn't do anything.

Function:

Calculates the ViewAngle that Other is being seen from. This function is a copy of the native GetSpriteAngle() function. However, it lacks the handling of actors with +INTERPOLATEANGLES, because of interpolation data that is not exposed to GZDoom. The current tick fraction can be retrieved using System.GetTimeFrac(), however the fraction should always be 1.0, since it's being called from the playsim, which only runs exactly every tick. Unlike other segments of the engine like the renderer (Which the native version of this function is used from) and the UI scope.

Return:

  • The angle that Other is being viewed from.

GetSwimmable3DFloor()

Parameters:

  • Other: The actor to check.

Function:

Checks if the actor is within a swimmable 3D floor, and if they are, returns a pointer to it.

Return:

A pointer to the swimmable 3D floor Other is in, if any.

Clone this wiki locally