XP and level up systems implemented.
This commit is contained in:
+53
-1
@@ -51,7 +51,6 @@ All rights reserved.
|
||||
#include "config.h"
|
||||
#include <string_view>
|
||||
|
||||
|
||||
INCLUDE_MONSTER_DATA
|
||||
INCLUDE_MONSTER_LIST
|
||||
INCLUDE_ANIMATION_DATA
|
||||
@@ -958,6 +957,9 @@ void EntityStats::SetBaseStat(ItemAttribute stat,float val){
|
||||
baseStats.A(stat)=val;
|
||||
RecalculateEquipStats();
|
||||
}
|
||||
void EntityStats::SetBaseStat(std::string_view stat,float val){
|
||||
SetBaseStat(ItemAttribute::Get(stat),val);
|
||||
}
|
||||
void Player::SetBaseStat(std::string_view a,float val){
|
||||
stats.SetBaseStat(ItemAttribute::Get(a),val);
|
||||
}
|
||||
@@ -1089,4 +1091,54 @@ const float Player::GetDamageReductionPct()const{
|
||||
float modDmgReductionPct=0;
|
||||
modDmgReductionPct+=GetStat("Damage Reduction")/100;
|
||||
return modDmgReductionPct;
|
||||
}
|
||||
|
||||
void Player::AddXP(const uint32_t xpGain){
|
||||
currentLevelXP+=xpGain;
|
||||
totalXPEarned+=xpGain;
|
||||
uint32_t nextLevelXP=NextLevelXPRequired();
|
||||
if(Level()<LevelCap()){
|
||||
if(currentLevelXP>nextLevelXP){
|
||||
currentLevelXP-=nextLevelXP;
|
||||
level++;
|
||||
OnLevelUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::OnLevelUp(){
|
||||
stats.SetBaseStat("Health",GetBaseStat("Health")+hpGrowthRate);
|
||||
stats.SetBaseStat("Attack",GetBaseStat("Attack")+atkGrowthRate);
|
||||
Heal(GetBaseStat("Health"));
|
||||
}
|
||||
const uint8_t Player::LevelCap()const{
|
||||
return levelCap;
|
||||
}
|
||||
const uint8_t Player::Level()const{
|
||||
return level;
|
||||
}
|
||||
const uint32_t Player::CurrentXP()const{
|
||||
return currentLevelXP;
|
||||
}
|
||||
const uint32_t Player::TotalXP()const{
|
||||
return totalXPEarned;
|
||||
}
|
||||
|
||||
const uint32_t Player::NextLevelXPRequired()const{
|
||||
if(Level()<LevelCap()){
|
||||
return DATA.GetProperty(std::format("PlayerXP.LEVEL[{}]",Level()+1)).GetInt();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Player::ResetAccumulatedXP(){
|
||||
accumulatedXP=0;
|
||||
}
|
||||
void Player::AddAccumulatedXP(const uint32_t xpGain){
|
||||
accumulatedXP+=xpGain;
|
||||
}
|
||||
|
||||
const uint32_t Player::GetAccumulatedXP()const{
|
||||
return accumulatedXP;
|
||||
}
|
||||
Reference in New Issue
Block a user