diff --git a/Adventures in Lestoria Tests/EnchantTests.cpp b/Adventures in Lestoria Tests/EnchantTests.cpp index 6437c600..22e0b79e 100644 --- a/Adventures in Lestoria Tests/EnchantTests.cpp +++ b/Adventures in Lestoria Tests/EnchantTests.cpp @@ -380,6 +380,30 @@ namespace EnchantTests break; } if(!foundSoul)Assert::Fail(L"A soul was not generated from a kill with the Reaper of Souls enchant."); + testGame->SetElapsedTime(3.5f); + testGame->OnUserUpdate(3.5f); + player->Hurt(5,player->OnUpperLevel(),player->GetZ()); + player->ConsumeMana(10); + player->GetRightClickAbility().cooldown=player->GetAbility1().cooldown=player->GetAbility2().cooldown=player->GetAbility3().cooldown=player->GetAbility4().cooldown=0.4f; + for(int i:std::ranges::iota_view(0,2)){ + testGame->SetElapsedTime(0.001f); + testGame->OnUserUpdate(0.001f); + } + Assert::AreEqual(98,player->GetHealth(),L"Player should have healed for 3 health from contacting the soul."); + Assert::AreEqual(92,player->GetMana(),L"Player should have gained 2 mana from contacting the soul."); + Assert::AreEqual(0.f,player->GetRightClickAbility().cooldown,L"Player's ability cooldowns should reduce from contacting the soul."); + Assert::AreEqual(0.f,player->GetAbility1().cooldown,L"Player's ability cooldowns should reduce from contacting the soul."); + Assert::AreEqual(0.f,player->GetAbility2().cooldown,L"Player's ability cooldowns should reduce from contacting the soul."); + Assert::AreEqual(0.f,player->GetAbility3().cooldown,L"Player's ability cooldowns should reduce from contacting the soul."); + Assert::AreEqual(0.f,player->GetAbility4().cooldown,L"Player's ability cooldowns should reduce from contacting the soul."); + //This should be the moment the wisp is fading out. + testGame->SetElapsedTime(0.5f); + testGame->OnUserUpdate(0.5f); + + + for(Effect*eff:game->GetAllEffects()|std::views::filter([](Effect*eff){return eff->GetType()==EffectType::MONSTER_SOUL;})){ + Assert::Fail(L"A Monster Soul has not disappeared after colliding with a player."); + } } }; } \ No newline at end of file diff --git a/Adventures in Lestoria/MonsterSoul.cpp b/Adventures in Lestoria/MonsterSoul.cpp index befafc4a..bd3d4d46 100644 --- a/Adventures in Lestoria/MonsterSoul.cpp +++ b/Adventures in Lestoria/MonsterSoul.cpp @@ -64,9 +64,10 @@ bool MonsterSoul::Update(float fElapsedTime){ z=util::lerp(7,13,abs(sin(3*PI*lifetime))); moveSpd+=48.f*fElapsedTime; vf2d projectedPos{pos+util::pointTo(pos,game->GetPlayer()->GetPos())*moveSpd*fElapsedTime}; + const bool TooCloseToPlayer{util::distance(pos,game->GetPlayer()->GetPos())<=8.f*game->GetPlayer()->GetSizeMult()}; geom2d::linecollisionLine{pos,projectedPos}; pos=projectedPos; - if(geom2d::overlaps(collisionLine,geom2d::circle(game->GetPlayer()->GetPos(),game->GetPlayer()->GetSizeMult()*8.f))){ + if(TooCloseToPlayer||geom2d::overlaps(collisionLine,geom2d::circle(game->GetPlayer()->GetPos(),game->GetPlayer()->GetSizeMult()*8.f))){ lifetime=0.f; fadeout=fadeoutTime; game->GetPlayer()->Heal("Reaper of Souls"_ENC["HEALTH GAIN"]); diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index d9722427..31255538 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -237,8 +237,8 @@ bool Player::SetPos(vf2d pos,MoveFlag::MoveFlag flags){ return resultX||resultY; } -vf2d&Player::GetPos()const{ - return const_cast(pos); +const vf2d&Player::GetPos()const{ + return pos; } float Player::GetX(){ diff --git a/Adventures in Lestoria/Player.h b/Adventures in Lestoria/Player.h index 6b9e8b28..f2aaa961 100644 --- a/Adventures in Lestoria/Player.h +++ b/Adventures in Lestoria/Player.h @@ -114,7 +114,7 @@ public: //one. It's hackish but it means we can reduce the amount of extra boilerplate when class changing...I don't know how to feel about this. Player(Player*player); static float GROUND_SLAM_SPIN_TIME; - vf2d&GetPos()const; + const vf2d&GetPos()const; float GetX(); float GetY(); float GetZ(); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index bff88869..600f2934 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 10694 +#define VERSION_BUILD 10703 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/olcUTIL_Camera2D.h b/Adventures in Lestoria/olcUTIL_Camera2D.h index ac8080bd..10c69d88 100644 --- a/Adventures in Lestoria/olcUTIL_Camera2D.h +++ b/Adventures in Lestoria/olcUTIL_Camera2D.h @@ -114,7 +114,7 @@ namespace olc::utils } // Set tracked point via pointer - inline void SetTarget(olc::vf2d& vTarget) + inline void SetTarget(const olc::vf2d& vTarget) { m_pTarget = &vTarget; } @@ -184,7 +184,7 @@ namespace olc::utils // Directly moves the camera to a new point, useful when transitioning areas. inline void MoveCamera(vf2d pos){ Mode prevMode=m_nMode; - vf2d&prevTarget=*m_pTarget; + const vf2d&prevTarget=*m_pTarget; SetMode(Mode::Simple); SetTarget(pos); Update(0); @@ -251,7 +251,7 @@ namespace olc::utils Mode m_nMode = Mode::Simple; // Target Vector2D object camera should follow (either ref or ptr) - olc::vf2d* m_pTarget = nullptr; + const olc::vf2d* m_pTarget = nullptr; olc::vf2d m_vLocalTarget; // World Boundary diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 0a7d2fe3..2cab8396 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ