Esempio n. 1
0
// The nexus is open.  A ship has entered it.  Now what?
// Runs on server only
void NexusGameType::shipTouchNexus(Ship *ship, NexusZone *nexus)
{
    FlagItem *flag = findFirstFlag(ship);

    if(!flag)      // findFirstFlag can return NULL
        return;

    S32 flagsReturned = flag->getFlagCount();

    if(flagsReturned == 0)
        return;

    updateScore(ship, ReturnFlagsToNexus, flagsReturned);
    nexus->s2cFlagsReturned();       // Alert the Nexus that someone has returned flags to it

    ClientInfo *clientInfo = ship->getClientInfo();

    if(clientInfo)          // Should always be true!!
    {
        if(!isGameOver())    // Avoid flooding messages at end of game
        {
            S32 score = getEventScore(TeamScore, ReturnFlagsToNexus, flag->getFlagCount());
            s2cNexusMessage(NexusMsgScore, clientInfo->getName().getString(), flag->getFlagCount(), score);
        }

        // See if this event qualifies for an achievement
        if(flagsReturned >= 25 &&                                   // Return 25+ flags
                clientInfo && clientInfo->isAuthenticated() &&           // Player must be authenticated
                getGame()->getPlayerCount() >= 4 &&                      // Game must have 4+ human players
                getGame()->getAuthenticatedPlayerCount() >= 2 &&         // Two of whom must be authenticated
                !hasFlagSpawns() && !hasPredeployedFlags() &&            // Level can have no flag spawns, nor any predeployed flags
                !clientInfo->hasBadge(BADGE_TWENTY_FIVE_FLAGS))          // Player doesn't already have the badge
        {
            achievementAchieved(BADGE_TWENTY_FIVE_FLAGS, clientInfo->getName());
        }
    }

    flag->changeFlagCount(0);
}