void ACSUEBomb::checkOverlap() { TArray<AActor*> nearbyT; //UE_LOG(LogTemp, Warning, TEXT("FOUND ACTOR")); bombMesh->GetOverlappingActors(nearbyT); for (int32 i = 0; i < nearbyT.Num(); i++) { //UE_LOG(LogTemp, Warning, TEXT("FOUND ACTOR")); auto terrorist = Cast<ACSUETerrorist>(nearbyT[i]); auto ct = Cast<ACSUECounterTerrorist>(nearbyT[i]); auto player = Cast<ACSUECharacter>(nearbyT[i]); if (terrorist) { //UE_LOG(LogTemp, Warning, TEXT("FOUND TERRORIST")); //start bomb timer if (!planted) { GetWorldTimerManager().SetTimer(bombTimer, this, &ACSUEBomb::bombExplode, 2.f, false); planted = true; UE_LOG(LogTemp, Warning, TEXT("bomb planted")); } } if (player && player->getEnemyTeam() == FString(TEXT("ct"))) { //UE_LOG(LogTemp, Warning, TEXT("FOUND TERRORIST")); if (!planted) { GetWorldTimerManager().SetTimer(bombTimer, this, &ACSUEBomb::bombExplode, 10.f, false); planted = true; UE_LOG(LogTemp, Warning, TEXT("bomb planted")); } } else if (ct) { //defuse shit //timer not started yet? if (!GetWorldTimerManager().IsTimerActive(defuseTimer)) { GetWorldTimerManager().SetTimer(defuseTimer, this, &ACSUEBomb::bombDefused, 3.f, false); } } else { //if defuse timer is active, turn it off if (GetWorldTimerManager().IsTimerActive(defuseTimer)) { GetWorldTimerManager().ClearTimer(defuseTimer); } } } }
bool AI::makeMove(SDL_Event *event){ // Init enemyTeam that this class can use getEnemyTeam(); for(int index=0;index<team.size();index++){ currentIndex = index; team[index].directionValues[0] = maxValue(Board->virtualBoard, team, enemyTeam, MAX_DEPTH, LEFT); team[index].directionValues[1] = maxValue(Board->virtualBoard, team, enemyTeam, MAX_DEPTH, RIGHT); if (team[index].isKing()) { team[index].directionValues[3] = maxValue(Board->virtualBoard, team, enemyTeam, MAX_DEPTH, BACK_RIGHT); team[index].directionValues[2] = maxValue(Board->virtualBoard, team, enemyTeam, MAX_DEPTH, BACK_LEFT); } cout<<"Index: "<<index<<" ("<< team[index].x << "," << team[index].y; cout<<") Left: "<<team[index].directionValues[0]<<" Right: "<<team[index].directionValues[1]; cout<<" bLeft: "<<team[index].directionValues[2]<<" bRight: "<<team[index].directionValues[3]<<endl; team[index].findBestDirection(); team[index].findLargestPotenial(); } int bestPieceIndex = bestPiece(team); cout<< "The chosen one: " << bestPieceIndex << " -> ("<< team[bestPieceIndex].x << "," << team[bestPieceIndex].y; int x = team[bestPieceIndex].x; int y = team[bestPieceIndex].y; // Makes sure the move isnt out of bounds // if (team[bestPieceIndex].potential != OUT_OF_BOUND) { changeWithDirection(x, y, team[bestPieceIndex].bestDirection, false); if(sameTeam(Board->virtualBoard[x][y],ENEMY_TEAM_NUMBER)){ // Changes it again for moving 2 units diagonally // changeWithDirection(x, y, team[bestPieceIndex].bestDirection, false); } cout<<") best move: (" << x << "," << y <<")"<< endl; movePiece(Board->virtualBoard, team, bestPieceIndex, x, y); return true; } return false; }