Change starting location of DOT damage numbers. Fix velocity getting multiplied dramatically when damage numbers stack up and change size. Make gcc happy with unsigned long long cast syntax. Remove pthread flag from CMakeLists. Release Build 11014.

mac-build
sigonasr2 4 months ago
parent 7ae7d3dcb3
commit 6d7240c765
  1. 17
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/Audio.cpp
  3. 55
      Adventures in Lestoria/DamageNumber.cpp
  4. 19
      Adventures in Lestoria/DamageNumber.h
  5. 17
      Adventures in Lestoria/Monster.cpp
  6. 11
      Adventures in Lestoria/Player.cpp
  7. 2
      Adventures in Lestoria/Version.h
  8. 10
      CMakeLists.txt
  9. BIN
      x64/Release/Adventures in Lestoria.exe

@ -798,7 +798,7 @@ void AiL::UpdateEffects(float fElapsedTime){
std::erase_if(EMITTER_LIST,[](std::unique_ptr<Emitter>&e){return e->dead;}); std::erase_if(EMITTER_LIST,[](std::unique_ptr<Emitter>&e){return e->dead;});
std::erase_if(backgroundEffects,[](std::unique_ptr<Effect>&e){return e->dead;}); std::erase_if(backgroundEffects,[](std::unique_ptr<Effect>&e){return e->dead;});
std::erase_if(foregroundEffects,[](std::unique_ptr<Effect>&e){return e->dead;}); std::erase_if(foregroundEffects,[](std::unique_ptr<Effect>&e){return e->dead;});
std::erase_if(DAMAGENUMBER_LIST,[](std::shared_ptr<DamageNumber>&n){return n->lifeTime>1;}); std::erase_if(DAMAGENUMBER_LIST,[](std::shared_ptr<DamageNumber>&n){return n->IsDead();});
for(auto it=foregroundEffectsToBeInserted.begin();it!=foregroundEffectsToBeInserted.end();++it){ for(auto it=foregroundEffectsToBeInserted.begin();it!=foregroundEffectsToBeInserted.end();++it){
foregroundEffects.push_back(std::move(*it)); foregroundEffects.push_back(std::move(*it));
@ -4410,20 +4410,7 @@ void AiL::GlobalGameUpdates(){
#pragma region Damage Numbers update #pragma region Damage Numbers update
for(std::vector<std::shared_ptr<DamageNumber>>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ for(std::vector<std::shared_ptr<DamageNumber>>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){
DamageNumber*dn=(*it).get(); DamageNumber*dn=(*it).get();
if(dn->pauseTime>0){ dn->Update();
dn->pauseTime-=GetElapsedTime();
} else{
dn->lifeTime+=GetElapsedTime();
if(dn->lifeTime<=1){
if(dn->lifeTime<DamageNumber::MOVE_UP_TIME){
if(dn->invertedDirection){
dn->pos.y+=dn->riseSpd*GetElapsedTime();
}else{
dn->pos.y-=dn->riseSpd*GetElapsedTime();
}
}
}
}
} }
#pragma endregion #pragma endregion

@ -332,7 +332,7 @@ void Audio::Update(){
float currentTimestamp{Engine().GetCursorMilliseconds(track.GetChannelIDs()[0])/1000.f}; float currentTimestamp{Engine().GetCursorMilliseconds(track.GetChannelIDs()[0])/1000.f};
if(Self().lastTimestamp>currentTimestamp){ if(Self().lastTimestamp>currentTimestamp){
for(int trackID:track.GetChannelIDs()){ 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. currentTimestamp=Engine().GetCursorMilliseconds(track.GetChannelIDs()[0])/1000.f; //Update to new timestamp now that it's been shifted over.
} }

@ -44,13 +44,8 @@ const float DamageNumber::MOVE_UP_TIME=0.4f;
using enum DamageNumberType::DamageNumberType; using enum DamageNumberType::DamageNumberType;
DamageNumber::DamageNumber()
:damage(0){
}
DamageNumber::DamageNumber(vf2d pos,int damage,bool friendly,DamageNumberType::DamageNumberType type): 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){ pos(pos),damage(damage),friendly(friendly),type(type),invertedDirection(type==INTERRUPT),riseSpd(GetOriginalRiseSpd()){
if(type==INTERRUPT||type==MANA_GAIN)riseSpd=40.f;
RecalculateSize(); RecalculateSize();
} }
@ -59,12 +54,30 @@ void DamageNumber::RecalculateSize(){
if(!friendly){ if(!friendly){
float newSize=std::clamp(roundf(damageMultRatio),1.0f,4.0f); 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}; size=vf2d{newSize,newSize};
} }
} }
void DamageNumber::Update(){
if(pauseTime>0){
pauseTime-=game->GetElapsedTime();
} else{
lifetime+=game->GetElapsedTime();
if(lifetime<=1){
if(lifetime<DamageNumber::MOVE_UP_TIME){
if(invertedDirection){
pos.y+=riseSpd*game->GetElapsedTime();
}else{
pos.y-=riseSpd*game->GetElapsedTime();
}
}
}
}
}
void DamageNumber::Draw(){ void DamageNumber::Draw(){
#define NumberScalesWithDamage true #define NumberScalesWithDamage true
#define NormalNumber false #define NormalNumber false
@ -123,3 +136,31 @@ void DamageNumber::Draw(){
default:ERR(std::format("Damage Number Type {} is not implemented! THIS SHOULD NOT BE HAPPENING!",int(type))); 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;
}

@ -51,19 +51,26 @@ namespace DamageNumberType{
} }
struct DamageNumber{ 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; vf2d pos;
int damage; int damage;
float lifeTime=0; float lifetime=0;
float pauseTime=0; float pauseTime=0;
DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS;
float riseSpd=0.f; float riseSpd=0.f;
vf2d size{1.f,1.f}; vf2d size{1.f,1.f};
bool friendly=false; bool friendly=false;
bool invertedDirection=false; bool invertedDirection=false;
DamageNumberType::DamageNumberType type=DamageNumberType::HEALTH_LOSS;
const static float MOVE_UP_TIME; const static float MOVE_UP_TIME;
DamageNumber(); float GetOriginalRiseSpd();
//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 RecalculateSize(); void RecalculateSize();
void Draw();
}; };

@ -717,30 +717,27 @@ bool Monster::_Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag da
if(IsDOT){ if(IsDOT){
if(lastDotTimer>0){ if(lastDotTimer>0){
dotNumberPtr.get()->damage+=int(mod_dmg); dotNumberPtr.get()->AddDamage(int(mod_dmg));
dotNumberPtr.get()->RecalculateSize();
}else{ }else{
dotNumberPtr=std::make_shared<DamageNumber>(pos-vf2d{0,GetCollisionRadius()/2.f},int(mod_dmg),false,DamageNumberType::DOT); dotNumberPtr=std::make_shared<DamageNumber>(pos+vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT);
dotNumberPtr->riseSpd=-10.f;
DAMAGENUMBER_LIST.push_back(dotNumberPtr); DAMAGENUMBER_LIST.push_back(dotNumberPtr);
} }
lastDotTimer=0.05f; lastDotTimer=0.05f;
}else{ }else{
if(lastHitTimer>0){ if(lastHitTimer>0){
damageNumberPtr.get()->damage+=int(mod_dmg); damageNumberPtr.get()->AddDamage(int(mod_dmg));
damageNumberPtr.get()->pauseTime=0.4f; damageNumberPtr.get()->SetPauseTimer(0.4f);
damageNumberPtr.get()->RecalculateSize();
}else{ }else{
damageNumberPtr=std::make_shared<DamageNumber>(pos,int(mod_dmg)); damageNumberPtr=std::make_shared<DamageNumber>(pos,int(mod_dmg));
DAMAGENUMBER_LIST.push_back(damageNumberPtr); DAMAGENUMBER_LIST.push_back(damageNumberPtr);
} }
#pragma region Change Label based on bonus conditions (Crit/Backstab) #pragma region Change Label based on bonus conditions (Crit/Backstab)
if(crit){ 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){ if(backstabOccurred){
damageNumberPtr.get()->type=DamageNumberType::BACKSTAB; damageNumberPtr.get()->SetType(DamageNumberType::BACKSTAB);
} }
doneChangingDamageNumberColors: doneChangingDamageNumberColors:
#pragma endregion #pragma endregion

@ -931,19 +931,16 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z,const TrueDamageFlag dama
if(IsDOT){ if(IsDOT){
if(lastDotTimer>0){ if(lastDotTimer>0){
dotNumberPtr.get()->damage+=int(mod_dmg); dotNumberPtr.get()->AddDamage(int(mod_dmg));
dotNumberPtr.get()->RecalculateSize();
}else{ }else{
dotNumberPtr=std::make_shared<DamageNumber>(pos-vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT); dotNumberPtr=std::make_shared<DamageNumber>(pos+vf2d{0,8.f},int(mod_dmg),false,DamageNumberType::DOT);
dotNumberPtr->riseSpd=-10.f;
DAMAGENUMBER_LIST.push_back(dotNumberPtr); DAMAGENUMBER_LIST.push_back(dotNumberPtr);
} }
lastDotTimer=0.05f; lastDotTimer=0.05f;
}else{ }else{
if(lastHitTimer>0){ if(lastHitTimer>0){
damageNumberPtr.get()->damage+=int(mod_dmg); damageNumberPtr.get()->AddDamage(int(mod_dmg));
damageNumberPtr.get()->pauseTime=0.4f; damageNumberPtr.get()->SetPauseTimer(0.4f);
damageNumberPtr.get()->RecalculateSize();
}else{ }else{
damageNumberPtr=std::make_shared<DamageNumber>(pos,int(mod_dmg),true); damageNumberPtr=std::make_shared<DamageNumber>(pos,int(mod_dmg),true);
DAMAGENUMBER_LIST.push_back(damageNumberPtr); DAMAGENUMBER_LIST.push_back(damageNumberPtr);

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 3 #define VERSION_PATCH 3
#define VERSION_BUILD 11008 #define VERSION_BUILD 11014
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -10,7 +10,7 @@ project("Adventures in Lestoria")
if (EMSCRIPTEN) if (EMSCRIPTEN)
add_compile_options("-s" "USE_FREETYPE=1") add_compile_options("-s" "USE_FREETYPE=1")
add_compile_options("-pthread") # add_compile_options("-pthread")
endif() endif()
add_compile_options("-O2") add_compile_options("-O2")
@ -309,8 +309,8 @@ if (EMSCRIPTEN)
-sFETCH=1 -sFETCH=1
-sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8
-std=c++2a -std=c++2a
-pthread # -pthread
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency # -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency
--proxy-to-worker --proxy-to-worker
--preload-file ${SOURCE_DATA_EMSCRIPTEN_DIR}@assets) --preload-file ${SOURCE_DATA_EMSCRIPTEN_DIR}@assets)
else() else()
@ -325,8 +325,8 @@ if (EMSCRIPTEN)
-sFETCH=1 -sFETCH=1
-sEXPORTED_RUNTIME_METHODS=stringToNewUTF8 -sEXPORTED_RUNTIME_METHODS=stringToNewUTF8
-std=c++2a -std=c++2a
-pthread # -pthread
-sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency # -sPTHREAD_POOL_SIZE=navigator.hardwareConcurrency
--proxy-to-worker --proxy-to-worker
-sLLD_REPORT_UNDEFINED) -sLLD_REPORT_UNDEFINED)
endif() endif()

Loading…
Cancel
Save