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

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