Set bonuses implemented in equip stats.

pull/28/head
sigonasr2 12 months ago
parent 13104bae66
commit dc6ecf40c2
  1. 7
      Crawler/AttributableStat.h
  2. 18
      Crawler/Item.cpp
  3. 13
      Crawler/Item.h
  4. 17
      Crawler/Player.cpp
  5. 2
      Crawler/Version.h

@ -108,8 +108,11 @@ public:
inline int&get(ItemAttribute a){
return attributes[a];
}
inline const int get_readOnly(ItemAttribute a){
return attributes[a];
inline const int get_readOnly(ItemAttribute a)const{
if(attributes.count(a)){
return attributes.at(a);
}
return 0;
}
inline static AttributeData GetDisplayInfo(ItemAttribute a){
return data[a];

@ -474,12 +474,11 @@ const Stats&EnhancementInfo::operator[](int level)const{
return enhancementStats[level];
}
bool ItemInfo::HasItemSet(){
return ItemSet::sets.count(set);
}
const ItemSet&ItemInfo::ItemSet()const{
return ItemSet::sets[set];
const std::optional<const ItemSet const*>ItemInfo::ItemSet()const{
if(ItemSet::sets.count(set)){
return &ItemSet::sets[set];
}
return {};
};
const Stats&ItemSet::operator[](int setPieces)const{
@ -489,7 +488,8 @@ const Stats&ItemSet::operator[](int setPieces)const{
void ItemSet::AddSetBonus(std::string setName,int pieceCount,Stats&bonuses){
if(pieceCount<=0||pieceCount>=9)ERR("Piece count is invalid! Expecting a value (1-8) but got "<<pieceCount);
for(int i=pieceCount-1;i<sets[setName].setBonuses.size();i++){
sets[setName].name=setName;
for(int i=pieceCount;i<sets[setName].setBonuses.size();i++){
sets[setName].setBonuses[i]+=bonuses;
}
}
@ -563,4 +563,8 @@ Stats Item::GetStats()const{
const size_t EnhancementInfo::size()const{
return enhancementStats.size();
};
const std::optional<const ItemSet const*>Item::ItemSet()const{
return it->ItemSet();
};

@ -95,11 +95,17 @@ class ItemSet{
friend class ItemInfo;
static std::map<std::string,ItemSet>sets;
std::array<Stats,8>setBonuses;
std::string name;
public:
//NO CONSTRUCTOR REQUIRED!
//Specify the piece count(1-8) for a set bonus to be applied.
static void AddSetBonus(std::string setName,int pieceCount,Stats&bonuses);
//Gets a set bonus based on number of pieces (1-8)
const Stats&operator[](int setPieces)const;
const std::string&GetSetName()const;
bool operator<(const ItemSet&rhs)const{
return name<rhs.name;
}
};
class Item{
@ -127,6 +133,7 @@ public:
bool IsBlank();
static Item BLANK;
bool operator==(const Item&rhs)const;
const std::optional<const ItemSet const*>ItemSet()const;
};
class Inventory{
@ -186,7 +193,7 @@ class ItemInfo{
EquipSlot slot;
EnhancementInfo enhancement;
Decal*img;
std::string set;
std::string set="";
//Returns true if the item can be used, false otherwise
std::string useFunc="";
//Custom properties for this specific item's script.
@ -212,9 +219,7 @@ public:
float CastTime();
float CooldownTime();
EquipSlot Slot();
bool HasItemSet();
//NOTE: Not every item has a set! Verify with HasItemSet() first!
const ItemSet&ItemSet()const;
const std::optional<const ItemSet const*>ItemSet()const;
};
class ItemOverlay{

@ -867,11 +867,22 @@ const int Player::GetBaseStat(ItemAttribute a)const{
void PlayerStats::RecalculateEquipStats(){
baseStats.copyTo(equipStats);
std::map<ItemSet,int>setCounts;
for(int i=int(EquipSlot::HELMET);i<=int(EquipSlot::RING2);i<<=1){
EquipSlot slot=EquipSlot(i);
Item*equip=Inventory::GetEquip(slot);
if(equip->IsBlank())continue;
for(ItemAttribute a=ItemAttribute(int(ItemAttribute::ENUM_START)+1);a<ItemAttribute::ENUM_END;a=ItemAttribute(int(a)+1)){
equipStats.get(a)+=equip->GetStats().A(a);
equipStats.A(a)+=equip->GetStats().A(a);
}
if(equip->ItemSet().has_value()){
setCounts[*equip->ItemSet().value()]++;
}
}
for(const auto&[set,equipCount]:setCounts){
const Stats&setStats=set[equipCount];
for(ItemAttribute a=ItemAttribute(int(ItemAttribute::ENUM_START)+1);a<ItemAttribute::ENUM_END;a=ItemAttribute(int(a)+1)){
equipStats.A(a)+=setStats.A_Read(a);
}
}
for(MenuComponent*component:Menu::equipStatListeners){
@ -891,4 +902,8 @@ void PlayerStats::SetBaseStat(ItemAttribute stat,int val){
}
void Player::SetBaseStat(ItemAttribute a,int val){
PlayerStats::SetBaseStat(a,val);
}
const std::string&ItemSet::GetSetName()const{
return name;
}

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 3614
#define VERSION_BUILD 3623
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save