home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 April / Gamestar_83_2006-04_dvd.iso / Dema / demowot_english.exe / Script / Source / Test / test-objective-eval.sma < prev    next >
Text File  |  2005-03-11  |  2KB  |  72 lines

  1. #include "akscript.inc"
  2.  
  3.  
  4.  
  5.  
  6. public main()
  7. {
  8.     // Add sleeping objectives:
  9.     ShowShortMessage( "" );
  10.     AddObjective( "TakeOut", OT_PRIMARY, "Take out the retreating British Army Division!", "Take out the retreating British Army Division!", OS_SLEEPING );
  11.         
  12.     // Add objectives:
  13.     AddObjective( "Scout", OT_PRIMARY, "Scout the area!", "Scout the area!", OS_IN_PROGRESS );
  14.     AddObjective( "Survive", OT_HIDDEN, "At least one unit must survive.", "At least one unit must survive.", OS_IN_PROGRESS );
  15.  
  16.     AddAKEntityEvent( "TestEventHandler", ANY_ENTITY, TEST_EVENT );
  17. }
  18.  
  19.  
  20.  
  21.  
  22. public TestEventHandler()
  23. {
  24.     // Itt lehet nyugodtan allitgatni dogokat:
  25.     SetObjectiveState( "TakeOut", OS_COMPLETED );
  26.     SetObjectiveState( "Scout", OS_FAILED );
  27.     SetObjectiveState( "Survive", OS_COMPLETED );
  28.     
  29.     ObjectiveChanged();    
  30. }
  31.  
  32.  
  33.  
  34.  
  35. public ObjectiveChanged()
  36. {
  37.     // Scout Completed:
  38.     if( GetObjectiveState( "Scout" ) == OS_COMPLETED ) {
  39.         if( GetObjectiveState( "TakeOut" ) == OS_SLEEPING )
  40.             SetObjectiveState( "TakeOut", OS_IN_PROGRESS );            
  41.     }
  42.     // Scout Failed: Cannot fail explicitly
  43.     
  44.     // TakeOut Completed and SurviveLoot:
  45.     if( GetObjectiveState( "TakeOut" ) == OS_COMPLETED ) {
  46.         //if( GetPropertyBool( GetEntity( "al_daimler2" ), "Alive" ) && GetPropertyBool( GetEntity( "al_daimler3" ), "Alive" ))
  47.         //    SetObjectiveState( "SurviveLoot" , OS_COMPLETED );
  48.         //else
  49.         //    SetObjectiveState( "SurviveLoot" , OS_FAILED );
  50.         EndMission( MS_ACCOMPLISHED );
  51.         return true;
  52.     }
  53.     // TakeOut Failed and SurviveLoot: TakeOut cannot fail explicitely
  54.  
  55.     // Survive Completed: Cannot complete explicitly
  56.     // Survive Failed: 
  57.     if( GetObjectiveState( "Survive" ) == OS_FAILED ) {
  58.         EndMission( MS_FAILED );
  59.         return false;
  60.     }
  61.     
  62.     // Capture Completed: handled elsewere: at Scout Completed
  63.     // Capture Failed: Cannot fail explicitly
  64.     return true;
  65. }
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.