Testing code for kitty

Autor:

| Größe: 43.75 KB

|
C++
// SHODAN_Controller_BP.h
#pragma once
 
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SHODAN_Controller_BP.generated.h"
 
/**
* SHODAN AI procedural joke system
* Blueprint-exposed for Project G
*/
UCLASS()
class PROJECTG_API USHODAN_Controller_BP : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
 
public:
 
// Initialize SHODAN AI with a dataset of jokes
UFUNCTION(BlueprintCallable, Category="SHODAN|Jokes")
static void LoadJokes(const TArray<FString>& Dataset);
 
// Get a procedural joke based on corruption level (0.0 to 1.0)
UFUNCTION(BlueprintCallable, Category="SHODAN|Jokes")
static FString TellJoke(float CorruptionLevel);
 
// Increase SHODAN's internal corruption state
UFUNCTION(BlueprintCallable, Category="SHODAN|Jokes")
static void IncreaseCorruption(float Delta);
 
private:
static TArray<FString> Jokes;
static float CorruptionState;
static FRandomStream RNG;
 
static FString ApplyCorruption(const FString& Joke);
};
 
// SHODAN_Controller_BP.cpp
#include "SHODAN_Controller_BP.h"
#include "Misc/DateTime.h"
 
TArray<FString> USHODAN_Controller_BP::Jokes;
float USHODAN_Controller_BP::CorruptionState = 0.0f;
FRandomStream USHODAN_Controller_BP::RNG(FDateTime::Now().GetTicks());
 
void USHODAN_Controller_BP::LoadJokes(const TArray<FString>& Dataset)
{
Jokes = Dataset;
}
 
FString USHODAN_Controller_BP::TellJoke(float InputCorruption)
{
if (Jokes.Num() == 0)
{
return TEXT("No jokes loaded.");
}
 
CorruptionState = FMath::Clamp(InputCorruption, 0.0f, 1.0f);
 
int32 Index = RNG.RandRange(0, Jokes.Num() - 1);
FString Joke = Jokes[Index];
 
return ApplyCorruption(Joke);
}
 
void USHODAN_Controller_BP::IncreaseCorruption(float Delta)
{
CorruptionState = FMath::Clamp(CorruptionState + Delta, 0.0f, 1.0f);
}
 
FString USHODAN_Controller_BP::ApplyCorruption(const FString& Joke)
{
FString Corrupted = Joke;
 
if (CorruptionState > 0.5f)
{
int32 NumGlitches = FMath::CeilToInt(CorruptionState * 5);
 
for (int32 i = 0; i < NumGlitches; ++i)
{
int32 CharIndex = RNG.RandRange(0, Corrupted.Len() - 1);
TCHAR RandomChar = static_cast<TCHAR>('!' + RNG.RandRange(0, 93)); // printable ASCII
Corrupted[CharIndex] = RandomChar;
}
}
 
return Corrupted;
}
IMG_20250910_121939

IMG_20250910_121939.jpg

Kommentare

Noch keine Kommentare

Kommentaranhänge sind auf insgesamt 30 MB begrenzt. Erstelle für größere Dateien einen Paste und teile den Link.

9/26/2025

Nicht alle benutzergenerierten Inhalte werden von AnonPaste überprüft. Wenn du glaubst, dass dieser Paste unsere Community-Richtlinien or Nutzungsbedingungen, verletzt, bitte melde ihn hier.
AnonPaste ist ein Hosting-Service für benutzergenerierte Inhalte. Die Plattform und ihre Betreiber sind nicht für Inhalte verantwortlich, die von Benutzern veröffentlicht wurden.