home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Gameplay / Classes / ScriptedSequence.uc < prev    next >
Text File  |  2003-12-11  |  3KB  |  115 lines

  1. //=============================================================================
  2. // ScriptedSequence
  3. // used for setting up scripted sequences for pawns.
  4. // A ScriptedController is spawned to carry out the scripted sequence.
  5. //=============================================================================
  6. class ScriptedSequence extends AIScript;
  7.  
  8. var(AIScript) export editinline Array<ScriptedAction> Actions;
  9. var class<ScriptedController>  ScriptControllerClass;
  10.  
  11. /* SpawnController()
  12. Spawn and initialize an AI Controller (called by a non-player controlled Pawn at level startup)
  13. */
  14. function SpawnControllerFor(Pawn P)
  15. {
  16.     Super.SpawnControllerFor(P);
  17.     TakeOver(P);
  18. }
  19.  
  20. /* TakeOver()
  21. Spawn a scripted controller, which temporarily takes over the actions of the pawn,
  22. unless pawn is currently controlled by a scripted controller - then just change its script
  23. */
  24. function TakeOver(Pawn P)
  25. {
  26.     local ScriptedController S;
  27.  
  28.     if ( ScriptedController(P.Controller) != None )
  29.         S = ScriptedController(P.Controller);
  30.     else
  31.     {
  32.         S = spawn(ScriptControllerClass);
  33.         S.PendingController = P.Controller;
  34.         if ( S.PendingController != None )
  35.             S.PendingController.PendingStasis();
  36.     }
  37.     S.MyScript = self;
  38.     S.TakeControlOf(P);
  39.     S.SetNewScript(self);
  40. }
  41.         
  42. //*****************************************************************************************
  43. // Script Changes
  44.  
  45. function bool ValidAction(Int N)
  46. {
  47.     return true;
  48. }
  49.  
  50. function SetActions(ScriptedController C)
  51. {
  52.     local ScriptedSequence NewScript;
  53.     local bool bDone;
  54.  
  55.     if ( C.CurrentAnimation != None )
  56.         C.CurrentAnimation.SetCurrentAnimationFor(C);
  57.     while ( !bDone )
  58.     {
  59.         if ( C.ActionNum < Actions.Length )
  60.         {
  61.             if ( ValidAction(C.ActionNum) )
  62.                 NewScript = Actions[C.ActionNum].GetScript(self);
  63.             else
  64.             {
  65.                 NewScript = None;
  66.                 warn(GetItemName(string(self))$" action "$C.ActionNum@Actions[C.ActionNum].GetActionString()$" NOT VALID!!!");
  67.             }
  68.         }
  69.         else 
  70.             NewScript = None;
  71.         if ( NewScript == None )
  72.         {
  73.             C.CurrentAction = None;
  74.             return;
  75.         }
  76.         if ( NewScript != self )
  77.         {
  78.             C.SetNewScript(NewScript);
  79.             return;
  80.         }
  81.         if ( Actions[C.ActionNum] == None )
  82.         {
  83.             Warn(self$" no action "$C.ActionNum$"!!!");
  84.             C.CurrentAction = None;
  85.             return;
  86.         }
  87.         bDone = Actions[C.ActionNum].InitActionFor(C);
  88.         if ( bLoggingEnabled )
  89.             log(GetItemName(string(C.Pawn))$" script "$GetItemName(string(tag))$" action "$C.ActionNum@Actions[C.ActionNum].GetActionString());
  90.         if  ( !bDone )
  91.         {
  92.             if ( Actions[C.ActionNum] == None )
  93.             {
  94.                 Warn(self$" has no action "$C.ActionNum$"!!!");
  95.                 C.CurrentAction = None;
  96.                 return;
  97.             }
  98.             Actions[C.ActionNum].ProceedToNextAction(C);
  99.         }
  100.     }
  101. }
  102.  
  103. defaultproperties
  104. {
  105.     bStatic=true
  106.     ScriptControllerClass=class'Gameplay.ScriptedController'
  107.     bCollideWhenPlacing=true
  108.     CollisionRadius=+00050.000000
  109.     CollisionHeight=+00100.000000
  110.     bDirectional=true
  111.     bNavigate=true
  112.     bLoggingEnabled=false
  113. }
  114.  
  115.