I love the smell of UnrealEd crashing in the morning. – tarquin

Legacy:MonsterController

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
UT2003 :: Object >> Actor >> Controller >> AIController >> ScriptedController >> MonsterController (Package: SkaarjPack)

Simple AI that always hunts down players as enemies.

// note ut2004 monster controller code is just about identical

// but ut2004 has a problem a serious one the monsters jump though states too fast

// and will crash the entire game by calling the find new enemy function untill the recursions exceed 10000

Properties[edit]

All MonsterController properties are hidden.

Magic numbers[edit]

(from remark in code) "Distance based, so scale to bot speed/weapon range"

MAXSTAKEOUTDIST = 2000 (const)
ENEMYLOCATIONFUZZ = 1200 (const)
TACTICALHEIGHTADVANTAGE = 320 (const)
MINSTRAFEDIST = 200 (const)
MINVIEWDIST = 200 (const)

Flags[edit]

bool bCanFire 
Used by TacticalMove and Charging states
bool bStrafeDir 
bool bLeadTarget 
Lead target with projectile attack
bool bChangeDir 
Tactical move boolean
bool bEnemyIsVisible 
bool bMustCharge 
bool bJustLanded 
bool bRecommendFastMove 
bool bHasFired 
bool bForcedDirection 

Advanced AI[edit]

float AcquireTime 
Time at which current enemy was acquired
float LoseEnemyCheckTime 
Not implemented.
float StartTacticalTime 
vector HidingSpot 
float ChallengeTime 

Modifiable AI[edit]

float Accuracy 
-1 to 1 (0 is default, higher is more accurate)
float StrafingAbility 
-1 to 1 (higher uses strafing more)
float CombatStyle 
-1 to 1 = low means tends to stay off and snipe, high means tends to charge and melee
float ReactionTime 

Team AI[edit]

string GoalString 
For debugging - used to show what bot is thinking (with 'ShowDebug')
string SoakString 
For debugging - shows problem when soaking

Used in ChooseAttackMode() State[edit]

int ChoosingAttackLevel 
float ChooseAttackTime 
int ChooseAttackCounter 
float EnemyVisibilityTime 
Pawn VisibleEnemy 
Pawn OldEnemy 
float StopStartTime 
float LastRespawnTime 
float FailedHuntTime 
Pawn FailedHuntEnemy 

Miscellaneous[edit]

int NumRandomJumps 
Attempts to free monster from being stuck

Functions[edit]

(incomplete)

Trigger( Actor Other, Pawn EventInstigator ) 
If Other is a Pawn and Pawn.Health >= 0, calls SetEnemy( EventInstigator, true ).
FightEnemy( bool bCanCharge ) 
Decides how to attack: Hunt, StakeOut, Melee, Ranged, etc. Also performs a "teleport" (SetLocation() to a PlayerStart), if the FailedHuntTime is reached and the controlled Pawn not currently seen by the enemy.
ChooseAttackMode() 
Handles tactical attacking state selection - choose which type of attack to do from here.
bool FindBestPathToward( Actor A, bool bCheckedReach, bool bAllowDetour ) 
Assumes the desired destination is not directly reachable. It tries to set Destination to the location of the best waypoint, and returns true if successful.
bool NearWall( float walldist ) 
Returns true if there is a nearby barrier at eyeheight, and changes FocalPoint to a suggested place to look.
rotator AdjustAim( FireProperties FiredAmmunition, vector projStart, int aimerror ) 
Returns a rotation which is the direction the bot should aim - after introducing the appropriate aiming error.
bool Formation() 
Returns false.
DoStakeOut() 
Switches to state StakeOut.
DoCharge() 
If in WaterVolume and bCanSwim is false or if bCanFly and bCanWalk are false, calls DoTacticalMove(). Otherwise, switches to state Charging.
DoTacticalMove() 
Switches to state TacticalMove.
bool DefendMelee( float Dist ) 
Return true if defending against melee attack.
bool IsStrafing() 
Returns false.
bool IsHunting() 
Returns false.
bool Stopped() 
Returns bPreparingMove.
GameHasEnded() 
EMPTY

States[edit]

NoGoal[edit]

EMPTY

RestFormation[edit]

Ignores EnemyNotVisible(). Calls WaitForLanding().

Functions[edit]

CancelCampFor( Controller C ) 
Calls DirectedWander(Normal(Pawn.Location - C.Pawn.Location)).
bool Formation() 
Returns true.
Timer() 
Calls and enables NotifyBump.
PickDestination() 
If TestDirection(VRand(),Destination), return. Otherwise, call TestDirection(VRand(),Destination).
BeginState() 
Sets Enemy = None, Pawn.bCanJump = false, Pawn.bAvoidLedges = true, Pawn.bStopAtLedges = true, calls Pawn.SetWalking(true) and sets MinHitWall += 0.15.
EndState() 
Sets MonitoredPawn = None and MinHitWall -= 0.15. If Pawn != None, sets Pawn.bStopAtLedges = false and Pawn.bAvoidLedges = false, calls Pawn.SetWalking(false) and if Pawn.JumpZ > 0, sets Pawn.bCanJump = true.

Events[edit]

MonitoredPawnAlert() 
Calls WhatToDoNext(6).
Begin 
Calls WaitForLanding(); ...
Camping 
Sets Pawn.Acceleration = vect(0,0,0), Focus = None, FocalPoint = VRand(). Calls NearWall(MINVIEWDIST), FinishRotation() and Sleep(3 + FRand()) ...
Moving 
Calls WaitForLanding() and PickDestination() ...
WaitForAnim 
If Monster(Pawn).bShotAnim, calls Sleep(0.5) and goes to WaitForAnim. Calls MoveTo(Destination,,true). If Pawn.bCanFly and Physics == PHYS_Walking, calls SetPhysics(PHYS_Flying). Calls WhatToDoNext(8). Goes to Begin.

MoveToGoal[edit]

MoveToGoalNoEnemy extends MoveToGoal[edit]

EMPTY

MoveToGoalWithEnemy extends MoveToGoal[edit]

When Timer() is called, calls TimedFireWeaponAtEnemy().

Roaming extends MoveToGoalNoEnemy[edit]

Ignores EnemyNotVisible.
Begin 
Calls SwitchToBestWeapon(), WaitForLanding() and MoveToward(MoveTarget,FaceActor(1),,ShouldStrafeTo(MoveTarget)).
DoneRoaming 

Charging extends MoveToGoalWithEnemy[edit]

Ignores SeePlayer and HearNoise.
Begin 
WaitForAnim 
Moving 

TacticalMove[edit]

Ignores SeePlayer and HearNoise.
TacticalTick 
Begin 
DoMove 
WaitForAnim 
DoStrafeMove 
RecoverEnemy 
FinishedStrafe 

Hunting extends MoveToGoalWithEnemy[edit]

Ignores EnemyNotVisible.
AdjustFromWall 
Begin 
WaitForAnim 
SpecialNavig 

StakeOut[edit]

Ignores EnemyNotVisible.
Begin 

RangedAttack[edit]

Ignores SeePlayer, HearNoise and Bump.
Begin 

WaitForAnim[edit]

Ignores SeePlayer, HearNoise, KilledBy, NotifyBump, HitWall, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange, Falling, TakeDamage and ReceiveWarning.

Events[edit]

AnimEnd( int Channel ) 
Calls Pawn.AnimEnd(Channel). If !Monster(Pawn).bShotAnim, calls WhatToDoNext(99).

WaitingForLanding[edit]

Functions[edit]

bool DoWaitForLanding() 
bool NotifyLanded( vector HitNormal ) 
Timer() 
If Focus == Enemy, call TimedFireWeaponAtEnemy(), else call SetCombatTimer().
BeginState() 
Set bJustLanded = false. If MoveTarget != None and Enemy == None or Focus != Enemy, set FaceActor(1.5). If Enemy == None or Focus != Enemy, call StopFiring().

Related Topics[edit]

Discussion[edit]

SuperApe: Created. Could use brief definitions of each state. Rest of functions need to be added.


Category:Legacy Class (UT2003)

Category:Legacy Class (UT2004)

Category:Legacy To Do – Finish state definitions.