/*-----------------------------------------------------------------------------
    Name        : airAddedResourceCollector
    Description : called when a resource collector is added
    Inputs      :
    Outputs     :
    Return      :
----------------------------------------------------------------------------*/
void airAddedResourceCollector(Ship *ship)
{
    Resource *resource;
    SelectCommand selectone;
    udword new_team_num = aiCurrentAIPlayer->numSupportTeams;
    AITeam *team;

    growSelectAddShip(&aiCurrentAIPlayer->airResourceCollectors, ship);

    aiCurrentAIPlayer->airNumRCollectors++;
    if (aiCurrentAIPlayer->NumRCollectorsBeingBuilt > 0) aiCurrentAIPlayer->NumRCollectorsBeingBuilt--;

    if (aiuResourceFeatureEnabled(AIR_ACTIVE_RESOURCE_COLLECTION))
    {
        //add the resource collector to an existing team, or make a new team
        team = aitFindNextTeamWithFlag(NULL, RESOURCECOLLECT_TEAM);

        while (team)
        {
            if (team->shipList.selection->numShips < 3)
            {
                aitAddShip(team, ship);
                break;
            }
            team = aitFindNextTeamWithFlag(team, RESOURCECOLLECT_TEAM);
        }

        if (!team)
        {
            team = aiCurrentAIPlayer->supportTeam[new_team_num] = aitCreate(ResourceTeam);
            bitSet(aiCurrentAIPlayer->supportTeam[new_team_num]->teamFlags, RESOURCECOLLECT_TEAM);
            growSelectAddShip(&aiCurrentAIPlayer->supportTeam[new_team_num]->shipList, ship);
            aioCreateResourcer(aiCurrentAIPlayer->supportTeam[new_team_num]);
            aiCurrentAIPlayer->numSupportTeams++;
        }
        if (aiuResourceFeatureEnabled(AIR_AGGRESSIVE_RESOURCING))
        {
            aiuWrapSetTactics(team->shipList.selection, Aggressive);
        }
    }
    else
    {
        resource = univFindNearestResource(ship, 0, NULL);

        selectone.numShips = 1;
        selectone.ShipPtr[0] = ship;

        if (aiuResourceFeatureEnabled(AIR_AGGRESSIVE_RESOURCING))
        {
            aiuWrapSetTactics(&selectone, Aggressive);
        }
        aiuWrapCollectResource(&selectone,resource);
    }
}
Beispiel #2
0
sdword aimProcessKamikaze(AITeam *team)
{
    AITeamMove *thisMove = team->curMove;
    SelectCommand *selection = team->shipList.selection;

    if (selection->numShips == 0)
    {
        aiplayerLog((aiIndex,"Kamikaze Move, Zero Sized Team"));
        return TRUE;
    }

    if (!thisMove->processing)
    {
        if ((selection->numShips > 0) && (thisMove->params.kamikaze.ships->numShips > 0))
        {
            if (aiuWrapSetTactics(selection,Aggressive))
            {
                if (aiuWrapAttack(selection, thisMove->params.kamikaze.ships))
                {
                    aiuWrapSetKamikaze(selection);
                    thisMove->processing = TRUE;
                }
            }
        }
        else
        {
            aiplayerLog((aiIndex,"Warning: no ships to kamikaze into"));
            thisMove->processing = TRUE;
        }

        return FALSE;
    }
    else
    {
        if ((selection->numShips == 0) || (thisMove->params.kamikaze.ships->numShips == 0) ||
            (aiuShipsNoLongerAttacking(selection)))
        {
            // we're done
            memFree(thisMove->params.kamikaze.ships);
            thisMove->params.kamikaze.ships = NULL;

            return TRUE;
        }
        else
        {
            return FALSE;
        }
    }
}