コード例 #1
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
long TeamSensorSystem::getVisualContacts (MoverPtr* moverList) {

	long numVisualContacts = 0;
	for (long i = 0; i < numContacts; i++) {
		MoverPtr contact = (MoverPtr)ObjectManager->get(contacts[i]);
		if (!contact->getFlag(OBJECT_FLAG_REMOVED))
			if (contact->getContactStatus(teamId, true) == CONTACT_VISUAL)
				moverList[numVisualContacts++] = contact;
	}
	return(numVisualContacts);
}
コード例 #2
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
bool SensorSystem::isContact (MoverPtr mover) {

	if (mover->getFlag(OBJECT_FLAG_REMOVED))
		return(false);
	if (notShutdown)
		return(mover->getContactInfo()->getSensor(id) < 255);
	for (long i = 0; i < numContacts; i++)
		if ((contacts[i] & 0x7FFF) == mover->getHandle())
			return(true);
	return(false);
}
コード例 #3
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
bool TeamSensorSystem::hasSensorContact (long teamID) {

	for (long i = 0; i < numContacts; i++) {
		MoverPtr mover = (MoverPtr)ObjectManager->get(contacts[i]);
		if (!mover->getFlag(OBJECT_FLAG_REMOVED)) {
			static bool isSensor[NUM_CONTACT_STATUSES] = {false, true, true, true, true, false};
			if (isSensor[mover->getContactStatus(teamID, true)])
				return(true);
		}
	}
	return(false);
}
コード例 #4
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
long TeamSensorSystem::getSensorContacts (MoverPtr* moverList) {

	static bool isSensor[NUM_CONTACT_STATUSES] = {false, true, true, true, true, false};
	long numSensorContacts = 0;
	for (long i = 0; i < numContacts; i++) {
		MoverPtr contact = (MoverPtr)ObjectManager->get(contacts[i]);
		if (!contact->getFlag(OBJECT_FLAG_REMOVED))
			if (isSensor[contact->getContactStatus(teamId, true)])
				moverList[numSensorContacts++] = contact;
	}
	return(numSensorContacts);
}
コード例 #5
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
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);
}
コード例 #6
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
long TeamSensorSystem::getContactStatus (MoverPtr mover, bool includingAllies) {

	if (mover->getFlag(OBJECT_FLAG_REMOVED))
		return(CONTACT_NONE);
	return(mover->getContactInfo()->getContactStatus(Team::teams[teamId]->getId(), true));
}
コード例 #7
0
ファイル: Contact.cpp プロジェクト: Ariemeth/MechCommander2HD
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);
}