Implemented Fair NPC Station Randomizer
This commit is contained in:
		
							parent
							
								
									956da86677
								
							
						
					
					
						commit
						5bec94540b
					
				
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/StarterContent/Blueprints/Blueprint_CeilingLight.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset
									 (Stored with Git LFS)
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -38,9 +38,26 @@ void ANPC_Manager::BeginPlay() | ||||
| 
 | ||||
| 	if (NPC_StationClasses.IsEmpty()) return; | ||||
| 	FRotator DefaultRot = FRotator(0, 0, 0); | ||||
| 	int StationSlots = (StationPoints.Num() / NPC_StationClasses.Num()) + 1; | ||||
| 	TArray<int> NumOfUniqueStations; | ||||
| 	for (auto UniqueStation : NPC_StationClasses) | ||||
| 	{ | ||||
| 		NumOfUniqueStations.Add(StationSlots); | ||||
| 	} | ||||
| 	for (FVector StationPoint : StationPoints) | ||||
| 	{ | ||||
| 		int RandInt = FMath::RandRange(0, NPC_StationClasses.Num() - 1); | ||||
| 		bool FoundRandomFairInt = false; | ||||
| 		int RandInt = 0; | ||||
| 		while (!FoundRandomFairInt) | ||||
| 		{ | ||||
| 			RandInt = FMath::RandRange(0, NPC_StationClasses.Num() - 1); | ||||
| 			if (NumOfUniqueStations[RandInt] > 0) | ||||
| 			{ | ||||
| 				NumOfUniqueStations[RandInt]--; | ||||
| 				FoundRandomFairInt = true; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		FVector StationPointWorldLocation = StationPoint + GetActorLocation(); | ||||
| 		ANPC_Station* NPC_Station = GetWorld()->SpawnActor<ANPC_Station>(NPC_StationClasses[RandInt], StationPointWorldLocation, DefaultRot); | ||||
| 		if (IsValid(NPC_Station)) NPC_Stations.Add(NPC_Station); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user