Implemented chapter limits for equipment upgrades.

pull/35/head
sigonasr2 12 months ago
parent 32bec29f61
commit 689eaa6d10
  1. 4
      Adventures in Lestoria/ConsumableCraftingWindow.cpp
  2. 3
      Adventures in Lestoria/CraftItemWindow.cpp
  3. 2
      Adventures in Lestoria/EnhancementStatsLabel.h
  4. 4
      Adventures in Lestoria/InventoryCreator.cpp
  5. 24
      Adventures in Lestoria/Item.cpp
  6. 3
      Adventures in Lestoria/Item.h
  7. 46
      Adventures in Lestoria/RequiredMaterialsList.h
  8. 14
      Adventures in Lestoria/RowItemDisplay.h
  9. 4
      Adventures in Lestoria/TODO.txt
  10. 2
      Adventures in Lestoria/Version.h
  11. 36
      Adventures in Lestoria/assets/config/items/Weapons.txt
  12. 4
      Adventures in Lestoria/assets/config/items/items.txt
  13. BIN
      x64/Release/Adventures in Lestoria.exe

@ -63,14 +63,14 @@ void Menu::InitializeConsumableCraftingWindow(){
Component<MenuLabel>(CONSUMABLE_CRAFT_ITEM,"Item Name Header")->SetLabel(std::format("Crafting {}",item.lock()->DisplayName()));
Component<RequiredMaterialsList>(CONSUMABLE_CRAFT_ITEM,"Required Materials List")->SetItem(item);
Component<MenuComponent>(CONSUMABLE_CRAFT_ITEM,"Craft Button")->SetGrayedOut(!item.lock()->CanEnhanceItem());
if(item.lock()->GetEnhancementInfo().AvailableChapter()<=game->GetCurrentChapter()){
if(item.lock()->GetEnhancementInfo()[0].chapterAvailable<=game->GetCurrentChapter()){
Menu::OpenMenu(CONSUMABLE_CRAFT_ITEM);
}
return true;
},
[](MenuFuncData data){
std::weak_ptr<RowItemDisplay>rowItem=DYNAMIC_POINTER_CAST<RowItemDisplay>(data.component.lock());
if(rowItem.lock()->GetItem().lock()->GetEnhancementInfo().AvailableChapter()<=game->GetCurrentChapter()){
if(rowItem.lock()->GetItem().lock()->GetEnhancementInfo()[0].chapterAvailable<=game->GetCurrentChapter()){
Component<MenuItemItemButton>(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(false);
}else{
Component<MenuItemItemButton>(CRAFT_CONSUMABLE,"Item Icon")->SetHideDetails(true);

@ -70,7 +70,8 @@ void Menu::InitializeCraftItemWindow(){
}
}
std::string label="";
if(item.lock()->EnhancementIsPossible()&&item.lock()->GetEnhancementInfo().size()>item.lock()->EnhancementLevel()+1){
if(item.lock()->EnhancementIsPossible()&&item.lock()->GetEnhancementInfo().size()>item.lock()->EnhancementLevel()+1
&&item.lock()->GetEnhancementInfo()[item.lock()->EnhancementLevel()+1].chapterAvailable<=game->GetCurrentChapter()){
label=std::format("Level {} ->#00AA00 {}",item.lock()->EnhancementLevel(),item.lock()->EnhancementLevel()+1);
}
Component<MenuLabel>(CRAFT_ITEM,"Item Name Header")->SetLabel(std::format("Enhancing {}",item.lock()->DisplayName()));

@ -96,7 +96,7 @@ protected:
}else{ //This item is getting enhanced to the next level.
window.DrawShadowStringDecal(drawPos+vf2d{maxAttributeLabelSize+4+24,yOffset},std::format("{:>5} ->#00AA00 {:<5}",
attr.ShowAsDecimal()?std::format("{:>4.2f}{}",value,percentageSign):std::format("{}{}",value,percentageSign),
nextEnhanceLevel<="Item.Item Max Enhancement Level"_I?
(nextEnhanceLevel<="Item.Item Max Enhancement Level"_I&&itemRef.lock()->GetEnhancementInfo()[nextEnhanceLevel].chapterAvailable<=game->GetCurrentChapter())?
attr.ShowAsDecimal()?std::format("{:<4.2f}{}",nextStageValue,percentageSign):std::format("{}{}",nextStageValue,percentageSign)
:"MAX"),
WHITE,BLACK,adjustedScale,fitToLabel?std::numeric_limits<float>::max():rect.size.x,1.0f);

@ -140,7 +140,7 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
[](InventoryScrollableWindowComponent&component,ITCategory cat){
std::vector<std::weak_ptr<Item>>weapons;
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(weapons),[](std::shared_ptr<Item>item){return item->IsWeapon();});
std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(weapons),[](std::shared_ptr<Item>item){return game->GetCurrentChapter()>=item->GetEnhancementInfo().AvailableChapter()&&item->GetClass()==game->GetPlayer()->GetClassName()&&item->IsWeapon();});
std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(weapons),[](std::shared_ptr<Item>item){return item->CanEnhanceItem()&&item->GetClass()==game->GetPlayer()->GetClassName()&&item->IsWeapon();});
std::sort(weapons.begin(),weapons.end(),[](const std::weak_ptr<Item>&it1,const std::weak_ptr<Item>&it2){
return ItemSortRules::GetItemSortRanking(it1)<ItemSortRules::GetItemSortRanking(it2);
@ -181,7 +181,7 @@ std::function<void(InventoryScrollableWindowComponent&component,ITCategory cat)>
[](InventoryScrollableWindowComponent&component,ITCategory cat){
std::vector<std::weak_ptr<Item>>armor;
std::copy_if(Inventory::get("Equipment").begin(),Inventory::get("Equipment").end(),std::back_inserter(armor),[](std::shared_ptr<Item>item){return item->IsArmor();});
std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(armor),[](std::shared_ptr<Item>item){return game->GetCurrentChapter()>=item->GetEnhancementInfo().AvailableChapter()&&item->GetClass()==game->GetPlayer()->GetClassName()&&item->IsArmor();});
std::copy_if(Inventory::blacksmithInventory.begin(),Inventory::blacksmithInventory.end(),std::back_inserter(armor),[](std::shared_ptr<Item>item){return item->CanEnhanceItem()&&item->GetClass()==game->GetPlayer()->GetClassName()&&item->IsArmor();});
std::sort(armor.begin(),armor.end(),[](const std::weak_ptr<Item>&it1,const std::weak_ptr<Item>&it2){
return ItemSortRules::GetItemSortRanking(it1)<ItemSortRules::GetItemSortRanking(it2);

@ -194,7 +194,9 @@ void ItemInfo::InitializeItems(){
datafile&item=data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)][std::format("Item[{}]",itemsRequired.size())];
itemsRequired.push_back({item.GetString(0),item.GetInt(1)});
}
goldCost=data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)]["Gold"].GetInt();
if(data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)].HasProperty("Gold")){
goldCost=data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)]["Gold"].GetInt();
}
if(data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)].HasProperty("AvailableChapter")){
availableChapter=data[key]["Crafting"][std::format("Level[{}]",enhancementLevel)]["AvailableChapter"].GetInt();
}
@ -205,7 +207,9 @@ void ItemInfo::InitializeItems(){
datafile&item=data[key]["Crafting"][std::format("Item[{}]",itemsRequired.size())];
itemsRequired.push_back({item.GetString(0),item.GetInt(1)});
}
goldCost=data[key]["Crafting"]["Gold"].GetInt();
if(data[key]["Crafting"].HasProperty("Gold")){
goldCost=data[key]["Crafting"]["Gold"].GetInt();
}
if(data[key]["Crafting"].HasProperty("AvailableChapter")){
availableChapter=data[key]["Crafting"]["AvailableChapter"].GetInt();
}
@ -317,7 +321,7 @@ void ItemInfo::InitializeItems(){
ReadItems(DATA["ItemDatabase"]);
ReadItems(DATA["Equipment"]);
std::sort(craftableConsumables.begin(),craftableConsumables.end(),[](std::shared_ptr<Item>&item1,std::shared_ptr<Item>&item2){return item1.get()->GetEnhancementInfo().AvailableChapter()<item2.get()->GetEnhancementInfo().AvailableChapter();});
std::sort(craftableConsumables.begin(),craftableConsumables.end(),[](std::shared_ptr<Item>&item1,std::shared_ptr<Item>&item2){return item1.get()->GetEnhancementInfo()[0].chapterAvailable<item2.get()->GetEnhancementInfo()[0].chapterAvailable;});
ITEM_DATA.SetInitialized();
ITEM_CATEGORIES.SetInitialized();
@ -801,7 +805,7 @@ const float Item::CooldownTime()const{
}
const EnhancementLevelInfo EnhancementInfo::operator[](int level)const{
return EnhancementLevelInfo{const_cast<Stats&>(enhancementStats.at(level)),const_cast<CraftingRequirement&>(craftingRequirements.at(level))};
return EnhancementLevelInfo{const_cast<Stats&>(enhancementStats.at(level)),const_cast<CraftingRequirement&>(craftingRequirements.at(level)),craftingRequirements.at(level).GetAvailableChapter()};
}
const std::optional<const ItemSet *const>ItemInfo::ItemSet()const{
@ -1064,21 +1068,21 @@ void Stats::InitializeDamageReductionTable(){
void EnhancementInfo::SetCraftingRequirements(const int enhanceLevel,const std::vector<std::pair<IT,int>>&requiredItems,const uint32_t goldCost,const uint8_t availableChapter){
while(craftingRequirements.size()<=enhanceLevel){
craftingRequirements.push_back(CraftingRequirement({},0));
craftingRequirements.push_back(CraftingRequirement({},0,availableChapter));
}
craftingRequirements[enhanceLevel]=CraftingRequirement(requiredItems,goldCost,availableChapter);
}
EnhancementLevelInfo::EnhancementLevelInfo(const Stats&stats,const CraftingRequirement&craftingRequirement)
:stats(stats),craftingRequirement(craftingRequirement){}
EnhancementLevelInfo::EnhancementLevelInfo(const Stats&stats,const CraftingRequirement&craftingRequirement,const uint8_t chapterAvailable)
:stats(stats),craftingRequirement(craftingRequirement),chapterAvailable(chapterAvailable){}
const bool Item::CanEnhanceItem(uint8_t qty)const{
if(qty==0)ERR("WARNING! Must specify at least 1 for the quantity!")
if(ISBLANK(std::make_shared<Item>(*this)))return false;
if(!GetEnhancementInfo().CanBeEnhanced())return false;
if(GetEnhancementInfo().AvailableChapter()<game->GetCurrentChapter())return false;
size_t enhanceIndex=std::min(EnhancementLevel()+1,"Item.Item Max Enhancement Level"_I);
if(IsEquippable()&&Inventory::GetItemCount(ActualName())==0)enhanceIndex=0;//Equipment we don't have we need to first craft.
if(game->GetCurrentChapter()<GetEnhancementInfo()[enhanceIndex].chapterAvailable)return false;
const EnhancementLevelInfo&enhanceInfo=GetEnhancementInfo()[enhanceIndex];
if(GetEnhancementInfo().size()>2){ //If the item has exactly 2 enhancement levels, then it's an item that can only simply be crafted. Therefore, don't do the max enhancement level check.
if(EnhancementLevel()>="Item.Item Max Enhancement Level"_I)return false;
@ -1141,10 +1145,6 @@ const bool Item::EnhancementIsPossible()const{
return it->IsCraftable();
}
const uint8_t EnhancementInfo::AvailableChapter()const{
return availableChapter;
}
const Stats&Item::RandomStats()const{
return randomizedStats;
};

@ -115,7 +115,8 @@ class CraftingRequirement;
struct EnhancementLevelInfo{
const Stats&stats;
const CraftingRequirement&craftingRequirement;
EnhancementLevelInfo(const Stats&stats,const CraftingRequirement&craftingRequirement);
const uint8_t chapterAvailable;
EnhancementLevelInfo(const Stats&stats,const CraftingRequirement&craftingRequirement,const uint8_t chapterAvailable);
};
struct EnhancementInfo{

@ -71,31 +71,33 @@ protected:
if(itemRef.lock()->EnhancementIsPossible()){
size_t enhancementIndex=std::min(itemRef.lock()->EnhancementLevel()+1,"Item.Item Max Enhancement Level"_I);
if(itemRef.lock()->IsEquippable()&&Inventory::GetItemCount(itemRef.lock()->ActualName())==0)enhancementIndex=0;//If we don't have the item, use the initial crafting list instead. But only for equipment!
float drawWidth=rect.size.x/3;
int index=0;
for(const auto&[name,amt]:itemRef.lock()->GetEnhancementInfo()[enhancementIndex].craftingRequirement.GetItems()){
if(!itemRef.lock()->IsEquippable()||itemRef.lock()->GetEnhancementInfo()[enhancementIndex].chapterAvailable<=game->GetCurrentChapter()&&itemRef.lock()->EnhancementLevel()!="Item.Item Max Enhancement Level"_I){
if(itemRef.lock()->IsEquippable()&&Inventory::GetItemCount(itemRef.lock()->ActualName())==0)enhancementIndex=0;//If we don't have the item, use the initial crafting list instead. But only for equipment!
float drawWidth=rect.size.x/3;
int index=0;
for(const auto&[name,amt]:itemRef.lock()->GetEnhancementInfo()[enhancementIndex].craftingRequirement.GetItems()){
Pixel textCol=WHITE;
if(Inventory::GetItemCount(name)<amt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string labelText=std::format("{}",std::string(const_cast<IT&>(name)));
float labelWidth=game->GetTextSizeProp(labelText).x;
window.DrawShadowStringDecal(drawPos,std::format("{:>3}",amt*qty),textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{26,0},labelText,textCol,BLACK,{std::min(1.f,(drawWidth-26-2)/labelWidth),1.f});
index++;
}
Pixel textCol=WHITE;
if(Inventory::GetItemCount(name)<amt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string labelText=std::format("{}",std::string(const_cast<IT&>(name)));
float labelWidth=game->GetTextSizeProp(labelText).x;
window.DrawShadowStringDecal(drawPos,std::format("{:>3}",amt*qty),textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{26,0},labelText,textCol,BLACK,{std::min(1.f,(drawWidth-26-2)/labelWidth),1.f});
uint32_t goldAmt=itemRef.lock()->GetEnhancementInfo()[enhancementIndex].craftingRequirement.GetCost();
if(goldAmt>0){
if(game->GetPlayer()->GetMoney()<goldAmt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string goldAmtText=std::format("{:>3}",goldAmt*qty);
std::string labelText=std::format("{}","Item.Currency Name"_S);
float goldAmtWidth=game->GetTextSize(goldAmtText).x;
window.DrawShadowStringDecal(drawPos,goldAmtText,textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{goldAmtWidth+2,0},labelText,textCol,BLACK);
}
index++;
}
Pixel textCol=WHITE;
uint32_t goldAmt=itemRef.lock()->GetEnhancementInfo()[enhancementIndex].craftingRequirement.GetCost();
if(goldAmt>0){
if(game->GetPlayer()->GetMoney()<goldAmt*qty)textCol=RED;
vf2d drawPos=rect.pos+vf2d{drawWidth*(index%3),12.f*(index/3)};
std::string goldAmtText=std::format("{:>3}",goldAmt*qty);
std::string labelText=std::format("{}","Item.Currency Name"_S);
float goldAmtWidth=game->GetTextSize(goldAmtText).x;
window.DrawShadowStringDecal(drawPos,goldAmtText,textCol,BLACK);
window.DrawShadowStringPropDecal(drawPos+vf2d{goldAmtWidth+2,0},labelText,textCol,BLACK);
}
index++;
}
}
};

@ -70,7 +70,7 @@ public:
}
virtual inline void DrawDecal(ViewPort&window,bool focused)override{
bool canEnhance=itemRef.lock()->CanEnhanceItem();
bool locked=fadeOutIfMissingRequirements&&itemRef.lock()->EnhancementIsPossible()&&itemRef.lock()->GetEnhancementInfo().AvailableChapter()>game->GetCurrentChapter();
bool locked=fadeOutIfMissingRequirements&&itemRef.lock()->EnhancementIsPossible()&&itemRef.lock()->GetEnhancementInfo()[0].chapterAvailable>game->GetCurrentChapter();
MenuComponent::DrawDecal(window,focused);
@ -130,6 +130,14 @@ public:
}
}break;
case PriceLabel::UPGRADEABLE:{
uint8_t nextLevel=std::min(itemRef.lock()->EnhancementLevel()+1,"Item.Item Max Enhancement Level"_I);
bool lockedDueToChapterReq=itemRef.lock()->GetEnhancementInfo()[nextLevel].chapterAvailable>game->GetCurrentChapter()||itemRef.lock()->EnhancementLevel()=="Item.Item Max Enhancement Level"_I;
if(lockedDueToChapterReq){
vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Maxed Item Text"_S))*vf2d{1.f,0.85f};
window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Maxed Item Text"_S,"Item.Maxed Item Text Color"_Pixel,BLACK,{1.f,0.85f});
borderCol="Item.Maxed Item Text Color"_Pixel;
}else
if(!canEnhance&&fadeOutIfMissingRequirements){
vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Missing Upgradeable Item Text"_S))*vf2d{1.f,0.85f};
window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Missing Upgradeable Item Text"_S,"Item.Missing Upgradeable Item Text Color"_Pixel,BLACK,{1.f,0.85f});
@ -137,7 +145,7 @@ public:
}else{
vf2d craftableTextSize=vf2d(game->GetTextSizeProp("Item.Upgradeable Item Text"_S))*vf2d{1.f,0.85f};
window.DrawShadowStringPropDecal(rect.pos+vf2d{rect.size.x-craftableTextSize.x-1,3},"Item.Upgradeable Item Text"_S,"Item.Upgradeable Item Text Color"_Pixel,BLACK,{1.f,0.85f});
borderCol=YELLOW;
borderCol="Item.Upgradeable Item Text Color"_Pixel;
}
}break;
case PriceLabel::SELL_LABEL:{
@ -206,7 +214,7 @@ public:
labelNameText="";
labelDescriptionText="";
}
if(hideLabelWhileLocked&&itemRef.lock()->EnhancementIsPossible()&&itemRef.lock()->GetEnhancementInfo().AvailableChapter()>game->GetCurrentChapter()){
if(hideLabelWhileLocked&&itemRef.lock()->EnhancementIsPossible()&&itemRef.lock()->CanEnhanceItem()){
std::for_each(labelNameText.begin(),labelNameText.end(),[](char&c){if(c>='0'&&c<='z'){c='?';}});
std::for_each(labelDescriptionText.begin(),labelDescriptionText.end(),[](char&c){if(c>='0'&&c<='z'){c='?';}});
}

@ -19,8 +19,10 @@ Settings Menu
- Clamp bosses in boss arenas.
- Save randomized traveling merchant.
- Track items used during a stage, on death, restore the loadout item quantities used.
- Stage Plate Navigation bugs
January 31st
============

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 6699
#define VERSION_BUILD 6717
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -460,8 +460,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -576,8 +574,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -647,15 +643,11 @@ Equipment
{
# When this enhancement is available.
AvailableChapter = 1
Item[0] = Green Slime Remains,1
Gold = 1
}
Level[2]
{
# When this enhancement is available.
AvailableChapter = 1
Item[0] = Green Slime Remains,1
Gold = 1
}
@ -663,7 +655,6 @@ Equipment
{
# When this enhancement is available.
AvailableChapter = 1
Item[0] = Green Slime Remains,1
Gold = 1
}
@ -671,18 +662,17 @@ Equipment
{
# When this enhancement is available.
AvailableChapter = 1
Item[0] = Green Slime Remains,1
Gold = 1
}
Level[5]
{
# When this enhancement is available.
AvailableChapter = 1
Item[0] = Green Slime Remains,30
AvailableChapter = 2
Item[0] = Green Slime Remains,1
Item[1] = High-Quality Logs,1
Gold = 150
Gold = 0
}
Level[6]
{
@ -692,8 +682,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -808,8 +796,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -924,8 +910,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1040,8 +1024,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1156,8 +1138,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1272,8 +1252,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1388,8 +1366,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1505,8 +1481,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1623,8 +1597,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.
@ -1740,8 +1712,6 @@ Equipment
Gold = 1
}
# When this enhancement is available.
AvailableChapter = 1
Level[7]
{
# When this enhancement is available.

@ -27,6 +27,10 @@ Item
Missing Upgradeable Item Text = Missing Materials
# Color of the text that displays when items can be upgraded in the Blacksmith but the player doesn't have enough material.
Missing Upgradeable Item Text Color = 192,0,0,255
# Text that displays when items are maxed out at the Blacksmith.
Maxed Item Text = MAX LV
# Color of the text that displays when items are maxed out at the Blacksmith.
Maxed Item Text Color = 0,255,255,255
# The names of items to be sorted for equipment lists.
Equipment Sort Order Primary = Wooden, Leather, Steel, Copper, Shell, Bone, Laser, Plasma, Unknown

Loading…
Cancel
Save