Added helper functions for auto attack timer. Added unit test for auto attack timer functions. Implemented Quickdraw enchant. 132/132 tests passing. Release Build 10800.

mac-build
sigonasr2 4 months ago
parent 859ff52ac2
commit 78956e986c
  1. 30
      Adventures in Lestoria Tests/EnchantTests.cpp
  2. 7
      Adventures in Lestoria Tests/PlayerTests.cpp
  3. 24
      Adventures in Lestoria/Monster.cpp
  4. 9
      Adventures in Lestoria/Player.cpp
  5. 2
      Adventures in Lestoria/Player.h
  6. 2
      Adventures in Lestoria/Version.h
  7. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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_ptr<Item>nullRing{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.");
}
};
}

@ -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.");
}
};
}

@ -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();

@ -1950,3 +1950,12 @@ 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;
}

@ -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;

@ -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

Loading…
Cancel
Save