diff --git a/Crawler/AttributableStat.cpp b/Crawler/AttributableStat.cpp index 68fafbbb..b97757b5 100644 --- a/Crawler/AttributableStat.cpp +++ b/Crawler/AttributableStat.cpp @@ -59,7 +59,7 @@ ItemAttributable&ItemAttributable::operator+=(ItemAttributable&rhs){ }; ItemAttribute::ItemAttribute(std::string_view name,bool isPct,std::string_view modifies) - :name(name),isPct(isPct),modifies(modifies){} + :name(std::string(name)),isPct(isPct),modifies(std::string(modifies)){} void ItemAttribute::Initialize(){ for(auto&[key,size]:DATA["Stats"]){ @@ -73,7 +73,9 @@ void ItemAttribute::Initialize(){ } ItemAttribute&ItemAttribute::Get(const std::string_view name,const std::optional>target){ - attributes.at(std::string(name)).target=target; + if(target.has_value()){ + attributes.at(std::string(name)).target=target; + } return attributes.at(std::string(name)); } const std::string_view ItemAttribute::Name()const{ diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 185c6188..ac99fa54 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -201,6 +201,7 @@ bool Crawler::OnUserCreate(){ Inventory::AddItem("Bone Pants"); Inventory::AddItem("Bone Gloves"); Inventory::AddItem("Elixir of Bear Strength",3); + Inventory::AddItem("Leather Helmet"); LoadLevel(LEVEL_NAMES["starting_map"_S]); ChangePlayerClass(WARRIOR); @@ -1518,8 +1519,12 @@ void Crawler::LoadLevel(MapName map){ totalBossEncounterMobs=0; Inventory::Clear("Monster Loot"); Inventory::Clear("Stage Loot"); + std::cout<hp<hp=GetPlayer()->GetStat("Health"); + GetPlayer()->mana=GetPlayer()->GetMaxMana(); GetPlayer()->SetState(State::NORMAL); GetPlayer()->GetCastInfo()={}; + std::cout<hp<useItem3; uint32_t oldMoney=player->money; std::setmoneyListeners=Player::moneyListeners; + EntityStats previousStats=player->stats; switch(cl){ case WARRIOR:{ player.reset(NEW Warrior(player.get())); @@ -1855,6 +1861,7 @@ void Crawler::ChangePlayerClass(Class cl){ player.reset(NEW Witch(player.get())); }break; } + player->stats=previousStats; player->SetBaseStat("Health",DATA.GetProperty(player->GetClassName()+".BaseHealth").GetInt()); player->hp=player->GetBaseStat("Health"); player->SetBaseStat("Attack",DATA.GetProperty(player->GetClassName()+".BaseAtk").GetInt()); @@ -2000,6 +2007,9 @@ float operator ""_FRange(const char*key,std::size_t len){ Crawler::OutputDebugInfo(key,len); return float(util::random(float(DATA.GetProperty(std::string(key,len)).GetReal(1)-DATA.GetProperty(std::string(key,len)).GetReal(0)))+DATA.GetProperty(std::string(key,len)).GetReal(0)); } +float operator ""_Pct(long double pct){ + return pct/100; +} double operator ""_D(const char*key,std::size_t len){ Crawler::OutputDebugInfo(key,len); diff --git a/Crawler/Item.cpp b/Crawler/Item.cpp index 07063f16..9f51fbde 100644 --- a/Crawler/Item.cpp +++ b/Crawler/Item.cpp @@ -798,24 +798,24 @@ void Stats::InitializeDamageReductionTable(){ maxDamageReductionTable[0]=0; for(int i=1;i<=1000;i++){ if(i<=10){ - totalReduction+=0.01; + totalReduction+=1._Pct; }else if(i<=30){ - totalReduction+=0.00'5; + totalReduction+=0.5_Pct; }else if(i<=70){ - totalReduction+=0.00'25; + totalReduction+=0.25_Pct; }else if(i<=150){ - totalReduction+=0.00'125; + totalReduction+=0.125_Pct; }else if(i<=310){ - totalReduction+=0.00'0625; + totalReduction+=0.0625_Pct; }else if(i<=950){ - totalReduction+=0.00'03125; + totalReduction+=0.03125_Pct; }else{ - totalReduction+=0.00'1; + totalReduction+=0.1_Pct; } maxDamageReductionTable[i]=totalReduction; } diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 78a5bb60..10e0886d 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -60,7 +60,7 @@ safemap>STRATEGY_DAT std::mapMonsterData::imgs; Monster::Monster(vf2d pos,MonsterData data,bool upperLevel,bool bossMob): - pos(pos),maxhp(data.GetHealth()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),name(data.GetDisplayName()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(DOWN){ + pos(pos),hp(data.GetHealth()),size(data.GetSizeMult()),targetSize(data.GetSizeMult()),strategy(data.GetAIStrategy()),name(data.GetDisplayName()),upperLevel(upperLevel),isBoss(bossMob),facingDirection(DOWN){ bool firstAnimation=true; for(std::string&anim:data.GetAnimations()){ animation.AddState(anim,ANIMATION_DATA[anim]); @@ -78,7 +78,7 @@ vf2d&Monster::GetPos(){ return pos; } int Monster::GetHealth(){ - return stats.A("Health"); + return hp; } int Monster::GetAttack(){ float mod_atk=float(stats.A("Attack")); @@ -290,7 +290,7 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){ mod_dmg-=damage*b.intensity; } mod_dmg=std::ceil(mod_dmg); - stats.A("Health")=std::max(0.f,stats.A("Health")-int(mod_dmg)); + hp=std::max(0,hp-int(mod_dmg)); if(lastHitTimer>0){ damageNumberPtr.get()->damage+=int(mod_dmg); damageNumberPtr.get()->pauseTime=0.4f; @@ -302,7 +302,7 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){ if(!IsAlive()){ OnDeath(); }else{ - stats.A("Health")=std::max(1.f,stats.A("Health")); //Make sure it stays alive if it's supposed to be alive... + hp=std::max(1,hp); //Make sure it stays alive if it's supposed to be alive... } if(game->InBossEncounter()){ game->BossDamageDealt(int(mod_dmg)); @@ -313,7 +313,7 @@ bool Monster::Hurt(int damage,bool onUpperLevel,float z){ } bool Monster::IsAlive(){ - return stats.A("Health")>0||!diesNormally; + return hp>0||!diesNormally; } vf2d&Monster::GetTargetPos(){ return target; diff --git a/Crawler/Monster.h b/Crawler/Monster.h index b6b1fdab..2bbd776c 100644 --- a/Crawler/Monster.h +++ b/Crawler/Monster.h @@ -165,7 +165,7 @@ private: float friction=400; vf2d target={0,0}; float targetAcquireTimer=0; - int maxhp; + int hp; ItemAttributable stats; float size; float attackCooldownTimer=0; diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index adb907a1..b0e5781e 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -48,6 +48,7 @@ All rights reserved. #include "Menu.h" #include "GameState.h" #include "MenuComponent.h" +#include "config.h" #include @@ -612,13 +613,13 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){ float finalPctDmgTaken=armorDmgTaken*otherDmgTaken; - if(finalPctDmgTaken<=0.06f){ + if(finalPctDmgTaken<=6._Pct){ std::cout<<"WARNING! Damage Reduction has somehow ended up below 6%, which is over the cap!"<OnEquipStatsUpdate(); } } -const int&EntityStats::GetStat(ItemAttribute stat)const{ +const float&EntityStats::GetStat(ItemAttribute stat)const{ return equipStats.A_Read(stat); } -const int&EntityStats::GetStat(std::string_view stat)const{ +const float&EntityStats::GetStat(std::string_view stat)const{ return equipStats.A_Read(stat); } -const int&EntityStats::GetBaseStat(ItemAttribute stat)const{ +const float&EntityStats::GetBaseStat(ItemAttribute stat)const{ return baseStats.A_Read(stat); } -const int&EntityStats::GetBaseStat(std::string_view stat)const{ +const float&EntityStats::GetBaseStat(std::string_view stat)const{ return baseStats.A_Read(stat); } -void EntityStats::SetBaseStat(ItemAttribute stat,int val){ +void EntityStats::SetBaseStat(ItemAttribute stat,float val){ baseStats.A(stat)=val; RecalculateEquipStats(); } -void Player::SetBaseStat(std::string_view a,int val){ +void Player::SetBaseStat(std::string_view a,float val){ stats.SetBaseStat(ItemAttribute::Get(a),val); } -void Player::SetBaseStat(ItemAttribute a,int val){ +void Player::SetBaseStat(ItemAttribute a,float val){ stats.SetBaseStat(a,val); } diff --git a/Crawler/Player.h b/Crawler/Player.h index fbc86f12..43832f29 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -68,11 +68,11 @@ class EntityStats{ public: void RecalculateEquipStats(); //Called when equipment is updated. const ItemAttributable&GetStats()const; - const int&GetStat(ItemAttribute stat)const; //Get stats with equipment applied. - const int&GetStat(std::string_view stat)const; //Get stats with equipment applied. - const int&GetBaseStat(ItemAttribute stat)const; - const int&GetBaseStat(std::string_view stat)const; - void SetBaseStat(ItemAttribute a,int val); + const float&GetStat(ItemAttribute stat)const; //Get stats with equipment applied. + const float&GetStat(std::string_view stat)const; //Get stats with equipment applied. + const float&GetBaseStat(ItemAttribute stat)const; + const float&GetBaseStat(std::string_view stat)const; + void SetBaseStat(ItemAttribute a,float val); }; struct Player{ @@ -102,8 +102,8 @@ public: const int&GetStat(std::string_view a)const; const int&GetBaseStat(ItemAttribute a)const; const int&GetBaseStat(std::string_view a)const; - void SetBaseStat(std::string_view a,int val); - void SetBaseStat(ItemAttribute a,int val); + void SetBaseStat(std::string_view a,float val); + void SetBaseStat(ItemAttribute a,float val); const int GetMaxHealth()const; const int GetHealth()const; const int GetMana()const; diff --git a/Crawler/SlimeKing.cpp b/Crawler/SlimeKing.cpp index 94638a09..4463221a 100644 --- a/Crawler/SlimeKing.cpp +++ b/Crawler/SlimeKing.cpp @@ -240,7 +240,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat m.phase=ConfigInt("StartPhase"); }break; case 1:{ - if(m.stats.A("Health")<=m.maxhp*ConfigFloat("Phase2.Change")/100){ + if(m.hp<=m.stats.A("Health")*ConfigFloat("Phase2.Change")/100){ m.phase=2; m.SetSize(ConfigFloat("Phase2.Size")/100,false); TransitionPhase(m.phase); @@ -273,7 +273,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat } }break; case 2:{ - if(m.stats.A("Health")<=m.maxhp*ConfigFloat("Phase3.Change")/100){ + if(m.hp<=m.stats.A("Health")*ConfigFloat("Phase3.Change")/100){ m.phase=3; m.SetSize(ConfigFloat("Phase3.Size")/100,false); TransitionPhase(m.phase); @@ -297,7 +297,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat } }break; case 3:{ - if(m.stats.A("Health")<=m.maxhp*ConfigFloat("Phase4.Change")/100){ + if(m.hp<=m.stats.A("Health")*ConfigFloat("Phase4.Change")/100){ m.phase=4; m.SetSize(ConfigFloat("Phase4.Size")/100,false); m.AddBuff(BuffType::SLOWDOWN,99999,ConfigFloat("Phase4.MoveSpdModifier")/100); @@ -325,7 +325,7 @@ void Monster::STRATEGY::SLIMEKING(Monster&m,float fElapsedTime,std::string strat } }break; case 4:{ - if(m.stats.A("Health")<=1){ //HP can't reach 0 when the dies normally flag is on. + if(m.hp<=1){ //HP can't reach 0 when the dies normally flag is on. m.phase=5; m.F(A::IFRAME_TIME_UPON_HIT)=1; m.I(A::HITS_UNTIL_DEATH)=int(m.GetSizeMult()*100/ConfigFloat("Phase5.SizeLossPerHit"))-1; diff --git a/Crawler/TODO.txt b/Crawler/TODO.txt index 55d0edd0..e2561954 100644 --- a/Crawler/TODO.txt +++ b/Crawler/TODO.txt @@ -1,6 +1,6 @@ January 1st =========== -Buff Item Script (Implement Other Stats) +Buff Item Script (Implement Other Stats, Level Up Stats) Sell Item Merchant Screen Blacksmith Item Crafting Screen Randomized Item Stats diff --git a/Crawler/Version.h b/Crawler/Version.h index a97be63d..5d8dadb4 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 4643 +#define VERSION_BUILD 4672 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/Campaigns/1_1_v2.tmx b/Crawler/assets/Campaigns/1_1_v2.tmx index 2606d524..0a9ab3c2 100644 --- a/Crawler/assets/Campaigns/1_1_v2.tmx +++ b/Crawler/assets/Campaigns/1_1_v2.tmx @@ -1,5 +1,5 @@ - + @@ -1971,5 +1971,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Crawler/config.h b/Crawler/config.h index 206d865b..b0661b7f 100644 --- a/Crawler/config.h +++ b/Crawler/config.h @@ -60,4 +60,5 @@ double operator ""_D(const char*key,std::size_t len); utils::datafile operator ""_A(const char*key,std::size_t len); Pixel operator ""_Pixel(const char*key,std::size_t len); -float operator ""_FRange(const char*key,std::size_t len); \ No newline at end of file +float operator ""_FRange(const char*key,std::size_t len); +float operator ""_Pct(long double pct); \ No newline at end of file diff --git a/x64/Release/Crawler.exe b/x64/Release/Crawler.exe index ff1195ed..0e43aba4 100644 Binary files a/x64/Release/Crawler.exe and b/x64/Release/Crawler.exe differ