Convert monster stats to calculate using stat up bonuses instead of manual calculations. Release Build 9922.

removeExposedPackKey
sigonasr2 7 months ago
parent a7b9017fa7
commit a8d04d258f
  1. 29
      Adventures in Lestoria/Monster.cpp
  2. 1
      Adventures in Lestoria/Monster.h
  3. 2
      Adventures in Lestoria/Version.h

@ -87,13 +87,10 @@ const int Monster::GetHealth()const{
return hp; return hp;
} }
const int Monster::GetMaxHealth()const{ const int Monster::GetMaxHealth()const{
return stats.A_Read("Health"); return int(GetModdedStatBonuses("Health"));
} }
int Monster::GetAttack(){ int Monster::GetAttack(){
float mod_atk=float(stats.A("Attack")); return int(GetModdedStatBonuses("Attack"));
mod_atk+=GetBonusStat("Attack %");
mod_atk+=GetBonusStat("Attack");
return int(mod_atk);
} }
float Monster::GetMoveSpdMult(){ float Monster::GetMoveSpdMult(){
float moveSpdPct=stats.A("Move Spd %")/100.f; 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::set<ItemAttribute>attr){ void Monster::AddBuff(BuffType type,float duration,float intensity,std::set<ItemAttribute>attr){
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::set<std::string>attr){ void Monster::AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr){
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){ void Monster::RemoveBuff(BuffType type){
@ -1154,3 +1153,19 @@ void Monster::_DealTrueDamage(const uint32_t damageAmt){
void Monster::Heal(const int healAmt){ void Monster::Heal(const int healAmt){
hp=std::clamp(hp+healAmt,0,int(GetMaxHealth())); 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;
}

@ -197,6 +197,7 @@ public:
const float GetHealthRatio()const; const float GetHealthRatio()const;
void _DealTrueDamage(const uint32_t damageAmt); void _DealTrueDamage(const uint32_t damageAmt);
void Heal(const int healAmt); void Heal(const int healAmt);
const float GetModdedStatBonuses(std::string_view stat)const;
private: private:
//NOTE: Marking a monster for deletion does not trigger any death events. It just simply removes the monster from the field!! //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. // 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.

@ -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 9911 #define VERSION_BUILD 9922
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

Loading…
Cancel
Save