diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index 844b1048..8392e436 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -87,13 +87,10 @@ const int Monster::GetHealth()const{ return hp; } const int Monster::GetMaxHealth()const{ - return stats.A_Read("Health"); + return int(GetModdedStatBonuses("Health")); } int Monster::GetAttack(){ - float mod_atk=float(stats.A("Attack")); - mod_atk+=GetBonusStat("Attack %"); - mod_atk+=GetBonusStat("Attack"); - return int(mod_atk); + return int(GetModdedStatBonuses("Attack")); } float Monster::GetMoveSpdMult(){ float moveSpdPct=stats.A("Move Spd %")/100.f; @@ -720,11 +717,13 @@ void Monster::AddBuff(BuffType type,float duration,float intensity){ } void Monster::AddBuff(BuffType type,float duration,float intensity,std::setattr){ - buffList.push_back(Buff{type,duration,intensity,attr}); + if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const ItemAttribute&attr){if(attr.ActualName()!="Health"&&attr.ActualName()!="Health %"&&attr.ActualName()!="Attack"&&attr.ActualName()!="Attack %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr.ActualName()));}); + buffList.emplace_back(type,duration,intensity,attr); } void Monster::AddBuff(BuffType type,float duration,float intensity,std::setattr){ - buffList.push_back(Buff{type,duration,intensity,attr}); + if(type==STAT_UP)std::for_each(attr.begin(),attr.end(),[](const std::string&attr){if(attr!="Health"&&attr!="Health %"&&attr!="Attack"&&attr!="Attack %")ERR(std::format("WARNING! Stat Up Attribute type {} is NOT IMPLEMENTED!",attr));}); + buffList.emplace_back(type,duration,intensity,attr); } void Monster::RemoveBuff(BuffType type){ @@ -1153,4 +1152,20 @@ void Monster::_DealTrueDamage(const uint32_t damageAmt){ void Monster::Heal(const int healAmt){ hp=std::clamp(hp+healAmt,0,int(GetMaxHealth())); +} + +const float Monster::GetModdedStatBonuses(std::string_view stat)const{ + if(ItemAttribute::Get(stat).DisplayAsPercent())ERR(std::format("WARNING! Stat {} was provided. A percentage-based stat should not be supplied here! GetModdedStatBonuses() is supposed to calculate using a BASE stat and includes the percentage modifier already! Please fix this!",stat)) + float flatBonuses{stats.A_Read(stat)+GetBonusStat(stat)}; + float pctBonusSum{}; + for(const Buff&buff:GetBuffs(BuffType::STAT_UP)){ + for(const ItemAttribute&attr:buff.attr){ + if(attr.Modifies()==stat){ + if(attr.DisplayAsPercent()){ + pctBonusSum+=buff.intensity*100.f; + } + } + } + } + return flatBonuses+flatBonuses*pctBonusSum/100.f; } \ No newline at end of file diff --git a/Adventures in Lestoria/Monster.h b/Adventures in Lestoria/Monster.h index 3ea01428..5eed8159 100644 --- a/Adventures in Lestoria/Monster.h +++ b/Adventures in Lestoria/Monster.h @@ -197,6 +197,7 @@ public: const float GetHealthRatio()const; void _DealTrueDamage(const uint32_t damageAmt); void Heal(const int healAmt); + const float GetModdedStatBonuses(std::string_view stat)const; private: //NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!! // The way this works is that monsters marked for deletion will cause the monster update loop to detect there's at least one or more monsters that must be deleted and will call erase_if on the list at the end of the iteration loop. diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index 8d5aea2f..21ac0996 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 9911 +#define VERSION_BUILD 9922 #define stringify(a) stringify_(a) #define stringify_(a) #a