/*----------------------------------------------------------------------------- Name : aihKamikazeHealthLowHandler Description : Finds the ship who's health is low and kamikaze's it into the enemy Inputs : team - the team with the suicide bombers Outputs : Forces pilots to kill themselves in the name of greater good Return : void ----------------------------------------------------------------------------*/ void aihKamikazeHealthLowHandler(AITeam *team) { MaxSelection shipsToDie; udword i; ShipPtr ship; dbgAssert(team->shipList.selection->numShips); shipsToDie.numShips = 0; for (i=0;i<team->shipList.selection->numShips;i++) { ship = team->shipList.selection->ShipPtr[i]; if ((isShipOfClass(ship, CLASS_Fighter) || isShipOfClass(ship, CLASS_Corvette)) && ((100 * ship->health) < (team->curMove->events.healthLow.watchPercentage * ship->staticinfo->maxhealth))) { selSelectionAddSingleShip(&shipsToDie, ship); } } dbgAssert(shipsToDie.numShips); aiuWrapSetKamikaze((SelectCommand *)&shipsToDie); }
/*----------------------------------------------------------------------------- Name : airAddedProximitySensor Description : Does that proximity sensor adding stuff that we all read about in Newsweek. Proximity Sensor positioning and stuff is taken care of by the defense manager Inputs : ship - the new ship Outputs : Return : void ----------------------------------------------------------------------------*/ void airAddedProximitySensor(ShipPtr ship) { if (!aiCurrentAIPlayer->aidProximitySensors) { aiuNewSelection(aiCurrentAIPlayer->aidProximitySensors, 10, "dproxsens"); } selSelectionAddSingleShip((MaxSelection *)aiCurrentAIPlayer->aidProximitySensors, ship); }
/*----------------------------------------------------------------------------- Name : aioCreateP2MothershipAttack Description : Creates the moves to make the P2 Mothership pulverize the enemy Inputs : team - the multibeamFrigate team Outputs : Creates a bunch'a moves Return : void ----------------------------------------------------------------------------*/ void aioCreateP2MothershipAttack(AITeam *team) { SelectCommand *enemy; aiuNewPyroSelection(enemy, 1, "p2am"); selSelectionAddSingleShip((MaxSelection *)enemy, aiuFindEnemyMothership(aiCurrentAIPlayer->player)); aimCreateAttack(team, enemy, NO_FORMATION, TRUE, TRUE); aimCreateMoveDone(team, FALSE, FALSE); }
/*----------------------------------------------------------------------------- Name : aioCreateMultiBeamAttack Description : Creates the moves to make the P2 Multi Beam Frigates pulverize the enemy Inputs : team - the multibeamFrigate team Outputs : Creates a bunch'a moves Return : void ----------------------------------------------------------------------------*/ void aioCreateMultiBeamAttack(AITeam *team) { SelectCommand *enemy; aiuNewPyroSelection(enemy, 1, "mbam"); selSelectionAddSingleShip((MaxSelection *)enemy, aiuFindEnemyMothership(aiCurrentAIPlayer->player)); aimCreateFlankAttack(team, enemy, FALSE, TRUE, TRUE); aimCreateMoveDone(team, FALSE, FALSE); }
/*----------------------------------------------------------------------------- Name : airCheckForDistressSignals Description : Checks all resource ships to make sure they aren't being attacked. If they are, a distress signal is sent to the defense manager Inputs : None Outputs : Creates a selection of distressed ships, if there are any Return : void ----------------------------------------------------------------------------*/ void airCheckForDistressSignals(void) { udword i, numShips = aiCurrentAIPlayer->airResourceReserves.selection->numShips; ShipPtr ship; MaxSelection distressed_ships; distressed_ships.numShips = 0; for (i = 0; i < numShips; i++) { ship = aiCurrentAIPlayer->airResourceReserves.selection->ShipPtr[i]; if (ship->gettingrocked) { selSelectionAddSingleShip(&distressed_ships, ship); } } if (distressed_ships.numShips) { aidSendDistressSignal((SelectCommand *)&distressed_ships); } }
/*----------------------------------------------------------------------------- Name : aihSlowDefenseDistressHandler Description : Handles distress calls for slow defense teams Inputs : team - the team handling the distress call, intvar - the variable that is being watched, in this case the aiplayer->aidDefenseTargets Outputs : Creates new moves to deal with the poopyhead attacking the defensless ship Return : void ----------------------------------------------------------------------------*/ void aihSlowDefenseDistressHandler(struct AITeam *team, udword *intvar) { AITeamMove *newMove, *thisMove = team->curMove; SelectCommand *HandlerShips = (SelectCommand *)(*intvar); SelectCommand *enemyShips; MaxSelection distressShips, invadingShips; udword i; real32 distsq_to_ships; TypeOfFormation formation; if (!team->shipList.selection->numShips) { // just in case return; } if (aiCurrentAIPlayer->aidDistressShips) { selSelectionCopy((MaxAnySelection *)&distressShips, (MaxAnySelection *)aiCurrentAIPlayer->aidDistressShips); if (aiuRescueShipType((SelectCommand *)&distressShips, team, AdvanceSupportFrigate)) { return; } if (aiuRescueShipType((SelectCommand *)&distressShips, team, ResourceController)) { return; } } if (aiCurrentAIPlayer->aidInvadingShips) { selSelectionCopy((MaxAnySelection *)&invadingShips, (MaxAnySelection *)aiCurrentAIPlayer->aidInvadingShips); //later choose between ships on the distress ships list //closest/most important/etc. for (i = 0; i < invadingShips.numShips; i++) { enemyShips = aiuFindNearbyDangerousEnemyShips(invadingShips.ShipPtr[i], AIH_SLOWDEF_INVADER_ENEMYDIST); selSelectionAddSingleShip((MaxSelection *)enemyShips, invadingShips.ShipPtr[i]); distsq_to_ships = aiuFindDistanceSquared(team->shipList.selection->ShipPtr[0]->posinfo.position, invadingShips.ShipPtr[i]->posinfo.position); //if other teams need help and if the enemy is less than 10 km away... if ((aitCheckIfOtherDefTeamAnsweringSignalNeedsHelp(team, enemyShips)) && (distsq_to_ships < AIH_SLOWDEF_RESPONSE_MAXDISTSQ)) { if (enemyShips->numShips > AIH_SLOWDEF_INVADER_LOTSFEW_LIMIT) { formation = AIH_SLOWDEF_INVADER_LOTS_FORMATION; } else { formation = AIH_SLOWDEF_INVADER_FEW_FORMATION; } newMove = aimCreateAdvancedAttackNoAdd(team, selectMemDupSelection(enemyShips, "sddh", 0), formation,Aggressive,TRUE, TRUE); newMove->events = thisMove->events; if (aiuAttackFeatureEnabled(AIA_KAMIKAZE)) { if (aitTeamShipClassIs(CLASS_Corvette, team)) { aieHandlerSetHealthLow(newMove, AIO_CORVETTE_KAMIKAZE_HEALTH, TRUE, FALSE, aihKamikazeHealthLowHandler); } } newMove->events.interrupt.handler = NULL; newMove->events.numbersLow.handler = NULL; team->curMove->processing = FALSE; aitAddmoveBeforeAndMakeCurrent(team, newMove, thisMove); memFree(enemyShips); return; } memFree(enemyShips); } } }
/*----------------------------------------------------------------------------- Name : aihFastDefenseDistressHandler Description : Handles distress calls for fast defense teams Inputs : team - the team handling the distress call, intvar - the variable that is being watched, in this case the aiplayer->aidDefenseTargets Outputs : Creates new moves to deal with the poopyhead attacking the defensless ship Return : void ----------------------------------------------------------------------------*/ void aihFastDefenseDistressHandler(struct AITeam *team, udword *intvar) { AITeamMove *newMove, *thisMove = team->curMove; SelectCommand *HandlerShips = (SelectCommand *)(*intvar); SelectCommand *enemyShips; MaxSelection invadingShips, distressShips; udword i; TypeOfFormation formation; if (aiCurrentAIPlayer->aidDistressShips) { selSelectionCopy((MaxAnySelection *)&distressShips, (MaxAnySelection *)aiCurrentAIPlayer->aidDistressShips); if (aiuRescueShipType((SelectCommand *)&distressShips, team, AdvanceSupportFrigate)) { return; } if (aiuRescueShipType((SelectCommand *)&distressShips, team, ResourceController)) { return; } } if (aiCurrentAIPlayer->aidInvadingShips) { selSelectionCopy((MaxAnySelection *)&invadingShips, (MaxAnySelection *)aiCurrentAIPlayer->aidInvadingShips); // if (aihTakeoutSmallCombatInvaders(invaderShips, team)) // return; // if (aihTakeoutBigCombatInvaders(invaderShips, team)) // return; //later choose between ships on the distress ships list //closest/most important/etc. for (i = 0; i < invadingShips.numShips; i++) { enemyShips = aiuFindNearbyDangerousEnemyShips(invadingShips.ShipPtr[i], AIH_FASTDEF_INVADER_ENEMYDIST); selSelectionAddSingleShip((MaxSelection *)enemyShips, invadingShips.ShipPtr[i]); if (aitCheckIfOtherDefTeamAnsweringSignalNeedsHelp(team, enemyShips)) { if (enemyShips->numShips > AIH_FASTDEF_INVADER_LOTSFEW_LIMIT) { formation = AIH_FASTDEF_INVADER_LOTS_FORMATION; } else { formation = AIH_FASTDEF_INVADER_FEW_FORMATION; } newMove = aimCreateAdvancedAttackNoAdd(team, selectMemDupSelection(enemyShips, "fddh", 0), formation,Aggressive,TRUE, TRUE); newMove->events = thisMove->events; if (aiuAttackFeatureEnabled(AIA_KAMIKAZE)) { aieHandlerSetHealthLow(newMove, AIO_FIGHTER_KAMIKAZE_HEALTH, TRUE, FALSE, aihKamikazeHealthLowHandler); } newMove->events.interrupt.handler = NULL; newMove->events.numbersLow.handler = NULL; team->curMove->processing = FALSE; aitAddmoveBeforeAndMakeCurrent(team, newMove, thisMove); memFree(enemyShips); return; } memFree(enemyShips); } } if ((aiCurrentAIPlayer->aidDistressShips) && (distressShips.numShips)) { if (aiuRescueShipType((SelectCommand *)&distressShips, team, ResourceCollector)) { return; } } }