Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UDKBase.UDKBot


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
/**
 * AI Controller that simulates the  behavior of a human player
 *
 * Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
 */

class UDKBot extends AIController
	native;

/** Squad this bot is in.  Squads share the same goal, and handle AI planning. */
var UDKSquadAI			Squad;

/** component that handles delayed calls ExecuteWhatToDoNext() to when triggered */
var UDKAIDecisionComponent DecisionComponent;

/** temporarily look at this actor (for e.g. looking at shock ball for combos) - only used when looking at enemy */
var Actor TemporaryFocus;

/** set when in ExecuteWhatToDoNext() so we can detect bugs where
 * it calls WhatToDoNext() again and causes decision-making to happen every tick
 */
var bool bExecutingWhatToDoNext;

/** script flags that cause various events to be called to override C++ functionality */
var bool bScriptSpecialJumpCost;

/** used with route reuse to force the next route finding attempt to do the full path search */
var bool bForceRefreshRoute;

/** if set pass bRequestAlternateLoc = TRUE to GetTargetLocation() when determining FocalPoint from Focus */
var bool bTargetAlternateLoc;

var		bool		bEnemyInfoValid;	// false when change enemy, true when LastSeenPos etc updated

var		bool		bEnemyIsVisible;		/** Result of last enemy LineOfSightTo() check */

var		bool		bLeadTarget;		// lead target with projectile attack

var		bool		bJumpOverWall;					// true when jumping to clear obstacle

var		bool		bPlannedJump;		// set when doing voluntary jump

/** bInDodgeMove is true if a bot is currently executing a dodge, and has not yet landed from it */
var		bool		bInDodgeMove;

/** bEnemyAcquired is true if the bot has been able to face the enemy directly.  The bot has improved tracking after acquiring an enemy (uses AcquisitionYawRate instead of RotationRate to track enemy before acquired). */
var		bool		bEnemyAcquired;

/** triggers the bot to call DelayedLeaveVehicle() during its next tick - used in the 'non-blocking' case of LeaveVehicle() */
var bool bNeedDelayedLeaveVehicle;

/** if true, when pathfinding to the same RouteGoal as the last time, use old RouteCache if it's still valid and all paths on it usable */
var bool bAllowRouteReuse;

/** if not 255, bot always uses this fire mode - for scripting bot actions */
var byte ScriptedFireMode;

// caching visibility of enemies
var		float		EnemyVisibilityTime;	/** When last enemy LineOfSightTo() check was done */
var		pawn		VisibleEnemy;			/** Who the enemy was for the last LineOfSightTo() check */

/** Last vehicle which blocked the path of this bot */
var		Vehicle		LastBlockingVehicle;

/** Normally the current enemy.  Reset SavedPositions if this changes. */
var		Pawn		CurrentlyTrackedEnemy;	

struct native EnemyPosition
{
	var vector	Position;
	var	vector	Velocity;
	var float	Time;
};

/** Position and velocity of enemy at previous ticks.  
Used for smooth bot aiming prediction - bots aim at where they think the target is based on his position and velocity a few 100 msec ago, like a player. */
var array<EnemyPosition> SavedPositions;	

/** velocity added while falling (bot tries to correct for it) */
var vector	ImpactVelocity;	 

/** The bot uses AcquisitionYawRate instead of RotationRate to track enemy before acquired. */
var		int		AcquisitionYawRate;

/** distance at which bot will notice noises. */
var float			HearingThreshold;	

/** How long ahead to predict inventory respawns */
var		float							RespawnPredictionTime;

/** delay before act on warning about being shot at by InstantWarnTarget() or ReceiveProjectileWarning() */
var float WarningDelay;	

/** Projectile bot has been warned about and will react to (should set in ReceiveProjectileWarning()) */
var Projectile WarningProjectile;

/** for monitoring the position of a pawn.  Will receive a MonitoredPawnAlert() event if the MonitoredPawn is killed or no longer possessed, 
or moves too far away from either MonitorStartLoc or the bot's position */
var		vector		MonitorStartLoc;	// Location checked versus current MonitoredPawn position to see if it has moved too far 
var		Pawn		MonitoredPawn;		// Pawn being monitored
var		float		MonitorMaxDistSq;	// Maximum distance the Monitored pawn can move before being considered too far away.

// enemy position information
var		vector		LastSeenPos; 	// enemy position when I last saw enemy (auto updated if EnemyNotVisible() enabled)
var		vector		LastSeeingPos;	// position where I last saw enemy (auto updated if EnemyNotVisible() enabled)
var		float		LastSeenTime;	// time at which last seen information was last updated.

/** Enemy tracking - bots use this for targeting their current enemy.  Bots actually aim at a position based that's predicted based on the 
target's position TrackingReactionTime ago, extrapolated using the target's velocity at that time.
This means, for example, that if a target suddenly changes directions, bots will miss because they'll fire at where they thought he was going 
(until their reactio delay catches up */
var		float		TrackingReactionTime;	/** How far back in time is bots model of enemy position based on */
var		float		BaseTrackingReactionTime;	/** Base value, modified by skill to set TrackingReactionTime */
var		vector		TrackedVelocity;		/** Current velocity estimate (lagged) of tracked enemy */

/** whether bot is currently using the squad alternate route - if false, FindPathToSquadRoute() just calls FindPathToward(Squad.RouteObjective) */
var bool bUsingSquadRoute;

/** if true, this bot uses the SquadAI's PreviousObjectiveRouteCache instead (used when the route changes while bot is following it) */
var bool bUsePreviousSquadRoute;

/** goal along squad's route, used when moving along alternate path via FindPathToSquadRoute() */
var NavigationPoint SquadRouteGoal;

/** Iterative aim correction in progress if set */
var pawn BlockedAimTarget;

/** pct lead for last targeting check */
var float LastIterativeCheck;

/* Aim update frequency.  How frequently bots check whether their tracking aim needs to be adjusted for obstacles, etc. */
var float AimUpdateFrequency;

/** Last time tracking aim was updated */
var float LastAimUpdateTime;

/** how often aim error is updated when bot has a visible enemy */
var float ErrorUpdateFrequency;

/** last time aim error was updated */
var float LastErrorUpdateTime;

/** aim error value currently being used */
var float CurrentAimError;

/** expected min landing height of dodge.  Hint used by bots to track whether they are about to miss their planned landing spot (if bInDodgeMove is true).
If so, the MissedDodge() event is triggered. */
var		float		DodgeLandZ;		

/** avoid these spots when moving - used for very short term stationary hazards like bio goo or sticky grenades. */
var		Actor	FearSpots[2];	

/** Likelihood that MayDodgeToMoveTarget() event is called when starting MoveToGoal(). */
var float			DodgeToGoalPct;

/** jump Z velocity bot can gain using multijumps (not counting first jump) */
var		float		MultiJumpZ;

cpptext
{
	DECLARE_FUNCTION(execPollWaitToSeeEnemy);
	DECLARE_FUNCTION(execPollLatentWhatToDoNext);
	UBOOL Tick( FLOAT DeltaSeconds, ELevelTick TickType );
	virtual void UpdateEnemyInfo(APawn* AcquiredEnemy);
	virtual void PrePollMove();
	virtual void PostPollMove();
	void CheckFears();
	virtual void PreAirSteering(FLOAT DeltaTime);
	virtual void PostAirSteering(FLOAT DeltaTime);
	virtual void PostPhysFalling(FLOAT DeltaTime);
	virtual UBOOL AirControlFromWall(FLOAT DeltaTime, FVector& RealAcceleration);
	virtual UReachSpec* PrepareForMove(ANavigationPoint *NavGoal, UReachSpec* CurrentPath);
	virtual void AdjustFromWall(FVector HitNormal, AActor* HitActor);
	virtual void JumpOverWall(FVector WallNormal);
	virtual void NotifyJumpApex();
	virtual FRotator SetRotationRate(FLOAT deltaTime);
	virtual DWORD LineOfSightTo(const AActor* Other, INT bUseLOSFlag = 0, const FVector* chkLocation = NULL, UBOOL bTryAlternateTargetLoc = FALSE);
	FLOAT SpecialJumpCost(FLOAT RequiredJumpZ);
	virtual UBOOL ForceReached(ANavigationPoint *Nav, const FVector& TestPosition);
	virtual void UpdatePawnRotation();
	virtual void MarkEndPoints(ANavigationPoint* EndAnchor, AActor* Goal, const FVector& GoalLocation);
	virtual UBOOL OverridePathTo(ANavigationPoint* EndAnchor, AActor* Goal, const FVector& GoalLocation, UBOOL bWeightDetours, FLOAT& BestWeight);
	virtual void FailMove();

	// Seeing and hearing checks
	virtual UBOOL ShouldCheckVisibilityOf(AController* C);
	virtual DWORD SeePawn(APawn* Other, UBOOL bMaySkipChecks = TRUE);
	virtual UBOOL CanHear(const FVector& NoiseLoc, FLOAT Loudness, AActor *Other);
	virtual void HearNoise(AActor* NoiseMaker, FLOAT Loudness, FName NoiseType);
}

/**
  * Used to determine which actor should be the focus of this bot (that he looks at while moving)
  */
function Actor FaceActor(float StrafingModifier);

/** entry point for AI decision making
 * this gets executed during the physics tick so actions that could change the physics state (e.g. firing weapons) are not allowed
 */
protected event ExecuteWhatToDoNext();

/** 
 * Warning from vehicle that bot is about to be run over.
*/
event ReceiveRunOverWarning(UDKVehicle V, float projSpeed, vector VehicleDir);

/** return when looking directly at visible enemy */
native final latent function WaitToSeeEnemy(); 

/** encapsulates calling WhatToDoNext() and waiting for the tick-delayed decision making process to occur using UDKAIDecisionComponent */
native final latent function LatentWhatToDoNext();

/** assumes valid CurrentPath, tries to see if CurrentPath can be combined with path to A */
native final function bool CanMakePathTo(Actor A); 

/**
* Searches the navigation network for a path that leads
* to nearby inventory pickups.
*/
native final function actor FindBestInventoryPath(out float MinWeight);

/**
* Returns shortest path to squad route (UTSquadAI.ObjectiveRouteCache), or next node along route
* if already on squad route
*/
native final function actor FindPathToSquadRoute(optional bool bWeightDetours);

/** 
* Called by squadleader.  Fills the squad's ObjectiveRouteCache.
* Builds upon previous attempts by adding cost to the routes
* in the SquadAI's SquadRoutes array, up to a maximum
* of MaxSquadRoutes iterations.
*/
native final function BuildSquadRoute();

/**
  * Sets all available "super pickups" as possible destinations, and determines best one
  * based on the value of and distance to the pickup (distance must be less than MaxDist).
  * A super pickup is a PickupFactory with bIsSuperItem==true
  * To be valid, it must be ready to pick up, or about to respawn (within this bot's RespawnPredictionTime)
  * not blocked by a vehicle, and desireable to this bot (based on the SuperDesireability() event).
  */
native function Actor FindBestSuperPickup(float MaxDist);

/** triggers ExecuteWhatToDoNext() to occur during the next tick
 * this is also where logic that is unsafe to do during the physics tick should be added
 * @note: in state code, you probably want LatentWhatToDoNext() so the state is paused while waiting for ExecuteWhatToDoNext() to be called
 */
event WhatToDoNext();

/**
 * Will receive a MonitoredPawnAlert() event if the MonitoredPawn is killed or no longer possessed, 
 * or moves too far away from either MonitorStartLoc or the bot's position 
 */
event MonitoredPawnAlert();

/** 
* If bot gets stuck trying to jump, then bCanDoubleJump is set false for the pawn
* Set a timer to reset the ability to double jump once the bot is clear.
*/
event TimeDJReset();

/* 
Called when starting MoveToGoal(), based on DodgeToGoalPct
Know have CurrentPath, with end lower than start
*/
event MayDodgeToMoveTarget();

/** Called when bScriptSpecialJumpCost is true and the bot is considering a path to DestinationActor
 *	that requires a jump with JumpZ greater than the bot's normal capability, but less than MaxSpecialJumpZ
 *	calculates any additional distance that should be applied to this path to take into account preparation, etc
 * @return true to override the cost with the value in the Cost out param, false to use the default natively-calculated cost
 */
event bool SpecialJumpCost(float RequiredJumpZ, out float Cost);

/*
 * Called from native FindBestSuperPickup() to determine how desireable a specific super pickup 
 * is to this bot.
 */
event float SuperDesireability(PickupFactory P);

/*
 * Aiming code requests an update to the aiming error periodically when tracking a target, based on ErrorUpdateFrequency.
 */
event float AdjustAimError(float TargetDist, bool bInstantProj );

/** 
 * If DodgeLandZ (expected min landing height of dodge) is missed when bInDodgeMove is true,
 * the MissedDodge() event is triggered.
 */
event MissedDodge();

/* If ReceiveWarning caused WarningDelay to be set, this will be called when it times out
*/
event DelayedWarning();

/** called just before the AI's next tick if bNeedDelayedLeaveVehicle is true */
event DelayedLeaveVehicle();

defaultproperties
{
	RotationRate=(Pitch=30000,Yaw=30000,Roll=2048)
	RemoteRole=ROLE_None

	Begin Object Class=UDKAIDecisionComponent Name=TheDecider
	End Object
	DecisionComponent=TheDecider
	Components.Add(TheDecider)

	AimUpdateFrequency=0.2
	LastIterativeCheck=1.0
	ErrorUpdateFrequency=0.45
	bLeadTarget=True

	AcquisitionYawRate=20000
	TrackingReactionTime=+0.25
	BaseTrackingReactionTime=+0.25
	bUsingSquadRoute=true
	bAllowRouteReuse=true
	HearingThreshold=2800.0
}


Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: to 6-1-2011 07:13:04.000 - Creation time: ti 22-3-2011 19:57:12.299 - Created with UnCodeX