Legacy:ScriptedController - Unreal Wiki

# Legacy:ScriptedController

### From Unreal Wiki, The Unreal Engine Documentation Site

UT2003 :: Actor >> Controller >> AIController >> ScriptedController

AIController which is controlling a pawn through a ScriptedSequence specified by an AIScript.

## Properties

Controller PendingController
  controller which will get this Pawn after scripted sequence is complete.
int ActionNum
  each action in a ScriptedSequence has a number.
int AnimsRemaining
  how many animations are left in an action or sequence.
ScriptedSequence SequenceScript
  the ScriptedSequence the ScriptedController will use.
LatentScriptedAction CurrentAction
  used for action completion queries.
Action_PLAYANIM CurrentAnimation
  the current animation in the sequence.
bool bBroken
  a Target is still in view or not.
bool bShootTarget
  ScriptedAction is an ACTION_ShootTarget or not.
bool bShootSpray
  continue shooting or not.
bool bPendingShoot
  waiting to shoot or not.
bool bFakeShot
  this is currently a hack.
bool bUseScriptFacing
  script is setting or not what the Pawn's focus is.
bool bPendingDoubleJump
  the Pawn can double jump or not.
bool bFineWeaponControl
  bPressFire or bPressAltFire? (ACTION_FireWeaponline45).
Actor ScriptedFocus
  the Actor or Target that the Pawn should be focused on.
PlayerController MyPlayerController
  the Pawn's controller, either a Player or not.
int NumShots
  number of times to shoot before StopFiring.
name FiringMode
  appropriate firing mode, bFire or bAltFire.
int IterationCounter
  number of iterations in an action.
int IterationSectionStart
  where to start the number of iterations.

## Functions

bool WeaponFireAgain( float RefireRate, bool bFinishedFire )
  called by Weapon. Returns false to stop firing weapon.
TakeControlOf( Pawn aPawn )
  lets the script take over the Pawn.
SetEnemyReaction( int AlertnessLevel )
  used in subclasses such as Bot to determine how to react to enemies.
Pawn GetMyPlayer()
  returns the original Controller of the Pawn.
Pawn GetInstigator()
  returns the Pawn who is causing damage to the Pawn being controlled.
Actor GetSoundSource()
  returns the SequenceScript that has a ScriptedAction that's an Action_PLAYSOUND.
bool CheckIfNearPlayer( float Distance )
  check if a Player is closer than the Distance passed in and is in view.
ClearScript()
  clear out any actions remaining in the SequenceScript.
SetNewScript( ScriptedSequence NewScript )
  set the SequenceScript to the NewScript that was passed in.
ClearAnimation()
  clear out any remaining animations.
int SetFireYaw( int FireYaw )
  set direction to shoot
rotator AdjustAim( Ammunition FiredAmmunition, vector projStart, int AimError )
  adjusts aiming direction.
LeaveScripting()
  leave the SequenceScript and unpossess the pawn

## Events

NotifyJumpApex()
  notified when Pawn is at jump apex.

## States

### Scripting

#### Functions

DisplayDebug( Canvas Canvas, out float YL, out float YPos )
UnPossess()
  Scripted sequence is over - return control to PendingController
LeaveScripting()
  Calls `UnPossess()`.
InitForNextAction()
Trigger( Actor Other, Pawn EventInstigator )
  if `CurrentAction.CompleteWhenTriggered()`, calls `CompleteAction()`.
Timer()
  if `CurrentAction.WaitForPlayer()` and `CheckIfNearPlayer(CurrentAction.GetDistance())`, calls `CompleteAction()`. Otherwise if `CurrentAction.CompleteWhenTimer()`, calls `CompleteAction()`.
AnimEnd( int Channel )
LIPSincAnimEnd()
  if `CurrentAction.CompleteOnLIPSincAnim()`, call `CompleteAction()`, else call `Pawn.LIPSincAnimEnd()`.
CompleteAction()
  Calls `CurrentAction.ActionCompleted()`, sets `ActionNum++` and switches to state Scripting.Begin.
SetMoveTarget()
AbortScript()
  Calls `LeaveScripting()`.
bool WeaponFireAgain( float RefireRate, bool bFinishedFire )
  Notification from weapon when it is ready to fire (either just finished firing, or just finished coming up/reloading). Returns true if weapon should fire. If it returns false, can optionally set up a weapon change.
Tick( float DeltaTime )
  If `bPendingShoot`, sets `bPendingShoot = false` and calls `MayShootTarget()`. If `!bPendingShoot` and `CurrentAction == None` or `!CurrentAction.StillTicking(self,DeltaTime)`, disables Tick().
MayShootAtEnemy()
  EMPTY
MayShootTarget()
  Calls `WeaponFireAgain(0,false)`.
EndState()
  Sets `bUseScriptFacing = true` and `bFakeShot = false`.
Begin
  Calls `InitforNextAction()`. If `bBroken`, switches to state Broken. If `CurrentAction.TickedAction()`, enables Tick(). If `!bFineWeaponControl`, if `!bShootTarget`, sets `bFire = 0` and `bAltFire = 0`, else calls `Pawn.Weapon.RateSelf()` and if `bShootSpray`, calls `MayShootTarget()`. If `CurrentAction.MoveToGoal()`, calls `Pawn.SetMovementPhysics()` and `WaitForLanding()` (and continues through KeepMoving)
KeepMoving
  (If `CurrentAction.TickedAction()`, ) Calls `SetMoveTarget()` and `MayShootTarget()` and if `MoveTarget != None` and `MoveTarget != Pawn`, calls `MoveToward(MoveTarget, Focus,,,Pawn.bIsWalking)` and if `MoveTarget != CurrentAction.GetMoveTargetFor(self)` or `!Pawn.ReachedDestination(CurrentAction.GetMoveTargetFor(self)`, goes to KeepMoving. Calls `CompleteAction()`. Else if `CurrentAction.TurnToGoal()`, calls `Pawn.SetMovementPhysics()`, sets `Focus = CurrentAction.GetMoveTargetFor(self)`, if `Focus == None`, sets `FocalPoint = Pawn.Location + 1000 * vector(SequenceScript.Rotation)`, calls `FinishRotation()` and `CompleteAction()`. Else sets `Pawn.Acceleration = vect(0,0,0)` and `Focus = ScriptedFocus`, if `!bUseScriptFacing`, sets `FocalPoint = Pawn.Location + 1000 * vector(Pawn.Rotation)`, else if, `Focus == None`, calls `MayShootAtEnemy()` and sets `FocalPoint = Pawn.Location + 1000 * vector(SequenceScript.Rotation)`, calls `FinishRotation()` and `MayShootTarget()`.

### Broken : Broken scripted sequence - for debugging

Begin
  Sends a warning to the log that the `ScriptedScript` is BROKEN and gives the `CurrentAction`. Sets `Pawn.bPhysicsAnimUpdate = false` and calls `Pawn.StopAnimating()`. If `GetMyPlayer() != None`, it calls `PlayerController(GetMyPlayer().Controller).SetViewTarget(Pawn)`.

## Known Subclasses

    ScriptedController
      +- Bot
      |   +- xBot
      |       +- InvasionBot (Epic Bonuspack & UT2004)
      +- MonsterController (Epic Bonuspack & UT2004)
      +- ScriptedTriggerController

## Related Topcis

- Creating And Using ScriptedActions
- Artificial Intelligence – A super topic for all AI
  - Bot Support
  - Monster Support
  - NPC Support

## Discussion

Categories: Legacy Class (UT2003) | Legacy Class (UT2004) | Legacy Class Tree

##### Views

- Legacy
- Discussion
- Current revision

##### Search