diff --git a/Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj b/Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj index 44b7f380..970dac05 100644 --- a/Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj +++ b/Adventures in Lestoria Tests/Adventures in Lestoria Tests.vcxproj @@ -67,6 +67,7 @@ Windows $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + discord_game_sdk.dll.lib;freetype.lib;steam_api64.lib;$(CoreLibraryDependencies);%(AdditionalDependencies) powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File ../unit-testing-prebuild.ps1 diff --git a/Adventures in Lestoria Tests/EnchantTests.cpp b/Adventures in Lestoria Tests/EnchantTests.cpp index 476377e3..e546918b 100644 --- a/Adventures in Lestoria Tests/EnchantTests.cpp +++ b/Adventures in Lestoria Tests/EnchantTests.cpp @@ -240,5 +240,25 @@ namespace EnchantTests player->Heal(11); Assert::AreEqual(0.0_Pct,player->GetHPRecoveryPct(),L"HP Recovery Pct is now 0% since Second Wind should no longer activate above 20% health."); } + TEST_METHOD(EmergencyRecoveryCheck){ + Assert::AreEqual(0.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is 0% at the start."); + Assert::AreEqual(0.0_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is 0% at the start."); + std::weak_ptrnullRing{Inventory::AddItem("Null Ring"s)}; + Inventory::EquipItem(nullRing,EquipSlot::RING1); + nullRing.lock()->EnchantItem("Emergency Recovery"); + Assert::AreEqual(1.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is base 1% even with full HP."); + Assert::AreEqual(0.0_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is still 0% since the player is not lower than 30% health."); + for(int i:std::ranges::iota_view(1,7)){ + player->Hurt(10,player->OnUpperLevel(),player->GetZ()); + Assert::AreEqual(1.0_Pct+0.5_Pct*i,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is increasing by 0.5% per 10% missing health."); + } + player->Hurt(10,player->OnUpperLevel(),player->GetZ()); + Assert::AreEqual(0.0_Pct,player->GetHP6RecoveryPct(),0.1_Pct,L"HP Recovery/6 Pct is now 0% as the HP Recovery/4 sec version should have activated."); + Assert::AreEqual(4.5_Pct,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is now 4.5%"); + for(int i:std::ranges::iota_view(1,3)){ + player->Hurt(10,player->OnUpperLevel(),player->GetZ()); + Assert::AreEqual(4.5_Pct+0.5_Pct*i,player->GetHP4RecoveryPct(),0.1_Pct,L"HP Recovery/4 Pct is increasing by 0.5% per 10% missing health."); + } + } }; } \ No newline at end of file diff --git a/Adventures in Lestoria.sln b/Adventures in Lestoria.sln index da969708..7fd217ba 100644 --- a/Adventures in Lestoria.sln +++ b/Adventures in Lestoria.sln @@ -43,8 +43,8 @@ Global {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x64.Build.0 = Release Desktop|x64 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.ActiveCfg = Release Desktop|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Release|x86.Build.0 = Release Desktop|Win32 - {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.ActiveCfg = Release Desktop|x64 - {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.Build.0 = Release Desktop|x64 + {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.ActiveCfg = Unit Testing|x64 + {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x64.Build.0 = Unit Testing|x64 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.ActiveCfg = Unit Testing|Win32 {8E3067AF-CFE7-4B11-BC6B-B867C32753D7}.Unit Testing|x86.Build.0 = Unit Testing|Win32 {11969B7B-3D50-4825-9584-AF01D15B88E0}.Debug|x64.ActiveCfg = Unit Testing|x64 diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 8c2bd866..2d8319c1 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -1466,11 +1466,35 @@ const float Player::GetHPRecoveryPct()const{ const float Player::GetHP6RecoveryPct()const{ float modHPRecoveryPct=0; modHPRecoveryPct+=GetEquipStat("HP6 Recovery %")/100; + + #pragma region Emergency Recovery Enchant Bonuses + const bool UseHP4RecoveryInstead{GetHealthRatio()<="Emergency Recovery"_ENC["FOUR SECOND HP THRESHOLD"]/100.f}; + if(HasEnchant("Emergency Recovery")&&!UseHP4RecoveryInstead){ + const float missingHealthRatio{std::ceil(((1-GetHealthRatio())*100))/100}; + const float effectBonusBasedOnMissingHealth{"Emergency Recovery"_ENC["GAIN AMOUNT PCT"]/100.f*int(missingHealthRatio/("Emergency Recovery"_ENC["MISSING HEALTH BONUS PCT"]/100.f))}; + + modHPRecoveryPct+="Emergency Recovery"_ENC["HP RECOVERY PCT"]/100.f; + modHPRecoveryPct+=effectBonusBasedOnMissingHealth; + } + #pragma endregion + return modHPRecoveryPct; } const float Player::GetHP4RecoveryPct()const{ float modHPRecoveryPct=0; modHPRecoveryPct+=GetEquipStat("HP4 Recovery %")/100; + + #pragma region Emergency Recovery Enchant Bonuses + const bool UseHP4RecoveryInstead{GetHealthRatio()<="Emergency Recovery"_ENC["FOUR SECOND HP THRESHOLD"]/100.f}; + if(HasEnchant("Emergency Recovery")&&UseHP4RecoveryInstead){ + const float missingHealthRatio{std::ceil(((1-GetHealthRatio())*100))/100}; + const float effectBonusBasedOnMissingHealth{"Emergency Recovery"_ENC["GAIN AMOUNT PCT"]/100.f*int(missingHealthRatio/("Emergency Recovery"_ENC["MISSING HEALTH BONUS PCT"]/100.f))}; + + modHPRecoveryPct+="Emergency Recovery"_ENC["HP RECOVERY PCT"]/100.f; + modHPRecoveryPct+=effectBonusBasedOnMissingHealth; + } + #pragma endregion + return modHPRecoveryPct; } diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 4f0e20a8..8fc3fbb8 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 3 -#define VERSION_BUILD 10646 +#define VERSION_BUILD 10653 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/items/ItemEnchants.txt b/Adventures in Lestoria/assets/config/items/ItemEnchants.txt index cd641b78..f6efc7c6 100644 --- a/Adventures in Lestoria/assets/config/items/ItemEnchants.txt +++ b/Adventures in Lestoria/assets/config/items/ItemEnchants.txt @@ -593,7 +593,7 @@ Item Enchants } Emergency Recovery { - Description = "Gain {HP RECOVERY PCT}% HP Recovery every 6 seconds. Effect increases by {GAIN AMOUNT PCT}% for every {MISSING HEALTH BONUS PCT}% health missing. Below {FOUR SECOND HP THRESHOLD}% Health Recovery happens every 4 seconds." + Description = "Gain {HP RECOVERY PCT}% HP Recovery every 6 seconds. Effect increases by {GAIN AMOUNT PCT}% for every {MISSING HEALTH BONUS PCT}% health missing. Below {FOUR SECOND HP THRESHOLD}% HP, Health Recovery happens every 4 seconds." HP RECOVERY PCT = 1% GAIN AMOUNT PCT = 0.5% diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 2aa9b0cf..de7a7831 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ