Prototype/Source/Prototype/Private/Task_VictimScan.cpp
/* Add survivor locations to environment map. Survivors have DETECTION_ACC chance of being successfully detected.
*/
Add survivor locations to environment map. Survivors have DETECTION_ACC chance of being successfully detected.
Add survivor locations to environment map . Survivors have DETECTION_ACC chance of being successfully detected .
void AUSARAgent::DetectionTask()
{
	FHitResult hitResult;
	FCollisionQueryParams queryParams;
	queryParams.AddIgnoredActor(this);
	FCollisionResponseParams responseParams;
	for (AVictimActor* vic : victimsInRange) {
		if (GetWorld()->LineTraceSingleByChannel(hitResult, GetActorLocation(), vic->GetActorLocation(), ECC_Pawn, queryParams, responseParams)) {
			if (hitResult.GetActor()->IsA(AVictimActor::StaticClass())) {
				float didDetect = FMath::FRand();
				if (didDetect <= DETECTION_ACC) {
					FVector vicLoc = vic->GetActorLocation();
					FGridStruct* grid = AddGrid(vicLoc, false);
					grid->survivors.AddUnique(vicLoc);
					for (AUSARAgent* n : neighborAgents) {
						n->ReceiveVictimData(vic);
					}
				}
			}
		}
	}
}
void AUSARAgent :: DetectionTask ( ) { FHitResult hitResult ; FCollisionQueryParams queryParams ; queryParams . AddIgnoredActor ( this ) ; FCollisionResponseParams responseParams ; for ( AVictimActor * vic : victimsInRange ) { if ( GetWorld ( ) -> LineTraceSingleByChannel ( hitResult , GetActorLocation ( ) , vic -> GetActorLocation ( ) , ECC_Pawn , queryParams , responseParams ) ) { if ( hitResult . GetActor ( ) -> IsA ( AVictimActor :: StaticClass ( ) ) ) { float didDetect = FMath :: FRand ( ) ; if ( didDetect <= DETECTION_ACC ) { FVector vicLoc = vic -> GetActorLocation ( ) ; FGridStruct * grid = AddGrid ( vicLoc , false ) ; grid -> survivors . AddUnique ( vicLoc ) ; } } } } }
Add survivor locations to environment map.
Add survivor locations to environment map .
//if (statusActiveSearch) { //	investigatingVic = true; //} //else { //	flockWPs.Insert(vicLoc, 0); //	 //	for (AUSARAgent* n : neighborAgents) { //		n->ReceiveVictimData(vic); //	} //} /*DEBUGGING*/ //DrawDebugPoint(GetWorld(), vic->GetActorLocation(), 25, FColor::Emerald, true, 1.f); /*DEBUGGING*/