diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 36cf4368..ec8e3e47 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2008,6 +2008,8 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ LoadingScreen::Reset(); previousLevel=currentLevel; currentLevel=map; + loadingWaitTime=0.f; + #pragma region Reset all data (Loading phase 1) LoadingScreen::AddPhase([&](){ if(game->MAP_DATA.count(GetCurrentLevel())==0)ERR(std::format("WARNING! Could not load map {}! Does not exist! Refer to levels.txt for valid maps.",map)); diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 6e8b83e3..b8df54d2 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -943,19 +943,42 @@ void Player::SetVelocity(vf2d vel){ } void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){ - if(GetClass()==Class::RANGER){ - if(targetDirection<=PI/4&&targetDirection>-PI/4){ - UpdateAnimation("RANGER_SHOOT_E"); - } else - if(targetDirection>=3*PI/4||targetDirection<-3*PI/4){ - UpdateAnimation("RANGER_SHOOT_W"); - } else - if(targetDirection<=3*PI/4&&targetDirection>PI/4){ - UpdateAnimation("RANGER_SHOOT_S"); - } else - if(targetDirection>=-3*PI/4&&targetDirection<-PI/4){ - UpdateAnimation("RANGER_SHOOT_N"); - } + auto FacingEast=[&](){return targetDirection<=PI/4&&targetDirection>-PI/4;}; + auto FacingWest=[&](){return targetDirection>=3*PI/4||targetDirection<-3*PI/4;}; + auto FacingSouth=[&](){return targetDirection<=3*PI/4&&targetDirection>PI/4;}; + auto FacingNorth=[&](){return targetDirection>=-3*PI/4&&targetDirection<-PI/4;}; + + switch(GetClass()){ + case Class::WARRIOR: + case Class::THIEF:{ + if(FacingNorth()){ + UpdateAnimation("WARRIOR_SWINGSWORD_N"); + }else + if(FacingSouth()){ + UpdateAnimation("WARRIOR_SWINGSWORD_S"); + }else + if(FacingWest()){ + UpdateAnimation("WARRIOR_SWINGSWORD_W"); + }else + if(FacingEast()){ + UpdateAnimation("WARRIOR_SWINGSWORD_E"); + } + }break; + case Class::RANGER: + case Class::TRAPPER:{ + if(FacingNorth()){ + UpdateAnimation("RANGER_SHOOT_N"); + }else + if(FacingSouth()){ + UpdateAnimation("RANGER_SHOOT_S"); + }else + if(FacingWest()){ + UpdateAnimation("RANGER_SHOOT_W"); + }else + if(FacingEast()){ + UpdateAnimation("RANGER_SHOOT_E"); + } + }break; } } diff --git a/Adventures in Lestoria/Warrior.cpp b/Adventures in Lestoria/Warrior.cpp index 6d7631ae..fdd1adcd 100644 --- a/Adventures in Lestoria/Warrior.cpp +++ b/Adventures in Lestoria/Warrior.cpp @@ -83,21 +83,10 @@ bool Warrior::AutoAttack(){ } attack_cooldown_timer=ATTACK_COOLDOWN-GetAttackRecoveryRateReduction(); swordSwingTimer="Warrior.Auto Attack.SwordSwingTime"_F; + + float dirToEnemy=geom2d::float(GetPos(),closest->GetPos()).vector().polar().y; SetState(State::SWING_SWORD); - switch(facingDirection){ - case DOWN:{ - UpdateAnimation("WARRIOR_SWINGSWORD_S",WARRIOR|THIEF); - }break; - case RIGHT:{ - UpdateAnimation("WARRIOR_SWINGSWORD_E",WARRIOR|THIEF); - }break; - case LEFT:{ - UpdateAnimation("WARRIOR_SWINGSWORD_W",WARRIOR|THIEF); - }break; - case UP:{ - UpdateAnimation("WARRIOR_SWINGSWORD_N",WARRIOR|THIEF); - }break; - } + SetAnimationBasedOnTargetingDirection(dirToEnemy); SoundEffect::PlaySFX("Warrior Auto Attack",SoundEffect::CENTERED); } return true; diff --git a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx index 1f0c5183..aaffff11 100644 --- a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx @@ -580,7 +580,7 @@ - +