示例#1
0
文件: sensors.cpp 项目: Kreyl/nute
// Implementation
void Sns_t::Task() {
    if (!Delay.Elapsed(&Timer, 306)) return;
    // Check sensor
    if (Detected() && !WasDetected) {
        WasDetected = true;
        if(EvtDetected != 0) {
            // Don't say anything if too little time passed
            //if(Delay.Elapsed(&TimerDetection, DETECTION_MAX_DELAY*1000))
            EvtDetected();
        }
    }
    else if(!Detected() && WasDetected) {
        WasDetected = false;
        klPrintf("Hide\r");
    }
}
示例#2
0
/* 2002-02-11 COMMENTED OUT BY S.G. TOO MANY CHANGES TO TRACK THEM ALL (LIKE FOR OTHER UNIT TYPES)
   int TaskForceClass::DetectVs (CampEntity e, float *d, int *combat, int *spot)
   {
   int		react,det;

   det = Detected(this,e,d);
   if (!(det & REACTION_MASK))
   return 0;
   react = Reaction(e,det,*d);
   if (det & ENEMY_DETECTED)
   e->SetSpotted(GetTeam(),TheCampaign.CurrentTime);
   if (det & ENEMY_IN_RANGE && react)
 *combat = 1;
 if (det & FRIENDLY_DETECTED)
 {
 SetSpotted(e->GetTeam(),TheCampaign.CurrentTime);
 *spot = 1;
 }

 return react;
 }

 */
int TaskForceClass::DetectVs (CampEntity e, float *d, int *combat, int *spot)
{
    int		react,det;

    det = Detected(this,e,d);

    int detTmp = det;

    // Check type of entity before GCI is used
    if (CheckValidType(this, e))
        detTmp |= e->GetSpotted(GetTeam()) ? ENEMY_DETECTED : 0;

    // Check type of entity before GCI is used
    if (CheckValidType(e, this))
        detTmp |= GetSpotted(e->GetTeam()) ? FRIENDLY_DETECTED : 0;

    if (!(detTmp & REACTION_MASK))
        return 0;

    react = Reaction(e,detTmp,*d);

    // We'll spot our enemy if we're not broken
    if (det & ENEMY_DETECTED) {
        if (IsAggregate() && CheckValidType(this, e))
            e->SetSpotted(GetTeam(),TheCampaign.CurrentTime, (CanItIdentify(this, e, *d, e->GetMovementType()))); // 2002-02-11 MODIFIED BY S.G. Say 'identified if it has the hability to identify
    }
    if (det & ENEMY_IN_RANGE && react)
        *combat = 1;
    if (det & FRIENDLY_DETECTED) {
        // Spotting will be set only if our enemy is aggregated or if he's an AWAC. SensorFusion or GroundClass::Exec will hanlde deaggregated vehicles.
        if ((e->IsAggregate() && CheckValidType(e, this)) || (e->IsFlight() && e->GetSType() == STYPE_UNIT_AWACS)) {
            SetSpotted(e->GetTeam(),TheCampaign.CurrentTime, 1); // 2002-02-11 Modified by S.G. Ground units are always identified (doesn't change a thing)
            *spot = 1;
        }
    }

    return react;
}
示例#3
0
int TaskForceClass::DetectVs (AircraftClass *ac, float *d, int *combat, int *spot)
{
    int			react,det = Detected(this,ac,d);
    CampEntity	e;

    e = ac->GetCampaignObject();

    // 2001-03-22 ADDED BY S.G. DETECTION DOESN'T INCLUDED SPOTTED, ONLY THAT THIS ENTITY DETECTED THE OTHER BY ITSELF.
    int detTmp = det;

    // Check type of entity before GCI is used
    if (CheckValidType(this, e))
        detTmp |= e->GetSpotted(GetTeam()) ? ENEMY_DETECTED : 0;

    // Check type of entity before GCI is used
    if (CheckValidType(e, this))
        detTmp |= GetSpotted(e->GetTeam()) ? FRIENDLY_DETECTED : 0;

    if (!(detTmp & REACTION_MASK))
        return 0;

    react = Reaction(e,detTmp,*d);

    if (det & ENEMY_IN_RANGE && react)
        *combat = 1;

    // Spotting will be set only if our enemy is aggregated or if he's an AWAC. SensorFusion or GroundClass::Exec will hanlde deaggregated vehicles.
    // I can't let SensorFusion handle the spotting for AWAC because this will put a too big toll on the CPU
    // e has to be a flight since it is derived from an aircraft class so less checks needs to be done here then against flights below
    if (det & FRIENDLY_DETECTED) {
        // Spotting will be set only if our enemy is aggregated or if he's an AWAC. SensorFusion or GroundClass::Exec will hanlde deaggregated vehicles.
        if ((e->IsAggregate() && CheckValidType(e, this)) || (e->IsFlight() && e->GetSType() == STYPE_UNIT_AWACS)) {
            SetSpotted(e->GetTeam(),TheCampaign.CurrentTime, CanItIdentify(this, e, *d, e->GetMovementType())); // 2002-02-11 MODIFIED BY S.G. Added 'CanItIdentify' which query if the target can be identified
            *spot = 1;
        }
    }
    return react;
}