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

  1. #include "script.inc"
  2.  
  3. new DrID:gWatchers[20];
  4. new DrID:gTargets[20];
  5.  
  6. new gWatcherGroup[10] = "Allied";
  7. new gTargetGroup[10] = "Axis";
  8.  
  9. public main() CommonAKMain();
  10.  
  11. new gActualWatcherIdx = -1;                // elol noveljuk, ezert egyel kisebb erteket adunk itt meg 0 helyett
  12. new gActualTargetIdx;
  13.  
  14. new Float:gWatcherOrigPos[vec3];
  15. new Float:gTargetOrigPos[vec3];
  16.  
  17. const Float:gDiff = 0.2;
  18. const Float:gFade = 3.0;
  19. const Float:gTreshold = 2.0;            // ennyi meter hiba meg elfogadhato
  20.  
  21. new DrID:PreviousTarget;
  22.  
  23. //======================================================================================================
  24. public PostGameStart()
  25. {
  26.     CommonAKInit();
  27.  
  28.     new Iterator:i = Iterate( gWatcherGroup );
  29.     new j = 0;
  30.     while( ItNext(i))
  31.         gWatchers[j++] = ItEntity(i);
  32.     ItStop(i);
  33.     
  34.     i = Iterate( gTargetGroup );
  35.     j = 0;
  36.     while( ItNext(i))
  37.         gTargets[j++] = ItEntity(i);
  38.     ItStop(i);
  39.     
  40.     SetCameraTargetPos( Float:{180.0, 128.0, 0.0} );
  41.     ProcessNextWatcher();
  42. }
  43.  
  44.  
  45.  
  46. public EnemySeen()
  47. {
  48.     new DrID:Watcher = gWatchers[gActualWatcherIdx];
  49.     new DrID:Target = gTargets[gActualTargetIdx];
  50.     new Float:SenseDistance = DistanceAKe2e( Watcher, Target );
  51.  
  52.     new TmpStr[40];
  53.     new Message[200] = " senses ";
  54.     
  55.     GetPropertyString( Watcher, "Name", 40, TmpStr );
  56.     ConcatString( Message, 200, TmpStr, Message );
  57.     
  58.     GetPropertyString( Target, "Name", 40, TmpStr );
  59.     ConcatString( Message, 200, Message, TmpStr );
  60.     
  61.     ConcatString( Message, 200, Message, " from " );
  62.     Float2Str( SenseDistance, TmpStr, 40 );
  63.     ConcatString( Message, 200, Message, TmpStr );
  64.     ConcatString( Message, 200, Message, " m. The calculated distance is " );
  65.             
  66.     // Display correct info if incorrect
  67.     new Float:FowRadius = GetPropertyFloat( GetBaseEntity( Watcher ), "FOWRangeRadius" );
  68.     new Float:SightingModifier = GetPropertyFloat( GetBaseEntity( Target ), "SightingModifier" );
  69.     new Float:CorrectValue = FowRadius * SightingModifier - gFade;
  70.  
  71.     Float2Str( CorrectValue, TmpStr, 40 );
  72.     ConcatString( Message, 200, Message, TmpStr );
  73.     ConcatString( Message, 200, Message, "m ( " );
  74.     
  75.     Float2Str( FowRadius, TmpStr, 40 );
  76.     ConcatString( Message, 200, Message, TmpStr );
  77.     
  78.     ConcatString( Message, 200, Message, " * " );
  79.     Float2Str( SightingModifier, TmpStr, 40 );
  80.     ConcatString( Message, 200, Message, TmpStr );
  81.  
  82.     ConcatString( Message, 200, Message, " - " );
  83.     Float2Str( gFade, TmpStr, 40 );
  84.     ConcatString( Message, 200, Message, TmpStr );
  85.  
  86.     ConcatString( Message, 200, Message, " ) " );
  87.     
  88.     if( FloatAbs( SenseDistance - CorrectValue) > gTreshold ) {
  89.         ConcatString( Message, 200, Message, " Incorrect!" );
  90.         ConcatString( Message, 200, "!!! ", Message );
  91.     }
  92.     else {
  93.         ConcatString( Message, 200, Message, " Correct!" );
  94.         ConcatString( Message, 200, "    ", Message );
  95.     }
  96.  
  97.     ShowShortMessage( Message );
  98.     Log( Message, "proglog\scriptlog" );
  99.  
  100.     // Go back    
  101.     CmdStop( PreviousTarget, Q_OVERRIDE );
  102.     CmdMove( PreviousTarget, Q_ENQUEUE, gTargetOrigPos, MF_TELEPORT );
  103.     
  104.     ProcessNextTarget();
  105. }
  106.  
  107.  
  108.  
  109. public ProcessNextWatcher()
  110. {
  111.     gActualWatcherIdx++;
  112.     gActualTargetIdx = -1;
  113.     
  114.     new Float:TmpSpeed = 8.0;
  115.     SetGameSpeed( TmpSpeed );
  116.  
  117.     new DrID:WatcherID = gWatchers[gActualWatcherIdx];
  118.     if( !WatcherID ) {     // Ha mar vegigertunk.
  119.         ShowShortMessage( "Finished." );
  120.         SetGameSpeed( Float:1.0 );
  121.         return;
  122.     }
  123.  
  124.     if( gActualWatcherIdx != 0 ) { // az elso kulonos elbiralast igenyel
  125.         CmdMove( gWatchers[gActualWatcherIdx-1], Q_OVERRIDE, gWatcherOrigPos, MF_TELEPORT );
  126.     }
  127.  
  128.     GetPropertyVec3( WatcherID, "Pos", gWatcherOrigPos );
  129.     CmdMove( WatcherID, Q_OVERRIDE, Float:{ 200.0, 128.0, 0.0}, MF_TELEPORT );
  130.  
  131.     RemoveEvent( "EnemySeen" );
  132.     AddAKEntityEvent( "EnemySeen", WatcherID, UNIT_ENEMY_SEEN );
  133.  
  134.     ProcessNextTarget();
  135. }
  136.  
  137.  
  138.  
  139. public ProcessNextTarget()
  140. {
  141.     gActualTargetIdx++;
  142.     
  143.     new DrID:TargetID = gTargets[gActualTargetIdx];
  144.     if( !TargetID ) {                                                // Ha nincs tobb
  145.         ProcessNextWatcher();
  146.         return;
  147.     }
  148.  
  149.     GetPropertyVec3( TargetID, "Pos", gTargetOrigPos );
  150.     CmdMove( TargetID, Q_OVERRIDE, Float:{ 160.0, 128.0, 0.0}, MF_TELEPORT );
  151.     CmdMove( TargetID, Q_ENQUEUE, Float:{ 200.0, 128.0, 0.0}, MF_NONE );
  152.     PreviousTarget = TargetID;
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.