Download

CSV Database: 11.000+ Names

http://s22.postimg.org/sw6jbwnch/image.jpg

:slight_smile: Hello guys! I’ve created a small CSV database of names and surnames for stuff I’m messing around within UE4 and I suppose it may be useful for someone else too, so I share it here with you; a little breakdown of content:

355 Fantasy Nobel Titles.
610 Fantasy Entitlements.
316 Nicknames.
100 Fantasy Surnames.
4810 Fantasy Names.
1415 Western Male Names.
1000 Western Female Names.
1255 Western Surnames.
1000 Hispanic Surnames.
1000 Asian Surnames.
75 Japanese Male Names.
80 Japanese Female Names.
990 Japanese Surnames.

I use this CSV data to generate random character names, fantasy titles and description in games;
This is very useful for games where players are required to create a name for their avatar, if player is out of ideas (s)he could just hit a “random name” button to get a name and description, like in these examples randomly generated:


The structs to load the data rows can be something like this:



/** Interfaces Character Name Data-Tables. */
USTRUCT(BlueprintType)
struct FCharacterName : public FTableRowBase {
    GENERATED_USTRUCT_BODY()
public:


    /** Object ID is the 'Name' Key:
        | ID | NAME | LENGTH |
    **/
    FCharacterName() : NAME(""), Length(0), Notes("") {}


    /** Given-Name. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Data")
    FString NAME;


    /** Array size used by RNG, should be equal to CSV's last 'Object ID'.
    NEVER! Set this value greater than actual Items in Data-Table; Or cyclic crash. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Property")
    int32 Length;
    
    /** Property Notes. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Property")
    FString Notes;


};


/** Interfaces Character Title Data-Tables. */
USTRUCT(BlueprintType)
struct FCharacterTitle : public FTableRowBase {
    GENERATED_USTRUCT_BODY()
public:


    /** Object ID is the 'Name' Key:
        | ID | TITLE | ICON | LENGTH |
    **/
    FCharacterTitle() : TITLE(""), ICON(nullptr), Length(0), Notes("") {}


    /** Achieved Title. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Data")
    FString TITLE;


    /** Achieved Title's Icon. */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Data")
    TAssetPtr<UTexture> ICON;


    /** Array size used by RNG, should be equal to CSV's last 'Object ID'.
    NEVER! Set this value greater than actual Items in Data-Table; Or cyclic crash. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Property")
    int32 Length;
    
    /** Property Notes. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Property")
    FString Notes;


};


/** Interfaces Character Entitlement Data-Tables. */
USTRUCT(BlueprintType)
struct FCharacterEntitlement : public FTableRowBase {
    GENERATED_USTRUCT_BODY()
public:


    /** Object ID is the 'Name' Key:
        | ID | ENTITLEMENT |
    **/
    FCharacterEntitlement() : ENTITLEMENT("") {}


    /** Achieved Title's Name. */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Data")
    FString ENTITLEMENT;


};


And the functions I use to generate random names from the CSV data are like these:



//----------HELPERS----------\\


/** Data-Table Lookup Context. */
static const FString DTContext(TEXT("GENERAL"));


int Random(int32 Max) {
    return FMath::RandRange(0,Max);
}




//----------GENERATORS----------\\


FName SGENERATOR::FGenerateCharacterName(UDataTable* DT) {
    FCharacterName* FRow = DT->FindRow<FCharacterName>("0",DTContext); int32 RNG = Random(FRow->Length);
    FRow = DT->FindRow<FCharacterName>(*FString::Printf(TEXT("%d"),RNG),DTContext);
    return FName(*FRow->NAME);
}


FText SGENERATOR::FGenerateCharacterTitle(UDataTable* DT) {
    FCharacterTitle* FRow = DT->FindRow<FCharacterTitle>("0",DTContext); int32 RNG = Random(FRow->Length);
    FRow = DT->FindRow<FCharacterTitle>(*FString::Printf(TEXT("%d"),RNG),DTContext);
    return FText::FromString(*FRow->TITLE);
}


FText SGENERATOR::FGenerateCharacterEntitlement(UDataTable* DT, FText* Title) {
    FString S = Title->ToString().Replace(*FString(" "),*FString(""));
    FCharacterEntitlement* FRow = DT->FindRow<FCharacterEntitlement>(*S,DTContext);
    return FText::FromString(*FRow->ENTITLEMENT);
}


Have fun :wink: Download:

This is cool. It looks like I am going to have a feature in my game that I didn’t think I would have. :slight_smile:

Also, this is the 1,111 thread in this section.

This is going to be super useful.