diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index debd9452..3fdad925 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -586,22 +586,7 @@ void AiL::HandleUserInput(float fElapsedTime){ player->footstepTimer+=GetElapsedTime()*animationSpd; if(player->footstepTimer>"Player.Footstep Timer"_F){ player->footstepTimer-="Player.Footstep Timer"_F; - - bool inWater=true; - - for(const LayerTag&layer:GetCurrentMap().LayerData){ - int tileID=layer.tiles[player->GetY()/24][player->GetX()/24]-1; - if(tileID!=-1&&!IsReflectiveTile(GetTileSheet(GetCurrentLevel(),tileID),tileID)){ - inWater=false; - break; - } - } - - if(inWater){ - SoundEffect::PlaySFX("Footstep - Wet",SoundEffect::CENTERED); - }else{ - SoundEffect::PlaySFX("Footstep",SoundEffect::CENTERED); - } + PlayFootstepSound(); } #pragma endregion }else{ //This means we are holding down movement keys but we aren't actually moving anywhere, so don't. @@ -4433,4 +4418,26 @@ void AiL::UsingSteamAPI(const bool usingSteam){ void AiL::InitializePlayer(){ player=std::make_unique(); +} + +void AiL::SetWorldZoom(float newZoomScale){ + targetZoom=newZoomScale; +} + +void AiL::PlayFootstepSound(){ + bool inWater=true; + + for(const LayerTag&layer:GetCurrentMap().LayerData){ + int tileID=layer.tiles[player->GetY()/24][player->GetX()/24]-1; + if(tileID!=-1&&!IsReflectiveTile(GetTileSheet(GetCurrentLevel(),tileID),tileID)){ + inWater=false; + break; + } + } + + if(inWater){ + SoundEffect::PlaySFX("Footstep - Wet",SoundEffect::CENTERED); + }else{ + SoundEffect::PlaySFX("Footstep",SoundEffect::CENTERED); + } } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index 13e53480..8072da78 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -377,6 +377,9 @@ public: const HurtList HurtMonsterType(vf2d pos,float radius,int damage,bool upperLevel,float z,const std::string_view monsterName)const; void InitializeGameConfigurations(); void InitializePlayer(); + void SetWorldZoom(float newZoomScale); + //Plays the correct footstep sound based on player's current tile. + void PlayFootstepSound(); struct TileGroupData{ vi2d tilePos; diff --git a/Adventures in Lestoria/Bullet.cpp b/Adventures in Lestoria/Bullet.cpp index 86fedd43..813c0f99 100644 --- a/Adventures in Lestoria/Bullet.cpp +++ b/Adventures in Lestoria/Bullet.cpp @@ -40,6 +40,7 @@ All rights reserved. #include "DEFINES.h" #include "safemap.h" #include "util.h" +#include "SoundEffect.h" INCLUDE_ANIMATION_DATA INCLUDE_game @@ -50,8 +51,8 @@ INCLUDE_WINDOW_SIZE Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col,vf2d scale,float image_angle) :pos(pos),vel(vel),radius(radius),damage(damage),col(col),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle){}; -Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col,vf2d scale,float image_angle) - :pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle){ +Bullet::Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple,float lifetime,bool rotatesWithAngle,bool friendly,Pixel col,vf2d scale,float image_angle,std::string_view hitSound) + :pos(pos),vel(vel),radius(radius),damage(damage),col(col),animated(true),rotates(rotatesWithAngle),lifetime(lifetime),hitsMultiple(hitsMultiple),friendly(friendly),upperLevel(upperLevel),scale(scale),image_angle(image_angle),hitSound(std::string(hitSound)){ this->animation.AddState(animation,ANIMATION_DATA.at(animation)); this->animation.ChangeState(internal_animState,animation); }; @@ -189,11 +190,13 @@ void Bullet::Draw(const Pixel blendCol)const{ BulletDestroyState Bullet::_PlayerHit(Player*player){ const BulletDestroyState destroyBullet=PlayerHit(player); if(iframeTimerOnHit>0.f)player->ApplyIframes(iframeTimerOnHit); + if(hitSound)SoundEffect::PlaySFX(hitSound.value(),pos); return destroyBullet; } BulletDestroyState Bullet::_MonsterHit(Monster&monster){ const BulletDestroyState destroyBullet=MonsterHit(monster); if(iframeTimerOnHit>0.f)monster.ApplyIframes(iframeTimerOnHit); + if(hitSound)SoundEffect::PlaySFX(hitSound.value(),pos); return destroyBullet; } BulletDestroyState Bullet::PlayerHit(Player*player){ diff --git a/Adventures in Lestoria/Bullet.h b/Adventures in Lestoria/Bullet.h index 4f140b8b..b890a50e 100644 --- a/Adventures in Lestoria/Bullet.h +++ b/Adventures in Lestoria/Bullet.h @@ -88,6 +88,7 @@ private: bool deactivated{false}; double aliveTime{}; float onContactFadeoutTime{}; //What fadeouttime will be set to when the bullet hits a monster. + std::optionalhitSound; protected: float drawOffsetY{}; BulletDestroyState _PlayerHit(Player*player); //Return true to destroy the bullet on hit, return false otherwise. THE BULLET HIT HAS ALREADY OCCURRED. @@ -102,7 +103,7 @@ public: virtual ~Bullet()=default; Bullet(vf2d pos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1},float image_angle=0.f); //Initializes a bullet with an animation. - Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1},float image_angle=0.f); + Bullet(vf2d pos,vf2d vel,float radius,int damage,std::string animation,bool upperLevel,bool hitsMultiple=false,float lifetime=INFINITE,bool rotatesWithAngle=false,bool friendly=false,Pixel col=WHITE,vf2d scale={1,1},float image_angle=0.f,std::string_view hitSound=""); public: void SimulateUpdate(const float fElapsedTime); diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 7d57940c..f2d3505c 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -478,19 +478,21 @@ void Player::Update(float fElapsedTime){ animation.UpdateState(internal_animState,fElapsedTime); }break; case State::ROLL:{ - rolling_timer-=fElapsedTime; + footstepTimer-=fElapsedTime; if(facingDirection==RIGHT)spin_angle+=util::degToRad("Thief.Right Click Ability.Roll Rotation Speed"_F)*fElapsedTime; else spin_angle-=util::degToRad("Thief.Right Click Ability.Roll Rotation Speed"_F)*fElapsedTime; ySquishFactor=0.5f*sin((PI*fElapsedTime)/"Thief.Right Click Ability.Bounce Period Time"_F)+0.5f; if(rolling_timer<=0.f){ - spin_angle=0.f; - ySquishFactor=1.f; SetState(State::NORMAL); } + if(footstepTimer<=0.f){ + game->PlayFootstepSound(); + footstepTimer=0.05f; + } }break; case State::DEADLYDASH:{ deadlyDashWaitTimer-=fElapsedTime; - deadlyDashAfterDashTimer-=fElapsedTime; + deadlyDashAdditiveBlendingToggleTimer-=fElapsedTime; if(deadlyDashWaitTimer<=0.f){ deadlyDashWaitTimer=INFINITY; }else @@ -499,21 +501,34 @@ void Player::Update(float fElapsedTime){ SetAdditiveBlending(!IsUsingAdditiveBlending()); } if(deadlyDashAfterDashTimer<=0.f){ - deadlyDashAfterDashTimer=INFINITY; SoundEffect::PlaySFX("Deadly Dash",GetPos()); SetPos(deadlyDashEndingPos); SetState(State::NORMAL); SetAdditiveBlending(false); + game->SetupWorldShake(0.3f); } }break; default:{ - spin_angle=0.f; - ySquishFactor=1.f; - SetAdditiveBlending(false); //Update animations normally. animation.UpdateState(internal_animState,fElapsedTime); } } + + #pragma region Reset certain state variables after timers expire. + if(deadlyDashAfterDashTimer<=0.f){ + deadlyDashAfterDashTimer=INFINITY; + SetAdditiveBlending(false); + game->SetWorldZoom(1.f); + } + if(rolling_timer<=0.f){ + rolling_timer=INFINITY; + spin_angle=0.f; + ySquishFactor=1.f; + } + rolling_timer-=fElapsedTime; + deadlyDashAfterDashTimer-=fElapsedTime; + #pragma endregion + float cooldownMultiplier; if(game->GetPlayer()->GetCooldownReductionPct()>=1.0f){ cooldownMultiplier=999999; diff --git a/Adventures in Lestoria/Thief.cpp b/Adventures in Lestoria/Thief.cpp index 4d160eb9..def3875e 100644 --- a/Adventures in Lestoria/Thief.cpp +++ b/Adventures in Lestoria/Thief.cpp @@ -111,6 +111,7 @@ void Thief::InitializeClassAbilities(){ float velocity=(0.5f*-p->friction*"Thief.Right Click Ability.Roll Time"_F*"Thief.Right Click Ability.Roll Time"_F-std::clamp(mouseDir.length(),24.f,24.f*"Thief.Right Click Ability.Max Roll Range"_F/100))/-"Thief.Right Click Ability.Roll Time"_F; //Derived from kinetic motion formula. p->SetVelocity(mouseDir.vector().norm()*velocity); p->ApplyIframes("Thief.Right Click Ability.Iframe Time"_F); + p->footstepTimer=0.f; return true; }; #pragma endregion @@ -129,7 +130,7 @@ void Thief::InitializeClassAbilities(){ const float daggerLifetime{"Thief.Ability 1.Dagger Range"_F/"Thief.Ability 1.Dagger Speed"_F}; - CreateBullet(Bullet)(p->GetPos(),vf2d{"Thief.Ability 1.Dagger Speed"_F,angleToCursor}.cart(),"Thief.Ability 1.Dagger Radius"_F,p->GetAttack()*"Thief.Ability 1.Damage"_I,"dagger.png",p->OnUpperLevel(),false,daggerLifetime,true,true)EndBullet; + CreateBullet(Bullet)(p->GetPos(),vf2d{"Thief.Ability 1.Dagger Speed"_F,angleToCursor}.cart(),"Thief.Ability 1.Dagger Radius"_F,p->GetAttack()*"Thief.Ability 1.Damage"_I,"dagger.png",p->OnUpperLevel(),false,daggerLifetime,true,true,WHITE,{1.f,1.f},0.f,"Dagger Hit")EndBullet; p->SetAnimationBasedOnTargetingDirection("IDLE",angleToCursor); p->SetState(State::RETREAT); SoundEffect::PlaySFX("Thief.Ability 1.Sound"_S,SoundEffect::CENTERED); @@ -140,7 +141,7 @@ void Thief::InitializeClassAbilities(){ Thief::ability2.action= [](Player*p,vf2d pos={}){ game->AddEffect(std::make_unique(p->GetPos()+vf2d{4.f,4.f},0.5f,0.5f,"shine.png",1.5f,vf2d{},WHITE,util::random(2*PI),PI/2,true)); - p->ApplyIframes("Thief.Ability 2.Initial Wait"_F+"Thief.Ability 2.Ending Wait"_F); + p->ApplyIframes("Thief.Ability 2.Initial Wait"_F+"Thief.Ability 2.Ending Wait"_F+0.2f); geom2d::line mouseDir{p->GetPos(),p->GetWorldAimingLocation()}; p->SetAnimationBasedOnTargetingDirection("DEADLYDASH",mouseDir.vector().polar().y); SoundEffect::PlaySFX("Charge Up",p->GetPos()); @@ -152,6 +153,7 @@ void Thief::InitializeClassAbilities(){ p->SetState(State::DEADLYDASH); p->deadlyDashWaitTimer="Thief.Ability 2.Initial Wait"_F; p->deadlyDashAfterDashTimer=p->deadlyDashWaitTimer+"Thief.Ability 2.Ending Wait"_F; + game->SetWorldZoom(1.1f); return true; }; #pragma endregion diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 4740ae7b..1a7578ca 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 10109 +#define VERSION_BUILD 10116 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/config/audio/events.txt b/Adventures in Lestoria/assets/config/audio/events.txt index 0e6dd45d..63a6595c 100644 --- a/Adventures in Lestoria/assets/config/audio/events.txt +++ b/Adventures in Lestoria/assets/config/audio/events.txt @@ -55,6 +55,12 @@ Events # Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%) File[0] = craft_equip.ogg, 70% } + Dagger Hit + { + CombatSound = True + # Specify file names, followed by volume %. Optional min and max pitch adjustment (Defaults are 90%,110%) + File[0] = dagger_hit.ogg, 80%, 50%, 100% + } Deadly Dash { CombatSound = True diff --git a/Adventures in Lestoria/assets/sounds/dagger_hit.ogg b/Adventures in Lestoria/assets/sounds/dagger_hit.ogg new file mode 100644 index 00000000..f09074e0 Binary files /dev/null and b/Adventures in Lestoria/assets/sounds/dagger_hit.ogg differ diff --git a/Adventures in Lestoria/assets/sounds/deadlydash.ogg b/Adventures in Lestoria/assets/sounds/deadlydash.ogg index a2038f23..1d8077bf 100644 Binary files a/Adventures in Lestoria/assets/sounds/deadlydash.ogg and b/Adventures in Lestoria/assets/sounds/deadlydash.ogg differ diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 3ef255cb..dde08f6a 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ