home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 8 (DVD) / XENIADVD08.iso / Fragzone / Files / AOM_MiniCampaign.exe / AI / mc01p7.xs < prev    next >
Encoding:
Text File  |  2002-12-06  |  3.6 KB  |  119 lines

  1. //==============================================================================
  2. // frostyai.xs - stripped-down AI for doing frosty stuff.
  3. //==============================================================================
  4. /*
  5.  
  6.   Add comments here.
  7.  
  8. */
  9. //==============================================================================
  10. //==============================================================================
  11. // miscStartup
  12. //==============================================================================
  13. void miscStartup(void)
  14. {
  15.     // Difficulty Level check.
  16.     int difflevel=-1;        
  17.     difflevel=aiGetWorldDifficulty();
  18.  
  19.    //Startup message(s).
  20.    aiEcho("");
  21.    aiEcho("");
  22.    aiEcho("Frosty AI Start, filename='"+cFilename+"'.");
  23.     aiEcho("Difficulty Level="+difflevel+".");
  24.    //Spit out the map size.
  25.    aiEcho("  Map size is ("+kbGetMapXSize()+", "+kbGetMapZSize()+").");
  26.    //Cheat like a bastard.  Once only, though.
  27.    kbLookAtAllUnitsOnMap();
  28.    //Calculate some areas.
  29.    kbAreaCalculate(1200.0);
  30.     //Reset random seed
  31.     aiRandSetSeed();
  32.    //Allocate all resources to the root escrow.
  33.    kbEscrowAllocateCurrentResources();
  34. }
  35.  
  36. //=========================================================================================
  37. // Kidd's cool configQuery function: used to create attack routes, etc.  Oooh, lovin' that!
  38. //=========================================================================================
  39. bool configQuery( int queryID = -1, int unitType = -1, int action = -1, int state = -1, int player = -1, vector center = vector(-1,-1,-1), bool sort = false, float radius = -1 )
  40. {
  41.    if ( queryID == -1)
  42.    {
  43.       return(false);
  44.    }
  45.  
  46.    if (player != -1)
  47.       kbUnitQuerySetPlayerID(queryID, player);
  48.    
  49.    if (unitType != -1)
  50.       kbUnitQuerySetUnitType(queryID, unitType);
  51.  
  52.    if (action != -1)
  53.       kbUnitQuerySetActionType(queryID, action);
  54.  
  55.    if (state != -1)
  56.       kbUnitQuerySetState(queryID, state);
  57.  
  58.    if (center != vector(-1,-1,-1))
  59.    {
  60.       kbUnitQuerySetPosition(queryID, center);
  61.       if (sort == true)
  62.          kbUnitQuerySetAscendingSort(queryID, true);
  63.       if (radius != -1)
  64.          kbUnitQuerySetMaximumDistance(queryID, radius);
  65.    }
  66.    return(true);
  67. }
  68.  
  69. //=====================================================================================
  70. // Cast Frost.  This is called from the scenario with an AI Func effect
  71. //=====================================================================================
  72. void castFrost(int value = -1)
  73. {
  74.    static int tempQuery = -1;
  75.  
  76.     if (tempQuery < 0)
  77.    {  // Doesn't exist, set it up
  78.       tempQuery = kbUnitQueryCreate("useFrost");
  79.  
  80.       vector frostSpot=kbGetBlockPosition("1859");
  81.  
  82.       if ( configQuery(tempQuery, cUnitTypeUnit, -1, cUnitStateAlive, 1, frostSpot, false, 30) == false)
  83.         {
  84.             aiEcho("DEBUG: frost failed - no player units found.");
  85.          return;
  86.         }
  87.    }
  88.  
  89.    kbUnitQueryResetResults(tempQuery);
  90.    int targetCount = kbUnitQueryExecute(tempQuery);
  91.  
  92.    if (targetCount < 1)
  93.     {
  94.         aiEcho("DEBUG: frost failed - no player units in range of query.");
  95.       return;
  96.     }
  97.  
  98.    int targetUnit = kbUnitQueryGetResult(tempQuery, 0);  // grab first visible unit.
  99.  
  100.    // confirm LOS
  101.    if ( kbUnitVisible(targetUnit) != true )
  102.     {
  103.         aiEcho("DEBUG: frost failed - target unit is not visible.");
  104.       return;
  105.     }
  106.  
  107.    // cast frost on him.
  108.     aiCastGodPowerAtUnit( cTechFrost, targetUnit);
  109. }
  110.  
  111. //==============================================================================
  112. // MAIN.
  113. //==============================================================================
  114. void main(void)
  115. {
  116.    //Startup.
  117.    miscStartup();
  118. }
  119.