Gah - a solution with more questions. – EntropicLqd
Legacy:MonsterController
From Unreal Wiki, The Unreal Engine Documentation Site
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
[edit] Properties
All MonsterController properties are hidden.
[edit] Magic numbers
(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)
[edit] Flags
- 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
[edit] Advanced AI
- float AcquireTime
- Time at which current enemy was acquired
- float LoseEnemyCheckTime
- Not implemented.
- float StartTacticalTime
- vector HidingSpot
- float ChallengeTime
[edit] Modifiable AI
- 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
[edit] Team AI
- string GoalString
- For debugging - used to show what bot is thinking (with 'ShowDebug')
- string SoakString
- For debugging - shows problem when soaking
[edit] Used in ChooseAttackMode() State
- int ChoosingAttackLevel
- float ChooseAttackTime
- int ChooseAttackCounter
- float EnemyVisibilityTime
- Pawn VisibleEnemy
- Pawn OldEnemy
- float StopStartTime
- float LastRespawnTime
- float FailedHuntTime
- Pawn FailedHuntEnemy
[edit] Miscellaneous
- int NumRandomJumps
- Attempts to free monster from being stuck
[edit] Functions
(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
[edit] States
[edit] NoGoal
- EMPTY
[edit] RestFormation
- Ignores EnemyNotVisible(). Calls WaitForLanding().
[edit] Functions
- 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.
[edit] Events
- 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.
[edit] MoveToGoal
[edit] MoveToGoalNoEnemy extends MoveToGoal
- EMPTY
[edit] MoveToGoalWithEnemy extends MoveToGoal
- When Timer() is called, calls TimedFireWeaponAtEnemy().
[edit] Roaming extends MoveToGoalNoEnemy
- Ignores EnemyNotVisible.
- Begin
- Calls SwitchToBestWeapon(), WaitForLanding() and MoveToward(MoveTarget,FaceActor(1),,ShouldStrafeTo(MoveTarget)).
- DoneRoaming
[edit] Charging extends MoveToGoalWithEnemy
- Ignores SeePlayer and HearNoise.
- Begin
- WaitForAnim
- Moving
[edit] TacticalMove
- Ignores SeePlayer and HearNoise.
- TacticalTick
- Begin
- DoMove
- WaitForAnim
- DoStrafeMove
- RecoverEnemy
- FinishedStrafe
[edit] Hunting extends MoveToGoalWithEnemy
- Ignores EnemyNotVisible.
- AdjustFromWall
- Begin
- WaitForAnim
- SpecialNavig
[edit] StakeOut
- Ignores EnemyNotVisible.
- Begin
[edit] RangedAttack
- Ignores SeePlayer, HearNoise and Bump.
- Begin
[edit] WaitForAnim
- Ignores SeePlayer, HearNoise, KilledBy, NotifyBump, HitWall, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange, Falling, TakeDamage and ReceiveWarning.
[edit] Events
- AnimEnd( int Channel )
- Calls Pawn.AnimEnd(Channel). If !Monster(Pawn).bShotAnim, calls WhatToDoNext(99).
[edit] WaitingForLanding
[edit] Functions
- 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().
[edit] Related Topics
- Monster
- Controller Overview
- Artificial Intelligence - Super topic for all AI (bots, Monsters, NPCs, etc)
[edit] Discussion
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.
