home *** CD-ROM | disk | FTP | other *** search
Wrap
//============================================================================== // frostyai.xs - stripped-down AI for doing frosty stuff. //============================================================================== /* Add comments here. */ //============================================================================== //============================================================================== // miscStartup //============================================================================== void miscStartup(void) { // Difficulty Level check. int difflevel=-1; difflevel=aiGetWorldDifficulty(); //Startup message(s). aiEcho(""); aiEcho(""); aiEcho("Frosty AI Start, filename='"+cFilename+"'."); aiEcho("Difficulty Level="+difflevel+"."); //Spit out the map size. aiEcho(" Map size is ("+kbGetMapXSize()+", "+kbGetMapZSize()+")."); //Cheat like a bastard. Once only, though. kbLookAtAllUnitsOnMap(); //Calculate some areas. kbAreaCalculate(1200.0); //Reset random seed aiRandSetSeed(); //Allocate all resources to the root escrow. kbEscrowAllocateCurrentResources(); } //========================================================================================= // Kidd's cool configQuery function: used to create attack routes, etc. Oooh, lovin' that! //========================================================================================= 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 ) { if ( queryID == -1) { return(false); } if (player != -1) kbUnitQuerySetPlayerID(queryID, player); if (unitType != -1) kbUnitQuerySetUnitType(queryID, unitType); if (action != -1) kbUnitQuerySetActionType(queryID, action); if (state != -1) kbUnitQuerySetState(queryID, state); if (center != vector(-1,-1,-1)) { kbUnitQuerySetPosition(queryID, center); if (sort == true) kbUnitQuerySetAscendingSort(queryID, true); if (radius != -1) kbUnitQuerySetMaximumDistance(queryID, radius); } return(true); } //===================================================================================== // Cast Frost. This is called from the scenario with an AI Func effect //===================================================================================== void castFrost(int value = -1) { static int tempQuery = -1; if (tempQuery < 0) { // Doesn't exist, set it up tempQuery = kbUnitQueryCreate("useFrost"); vector frostSpot=kbGetBlockPosition("1859"); if ( configQuery(tempQuery, cUnitTypeUnit, -1, cUnitStateAlive, 1, frostSpot, false, 30) == false) { aiEcho("DEBUG: frost failed - no player units found."); return; } } kbUnitQueryResetResults(tempQuery); int targetCount = kbUnitQueryExecute(tempQuery); if (targetCount < 1) { aiEcho("DEBUG: frost failed - no player units in range of query."); return; } int targetUnit = kbUnitQueryGetResult(tempQuery, 0); // grab first visible unit. // confirm LOS if ( kbUnitVisible(targetUnit) != true ) { aiEcho("DEBUG: frost failed - target unit is not visible."); return; } // cast frost on him. aiCastGodPowerAtUnit( cTechFrost, targetUnit); } //============================================================================== // MAIN. //============================================================================== void main(void) { //Startup. miscStartup(); }