#include "BustInGame.h" #include "goalZone.h" #include "game.h" namespace Zap { void BustInGameType::shipTouchFlag(Ship *theShip, FlagItem *theFlag) { if(theFlag->getZone() != NULL) // No pickup flag from any GoalZone allowed in this game mode. return; RetrieveGameType::shipTouchFlag(theShip, theFlag); } void BustInGameType::shipTouchZone(Ship *s, GoalZone *z) { // See if this is an opposing team's zone. If so, do nothing. if(s->getTeam() != z->getTeam() && z->getTeam() != -1) // allow bust-in into neutral team goal zones return; // See if this zone already has a flag in it. If so, do nothing. for(S32 i = 0; i < mFlags.size(); i++) if(mFlags[i]->getZone() == z) return; // Ok, it's an empty zone on our team: See if this ship is carrying a flag... S32 flagIndex = s->carryingFlag(); if(flagIndex == NO_FLAG) return; // Ok, the ship has a flag and it's on the ship and we're in an empty zone MoveItem *item = s->mMountedItems[flagIndex]; FlagItem *mountedFlag = dynamic_cast(item); if(mountedFlag) { static StringTableEntry capString("%e0 retrieved a flag!"); static StringTableEntry oneFlagCapString("%e0 retrieved the flag!"); // use different message for BustIn? Vector e; e.push_back(s->getName()); broadcastMessage(GameConnection::ColorNuclearGreen, SFXFlagCapture, (mFlags.size() == 1) ? oneFlagCapString : capString, e); // Drop the flag into the zone mountedFlag->dismount(); S32 flagIndex; for(flagIndex = 0; flagIndex < mFlags.size(); flagIndex++) if(mFlags[flagIndex] == mountedFlag) break; mFlags[flagIndex]->setZone(z); mountedFlag->setActualPos(z->getExtent().getCenter()); // Score the flag... updateScore(s, ReturnFlagToZone); if(s->getOwner()) s->getOwner()->mStatistics.mFlagScore++; bool allFlagsInZone = true; bool allZoneInThisTeamIsFull = true; // See if we can get any more flags in GoalZone for(S32 i = 0; i < mFlags.size(); i++) { if(mFlags[i]->getTeam() == s->getTeam() || mFlags[i]->getTeam() == -1) if(mFlags[i]->getZone() == NULL) allFlagsInZone = false; } // See if GoalZone in our team is full for(S32 i = 0; i < mZones.size(); i++) { if(mZones[i]->getTeam() == s->getTeam() || mZones[i]->getTeam() == -1) if(!mZones[i]->hasFlag()) allZoneInThisTeamIsFull = false; } if(allFlagsInZone || allZoneInThisTeamIsFull) { static StringTableEntry capAllString("All flags returned!"); if(mFlags.size() >= 2) // Don't bother sending this message unless there is 2 or more flags for(S32 i = 0; i < getGame()->getClientCount(); i++) getGame()->getClientInfo(i)->getConnection()->s2cTouchdownScored(SFXFlagCapture, -1, capAllString, Vector() ); // Return all the flags to their starting locations if need be for(S32 i = 0; i < mFlags.size(); i++) { mFlags[i]->setZone(NULL); if(!mFlags[i]->isAtHome()) mFlags[i]->sendHome(); } } } } TNL_IMPLEMENT_NETOBJECT(BustInGameType); }