Skip to content

KAI_BaseTurret

inkoalawetrust edited this page Sep 8, 2023 · 12 revisions

KAI_BaseTurret

Parent class: KAI_BaseVehicle

Description

This is the base class for the turrets that are attached to vehicle NPCs. They contain a lot of custom code, particularly code for making them able to visually aim up and down, and code that handles their semi-realistic turning/traverse. It's also possible to create nested turrets (Turrets on turrets !).

Flags

These are flags shared by all vehicle turrets.

FallOnDeath

The turret should be detached from its' vehicle when it is destroyed. Useful for making turrets that snap off their vehicle.

DontStayAround

If the turret has this flag, it tells its' vehicles StayStillAndShoot to return false.

TransferDamage

All damage the turret receives should be transferred to the vehicle it is attached to instead. Useful for vehicles where the turret is supposed to be an necessary part of the vehicle, like a tank. NOTE: Turrets with this flag must all have +NORADIUSDMG, otherwise the damage the vehicle will receive will be doubled !!!!!

NoCombatTraverse

The stock code that makes the turret turn to face its' target over time based on the CombatAngleTurnRate and CombatPitchTurnRate properties when it's in one of its' attack states does not run. Allowing you to write your own entirely custom logic on top of it, or simple make the turret use A_FaceTarget() like stock monsters do.

TurnSoundNoStop

The turn sound will wait for the last one to stop. Instead of playing every tick where the angle difference is big enough. This allows for playing longer turning sounds more effectively. Since it's assuming you will use this for long sounds. If the angle difference is no longer bigger than TurnSoundRadius, the turn sound will stop playing.

Properties

MaximumPitch, MinimumPitch

Variable names: MaxPitch, MinPitch

The maximum and minimum pitch that the turret can face up and down to, respectively. If both are 0, then the turret has no pitch limits.

TurnAmount

How much the turret turns back to the direction its' vehicle is facing when not in combat, this is applicable for situations like after the vehicle has stopped fighting. It's different from the turn rates of the CombatAngleTurnRate and CombatPitchTurnRate properties !

TurnSoundRadius

How much the turrets' angle must change from the last tick before its' TurnSound can play.

TurnSound

The turning sound the turret makes when rotating.

CombatAngleTurnRate, CombatPitchTurnRate

When in combat, how many degrees per second can the turret turn horizontally/vertically to aim at its' target ? You can plug in the traverse rates of IRL turrets to give them real world traverse rates or use your own.

AttackSpeed, FastAttackSpeed

Variable names: TurretAttackSpeed, FastTurretAttackSpeed

The Speed and FastSpeed of the turrets' attack, respectively. Used by AimAtTarget() to determine how far the turret should aim ahead.

Variables

TurretSnapDelay

Type: Integer

This delay can set how long it takes for the turret, after it has no target left to aim at, before it begins rotating back to facing its' vehicles' direction.

TurretRotationOffset

Type: Double

The angle to offset the turret relative from its' vehicle by. Used when the turret is destroyed/killed, and also used by prop turrets.

ElevationState

Type: Integer (Enum)

The current elevation state of the turret, used to check if the turret is trying to aim too high or low up over its' pitch limits, possible values are:

  • ELEVATION_TOOHIGH: The turret is trying to aim too high up.
  • ELEVATION_INBOUNDS: The turret is within its' pitch limits and can fire at its' target normally.
  • ELEVATION_TOOLOW: The turret is trying to aim too low down.

TurretAimPos

Type: Integer (Enum)

What part of the target should the turret aim at by default ? This value should ONLY be one of the flags from A_Face() as that's what this value is mostly used for (Along with offsetting line of fire checks.) The default is set to FAF_MIDDLE in PostBeginPlay(). Used to make turrets able to aim at partially obstructed enemies with GetFAFAimPos().

Functions

See here.

Clone this wiki locally