-
Notifications
You must be signed in to change notification settings - Fork 0
KAI_EventHandler
KAI_EventHandler is the basic event handler of the KAI library. It is used for tasks like parsing custom lumps, storing lists of all projectiles and vehicles in the map, all NPC groups, voice definitions, etc.
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.
}
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.
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.
Type: Dynamic KAI_Voice array
Important
This array is transient, which means that it is wiped when the game ends, so that the voice definitions can be parsed again for any updates. So any KAI_Voice entries that don't have any pointer elsewhere will be destroyed!
An array that stores a pointer to every KAI_Voice definition parsed by the library.
Note
This section does NOT document the code used by the KAI_VOICES parser, since it's not all that relevant for mod development, for that info, check the source code in Voices.zsc yourself.
- What: What actor to add to the ProjectileList array ?
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.
- What: What actor to remove from the ProjectileList array ?
Removes the specified actor from the projectile list if it was present there.
- Who: What vehicle to remove from the AllVehicles array ?
Removes a vehicle from the AllVehicles array. Must be a descendant of KAI_BaseVehicle. Again, no reason to use this directly.
- Group: The KAI_NPCGroup instance to add.
Handles adding NPC group classes into the NPCGroups map, primarily assigning them a random integer ID to be put in.
Caution
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 !
- The ID to search for in NPCGroups
Finds an NPC group, if any, based on it's ID (Key pair in NPCGroups). Basically a wrapper for GetIfExists()
Returns a pointer to the NPC group.
- 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.
Finds all NPC groups in the level that have the specified cosmetic group name.
Returns true if any groups with that name were found. The actual return is the Groups array that must be passed by reference.
- 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.
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.
Caution
THERE IS LITTLE REASON TO CALL THIS FUNCTION ON YOUR OWN.
- Name: The name of the voice pack to look for.
Looks through the NPCVoices array to find the NPC group with a name that matches Name. Useful for accessing whatever voice pack(s) an NPC is supposed to have access to.
- A KAI_Voice pointer to the found group.
- Sounds: The array to output the found sounds in. This is the actual function return.
- Type: The voice type to retrieve the sound entries of.
- Voice: The sound pack to retrieve them from.
- CustomType: The custom voice type to look for in the Voice pack, if the custom type is not found, the function will instead look for the default Type passed as a fallback.
Searches for the specified voice Type or CustomType inside the specified KAI_Voice entry. Then copies the sound files defined in that voice type into the Sounds array.
The Sounds array is the return, put a pointer to a Sound type array there. And the array will be filled with those sounds.
- Home
- Features
- Classes
- Functions
- Guides