diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 16081e5e..bca87914 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -759,6 +759,23 @@ const HurtList AiL::Hurt(vf2d pos,float radius,int damage,bool upperLevel,float return hitList; } +void AiL::ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtType knockbackTargets)const{ + const bool CheckForMonsterCollisions=knockbackTargets&HurtType::MONSTER; + const bool CheckForPlayerCollisions=knockbackTargets&HurtType::PLAYER; + if(CheckForMonsterCollisions){ + for(std::unique_ptr&m:MONSTER_LIST){ + if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m->GetPos(),12*m->GetSizeMult()))){ + m->ProximityKnockback(pos,knockbackAmt); + } + } + } + if(CheckForPlayerCollisions){ + if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(GetPlayer()->GetPos(),12*GetPlayer()->GetSizeMult()))){ + GetPlayer()->ProximityKnockback(pos,knockbackAmt); + } + } +} + const HurtList AiL::HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const{ HurtList affectedList; const bool CheckForMonsterCollisions=hurtTargets&HurtType::MONSTER; diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 8aed3ad0..f5adbaa7 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -239,6 +239,7 @@ public: //If back is true, places the effect in the background void AddEffect(std::unique_ptrforeground,bool back=false); const HurtList Hurt(vf2d pos,float radius,int damage,bool upperLevel,float z,const HurtType hurtTargets)const; + void ProximityKnockback(const vf2d pos,const float radius,const float knockbackAmt,const HurtType knockbackTargets)const; //NOTE: This function will also add any enemies that were hit into the hit list! const HurtList HurtNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z,const HurtType hurtTargets)const; // angle: The central angle where the arc will extend from. diff --git a/Adventures in Lestoria/LargeStone.cpp b/Adventures in Lestoria/LargeStone.cpp index f6e458b6..4c61a88c 100644 --- a/Adventures in Lestoria/LargeStone.cpp +++ b/Adventures in Lestoria/LargeStone.cpp @@ -65,22 +65,8 @@ void LargeStone::Update(float fElapsedTime){ game->AddEffect(std::make_unique(pos+vf2d{radius,randomDir}.cart(),0.f,"circle.png",OnUpperLevel(),vf2d{1.5f,1.5f}*util::random(2.f),util::random(1.f),vf2d{vf2d{radius,randomDir}.cart().x,-util::random(30.f)-20.f},BLACK)); } - #pragma region Knockback Effect - #pragma region Check for player knockback - float distToPlayer=geom2d::line(pos,game->GetPlayer()->GetPos()).length(); - if(distToPlayer<=radius){ - game->GetPlayer()->ProximityKnockback(pos,knockbackAmt); - } - #pragma endregion - #pragma region Check for monster knockback - for(auto&monsterPtr:MONSTER_LIST){ - float distToMonster=geom2d::line(pos,monsterPtr->GetPos()).length(); - if(distToMonster<=radius){ - monsterPtr->ProximityKnockback(pos,knockbackAmt); - } - } - #pragma endregion - #pragma endregion + + game->ProximityKnockback(pos,radius,knockbackAmt,HurtType::MONSTER|HurtType::PLAYER); fadeOutTime=0.5f; diff --git a/Adventures in Lestoria/MonsterAttribute.h b/Adventures in Lestoria/MonsterAttribute.h index 5676fd32..5ea2c76c 100644 --- a/Adventures in Lestoria/MonsterAttribute.h +++ b/Adventures in Lestoria/MonsterAttribute.h @@ -122,6 +122,6 @@ enum class Attribute{ WIND_STRENGTH, WIND_PHASE_TIMER, MARKED_DEAD, - LOOPING_SOUND_ID, + LOOPING_SOUND_ID, //Store looping sound IDs temporarily with this value. The game automatically cleans this up in Monster::OnDestroy() if you don't, since a monster that dies should not have their looping sound still playing. PLAYED_FLAG, }; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 4369c67f..7cd48ef2 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 9656 +#define VERSION_BUILD 9659 #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 68210847..ec763e46 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ