diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 8a35da6f..0399fe4a 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -771,7 +771,6 @@ const MonsterHurtList AiL::HurtEnemies(vf2d pos,float radius,int damage,bool upp return hitList; } - const MonsterHurtList AiL::HurtEnemiesNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z){ MonsterHurtList affectedList; for(Monster&m:MONSTER_LIST){ @@ -784,6 +783,22 @@ const MonsterHurtList AiL::HurtEnemiesNotHit(vf2d pos,float radius,int damage,Hi return affectedList; } +const MonsterHurtList AiL::HurtEnemiesConeNotHit(vf2d pos,float radius,float angle,float sweepAngle,int damage,HitList&hitList,bool upperLevel,float z){ + MonsterHurtList affectedList; + for(Monster&m:MONSTER_LIST){ + if(!hitList.count(&m)&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m.GetPos(),12*m.GetSizeMult()))){ + float angleToMonster=geom2d::line{pos,m.GetPos()}.vector().polar().y; + float angleDiff=util::angle_difference(angleToMonster,angle); + if(abs(angleDiff)<=sweepAngle){ + HurtReturnValue returnVal=m.Hurt(damage,upperLevel,z); + affectedList.push_back({&m,returnVal}); + hitList.insert(&m); + } + } + } + return affectedList; +} + void AiL::PopulateRenderLists(){ monstersBeforeLower.clear(); monstersAfterLower.clear(); diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index a5f3c836..9ee0fd58 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -218,6 +218,10 @@ public: const MonsterHurtList HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel,float z)const; //NOTE: This function will also add any enemies that were hit into the hit list! const MonsterHurtList HurtEnemiesNotHit(vf2d pos,float radius,int damage,HitList&hitList,bool upperLevel,float z); + // angle: The central angle where the arc will extend from. + // sweepAngle: The amount of radians to extend in both directions from the central angle. + // NOTE: This function will also add any enemies that were hit into the hit list! + const MonsterHurtList HurtEnemiesConeNotHit(vf2d pos,float radius,float angle,float sweepAngle,int damage,HitList&hitList,bool upperLevel,float z); vf2d GetWorldMousePos(); bool LeftHeld(); bool RightHeld(); diff --git a/Adventures in Lestoria/SwordSlash.cpp b/Adventures in Lestoria/SwordSlash.cpp index 605950ad..295ddb94 100644 --- a/Adventures in Lestoria/SwordSlash.cpp +++ b/Adventures in Lestoria/SwordSlash.cpp @@ -37,6 +37,7 @@ All rights reserved. #pragma endregion #include "Effect.h" #include "AdventuresInLestoria.h" +#include "util.h" INCLUDE_game @@ -45,7 +46,7 @@ SwordSlash::SwordSlash(float lifetime, std::string imgFile, vf2d size, float fad bool SwordSlash::Update(float fElapsedTime){ if(lifetime>0){ - game->HurtEnemiesNotHit(game->GetPlayer()->GetPos(),game->GetPlayer()->GetAttackRangeMult()*12.f,game->GetPlayer()->GetAttack(),hitList,game->GetPlayer()->OnUpperLevel(),game->GetPlayer()->GetZ()); + game->HurtEnemiesConeNotHit(game->GetPlayer()->GetPos(),game->GetPlayer()->GetAttackRangeMult()*12.f,rotation,util::degToRad("Warrior.Auto Attack.SwordSlashSweepAngle"_F),game->GetPlayer()->GetAttack(),hitList,game->GetPlayer()->OnUpperLevel(),game->GetPlayer()->GetZ()); } pos=game->GetPlayer()->GetPos(); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index f7454988..d5595ee9 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 0 #define VERSION_PATCH 0 -#define VERSION_BUILD 8451 +#define VERSION_BUILD 8457 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/classes/Warrior.txt b/Adventures in Lestoria/assets/config/classes/Warrior.txt index 83ae0fc7..7b374f9c 100644 --- a/Adventures in Lestoria/assets/config/classes/Warrior.txt +++ b/Adventures in Lestoria/assets/config/classes/Warrior.txt @@ -22,6 +22,8 @@ Warrior SwordAnimationSwingTime = 0.2s SwordSlashLingerTime = 0.125s + #Sweep angle of the sword slash (in both directions) + SwordSlashSweepAngle = 45° } Right Click Ability { diff --git a/Adventures in Lestoria/olcPixelGameEngine.h b/Adventures in Lestoria/olcPixelGameEngine.h index 7b84d975..9ccc16c2 100644 --- a/Adventures in Lestoria/olcPixelGameEngine.h +++ b/Adventures in Lestoria/olcPixelGameEngine.h @@ -939,6 +939,7 @@ namespace olc virtual olc::rcode DestroyDevice() = 0; virtual void DisplayFrame() = 0; virtual void PrepareDrawing() = 0; + virtual void SetVSync(const bool vSyncEnabled) = 0; virtual void PrepareRender(int width,int height) = 0; virtual void SetDecalMode(const olc::DecalMode& mode) = 0; virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) = 0; @@ -5074,6 +5075,7 @@ namespace olc virtual olc::rcode DestroyDevice() { return olc::rcode::OK; } virtual void DisplayFrame() {} virtual void PrepareDrawing() {} + virtual void SetVSync(const bool vSyncEnabled) {} virtual void PrepareRender(int width,int height) {}; virtual void SetDecalMode(const olc::DecalMode& mode) {} virtual void DrawLayerQuad(const olc::vf2d& offset, const olc::vf2d& scale, const olc::Pixel tint) {} @@ -5370,6 +5372,26 @@ namespace olc glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } + void SetVSync(const bool vSyncEnabled){ + #if defined(OLC_PLATFORM_WINAPI) + if (locSwapInterval) locSwapInterval(vSyncEnabled?1:0); + bSync = vSyncEnabled; + #endif + #if defined(OLC_PLATFORM_X11) + locSwapInterval(olc_Display, *olc_Window, vSyncEnabled?1:0); + #endif + #if defined(OLC_PLATFORM_EMSCRIPTEN) + locSwapInterval(olc_Display, vSyncEnabled?1:0); + #endif + #if defined(OLC_PLATFORM_GLUT) + #if defined(__APPLE__) + GLint sync = vSyncEnabled?1:0; + CGLContextObj ctx = CGLGetCurrentContext(); + if (ctx) CGLSetParameter(ctx, kCGLCPSwapInterval, &sync); + #endif + #endif + } + void SetDecalMode(const olc::DecalMode& mode) { if (mode != nDecalMode) @@ -5967,6 +5989,26 @@ namespace olc #endif } + void SetVSync(const bool vSyncEnabled){ + #if defined(OLC_PLATFORM_WINAPI) + if (locSwapInterval) locSwapInterval(vSyncEnabled?1:0); + bSync = vSyncEnabled; + #endif + #if defined(OLC_PLATFORM_X11) + locSwapInterval(olc_Display, *olc_Window, vSyncEnabled?1:0); + #endif + #if defined(OLC_PLATFORM_EMSCRIPTEN) + locSwapInterval(olc_Display, vSyncEnabled?1:0); + #endif + #if defined(OLC_PLATFORM_GLUT) + #if defined(__APPLE__) + GLint sync = vSyncEnabled?1:0; + CGLContextObj ctx = CGLGetCurrentContext(); + if (ctx) CGLSetParameter(ctx, kCGLCPSwapInterval, &sync); + #endif + #endif + } + void PrepareRender(int width,int height)override{ GLint sizeUniformLoc = locGetUniformLocation(m_nQuadShader, "size"); locUniform2f(sizeUniformLoc,width,height); diff --git a/Adventures in Lestoria/util.cpp b/Adventures in Lestoria/util.cpp index 7b97f0c3..7098f5d9 100644 --- a/Adventures in Lestoria/util.cpp +++ b/Adventures in Lestoria/util.cpp @@ -150,4 +150,18 @@ std::u32string util::WrapText(PixelGameEngine*pge,std::u32string str,int width,F long double operator""_Pixels(long double unitDist){ return unitDist/100*24.; +} + +float util::angle_difference(float angle_1, float angle_2) +{ + angle_1 = fmod(angle_1, 2 * PI); + angle_2 = fmod(angle_2, 2 * PI); + float angle_diff = angle_1 - angle_2; + + if (angle_diff > PI) + angle_diff -= 2 * PI; + else if (angle_diff < -PI) + angle_diff += 2 * PI; + + return -angle_diff; } \ No newline at end of file diff --git a/Adventures in Lestoria/util.h b/Adventures in Lestoria/util.h index 88c81870..71ad4225 100644 --- a/Adventures in Lestoria/util.h +++ b/Adventures in Lestoria/util.h @@ -57,6 +57,7 @@ namespace olc::util{ std::string timerStr(float time); std::string WrapText(PixelGameEngine*pge,std::string str,int width,bool proportional,vd2d scale); std::u32string WrapText(PixelGameEngine*pge,std::u32string str,int width,Font&font,vd2d scale); + float angle_difference(float angle_1, float angle_2); } template @@ -74,4 +75,4 @@ constexpr auto circ_add( } //Converts unit distances to pixels. (Every 100 units = 24 pixels) -long double operator""_Pixels(long double unitDist); \ No newline at end of file +long double operator""_Pixels(long double unitDist); diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 9d579f98..564ecdf6 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ