diff --git a/Adventures in Lestoria Tests/MonsterTests.cpp b/Adventures in Lestoria Tests/MonsterTests.cpp index c7dfc4e1..32a3f624 100644 --- a/Adventures in Lestoria Tests/MonsterTests.cpp +++ b/Adventures in Lestoria Tests/MonsterTests.cpp @@ -532,7 +532,25 @@ namespace MonsterTests Game::Update(1.f); parrot.Hurt(parrot.GetMaxHealth(),parrot.OnUpperLevel(),parrot.GetZ()); Assert::IsTrue(parrot.IsUnconscious(),L"Parrot should now be unconscious."); - + } + TEST_METHOD(MonsterCollisionRadiusTest){ + Monster&parrot{game->SpawnMonster({},MONSTER_DATA.at("Parrot"))}; + Game::Update(1.f); + Game::Update(1.f); + Assert::AreEqual(parrot.GetOriginalCollisionRadius(),parrot.GetCollisionRadius(),L"Parrot collision radius should be normal."); + + Assert::AreEqual(int(game->GetPlayer()->GetMaxHealth()-parrot.GetCollisionDamage()),game->GetPlayer()->GetHealth(),L"Player should take collision damage from the parrot."); + parrot.SetCollisionRadius(0.f); + Assert::AreEqual(0.f,parrot.GetCollisionRadius(),L"Parrot collision radius should now be zero."); + game->GetPlayer()->Heal(game->GetPlayer()->GetMaxHealth()); + game->GetPlayer()->_SetIframes(0.f); + parrot.SetPos({}); + game->GetPlayer()->ForceSetPos({}); + Game::Update(1.f); + Assert::AreEqual(game->GetPlayer()->GetMaxHealth(),game->GetPlayer()->GetHealth(),L"Player should be full health."); + parrot.SetCollisionRadius(parrot.GetOriginalCollisionRadius()); + Game::Update(1.f); + Assert::AreEqual(int(game->GetPlayer()->GetMaxHealth()-parrot.GetCollisionDamage()),game->GetPlayer()->GetHealth(),L"Player should take collision damage from the parrot."); } }; } \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 97496a73..543831ac 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -1560,7 +1560,7 @@ std::optional>Monster::GetNearestMonster(const vf2d point } const bool Monster::InUndamageableState(const bool onUpperLevel,const float z)const{ - return Invulnerable()||!IsAlive()||onUpperLevel!=OnUpperLevel()||AttackAvoided(z)||IsNPC(); + return Invulnerable()||!IsAlive()||onUpperLevel!=OnUpperLevel()||AttackAvoided(z)||IsNPC()||GetCollisionRadius()<=0.f; } void Monster::AddBuff(BuffRestorationType type,BuffOverTimeType::BuffOverTimeType overTimeType,float duration,float intensity,float timeBetweenTicks){ diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index e345ae1c..55f13530 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -635,7 +635,7 @@ void Player::Update(float fElapsedTime){ for(std::shared_ptr&m:MONSTER_LIST){ const float playerRadius{12*GetSizeMult()/2}; const float monsterRadius{m->GetCollisionRadius()}; - if(!HasIframes()&&abs(m->GetZ()-GetZ())<=1&&OnUpperLevel()==m->OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,playerRadius),geom2d::circle(m->GetPos(),monsterRadius))){ + if(!HasIframes()&&abs(m->GetZ()-GetZ())<=1&&OnUpperLevel()==m->OnUpperLevel()&&monsterRadius>0.f&&geom2d::overlaps(geom2d::circle(pos,playerRadius),geom2d::circle(m->GetPos(),monsterRadius))){ if(m->IsAlive()){ m->Collision(this); } diff --git a/Adventures in Lestoria/Sandworm.cpp b/Adventures in Lestoria/Sandworm.cpp index 4d09936f..59bc6790 100644 --- a/Adventures in Lestoria/Sandworm.cpp +++ b/Adventures in Lestoria/Sandworm.cpp @@ -55,9 +55,14 @@ void Monster::STRATEGY::SANDWORM(Monster&m,float fElapsedTime,std::string strate switch(PHASE()){ case INITIALIZE:{ SETPHASE(UNDERGROUND); + const float randomRange=util::random_range(0,ConfigFloat("Burrow Target Range")/100.f*24); + m.V(A::LOCKON_POS)=game->GetPlayer()->GetPos()+vf2d{randomRange,util::random(2*PI)}.cart(); }break; case UNDERGROUND:{ m.SetCollisionRadius(0.f); + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + m.PerformAnimation("SWIM",m.GetFacingDirection()); }break; + } } \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 45ae6eb7..9212c95e 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 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 11711 +#define VERSION_BUILD 11714 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/MonsterStrategies.txt b/Adventures in Lestoria/assets/config/MonsterStrategies.txt index 5ecb55ed..04cd9089 100644 --- a/Adventures in Lestoria/assets/config/MonsterStrategies.txt +++ b/Adventures in Lestoria/assets/config/MonsterStrategies.txt @@ -1121,7 +1121,8 @@ MonsterStrategy } Sandworm { - + # Furthest distance sandworm travels from the player while burrowing. + Burrow Target Range = 400 } Pirate Buccaneer {