diff --git a/Adventures in Lestoria Tests/EnchantTests.cpp b/Adventures in Lestoria Tests/EnchantTests.cpp index 9c606ed7..fc909df9 100644 --- a/Adventures in Lestoria Tests/EnchantTests.cpp +++ b/Adventures in Lestoria Tests/EnchantTests.cpp @@ -494,5 +494,35 @@ namespace EnchantTests Assert::AreEqual(110,player->GetAttack(),L"Attack damage is now 110."); Assert::AreEqual(10.0_Pct,player->GetCooldownReductionPct(),L"Cooldown reduction increased to 10%"); } + TEST_METHOD(QuickdrawCheck){ + MonsterData testMonsterData{"TestName","Test Monster",30,10,5,{MonsterDropData{"Health Potion",100.f,1,1}},200.f}; + MONSTER_DATA["TestName"]=testMonsterData; + Monster testMonster{{},MONSTER_DATA["TestName"]}; + + player->AutoAttack(); //Put auto attack on cooldown. + + for(int i:std::ranges::iota_view(0,20)){ + testMonster.Hurt(0,testMonster.OnUpperLevel(),testMonster.GetZ()); + Assert::AreEqual("Warrior.Auto Attack.Cooldown"_F,player->GetAutoAttackTimer(),L"The auto attack timer should not be reduced: No enchant + wasn't hit by a player ability."); + } + for(int i:std::ranges::iota_view(0,20)){ + testMonster.Hurt(0,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::PLAYER_ABILITY); + Assert::AreEqual("Warrior.Auto Attack.Cooldown"_F,player->GetAutoAttackTimer(),L"The auto attack timer should not be reduced: No enchant."); + } + + std::weak_ptrnullRing{Inventory::AddItem("Null Ring"s)}; + Inventory::EquipItem(nullRing,EquipSlot::RING1); + nullRing.lock()->EnchantItem("Quickdraw"); + + + for(int i:std::ranges::iota_view(0,20)){ + testMonster.Hurt(0,testMonster.OnUpperLevel(),testMonster.GetZ()); + Assert::AreEqual("Warrior.Auto Attack.Cooldown"_F,player->GetAutoAttackTimer(),L"The auto attack timer should not be reduced: Wasn't hit by a player ability."); + } + for(int i:std::ranges::iota_view(0,20)){ + testMonster.Hurt(0,testMonster.OnUpperLevel(),testMonster.GetZ(),HurtFlag::PLAYER_ABILITY); + } + Assert::AreEqual(0.f,player->GetAutoAttackTimer(),L"The auto attack timer should have been reset at some point."); + } }; } \ No newline at end of file diff --git a/Adventures in Lestoria Tests/PlayerTests.cpp b/Adventures in Lestoria Tests/PlayerTests.cpp index edd5d840..f5e8e542 100644 --- a/Adventures in Lestoria Tests/PlayerTests.cpp +++ b/Adventures in Lestoria Tests/PlayerTests.cpp @@ -672,5 +672,12 @@ namespace PlayerTests Assert::IsFalse(player->HasEnchant("Attack Boost")); Assert::IsFalse(player->HasEnchant("Mana Pool")); } + TEST_METHOD(AutoAttackReductionFunctionCheck){ + Assert::AreEqual(0.f,player->GetAutoAttackTimer(),L"Auto attack timer is not on cooldown."); + player->AutoAttack(); + Assert::AreEqual("Warrior.Auto Attack.Cooldown"_F,player->GetAutoAttackTimer(),L"Auto attack timer should've went on cooldown."); + player->ReduceAutoAttackTimer(0.2f); + Assert::AreEqual("Warrior.Auto Attack.Cooldown"_F-0.2f,player->GetAutoAttackTimer(),L"Auto attack timer should've been reduced by 0.2 seconds."); + } }; } \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index ae9e1a44..59b97e09 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -661,7 +661,7 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z,HurtFlag::HurtFlag hurtF return _Hurt(damage,onUpperLevel,z,TrueDamageFlag::NORMAL_DAMAGE,hurtFlags); } bool Monster::_Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag damageRule,HurtFlag::HurtFlag hurtFlags){ - const bool TriggersMark{bool(hurtFlags&HurtFlag::PLAYER_ABILITY)}; + const bool HitByPlayerAbility{bool(hurtFlags&HurtFlag::PLAYER_ABILITY)}; const bool TrueDamage{damageRule==TrueDamageFlag::IGNORE_DAMAGE_RULES}; const bool IsDOT{bool(hurtFlags&HurtFlag::DOT)}; @@ -688,16 +688,18 @@ bool Monster::_Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag da mod_dmg-=mod_dmg*GetDamageReductionFromBuffs(); } - if(TriggersMark&&GetMarkStacks()>0){ - Hurt(game->GetPlayer()->GetAttack()*"Trapper.Ability 1.Damage Increase Bonus"_F/100.f,OnUpperLevel(),GetZ(),HurtFlag::DOT); - RemoveMarkStack(); - } - - if(TriggersMark&&game->GetPlayer()->HasEnchant("Lethal Tempo")){ - Buff&lethalTempoBuff{game->GetPlayer()->GetOrAddBuff(BuffType::LETHAL_TEMPO,{"Lethal Tempo"_ENC["STACK DURATION"],0.f})}; - lethalTempoBuff.duration="Lethal Tempo"_ENC["STACK DURATION"]; - const int maxStackCount{int("Lethal Tempo"_ENC["MAX ATTACK SPEED INCREASE"]/"Lethal Tempo"_ENC["ATTACK SPEED INCREASE"])}; - lethalTempoBuff.intensity=std::min(maxStackCount,int(lethalTempoBuff.intensity)+1); + if(HitByPlayerAbility){ + if(GetMarkStacks()>0){ + Hurt(game->GetPlayer()->GetAttack()*"Trapper.Ability 1.Damage Increase Bonus"_F/100.f,OnUpperLevel(),GetZ(),HurtFlag::DOT); + RemoveMarkStack(); + } + if(game->GetPlayer()->HasEnchant("Lethal Tempo")){ + Buff&lethalTempoBuff{game->GetPlayer()->GetOrAddBuff(BuffType::LETHAL_TEMPO,{"Lethal Tempo"_ENC["STACK DURATION"],0.f})}; + lethalTempoBuff.duration="Lethal Tempo"_ENC["STACK DURATION"]; + const int maxStackCount{int("Lethal Tempo"_ENC["MAX ATTACK SPEED INCREASE"]/"Lethal Tempo"_ENC["ATTACK SPEED INCREASE"])}; + lethalTempoBuff.intensity=std::min(maxStackCount,int(lethalTempoBuff.intensity)+1); + } + if(game->GetPlayer()->HasEnchant("Quickdraw")&&util::random(1.f)<="Quickdraw"_ENC["RESET CHANCE"]/100.f)game->GetPlayer()->ReduceAutoAttackTimer(INFINITE); } mod_dmg*=GetDamageAmplificationMult(); diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index a1a5c910..8fc4b466 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -1949,4 +1949,13 @@ Ability&Player::GetItem3(){ const bool Player::LastReserveEnchantConditionsMet()const{ return HasEnchant("Last Reserve")&&GetHealthRatio()<="Last Reserve"_ENC["HP BELOW THRESHOLD"]/100.f; +} + +void Player::ReduceAutoAttackTimer(const float reduceAmt){ + if(reduceAmt<0.f)ERR(std::format("WARNING! Provided a negative number ({}) to reduce the player's auto attack number by. This is likely an error!!",reduceAmt)); + attack_cooldown_timer=std::max(0.f,attack_cooldown_timer-reduceAmt); +} + +const float&Player::GetAutoAttackTimer()const{ + return attack_cooldown_timer; } \ No newline at end of file diff --git a/Adventures in Lestoria/Player.h b/Adventures in Lestoria/Player.h index 8367246d..baf14e4f 100644 --- a/Adventures in Lestoria/Player.h +++ b/Adventures in Lestoria/Player.h @@ -303,6 +303,8 @@ public: const float GetDamageAmplificationMult()const; const bool HasEnchant(const std::string_view enchantName)const; void CheckAndPerformAbility(Ability&ability,InputGroup key); + void ReduceAutoAttackTimer(const float reduceAmt); + const float&GetAutoAttackTimer()const; private: int hp="Warrior.BaseHealth"_I; int mana="Player.BaseMana"_I; diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index c61972db..c59adc0f 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 10798 +#define VERSION_BUILD 10801 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 5a19cdf6..8dc37bc0 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ