Skip to content

KAI_BaseVehicle

inkoalawetrust edited this page May 5, 2023 · 8 revisions

KAI_BaseVehicle

Parent class: KAI_Actor

Child classes:

All the vehicles currently in my Military Vehicles Pack as of version 0.4.0.

Description

This is the base NPC class for all vehicle NPCs. This class covers any vehicles you may want to add to your mod, and has vehicle-specific behavior and code to make vehicles behave differently from normal monsters.

As of 5/5/2023, it is the most fully fledged NPC base, since the KAI library was made out of the base vehicle code of my MVP mod.

Features

Turrets

Vehicle.turret.mp4

NPC vehicles have the ability to have turrets attached to them, that move and act independent of the vehicle. The behavior of the turrets, how they are spawned and attached, etc, are completely customizable. Vehicle turrets can also be made to visually change their elevation based on their pitch, if you have the sprites for it. And much more !

For more information on turrets, click here.

Headlights

Headlights.mp4

NPC vehicles have a configurable system that allows you to give the vehicle headlights, which it will turn on and off when it is inside dark sectors. The size, color, cone etc of the headlight can be customized as well, along with how dark a sector needs to be for the vehicle to turn its' headlights on.

Corpse crushing

Corpse crushing NPC vehicles have the ability to crush corpses they touch, with the maximum dimensions of a corpse they can crush being configurable through properties. Keep in mind that crushing corpses has to manually be handled with a function call (TODO: Add link to KAI_CrushCorpses()) however.

More features

  • Stay away from enemies by default instead of charging headfirst like Doom monsters normally do. And can retreat from targets above a certain threshold.
  • Friendly vehicles keep some amount of distance between themselves and the player when following them. So players aren't dogpiled by multiple vehicles.
  • Can stay in place to let their turrets fire.
  • Can stop chasing their target after not seeing it for a certain amount of time, in case they get stuck trying to head to an unreachable enemy.

Variables

These are the variables shared by all vehicles and turrets.

Constants

  • DEFAULT_HEARDISTANCE = 4096: The default hear distance the vehicles' and turrets' KAI_Look() calls use.
  • DEFAULT_SEEDISTANCE = 8192: The default sight distance the vehicles' and turrets' KAI_Look() calls use.

NearestEnemy

Type: Actor pointer

A pointer to the enemy that is closest to the vehicle, if any. Used in KAI_LandVehicleChase() to make vehicles keep a set distance from all enemies.

ChaseTimer

Type: Integer

How long the vehicle has been chasing its' target for since it last saw it. Used in conjunction with the SearchTime property.

StayStillDelay

Type: Integer

Used by the StayStillAndShoot (TODO: Add link) virtual function to put a cap on how long until the vehicle can decided to stand around and shoot again.

Headlights

Type: Dynamic array

A dynamic array that stores pointers to each of the vehicle's headlights. Only accepts pointers to KAI_Headlight actors. Used to keep track of the headlights to turn them on or off or remove them when needed.

HeadlightsOn

Type: Boolean

Returns if the headlights should currently be on, this updates every tick based on if the current sectors' light level is below the HeadlightLevel, so it should not be touched, only read.

Turret

Type: KAI_BaseTurret pointer

A pointer to the vehicles' turret, if any.

TurretOffsets

Type: Vector3

The relative offsets to pass on top of the turrets' own attachment offsets. Turrets stick to the top of the vehicle's hitbox, so this is a useful property to perform micro-adjustments to the attachment height to fix small sprite clipping issues. Should be set before SpawnVehicleTurret() (TODO: Add link) is called. This will be made into a property once GZDoom 4.11 releases.

LightsOnAlready

Type: Boolean

Used in the headlight control functions (TODO: Add link) to prevent the headlights from being turned on and off every tick. Like HeadlightsOn this should not be modified, only read.

Flags

These are the flags shared by all vehicles and turrets.

Transport

Does nothing by default. Just marks the vehicle as being able to transport/spawn NPCs.

NoHeadlights

Disables the headlight system for the vehicle entirely.

PassThreatLevelToTurrets

If the vehicle has a threat level, and its' turret doesn't. Then the vehicles' threat level will be passed to the turret.

Properties

These are properties shared by all vehicles and turrets.

VehicleTurret

The class name of the vehicle turret to attach to the vehicle. This can only be an actor based on KAI_BaseTurret.

HeadlightLevel

If the light level of the sector the vehicle is currently in is below this threshold, the vehicle will turn on its' headlights. Default is 104.

RetreatRange

If an enemy is within this range of the vehicle, KAI_LandVehicleChase() should make it drive away from them. This range is 4 times longer for targets over the vehicle's ThreatLevelThreshold. If this is 0 or less, the vehicle will not drive away from enemies at all. Default is 768.

SearchTime

How long does the vehicle keep chasing its' target after losing sight of it, before giving up ? If this is 0 or less, vehicles never stop chasing their target after it goes out of sight, like normal Doom monsters. Keep in mind that this timer updates every time KAI_LandVehicleChase() is called, not every tick !

MaxCorpseRadius, MaxCorpseHeight

The maximum radius and height, respectively, of a corpse that the vehicle will be able to crush, anything over this will be uncrushable. Remember that corpse crushing has to be handled manually with the KAI_CrushCorpses() (TODO: Add link) function.

Functions

See here.

See also

Clone this wiki locally