diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index fee3d14c..9ec160b8 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -4101,4 +4101,13 @@ void AiL::ComputeModeColors(TilesetData&tileset){ #pragma endregion } } +} + +void AiL::UpdateEntities(){ + UpdateEffects(GetElapsedTime()); + GetPlayer()->Update(GetElapsedTime()); + UpdateMonsters(); + + ItemDrop::UpdateDrops(GetElapsedTime()); + UpdateBullets(GetElapsedTime()); } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 3f0aae6f..5cb6285d 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -336,6 +336,7 @@ public: const bool PreviousStageCompleted()const; void SetCompletedStageFlag(); void ResetCompletedStageFlag(); + void UpdateEntities(); Minimap minimap; struct TileGroupData{ diff --git a/Adventures in Lestoria/Boar.cpp b/Adventures in Lestoria/Boar.cpp index 95be42c6..ea553aec 100644 --- a/Adventures in Lestoria/Boar.cpp +++ b/Adventures in Lestoria/Boar.cpp @@ -54,6 +54,7 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){ MOVE, SCRATCH, CHARGE, + RECOVERY, }; switch(m.phase){ @@ -61,25 +62,50 @@ void Monster::STRATEGY::BOAR(Monster&m,float fElapsedTime,std::string strategy){ float distToPlayer=geom2d::line(m.GetPos(),game->GetPlayer()->GetPos()).length(); if(distToPlayer>=ConfigInt("Closein Range")/100.f*24){ m.RemoveBuff(BuffType::SLOWDOWN); + m.targetAcquireTimer=0.f; RUN_TOWARDS(m,fElapsedTime,"Run Towards"); }else if(distToPlayer<=ConfigInt("Backpedal Range")/100.f*24){ Key prevFacingDirection=m.GetFacingDirection(); m.AddBuff(BuffType::SLOWDOWN,INFINITE,(100-ConfigInt("Backpedal Movespeed"))/100.f); + m.targetAcquireTimer=0.f; RUN_AWAY(m,fElapsedTime,"Run Away"); m.UpdateFacingDirection(game->GetPlayer()->GetPos()); }else{ m.PerformOtherAnimation(0); - m.F(A::CASTING_TIMER)=m.GetCurrentAnimation().GetTotalAnimationDuration(); + m.F(A::CASTING_TIMER)=ConfigInt("Ground Scratch Count")*m.GetCurrentAnimation().GetTotalAnimationDuration(); m.phase=PhaseName::SCRATCH; } }break; case PhaseName::SCRATCH:{ m.RemoveBuff(BuffType::SLOWDOWN); - + m.F(A::CASTING_TIMER)-=fElapsedTime; + if(m.F(A::CASTING_TIMER)<=0.f){ + m.PerformShootAnimation(); + m.phase=PhaseName::CHARGE; + + vf2d chargeTargetPoint=geom2d::line(m.GetPos(),game->GetPlayer()->GetPos()).rpoint(ConfigFloat("Charge Distance")/100.f*24); + + m.target=chargeTargetPoint; + m.AddBuff(BuffType::SPEEDBOOST,INFINITE,ConfigFloat("Charge Movespeed")/100.f-1); + } }break; case PhaseName::CHARGE:{ - + float distToTarget=geom2d::line(m.GetPos(),m.target).length(); + if(m.bumpedIntoTerrain||distToTarget<4.f){ + m.phase=PhaseName::RECOVERY; + m.F(A::CHARGE_COOLDOWN)=ConfigFloat("Charge Recovery Time"); + m.PerformIdleAnimation(); + }else{ + m.targetAcquireTimer=INFINITY; //Don't acquire a new target. + RUN_TOWARDS(m,fElapsedTime,"Run Towards"); + } + }break; + case PhaseName::RECOVERY:{ + m.F(A::CHARGE_COOLDOWN)-=fElapsedTime; + m.targetAcquireTimer=0.f; + m.RemoveBuff(BuffType::SPEEDBOOST); + if(m.F(A::CHARGE_COOLDOWN)<=0)m.phase=PhaseName::MOVE; }break; } } \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 5c0709ae..87714888 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -258,6 +258,22 @@ bool Monster::Update(float fElapsedTime){ } } #pragma endregion + + if(vel.x>0){ + vel.x=std::max(0.f,vel.x-friction*fElapsedTime); + } else { + vel.x=std::min(0.f,vel.x+friction*fElapsedTime); + } + if(vel.y>0){ + vel.y=std::max(0.f,vel.y-friction*fElapsedTime); + } else { + vel.y=std::min(0.f,vel.y+friction*fElapsedTime); + } + bumpedIntoTerrain=false; + if(vel!=vf2d{0,0}){ + bumpedIntoTerrain|=SetX(pos.x+vel.x*fElapsedTime); + bumpedIntoTerrain|=SetY(pos.y+vel.y*fElapsedTime); + } if(IsAlive()){ for(std::vector::iterator it=buffList.begin();it!=buffList.end();++it){ @@ -297,20 +313,6 @@ bool Monster::Update(float fElapsedTime){ } Monster::STRATEGY::RUN_STRATEGY(*this,fElapsedTime); } - if(vel.x>0){ - vel.x=std::max(0.f,vel.x-friction*fElapsedTime); - } else { - vel.x=std::min(0.f,vel.x+friction*fElapsedTime); - } - if(vel.y>0){ - vel.y=std::max(0.f,vel.y-friction*fElapsedTime); - } else { - vel.y=std::min(0.f,vel.y+friction*fElapsedTime); - } - if(vel!=vf2d{0,0}){ - SetX(pos.x+vel.x*fElapsedTime); - SetY(pos.y+vel.y*fElapsedTime); - } if(!IsAlive()){ deathTimer+=fElapsedTime; if(deathTimer>3){ @@ -319,6 +321,7 @@ bool Monster::Update(float fElapsedTime){ } animation.UpdateState(internal_animState,randomFrameOffset+fElapsedTime); randomFrameOffset=0; + attackedByPlayer=false; return true; } Key Monster::GetFacingDirection()const{ diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index da4752d8..fd96545e 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -230,6 +230,8 @@ private: static void NPC(Monster&m,float fElapsedTime,std::string strategy); static void BOAR(Monster&m,float fElapsedTime,std::string strategy); }; + bool bumpedIntoTerrain=false; //Gets set to true before a strategy executes if the monster runs into some terrain on this frame. + bool attackedByPlayer=false; //Gets set to true before a strategy executes if the monster has been attacked by the player. }; struct MonsterSpawner{ diff --git a/Adventures in Lestoria/State_GameRun.cpp b/Adventures in Lestoria/State_GameRun.cpp index ba2617bc..48a9c268 100644 --- a/Adventures in Lestoria/State_GameRun.cpp +++ b/Adventures in Lestoria/State_GameRun.cpp @@ -81,13 +81,8 @@ void State_GameRun::OnUserUpdate(AiL*game){ game->HandleUserInput(game->GetElapsedTime()); - game->UpdateEffects(game->GetElapsedTime()); GameEvent::UpdateEvents(); - game->GetPlayer()->Update(game->GetElapsedTime()); - game->UpdateMonsters(); - - ItemDrop::UpdateDrops(game->GetElapsedTime()); - game->UpdateBullets(game->GetElapsedTime()); + game->UpdateEntities(); game->UpdateCamera(game->GetElapsedTime()); } void State_GameRun::Draw(AiL*game){ diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 9826c47c..ba4f1aa2 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 0 -#define VERSION_BUILD 8947 +#define VERSION_BUILD 8958 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/2_1.tmx b/Adventures in Lestoria/assets/Campaigns/2_1.tmx index 2ea393f0..509003e0 100644 --- a/Adventures in Lestoria/assets/Campaigns/2_1.tmx +++ b/Adventures in Lestoria/assets/Campaigns/2_1.tmx @@ -1878,51 +1878,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Adventures in Lestoria/assets/config/MonsterStrategies.txt b/Adventures in Lestoria/assets/config/MonsterStrategies.txt index c3b63e8a..2c7ccf87 100644 --- a/Adventures in Lestoria/assets/config/MonsterStrategies.txt +++ b/Adventures in Lestoria/assets/config/MonsterStrategies.txt @@ -537,12 +537,17 @@ MonsterStrategy Backpedal Range = 400 + # Number of times the boar scratches the ground before charging. + # The amount of time this takes is also dependent on the animation speed (extra animation 0) Ground Scratch Count = 2 Charge Movespeed = 130% Charge Distance = 900 + # Amount of time to wait after charging before returning to Move Phase. + Charge Recovery Time = 0.3s + Backpedal Movespeed = 50% } } \ No newline at end of file diff --git a/Adventures in Lestoria/assets/config/Monsters.txt b/Adventures in Lestoria/assets/config/Monsters.txt index b61b8a89..544f0547 100644 --- a/Adventures in Lestoria/assets/config/Monsters.txt +++ b/Adventures in Lestoria/assets/config/Monsters.txt @@ -458,7 +458,7 @@ Monsters XP = 19 - Strategy = Run Towards + Strategy = Boar #Size of each animation frame SheetFrameSize = 24,24 @@ -479,7 +479,8 @@ Monsters #Additional custom animations go down below. Start with ANIMATION[0] Order is: # File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other. - # ANIMATION[0] = 4, 0.1, OneShot + # Scratch animation. + ANIMATION[0] = 4, 0.2, OneShot } Goblin (Dagger) { @@ -514,8 +515,7 @@ Monsters #Additional custom animations go down below. Start with ANIMATION[0] Order is: # File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other. - # Scratch animation. - ANIMATION[0] = 1, 0.1, OneShot + # ANIMATION[0] = 1, 0.1, OneShot } Goblin (Bow) { @@ -690,6 +690,6 @@ Monsters #Additional custom animations go down below. Start with ANIMATION[0] Order is: # File name, Frame Count, Frame Speed (s), Frame Cycling (Repeat,OneShot,PingPong,Reverse) # NOTE: ANIMATION[0] will always be row 5 of an animation sheet, all numbers that follow are each below each other. - # ANIMATION[0] = 4, 0.1, OneShot + # ANIMATION[0] = 4, 0.2, OneShot } } \ No newline at end of file diff --git a/Adventures in Lestoria/assets/monsters/Boar.png b/Adventures in Lestoria/assets/monsters/Boar.png index 05fc2f11..92e2d911 100644 Binary files a/Adventures in Lestoria/assets/monsters/Boar.png and b/Adventures in Lestoria/assets/monsters/Boar.png differ diff --git a/Adventures in Lestoria/olcUTIL_Animate2D.h b/Adventures in Lestoria/olcUTIL_Animate2D.h index 98aeb0ce..bd063902 100644 --- a/Adventures in Lestoria/olcUTIL_Animate2D.h +++ b/Adventures in Lestoria/olcUTIL_Animate2D.h @@ -199,7 +199,7 @@ namespace olc::utils::Animate2D return ChangeState(state,sStateName); } // Change an animation state token to a new state - inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName) const + inline bool ChangeState(AnimationState& state, const StatesEnum& sStateName) { currentStateName=sStateName; size_t idx = m_mapStateIndices.at(sStateName); @@ -226,7 +226,7 @@ namespace olc::utils::Animate2D return m_vSequences[state.nIndex].GetFrame(state.fTime); } - inline const size_t GetFrameIndex()const{ + inline const size_t GetFrameIndex(const AnimationState& state)const{ return m_vSequences[state.nIndex].GetFrameIndex(state.fTime); } diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index b27499d9..7927648b 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ