home *** CD-ROM | disk | FTP | other *** search
Wrap
//============================================================================== // Minicampaign Scenario 1: AI Script for Minicampaign scenario 1, player 3 //============================================================================== /* AI owner: Karen Sparks Scenario owner: Karen Sparks Overview: The player must pass through the Frost Giant Folstag's (player 3) lands to get to the cave Forge. Folstag watches over the pass that leads into his land casting Frost on any who he sees enter the pass. Thanks Leary, for this fun bit of scripting. */ //============================================================================== // 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"); aiEcho("Frost vector is " +frostSpot); 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(); }