Fix Equipment file comments to be on newlines. Parse item stat values based on provided stat values in config instead of hard-coding.

pull/28/head
sigonasr2 1 year ago
parent ece5454c96
commit 0b912e199a
  1. 32
      Crawler/AttributableStat.h
  2. 30
      Crawler/Item.cpp
  3. 2
      Crawler/Version.h
  4. 60
      Crawler/assets/config/items/Equipment.txt

@ -41,6 +41,17 @@ All rights reserved.
#define A(attr) get(attr)
#define A_Read(attr) get_readOnly(attr)
namespace DisplayType{
enum DisplayType{
DISPLAY_AS_NUMBER=0,
DISPLAY_AS_PERCENT=1,
};
}
struct AttributeData{
std::string name;
DisplayType::DisplayType displayAsPercent;
};
enum class ItemAttribute{
/*////////////////////////////////////////////*/
/*//////*/ENUM_START,/*///////////////////////*/
@ -65,20 +76,11 @@ enum class ItemAttribute{
/*////////////////////////////////////////////*/
};
namespace DisplayType{
enum DisplayType{
DISPLAY_AS_NUMBER=0,
DISPLAY_AS_PERCENT=1,
};
}
struct AttributeData{
std::string name;
DisplayType::DisplayType displayAsPercent;
};
class ItemAttributable{
friend class ItemInfo;
std::map<ItemAttribute,int>attributes;
private:
inline static std::map<std::string,ItemAttribute>stringToAttribute;
inline static std::map<ItemAttribute,AttributeData>data{
{ItemAttribute::defense,{"Defense",DisplayType::DISPLAY_AS_NUMBER}},
{ItemAttribute::health,{"Health",DisplayType::DISPLAY_AS_NUMBER}},
@ -88,12 +90,13 @@ private:
{ItemAttribute::critPct,{"Crit Rate",DisplayType::DISPLAY_AS_PERCENT}},
{ItemAttribute::critDmgPct,{"Crit Dmg",DisplayType::DISPLAY_AS_PERCENT}},
{ItemAttribute::healthPct,{"Health %",DisplayType::DISPLAY_AS_PERCENT}}, //Percentage of health boost
{ItemAttribute::healthPctRecoveryPer6sec,{"HP Recovery %",DisplayType::DISPLAY_AS_NUMBER}}, //Percentage of health recovered every 6 seconds.
{ItemAttribute::healthPctRecoveryPer4sec,{"HP Recovery %",DisplayType::DISPLAY_AS_NUMBER}}, //Percentage of health recovered every 4 seconds.
{ItemAttribute::healthPctRecoveryPer6sec,{"HP6 Recovery %",DisplayType::DISPLAY_AS_NUMBER}}, //Percentage of health recovered every 6 seconds.
{ItemAttribute::healthPctRecoveryPer4sec,{"HP4 Recovery %",DisplayType::DISPLAY_AS_NUMBER}}, //Percentage of health recovered every 4 seconds.
{ItemAttribute::damageReductionPct,{"Damage Reduction",DisplayType::DISPLAY_AS_PERCENT}}, //Percentage of damage reduced directly.
{ItemAttribute::attackPct,{"Attack %",DisplayType::DISPLAY_AS_PERCENT}}, //Percentage of damage increased by.
};
public:
//Returns a copy of all the attributes to be passed to a new instance easily / to sync values between both.
inline void copyTo(ItemAttributable&target){
target.attributes=attributes;
@ -107,4 +110,7 @@ public:
inline static AttributeData GetDisplayInfo(ItemAttribute a){
return data[a];
}
inline static ItemAttribute GetAttributeFromString(std::string attrName){
return stringToAttribute[attrName];
};
};

@ -74,6 +74,11 @@ void ItemInfo::InitializeItems(){
nameToEquipSlot["Ring2"]=EquipSlot::RING2;
InitializeScripts();
//Setup Strings to Attribute map.
for(ItemAttribute attr=ItemAttribute(int(ItemAttribute::ENUM_START)+1);attr<ItemAttribute::ENUM_END;attr=ItemAttribute(int(attr)+1)){
ItemAttributable::stringToAttribute[ItemAttributable::GetDisplayInfo(attr).name]=attr;
}
for(auto&key:DATA["ItemCategory"].GetKeys()){
ITEM_CATEGORIES[key.first];
@ -91,7 +96,7 @@ void ItemInfo::InitializeItems(){
float castTime=0;
std::vector<std::string> slot;
float cooldownTime="Item.Item Cooldown Time"_F;
bool hasStatValues=false;
std::vector<ItemAttribute>statValueList;
for(auto&itemKey:data[key.first].GetKeys()){
std::string keyName=itemKey.first;
if(keyName=="Description"){
@ -114,24 +119,25 @@ void ItemInfo::InitializeItems(){
slot.push_back(val);
}
}else
if(keyName.starts_with("StatValues")){
hasStatValues=true;
if(keyName=="StatValues"){
for(int i=0;i<data[key.first]["StatValues"].GetValueCount();i++){
statValueList.push_back(ItemAttributable::GetAttributeFromString(data[key.first]["StatValues"].GetString(i)));
}
}else{ //THis is a custom override modifier for a script. NO-OP
}
}
ItemInfo&it=ITEM_DATA[key.first];
if(hasStatValues){
if(statValueList.size()>0){
EnhancementInfo enhancementStats;
for(int i=0;i<=10;i++){
datafile&dat=data[key.first]["StatValues["+std::to_string(i)+"]"];
int armor=dat.GetValueCount()>0?dat.GetInt(0):0;
int health=dat.GetValueCount()>1?dat.GetInt(1):0;
int attack=dat.GetValueCount()>2?dat.GetInt(2):0;
enhancementStats.SetAttribute(i,ItemAttribute::defense,armor);
enhancementStats.SetAttribute(i,ItemAttribute::health,health);
enhancementStats.SetAttribute(i,ItemAttribute::attack,attack);
for(int enhancementLevel=0;enhancementLevel<=10;enhancementLevel++){
datafile&dat=data[key.first]["StatValues["+std::to_string(enhancementLevel)+"]"];
int attrIndex=0;
for(ItemAttribute&attr:statValueList){
enhancementStats.SetAttribute(enhancementLevel,attr,dat.GetInt(attrIndex));
attrIndex++;
}
}
it.enhancement=enhancementStats;
}

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

@ -8,7 +8,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 3,2,0
StatValues[1] = 4,3,0
StatValues[2] = 5,3,0
@ -29,7 +30,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 5,1,0
StatValues[1] = 6,1,0
StatValues[2] = 7,2,0
@ -50,7 +52,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 4,1,1
StatValues[1] = 5,1,1
StatValues[2] = 6,1,2
@ -71,7 +74,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 1,0,1
StatValues[1] = 2,0,3
StatValues[2] = 3,0,3
@ -92,7 +96,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 2,1,0
StatValues[1] = 3,1,1
StatValues[2] = 4,2,1
@ -113,7 +118,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 7,5,2
StatValues[1] = 9,5,2
StatValues[2] = 10,6,3
@ -134,7 +140,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 10,3,2
StatValues[1] = 11,4,2
StatValues[2] = 12,4,3
@ -155,7 +162,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 9,3,3
StatValues[1] = 10,3,4
StatValues[2] = 11,4,4
@ -176,7 +184,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 5,2,5
StatValues[1] = 6,2,5
StatValues[2] = 6,3,6
@ -197,7 +206,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 6,3,3
StatValues[1] = 7,3,3
StatValues[2] = 7,4,4
@ -218,7 +228,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 12,8,4
StatValues[1] = 13,8,4
StatValues[2] = 18,9,4
@ -239,7 +250,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 14,6,4
StatValues[1] = 15,7,4
StatValues[2] = 20,7,4
@ -260,7 +272,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 13,5,6
StatValues[1] = 14,5,7
StatValues[2] = 16,6,7
@ -281,7 +294,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 8,4,7
StatValues[1] = 8,4,8
StatValues[2] = 8,4,9
@ -302,7 +316,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 9,5,4
StatValues[1] = 9,5,5
StatValues[2] = 9,6,6
@ -323,7 +338,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 24,12,5
StatValues[1] = 29,12,5
StatValues[2] = 31,13,5
@ -344,7 +360,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 33,9,5
StatValues[1] = 37,10,5
StatValues[2] = 41,11,5
@ -365,7 +382,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 24,7,9
StatValues[1] = 26,8,10
StatValues[2] = 30,8,11
@ -386,7 +404,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 9,5,11
StatValues[1] = 10,5,12
StatValues[2] = 11,5,13
@ -407,7 +426,8 @@ Equipment
ItemCategory = Equipment
# Stat Values of the item based on Enhancement level.
StatValues = Defense,Health,Attack # See ItemSets.txt for valid stat names
# See ItemSets.txt for valid stat names
StatValues = Defense,Health,Attack
StatValues[0] = 11,7,7
StatValues[1] = 11,8,8
StatValues[2] = 12,8,8

Loading…
Cancel
Save