Add class-specific level up achievements. Fix bug with recalculating next levelXP when obtaining multiple levels at once upon stage completion. Release Build 8534.

mac-build
sigonasr2 11 months ago
parent 3840b28468
commit 5742c03c4f
  1. 20
      Adventures in Lestoria/Player.cpp
  2. 2
      Adventures in Lestoria/Version.h
  3. 3
      Adventures in Lestoria/assets/config/Achievements.txt
  4. BIN
      x64/Release/Adventures in Lestoria.exe

@ -57,6 +57,9 @@ All rights reserved.
#include "GameSettings.h" #include "GameSettings.h"
#include "Unlock.h" #include "Unlock.h"
#include "Tutorial.h" #include "Tutorial.h"
#ifndef __EMSCRIPTEN__
#include <isteamuserstats.h>
#endif
INCLUDE_MONSTER_DATA INCLUDE_MONSTER_DATA
INCLUDE_MONSTER_LIST INCLUDE_MONSTER_LIST
@ -1301,9 +1304,8 @@ void Player::AddXP(const uint32_t xpGain){
currentLevelXP+=xpGain; currentLevelXP+=xpGain;
totalXPEarned+=xpGain; totalXPEarned+=xpGain;
if(Level()<LevelCap()){ if(Level()<LevelCap()){
uint32_t nextLevelXP=NextLevelXPRequired(); while(currentLevelXP>=NextLevelXPRequired()){
while(currentLevelXP>=nextLevelXP){ currentLevelXP-=NextLevelXPRequired();
currentLevelXP-=nextLevelXP;
SetLevel(Level()+1); SetLevel(Level()+1);
OnLevelUp(); OnLevelUp();
} }
@ -1324,6 +1326,18 @@ void Player::OnLevelUp(){
stats.SetBaseStat("Health",GetBaseStat("Health")+hpGrowthRate); stats.SetBaseStat("Health",GetBaseStat("Health")+hpGrowthRate);
stats.SetBaseStat("Attack",GetBaseStat("Attack")+atkGrowthRate); stats.SetBaseStat("Attack",GetBaseStat("Attack")+atkGrowthRate);
Heal(GetBaseStat("Health")); Heal(GetBaseStat("Health"));
if(SteamUserStats()){
for(auto&[key,size]:DATA.GetProperty("Achievement.Class Unlocks")){
datafile&unlock=DATA.GetProperty(std::format("Achievement.Class Unlocks.{}",key));
if(classutils::StringToClass(unlock["Class Requirement"].GetString())==GetClass()&&
Level()-1<unlock["Level Requirement"].GetInt()&&
Level()==unlock["Level Requirement"].GetInt()){
SteamUserStats()->SetAchievement(unlock["API Name"].GetString().c_str());
SteamUserStats()->StoreStats();
}
}
}
} }
const uint8_t Player::LevelCap()const{ const uint8_t Player::LevelCap()const{
return levelCap; return levelCap;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 8532 #define VERSION_BUILD 8534
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -70,16 +70,19 @@ Achievement
Warrior Lv5 Warrior Lv5
{ {
API Name = "WARRIOR_LV5" API Name = "WARRIOR_LV5"
Class Requirement = Warrior
Level Requirement = 5 Level Requirement = 5
} }
Ranger Lv5 Ranger Lv5
{ {
API Name = "RANGER_LV5" API Name = "RANGER_LV5"
Class Requirement = Ranger
Level Requirement = 5 Level Requirement = 5
} }
Wizard Lv5 Wizard Lv5
{ {
API Name = "WIZARD_LV5" API Name = "WIZARD_LV5"
Class Requirement = Wizard
Level Requirement = 5 Level Requirement = 5
} }
} }

Loading…
Cancel
Save