Testing code for kitty

Author:

| Size: 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

Comments

No comments yet

Comment attachments are limited to 30MB total. For larger files, create a paste and share the link.

9/26/2025

Suggested Pastes

Not all user generated content is reviewed by AnonPaste. If you believe this paste violates our community guideline or terms of service, please report it here.
AnonPaste is a user-generated content hosting service. The platform and its operators are not responsible for content posted by users.