# One more cup of SW coffee...

**URL:** <https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240>\
**Category:** Game Development\
**Tags:** unreal-engine\
**Created:** [September 3, 2023, 12:03am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240 "2023-09-03T00:03:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 3, 2023, 12:03am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/1 "2023-09-03T00:03:44Z")

</div>

How it looks (for you/plural)

 ![JR1A](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/1/eb12184857aabc78120043a3887401534d75b5cd.jpeg)

[And a video link…](https://www.veed.io/view/96750fb6-02c1-4157-b74c-299935802954?panel=share)This text will be hidden

How it works (for me)

```auto
UENUM()
enum class EDieType : uint8
{
	Invalid = 0x0,
	d2 = 0x2,
	d3 = 0x3,
	d4 = 0x4,
	d6 = 0x6,
	d8 = 0x8,
	d10 = 0xA,
	d12 = 0xC,
	d20 = 0x14,
	d100 = 0x64,
};

```

and

```auto
static FORCEINLINE int32 RollDice(EDieType DieType, int32 Roll = 1)
{
	check(DieType!=EDieType::Invalid);

	int32 dice = 0;

	for (int i = 1; i <= Roll; ++i)
	{
		dice += rand() % static_cast<int>(DieType) + 1;
	}

	return dice;
}

```

Some extra info, no tl;dr  
An average programmer, want to study some C++ in Unreal via a remake of sorts (KotOR in particular), so an omelet was one way, with random ingredients. Not an artist but I heard about projection matrices. Just added a shiny new DnD dice roll method.

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 4, 2023, 12:14am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/2 "2023-09-04T00:14:59Z")

</div>

a `how it looks` for you/plural

 ![MovingOnGalaxyMap](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/9/b593970ea653a7ecfe5c55d78815344b194cc325.jpeg)  
with a video link [here](https://vimeo.com/860740683?share=copy)

a `how it works` for me, no CMC, just interp on tick

```auto
SetActorLocation(FMath::VInterpConstantTo(GetActorLocation(), EndLocation, DeltaTime, MovementSpeed * SpeedModifier));

```

---

<div class="post-metadata">

**Author:** ![Zezkaii](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zezkaii/32/1194610_2.png) [@Zezkaii](https://forums.unrealengine.com/u/Zezkaii)\
**Post date:** [September 4, 2023, 9:40pm UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/3 "2023-09-04T21:40:58Z")

</div>

Greetings @JohnSmithrd3, I hope you’re having a great Monday! Welcome to the UE community; we appreciate you sharing your work with us in the forums. 😁

Is there a “Star Wars Journeys” out there, since you’re working on “Star Wars Journeys 2”? 😅

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 5, 2023, 1:20am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/4 "2023-09-05T01:20:06Z")

</div>

> [@Zezkaii](#):
>
> Star Wars Journeys

I think there was an Iphone app ~10 years ago. This project is for my learning Unreal C++ mainly, so the name is kinda random, but as it has a spaceship _journeying_ on the galaxy map, I assumed `Journeys 2` is appropriate

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 5, 2023, 1:22am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/5 "2023-09-05T01:22:07Z")

</div>

`how it looks` for you/plural, a Character Creation example

 ![SWJ2CC](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/7/d/07d07e2933944cd3a86b5e2c8c3c3a7ec7d95ebe.jpeg)

`how it works` for me

```auto
UENUM()
enum class ECharacterRace : uint8
{
    Invalid,
    Chiss,
    Cyborg,
    Human,
    Miraluka,
    Mirialan,
    Rattataki,
    SithPureblood,
    Twilek,
    Zabrak,
    Cathar,
    Togruta,
    Nautolan
};

```

and

```auto
UENUM()
enum class ECharacterClass : uint8
{
    Invalid,
    Soldier,
    Scout,
    Scoundrel,
    JediGuardian,
    JediConsular,
    JediSentinel,
    CombatDroid,
    ExpertDroid,
    Minion,
    TechSpecialist,
    BountyHunter,
    JediWeaponmaster,
    JediMaster,
    JediWatchman,
    SithMarauder,
    SithLord,
    SithAssassin
};

```

and

```auto
Chargen_ApplyRaceAttributeModifiers(Character, static_cast<ECharacterRace>(Character->GetCharacterVars()["Race"]));
    Chargen_ApplyClassAttributeModifiers(Character, static_cast<ECharacterClass>(Character->GetCharacterVars()["Class"]));
    Chargen_ApplyClassStatModifiers(Character, static_cast<ECharacterClass>(Character->GetCharacterVars()["Class"]));
    Chargen_ApplyClassAbilities(Character, static_cast<ECharacterClass>(Character->GetCharacterVars()["Class"]));

```

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 6, 2023, 12:47am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/6 "2023-09-06T00:47:39Z")

</div>

a `how it looks` for you

 ![Jedi_sw_atk_4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/2/0/f206d48e2c58708cc590db7ef833a62b386d3534.jpeg)  
with a video [link](https://vimeo.com/861464799?share=copy)

a `how it works` for me, the most beautiful thing in the world, `weak lambda`

```auto
        FTimerDelegate delayedCallback;
        delayedCallback.BindWeakLambda(GetWorld(), [this]
        {
            HandleCombatRound(bIsDone);
        });
        FTimerHandle unusedHandle;
        GetWorld()->GetTimerManager().SetTimer(unusedHandle, delayedCallback, fDelay, false);

```

---

<div class="post-metadata">

**Author:** ![Zezkaii](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zezkaii/32/1194610_2.png) [@Zezkaii](https://forums.unrealengine.com/u/Zezkaii)\
**Post date:** [September 6, 2023, 9:55pm UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/7 "2023-09-06T21:55:46Z")

</div>

Ah, I see. Thank you for the explanation! I bet this project is gratifying to work on. However, that may be my biased showing (I **love** anything Star Wars-related 😆).

I will continue to enjoy the screenshots and videos you share as you develop. Happy developing! 😁

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 7, 2023, 4:40am UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/8 "2023-09-07T04:40:19Z")

</div>

`how it looks` character sheet

 ![character_sheet_concept](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/c/f/3cfff1ffa83854ed9fefa25a96c69663c5dec808.png)

`how it works`, fetching values from a plaintext file, e.g. CSV instead of a traditional Unreal DataTable (I like either, but plain text is just easier to read than binary)

```auto
FString URPGGameInstance::GetTableValue(FName sTableName, FName sColumn, FName sRow)
{
	//this returns a FString to be converted to other types, e.g. float, int32, etc.
	FString sString = "NA";

	std::string line;
	const FString sData = FPaths::ProjectDir() + GetPathForData(sTableName);

	std::ifstream inData;
	inData.open(TCHAR_TO_UTF8(*sData));

	if (inData.fail())
	{
		UE_LOG(LogTemp, Error, TEXT("%s"), *FString::Printf(TEXT("ERROR: Couldn't find '%s'"), *sTableName.ToString()));
		inData.close();
	}

	FString sHeader = "";
	TArray<FString> RowArray;
	TArray<FString> HeaderArray;
	int32 nColumnIndex = INT_MAX;

	while (getline(inData, line))
	{
		const FString sLine = line.c_str();

		check(sLine.Contains(","));

		if (sHeader.IsEmpty())
		{
			sHeader = sLine;
			const TCHAR* delim = L",";

			sHeader.ParseIntoArray(HeaderArray, delim);
			for (int32 i = 0; i < HeaderArray.Num(); ++i)
			{
				if (HeaderArray[i] == sColumn.ToString())
				{
					nColumnIndex = i;
					break;
				}
			}

			check(nColumnIndex!=INT_MAX);
		}

		FString sKey;
		FString sValue;

		sLine.Split(TEXT(","), &sKey, &sValue);

		if (sKey == sRow.ToString())
		{
			const TCHAR* delim = L",";

			sLine.ParseIntoArray(RowArray, delim);
			sString = RowArray[nColumnIndex];
			break;
		}
	}

	check(sString!="NA");

	UE_LOG(LogTemp, Log, TEXT("%f %s"), UGameplayStatics::GetTimeSeconds(GetWorld()), *FString::Printf(TEXT("Done '%s'"), *FString( __FUNCTION__ )));

	return sString;
}

```

---

<div class="post-metadata">

**Author:** ![JohnSmithrd3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JohnSmithrd3](https://forums.unrealengine.com/u/JohnSmithrd3)\
**Post date:** [September 11, 2023, 11:43pm UTC](https://forums.unrealengine.com/t/one-more-cup-of-sw-coffee/1281240/9 "2023-09-11T23:43:13Z")

</div>

`how it looks`: Combat layout Darkest Dungeon like (actually Circus Electrique, it’s an Unreal game :D)

 ![JediRuleCombat1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/f/e/ffe2a643ebb393276bb02b591bf44023fd1ee6b0.jpeg)

`how it works`, a simple Initiative sort for the list on top of the screen above, the initiative is a 1D20 roll

```auto
//sort ascending
    CombatInitiativeList.Sort(
        [&](ARPGCombatAvatar& a1, ARPGCombatAvatar& a2)
        {
            return (a1.GetCharacterVars()[INITIATIVE] > a2.GetCharacterVars()[INITIATIVE]);
        });

```
