Space Plunder
Loading...
Searching...
No Matches
FCharacterSkill Struct Reference

The FCharacterSkill struct represents a skill of a character. More...

#include <BaseData.h>

Public Member Functions

 FCharacterSkill ()
 
 FCharacterSkill (const FGameplayTag SkillName)
 
 FCharacterSkill (const FGameplayTag SkillName, const int32 StartingLevel)
 
bool AddXP (const float Value)
 
bool AddLevel (const bool bIncrease)
 

Public Attributes

FGameplayTag Name = SkillTags::Strength
 
int32 Level = 1
 
float XP = 0.0f
 

Detailed Description

The FCharacterSkill struct represents a skill of a character.

See also
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/

This struct contains the properties necessary to define a character skill, such as the skill name, level, and experience points (XP). It also provides a method to add XP to the skill and level up the skill.

Constructor & Destructor Documentation

◆ FCharacterSkill() [1/3]

FCharacterSkill::FCharacterSkill ( )
inline
733 {
734
735 }

◆ FCharacterSkill() [2/3]

FCharacterSkill::FCharacterSkill ( const FGameplayTag SkillName)
inlineexplicit
737 {
738 Name = SkillName;
739 }
FGameplayTag Name
Definition BaseData.h:726

◆ FCharacterSkill() [3/3]

FCharacterSkill::FCharacterSkill ( const FGameplayTag SkillName,
const int32 StartingLevel )
inlineexplicit
741 {
742 Name = SkillName;
743 Level = StartingLevel;
744 XP = StartingLevel * XP_PER_LEVEL;
745 }
static int32 XP_PER_LEVEL
Definition BaseData.h:707
float XP
Definition BaseData.h:730
int32 Level
Definition BaseData.h:728

Member Function Documentation

◆ AddLevel()

bool FCharacterSkill::AddLevel ( const bool bIncrease)
inline
763 {
764 int32 PrevLevel = Level;
765 if(bIncrease)
766 {
767 Level++;
768 }
769 else
770 {
771 Level--;
772 }
773 Level = FMath::Min(FMath::Max(MIN_SKILL_LEVEL, Level), MAX_SKILL_LEVEL); // Ensure Level does not exceed MaxLevel
774 return Level != PrevLevel;
775 }
static int32 MIN_SKILL_LEVEL
Definition BaseData.h:708
static int32 MAX_SKILL_LEVEL
Definition BaseData.h:706

◆ AddXP()

bool FCharacterSkill::AddXP ( const float Value)
inline

Doesn't go past Max skill level

Parameters
Valueof XP to Add
Returns
if Leveled Up
752 {
753 const int32 LevelBefore = XP / XP_PER_LEVEL; // Level before adding XP
754 XP += Value;
755 // Level = XP / 1000;
756 //- Level after adding XP
757 Level = FMath::Min(static_cast<int32>(XP / XP_PER_LEVEL), MAX_SKILL_LEVEL); // Ensure Level does not exceed MaxLevel
758 return Level > LevelBefore;
759 }

Member Data Documentation

◆ Level

int32 FCharacterSkill::Level = 1

◆ Name

FGameplayTag FCharacterSkill::Name = SkillTags::Strength

Skill Name

◆ XP

float FCharacterSkill::XP = 0.0f

The documentation for this struct was generated from the following file: