Skip to content

KAI_EventHandler

inkoalawetrust edited this page Mar 24, 2024 · 4 revisions

KAI_EventHandler

KAI_EventHandler is the basic event handler of the KAI library. Currently, it's only purpose is keeping track of all projectiles currently flying around in the map and vehicles.

Variables

ProjectileList

Type: Dynamic actor array

Stores pointers to every projectile currently in the map that hasn't vanished or died/exploded yet. The array can be iterated through to check every projectile in the map as easily as this:

		ForEach (Proj : KAIHandler.ProjectileList)
		{
			//Run code here. Proj can be whatever pointer name you want to give to the currently iterated projectile.
		}

AllVehicles

Type: Dynamic KAI_BaseVehicle array

Stores pointers to every KAI vehicle in the map, vehicles are only removed from the array once destroyed, so dead vehicles still stay in.

NPCGroups

Type: Associative map with <Int,KAI_NPCGroup> pairs.

An associative map that stores references to all NPC groups in the level. The event handler also runs a "janitor" operation once every few seconds, to remove any groups still in the map, but that have no members in them.

Methods

AddToProjectileList ()

Parameters:

  • What: What actor to add to the ProjectileList array ?

Function:

Used to add projectiles to the projectile list. The actor in question must be a +MISSILE and do more than 0 damage. There shouldn't really be any reason to use this function, since it's already automatically handled every time an actor spawns.

RemoveFromProjectileList ()

Parameters:

  • What: What actor to remove from the ProjectileList array ?

Function:

Removes the specified actor from the projectile list if it was present there.

RemoveFromVehicleList ()

Parameters:

  • Who: What vehicle to remove from the AllVehicles array ?

Function:

Removes a vehicle from the AllVehicles array. Must be a descendant of KAI_BaseVehicle. Again, no reason to use this directly.

AddNPCGroup()

Parameters:

Function:

Handles adding NPC group classes into the NPCGroups map, primarily assigning them a random integer ID to be put in.

Note:

THIS FUNCTION SHOULD NOT HAVE TO BE CALLED MANUALLY, AS IT SHOULD BE HANDLED BY CREATEGROUP() ALREADY. IT WILL NOT CHECK WHETHER THE SAME GROUP IS IN THE MAP ALREADY !

FindNPCGroupByID()

Parameters:

  • The ID to search for in NPCGroups

Function:

Finds an NPC group, if any, based on it's ID (Key pair in NPCGroups). Basically a wrapper for GetIfExists()

Return:

Returns a pointer to the NPC group.

FindNPCGroupsByName()

Parameters:

  • GroupName: The cosmetic name to check if any groups have.
  • CaseSensitive: Should the string check be case sensitive ? For example, if it's not, both "Meal Team Six" and "meal team six" will be returned.
  • Groups: The KAI_NPCGroup array that must be passed by reference. All groups the function finds with the specified GroupName will be added to the array pointer passed here.

Function:

Finds all NPC groups in the level that have the specified cosmetic group name.

Return:

Returns true if any groups with that name were found. The actual return is the Groups array that must be passed by reference.

NPCGroupEventHandler()

Parameters:

  • EventType: The type of event to emit to all the relevant groups. A list of possible group event types can be seen here. (TODO: Add link to the group events enum once I write the KAI_NPCGroup page)
  • Affected: The actor that was affected by the specified EventType.

Function:

Handles the generic WorldThingDestroyed/Revived/Died events built into ZScript, by alerting the groups Affected is in of them, like if Affected is revived. All groups they're in will receive GRPEVNT_REVIVAL.

Note:

THERE IS LITTLE REASON TO CALL THIS FUNCTION ON YOUR OWN.

See also

Clone this wiki locally