diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 64a7cb31..fe7703f5 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -798,7 +798,7 @@ void AiL::UpdateEffects(float fElapsedTime){ std::erase_if(EMITTER_LIST,[](std::unique_ptr&e){return e->dead;}); std::erase_if(backgroundEffects,[](std::unique_ptr&e){return e->dead;}); std::erase_if(foregroundEffects,[](std::unique_ptr&e){return e->dead;}); - std::erase_if(DAMAGENUMBER_LIST,[](std::shared_ptr&n){return n->lifeTime>1;}); + std::erase_if(DAMAGENUMBER_LIST,[](std::shared_ptr&n){return n->IsDead();}); for(auto it=foregroundEffectsToBeInserted.begin();it!=foregroundEffectsToBeInserted.end();++it){ foregroundEffects.push_back(std::move(*it)); @@ -4410,20 +4410,7 @@ void AiL::GlobalGameUpdates(){ #pragma region Damage Numbers update for(std::vector>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ DamageNumber*dn=(*it).get(); - if(dn->pauseTime>0){ - dn->pauseTime-=GetElapsedTime(); - } else{ - dn->lifeTime+=GetElapsedTime(); - if(dn->lifeTime<=1){ - if(dn->lifeTimeinvertedDirection){ - dn->pos.y+=dn->riseSpd*GetElapsedTime(); - }else{ - dn->pos.y-=dn->riseSpd*GetElapsedTime(); - } - } - } - } + dn->Update(); } #pragma endregion diff --git a/Adventures in Lestoria/Audio.cpp b/Adventures in Lestoria/Audio.cpp index 46d9005e..bad98ab5 100644 --- a/Adventures in Lestoria/Audio.cpp +++ b/Adventures in Lestoria/Audio.cpp @@ -332,7 +332,7 @@ void Audio::Update(){ float currentTimestamp{Engine().GetCursorMilliseconds(track.GetChannelIDs()[0])/1000.f}; if(Self().lastTimestamp>currentTimestamp){ for(int trackID:track.GetChannelIDs()){ - Engine().Seek(trackID,unsigned long long(track.GetLoopStartTime())*1000); + Engine().Seek(trackID,(unsigned long long)(track.GetLoopStartTime())*1000); } currentTimestamp=Engine().GetCursorMilliseconds(track.GetChannelIDs()[0])/1000.f; //Update to new timestamp now that it's been shifted over. } diff --git a/Adventures in Lestoria/DamageNumber.cpp b/Adventures in Lestoria/DamageNumber.cpp index e6a38ed7..83d922e0 100644 --- a/Adventures in Lestoria/DamageNumber.cpp +++ b/Adventures in Lestoria/DamageNumber.cpp @@ -44,13 +44,8 @@ const float DamageNumber::MOVE_UP_TIME=0.4f; using enum DamageNumberType::DamageNumberType; -DamageNumber::DamageNumber() -:damage(0){ -} - DamageNumber::DamageNumber(vf2d pos,int damage,bool friendly,DamageNumberType::DamageNumberType type): - pos(pos),damage(damage),friendly(friendly),type(type),invertedDirection(type==INTERRUPT),riseSpd(20.f){ - if(type==INTERRUPT||type==MANA_GAIN)riseSpd=40.f; + pos(pos),damage(damage),friendly(friendly),type(type),invertedDirection(type==INTERRUPT),riseSpd(GetOriginalRiseSpd()){ RecalculateSize(); } @@ -59,12 +54,30 @@ void DamageNumber::RecalculateSize(){ if(!friendly){ float newSize=std::clamp(roundf(damageMultRatio),1.0f,4.0f); - if(type==HEALTH_LOSS||type==CRIT)riseSpd*=newSize; + float riseSpd{GetOriginalRiseSpd()}; + if(type==HEALTH_LOSS||type==CRIT||type==DOT)riseSpd*=newSize; size=vf2d{newSize,newSize}; } } +void DamageNumber::Update(){ + if(pauseTime>0){ + pauseTime-=game->GetElapsedTime(); + } else{ + lifetime+=game->GetElapsedTime(); + if(lifetime<=1){ + if(lifetimeGetElapsedTime(); + }else{ + pos.y-=riseSpd*game->GetElapsedTime(); + } + } + } + } +} + void DamageNumber::Draw(){ #define NumberScalesWithDamage true #define NormalNumber false @@ -122,4 +135,32 @@ void DamageNumber::Draw(){ }break; default:ERR(std::format("Damage Number Type {} is not implemented! THIS SHOULD NOT BE HAPPENING!",int(type))); } +} + +float DamageNumber::GetOriginalRiseSpd(){ + float riseSpd{20.f}; + if(type==INTERRUPT||type==MANA_GAIN)riseSpd=40.f; + if(type==DOT)riseSpd=-10.f; + return riseSpd; +} + +void DamageNumber::AddDamage(int damageAmt){ + if(damageAmt<0)ERR(std::format("WARNING! Trying to apply a negative damage amount to a damage counter: {}! THIS SHOULD NOT BE HAPPENING!",damageAmt)); + damage+=damageAmt; +} + +const bool DamageNumber::IsDead()const{ + return lifetime>1.f; +} + +void DamageNumber::SetPauseTimer(const float pauseTime){ + this->pauseTime=pauseTime; +} + +void DamageNumber::SetType(const DamageNumberType::DamageNumberType type){ + this->type=type; +} + +const DamageNumberType::DamageNumberType DamageNumber::GetType()const{ + return type; } \ No newline at end of file diff --git a/Adventures in Lestoria/DamageNumber.h b/Adventures in Lestoria/DamageNumber.h index d546a49e..5f82b8f5 100644 --- a/Adventures in Lestoria/DamageNumber.h +++ b/Adventures in Lestoria/DamageNumber.h @@ -51,19 +51,26 @@ namespace DamageNumberType{ } struct DamageNumber{ + //The friendly flag indicates if the number was for a friendly/player target or if it's for a monster target (set to false) + DamageNumber(vf2d pos,int damage,bool friendly=false,DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS); + void Update(); + void Draw(); + void AddDamage(int damageAmt); + const bool IsDead()const; + void SetPauseTimer(const float pauseTime); + void SetType(const DamageNumberType::DamageNumberType type); + const DamageNumberType::DamageNumberType GetType()const; +private: vf2d pos; int damage; - float lifeTime=0; + float lifetime=0; float pauseTime=0; + DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS; float riseSpd=0.f; vf2d size{1.f,1.f}; bool friendly=false; bool invertedDirection=false; - DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS; const static float MOVE_UP_TIME; - DamageNumber(); - //The friendly flag indicates if the number was for a friendly/player target or if it's for a monster target (set to false) - DamageNumber(vf2d pos,int damage,bool friendly=false,DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS); + float GetOriginalRiseSpd(); void RecalculateSize(); - void Draw(); }; \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 645287aa..086fe964 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -717,30 +717,27 @@ bool Monster::_Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag da if(IsDOT){ if(lastDotTimer>0){ - dotNumberPtr.get()->damage+=int(mod_dmg); - dotNumberPtr.get()->RecalculateSize(); + dotNumberPtr.get()->AddDamage(int(mod_dmg)); }else{ - dotNumberPtr=std::make_shared(pos-vf2d{0,GetCollisionRadius()/2.f},int(mod_dmg),false,DamageNumberType::DOT); - dotNumberPtr->riseSpd=-10.f; + dotNumberPtr=std::make_shared(pos+vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT); DAMAGENUMBER_LIST.push_back(dotNumberPtr); } lastDotTimer=0.05f; }else{ if(lastHitTimer>0){ - damageNumberPtr.get()->damage+=int(mod_dmg); - damageNumberPtr.get()->pauseTime=0.4f; - damageNumberPtr.get()->RecalculateSize(); + damageNumberPtr.get()->AddDamage(int(mod_dmg)); + damageNumberPtr.get()->SetPauseTimer(0.4f); }else{ damageNumberPtr=std::make_shared(pos,int(mod_dmg)); DAMAGENUMBER_LIST.push_back(damageNumberPtr); } #pragma region Change Label based on bonus conditions (Crit/Backstab) if(crit){ - damageNumberPtr.get()->type=DamageNumberType::CRIT; + damageNumberPtr.get()->SetType(DamageNumberType::CRIT); } - if(damageNumberPtr.get()->type==DamageNumberType::CRIT)goto doneChangingDamageNumberColors; //Crit number priority. Other colors should not apply if the crit has applied. + if(damageNumberPtr.get()->GetType()==DamageNumberType::CRIT)goto doneChangingDamageNumberColors; //Crit number priority. Other colors should not apply if the crit has applied. if(backstabOccurred){ - damageNumberPtr.get()->type=DamageNumberType::BACKSTAB; + damageNumberPtr.get()->SetType(DamageNumberType::BACKSTAB); } doneChangingDamageNumberColors: #pragma endregion diff --git a/Adventures in Lestoria/Player.cpp b/Adventures in Lestoria/Player.cpp index 15f852ef..d871bb95 100644 --- a/Adventures in Lestoria/Player.cpp +++ b/Adventures in Lestoria/Player.cpp @@ -931,19 +931,16 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag dama if(IsDOT){ if(lastDotTimer>0){ - dotNumberPtr.get()->damage+=int(mod_dmg); - dotNumberPtr.get()->RecalculateSize(); + dotNumberPtr.get()->AddDamage(int(mod_dmg)); }else{ - dotNumberPtr=std::make_shared(pos-vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT); - dotNumberPtr->riseSpd=-10.f; + dotNumberPtr=std::make_shared(pos+vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT); DAMAGENUMBER_LIST.push_back(dotNumberPtr); } lastDotTimer=0.05f; }else{ if(lastHitTimer>0){ - damageNumberPtr.get()->damage+=int(mod_dmg); - damageNumberPtr.get()->pauseTime=0.4f; - damageNumberPtr.get()->RecalculateSize(); + damageNumberPtr.get()->AddDamage(int(mod_dmg)); + damageNumberPtr.get()->SetPauseTimer(0.4f); }else{ damageNumberPtr=std::make_shared(pos,int(mod_dmg),true); DAMAGENUMBER_LIST.push_back(damageNumberPtr); diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index f6d18cb8..58a3a2b8 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 11008 +#define VERSION_BUILD 11014 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/CMakeLists.txt b/CMakeLists.txt index b4200a2b..1f2ef5ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ project("Adventures in Lestoria") if (EMSCRIPTEN) add_compile_options("-s" "USE_FREETYPE=1") - add_compile_options("-pthread") + # add_compile_options("-pthread") endif() add_compile_options("-O2") @@ -309,8 +309,8 @@ if (EMSCRIPTEN) -sFETCH=1 -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -std=c++2a - -pthread - -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency + # -pthread + # -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency --proxy-to-worker --preload-file ${SOURCE_DATA_EMSCRIPTEN_DIR}@assets) else() @@ -325,8 +325,8 @@ if (EMSCRIPTEN) -sFETCH=1 -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -std=c++2a - -pthread - -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency + # -pthread + # -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency --proxy-to-worker -sLLD_REPORT_UNDEFINED) endif() diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 8a9a079e..7bad2270 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ