void Team::markRadiusSeenToTeams(Stuff::Vector3D& location, float radius, bool shrinkForNight) { if(radius < 0.0) radius = fireVisualRange; if(shrinkForNight) radius -= (radius * 0.25f); bool didTeam[MAX_TEAMS] = {false, false, false, false, false, false, false, false}; for(size_t i = 0; i < ObjectManager->getNumMovers(); i++) { MoverPtr mover = ObjectManager->getMover(i); if(mover->getTeam() && !didTeam[mover->getTeamId()] && !isFriendly(mover->getTeam())) { Stuff::Vector3D result; result.x = location.x - mover->getPosition().x; result.y = location.y - mover->getPosition().y; result.z = 0.0; float dist = result.GetLength() * metersPerWorldUnit; if(dist < maxVisualRange) { markRadiusSeen(location, radius); didTeam[mover->getTeamId()] = true; } } } }
bool TeamSensorSystem::meetsCriteria (GameObjectPtr looker, MoverPtr mover, long contactCriteria) { bool isSensor[NUM_CONTACT_STATUSES] = {false, true, true, true, true, false}; long status = mover->getContactStatus(teamId, true); if (mover->getFlag(OBJECT_FLAG_REMOVED)) return(false); if (status == CONTACT_NONE) return(false); if (contactCriteria & CONTACT_CRITERIA_VISUAL_OR_SENSOR) if ((status != CONTACT_VISUAL) && !isSensor[status]) return(false); if (contactCriteria & CONTACT_CRITERIA_VISUAL) if (status != CONTACT_VISUAL) return(false); if (contactCriteria & CONTACT_CRITERIA_SENSOR) if (!isSensor[status]) return(false); if (contactCriteria & CONTACT_CRITERIA_NOT_CHALLENGED) { if (mover->getChallenger() != NULL) return(false); } if (contactCriteria & CONTACT_CRITERIA_NOT_DISABLED) { if (mover->isDisabled()) return(false); } if (contactCriteria & CONTACT_CRITERIA_ENEMY) { if ((teamId == -1) || !mover->getTeam()) return(false); if (!Team::teams[teamId]->isEnemy(mover->getTeam())) return(false); } if (contactCriteria & CONTACT_CRITERIA_ARMED) { if (mover->numFunctionalWeapons == 0) return(false); } return(true); }
long SensorSystem::calcContactStatus (MoverPtr mover) { if (!owner->getTeam()) return(CONTACT_NONE); if (mover->getFlag(OBJECT_FLAG_REMOVED)) { return(CONTACT_NONE); } //---------------------------------------------------------- //If object we are looking for is at the edge, NO CONTACT!! if (!Terrain::IsGameSelectTerrainPosition(mover->getPosition())) return CONTACT_NONE; //------------------------------------------------------------- // Should be properly set when active probes are implemented... long newContactStatus = CONTACT_NONE; if (!notShutdown || (range == 0.0) && !broken) { if (owner->lineOfSight(mover) && !mover->isDisabled()) newContactStatus = CONTACT_VISUAL; return(newContactStatus); } if ((masterIndex == -1) || (range < 0.0)) { return(CONTACT_NONE); } if (owner->isMover()) { MoverPtr mover = (MoverPtr)owner; if ((mover->sensor == 255) || mover->inventory[mover->sensor].disabled || broken) { return(CONTACT_NONE); } } if (mover->getFlag(OBJECT_FLAG_SENSOR) && !mover->isDisabled()) { bool moverNotContact = mover->hasNullSignature() || (mover->getEcmRange() != 0.0f); bool moverInvisible = (mover->getStatus() == OBJECT_STATUS_SHUTDOWN); if (!moverInvisible && !moverNotContact) { float distanceToMover = owner->distanceFrom(mover->getPosition()); float sensorRange = getEffectiveRange(); if (distanceToMover <= sensorRange) { //------------------------------------------- //No need to check shutdown and probe AGAIN! newContactStatus = getSensorQuality(); //--------------------------------------- // If ecm affecting me, my skill drops... // CUT, per Mitch 2/10/00 if ((ecmEffect < 1.0) && (newContactStatus > CONTACT_SENSOR_QUALITY_1)) newContactStatus--; //--------------------------------------------------- // We now we are within sensor range, check visual. float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } else //Still need to check if visual!!! ECM and Lookout Towers!! { float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } } else { //Target is shutdown, can ONLY be visual cause this platform has no probe. float startRadius = 0.0f; if (!owner->isMover()) startRadius = owner->getAppearRadius(); if (hasLOSCapability && owner->lineOfSight(mover,startRadius)) newContactStatus = CONTACT_VISUAL; } } //Let us know that we can see something, sensor or otherwise!! if (mover->getTeam() && (owner->getTeam() == Team::home) && mover->getTeam()->isEnemy(Team::home) && (newContactStatus != CONTACT_NONE)) { SensorSystemManager::enemyInLOS = true; } return(newContactStatus); }