Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
Protected Member Functions | Protected Attributes | List of all members
dp88_AI_ChargedTurret Class Reference

Charged Turret AI. More...

#include <dp88_customAI.h>

Protected Member Functions

virtual void attackTarget (GameObject *pSelf, GameObject *pTarget, bool primary)
 
virtual void attackLocation (GameObject *pSelf, Vector3 location, bool primary)
 
virtual void StartCharging (GameObject *pSelf)
 
virtual void StartDischarging (GameObject *pSelf)
 
virtual GameObject * GetAnimationObject (GameObject *pSelf)
 
virtual void ApplyIdleAnimation (GameObject *pSelf)
 

Protected Attributes

unsigned int m_myObjId
 My own GameObject ID, used by the observer callbacks.
 
bool m_bIsCharging
 
bool m_bIsDischarging
 
bool m_bIsPreReloading
 
int m_chargeAnimObjId
 
bool m_bPowerState
 
LoopedAnimationControllerm_pLoopedAnimCtrl
 
dp88_AI_ChargedTurret_AnimationObserverm_pAnimationObserver
 

Additional Inherited Members

- Public Member Functions inherited from dp88_customAI
virtual void ResetAllActions (GameObject *obj)
 

Detailed Description

Author
Daniel Paul (danpa.nosp@m.ul88.nosp@m.@yaho.nosp@m.o.co.nosp@m..uk)

An overloaded version of my custom turret AI incorporating charge up logic, which causes an animation sequence to be played prior to each clip fired by the turret. For maximum flexibility the animation can be played on either the turrets own model or on a seperate preset which is attached by this script to a specified bone on the turret model. This allows damage and charge up animations to be used on a turret simultaneously.

One notable feature is the ability to fire more than one shot each time the turret charges up, allowing for greater flexibility in usage. When the turret is fully charged it will fire at the enemy until it runs out of bullets and needs to reload, at which point it will restart the charge up animation.

Note
The weapon reload time must be less than the duration of the charging animation
Warning
Currently there is a design limitation in the script which requires that the weapon reload time must be at least 1.1 seconds in duration to ensure correct detection of the discharged state. If this is problematic in future the limitation can be removed. If your reload time is less than 1 second the turret could empty two or more complete clips of ammo before charging again.
Parameters
Priority_InfantryBase targetting priority for infantry targets, or 0 to ignore infantry
Weapon_InfantryWeapon to use against infantry targets: 1 for primary fire, 2 for secondary fire
Splash_InfantryDetermines if we should try to damage infantry with splash instead of hitting them directly. This is useful for slow / inaccurate weapons which do splash damage: 1 to enable, 0 to disable
Priority_Light_VehicleBase targetting priority for light vehicle targets, or 0 to ignore light vehicles
Weapon_Light_VehicleWeapon to use against light vehicle targets: 1 for primary fire, 2 for secondary fire
Priority_Heavy_VehicleBase targetting priority for heavy vehicle targets, or 0 to ignore heavy vehicles
Weapon_Heavy_VehicleWeapon to use against heavy vehicle targets: 1 for primary fire, 2 for secondary fire
Priority_VTOLBase targetting priority for flying targets, or 0 to ignore flying targets
Weapon_VTOLWeapon to use against flying targets: 1 for primary fire, 2 for secondary fire
Min_Attack_RangeMinimum distance at which the turret can engage enemies when using primary fire
Max_Attack_RangeMaximum distance at which the turret can engage enemies when using primary fire
Min_Attack_Range_SecondaryMinimum distance at which the turret can engage enemies when using secondary fire
Max_Attack_Range_SecondaryMaximum distance at which the turret can engage enemies when using secondary fire
Animation_ModelOptional name of a W3D model file to spawn and attach to the turret upon which the charge animations defined in this script will be applied. This allows the turret itself to be running a different set of animations, such as damage states via dp88_damageAnimation
Animation_Model_BoneIf you specify an Animation_Model above then you must also specify the a bone on the parent to which that model should be attached. This allows the animation model to be moved by the animation set executing on the turret.
AnimationName of the animation which contains the frames for the various charge states
Animation_Idle_Start_FrameFirst frame number for the idle animation, which will loop continually whilst the turret is powered and not currently attacking a target
Animation_Idle_End_FrameFinal frame number for the idle animation
Animation_Unpowered_Start_FrameFirst frame number for the unpowered animation, which will loop continually whilst the turret is in the unpowered state. This is not used if Requires_Power is disabled (see below).
Animation_Unpowered_End_FrameFinal frame number for the unpowered animation
Animation_Charge_Start_FrameFirst frame number for the charging animation, which will be played once each time the turret reloads its weapon. Once this animation completes the turret will fire again, therefore the length of this animation must be greater than the weapon reload time.
Animation_Charge_End_FrameFinal frame number for the charging animation
Charge_SoundOptional sound effect to be played each time the turret starts charging up
Modifier_DistancePriority modification to apply based on distance to target. Higher values will favour targets which are closer to the turret, good for less accurate weapons
Modifier_Target_DamagePriority modification to apply based on damage a target has already sustained. Higher values will favour targets which have already been damaged in combat, picking them off first
Modifier_Target_ValuePriority modification to apply based on the value of the target. Higher values will favour targets with a higher purchase cost, good for hard hitting weapons
Requires_PowerSpecify whether this turret requires base power to operate: 1 to require power, 0 to ignore
DebugSpecify whether to produce a debug logfile about the turrets targetting decisions, this is useful for fine tuning your base priorities and modifiers: 1 to enable, 0 to disable
Detects_StealthDetermine whether this turret can detect stealthed enemies or not: 1 to enable, 0 to disable
Note
Vehicles are always classified as light vehicles unless they have the dp88_AI_heavyVehicleMarker script attached to them

The turret can be disabled using custom messages, see the note about this in dp88_customAI
Warning
Never leave the Debug parameter enabled when releasing your mod, it will clog up everyones machines with useless text files everywhere... people usually don't like that :D

Member Function Documentation

◆ ApplyIdleAnimation()

void dp88_AI_ChargedTurret::ApplyIdleAnimation ( GameObject * pSelf)
protectedvirtual

Called when the turret is idle or unpowered to apply the correct animation frames

◆ attackLocation()

void dp88_AI_ChargedTurret::attackLocation ( GameObject * pSelf,
Vector3 location,
bool primary )
protectedvirtual

Overloaded form of dp88_AI_Turret::attackLocation which initiates turret charging (if it is not currently in progress) rather than actually attacking anything

Reimplemented from dp88_AI_Turret.

◆ attackTarget()

void dp88_AI_ChargedTurret::attackTarget ( GameObject * pSelf,
GameObject * pTarget,
bool primary )
protectedvirtual

Overloaded form of dp88_AI_Turret::attackTarget which initiates turret charging (if it is not currently in progress) rather than actually attacking anything

Reimplemented from dp88_AI_Turret.

◆ GetAnimationObject()

GameObject * dp88_AI_ChargedTurret::GetAnimationObject ( GameObject * pSelf)
protectedvirtual

Internal utility function to get a pointer to the object upon which the charge animation will be applied - this will either be the turret itself or the seperate charge animation object if one was specified in the script parameters

◆ StartCharging()

void dp88_AI_ChargedTurret::StartCharging ( GameObject * pSelf)
protectedvirtual

This function is called to initiate the charge up process, if it is not already in progress

◆ StartDischarging()

void dp88_AI_ChargedTurret::StartDischarging ( GameObject * pSelf)
protectedvirtual

This function is called when the turret is fully charged and is ready to fire at something

Member Data Documentation

◆ m_bIsCharging

bool dp88_AI_ChargedTurret::m_bIsCharging
protected

Are we currently charging ready for an attack?

◆ m_bIsDischarging

bool dp88_AI_ChargedTurret::m_bIsDischarging
protected

Are we currently discharging (ie: attacking an enemy)?

◆ m_bIsPreReloading

bool dp88_AI_ChargedTurret::m_bIsPreReloading
protected

This is true if the turret is reloading AND the remaining reload duration exceeds the charge up time. Prevents the charge animation starting prematurely and then hanging around waiting for the reload to be finished before firing

◆ m_bPowerState

bool dp88_AI_ChargedTurret::m_bPowerState
protected

Power state last time it was checked - if this changes we need to update our animation

◆ m_chargeAnimObjId

int dp88_AI_ChargedTurret::m_chargeAnimObjId
protected

ID of the charge animation object we have created for ourselves

◆ m_pAnimationObserver

dp88_AI_ChargedTurret_AnimationObserver* dp88_AI_ChargedTurret::m_pAnimationObserver
protected

An animation observer for the object identified by m_chargeAnimObjId, if used

◆ m_pLoopedAnimCtrl

LoopedAnimationController* dp88_AI_ChargedTurret::m_pLoopedAnimCtrl
protected

A looped animation controller for the idle and low power state animations