Added blacksmith's inventory for display underneath player's equipment for crafting. Fix bug with loadout item slot 2 not being reset properly (missing ability set function). Release build 6604.

pull/35/head
sigonasr2 10 months ago
parent db93e05afc
commit a6e8ec872c
  1. 1
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/BlacksmithCraftingWindow.cpp
  3. 1
      Adventures in Lestoria/ClassInfo.h
  4. 2
      Adventures in Lestoria/InventoryCreator.cpp
  5. 1
      Adventures in Lestoria/InventoryCreator.h
  6. 34
      Adventures in Lestoria/Item.cpp
  7. 8
      Adventures in Lestoria/Item.h
  8. 3
      Adventures in Lestoria/MenuComponent.cpp
  9. 1
      Adventures in Lestoria/MenuComponent.h
  10. 1
      Adventures in Lestoria/Monster.h
  11. 12
      Adventures in Lestoria/NPC.cpp
  12. 2
      Adventures in Lestoria/Version.h
  13. 15
      Adventures in Lestoria/assets/config/items/Weapons.txt
  14. BIN
      x64/Release/Adventures in Lestoria.exe

@ -2888,6 +2888,7 @@ void AiL::ClearLoadoutItem(int slot){
itemAbility.action=[&](Player*p,vf2d pos={}){
return game->UseLoadoutItem(1);
};
game->GetPlayer()->SetItem2UseFunc(itemAbility);
Component<MenuItemItemButton>(MenuType::ITEM_LOADOUT,"Loadout Item 2")->SetItem(Item::BLANK);
Component<MenuItemItemButton>(MenuType::ITEM_LOADOUT,"Loadout Item 2")->UpdateIcon();
}break;

@ -120,7 +120,6 @@ void Menu::InitializeBlacksmithCraftingWindow(){
InventoryCreator::RowPlayerWeapons_InventoryUpdate,
InventoryWindowOptions{.padding=1,.size={207,28}}
)END;
AddInventoryListener(weaponsDisplay,"Equipment");
weaponsDisplay->SetCompactDescriptions(CRAFTING_INFO);
#pragma endregion
@ -154,7 +153,6 @@ void Menu::InitializeBlacksmithCraftingWindow(){
InventoryCreator::RowPlayerArmor_InventoryUpdate,
InventoryWindowOptions{.padding=1,.size={207,28}}
)END;
AddInventoryListener(armorDisplay,"Equipment");
armorDisplay->Enable(false);
armorDisplay->SetCompactDescriptions(CRAFTING_INFO);
#pragma endregion

@ -59,6 +59,7 @@ public:
static inline Class StringToClass(std::string className){
const std::vector<std::string>&classList=DATA["class_list"].GetValues();
auto it=std::find(classList.begin(),classList.end(),className);
if(it==classList.end())ERR(std::format("WARNING! Class {} does not exist!",className));
int element=int(std::distance(classList.begin(),it));
return Class(1<<element); //Yes...It's bitwise flags, who in god's name knows why I did this.
};

@ -146,6 +146,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 item->IsWeapon();});
RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST<RowInventoryScrollableWindowComponent*>(&component);
@ -178,6 +179,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 item->IsArmor();});
RowInventoryScrollableWindowComponent*c=DYNAMIC_CAST<RowInventoryScrollableWindowComponent*>(&component);

@ -50,6 +50,7 @@ private:
class InventoryScrollableWindowComponent;
class InventoryCreator{
friend class Inventory;
_SETUP(Player);
_SETUP(RowPlayer);
_SETUP(RowMerchant);

@ -45,6 +45,8 @@ All rights reserved.
#include <numeric>
#include "util.h"
#include "SoundEffect.h"
#include "ClassInfo.h"
#include "RowInventoryScrollableWindowComponent.h"
INCLUDE_game
INCLUDE_DATA
@ -57,6 +59,7 @@ safemap<std::string,ItemScript>ITEM_SCRIPTS;
safemap<std::string,std::set<std::string>>ITEM_CATEGORIES;
std::shared_ptr<Item>Item::BLANK=std::make_shared<Item>();
std::multimap<IT,std::shared_ptr<Item>>Inventory::_inventory;
std::vector<std::shared_ptr<Item>>Inventory::blacksmithInventory;
std::map<ITCategory,std::vector<std::shared_ptr<Item>>>Inventory::sortedInv;
std::vector<ItemOverlay>ItemOverlay::items;
std::map<std::string,ItemSet>ItemSet::sets;
@ -112,6 +115,7 @@ void ItemInfo::InitializeItems(){
Stats minStats;
Stats maxStats;
bool useDuringCast=false;
std::string equippableClass="";
EventName useSound;
for(auto&[itemKey,itemValue]:data[key].GetKeys()){
std::string keyName=itemKey;
@ -152,6 +156,10 @@ void ItemInfo::InitializeItems(){
if(keyName=="UseSound"||keyName=="Equip Sound"){
useSound=data[key][keyName].GetString();
}else
if(keyName=="Class"){
equippableClass=data[key][keyName].GetString();
classutils::StringToClass(equippableClass); //If this errors out then we specified an invalid class!
}else
if(keyName.starts_with("Alternative Name")){
if(ITEM_CONVERSIONS.count(data[key][keyName].GetString()))ERR(std::format("Item {} already exists in Item Conversion database! Cannot add a duplicate entry!",data[key][keyName].GetString()));
ITEM_CONVERSIONS[data[key][keyName].GetString()]=key;
@ -241,6 +249,7 @@ void ItemInfo::InitializeItems(){
it.sellValue=sellValue;
it.useDuringCast=useDuringCast;
it.useSound=useSound;
it.equippableClass=equippableClass;
if(slot.size()>0){
for(std::string&s:slot){
if(!nameToEquipSlot.count(s))ERR("WARNING! Tried to add item "<<it.name<<" to slot "<<s<<" which doesn't exist!");
@ -1157,3 +1166,28 @@ const std::vector<std::shared_ptr<Item>>Inventory::GetInventory(){
}
return itemList;
}
const std::string&ItemInfo::GetClass()const{
return equippableClass;
}
const std::string&Item::GetClass()const{
return it->GetClass();
}
void Inventory::UpdateBlacksmithInventoryLists(){
auto weaponsList=Component<RowInventoryScrollableWindowComponent>(BLACKSMITH,"Weapon Inventory Display");
auto armorList=Component<RowInventoryScrollableWindowComponent>(BLACKSMITH,"Armor Inventory Display");
blacksmithInventory.clear();
#pragma region Retrieve all equipment that the player currently does not own
for(auto&[key,size]:DATA.GetProperty("Equipment")){
if(GetItemCount(key)==0){
blacksmithInventory.push_back(std::make_shared<Item>(1,key));
}
}
#pragma endregion
InventoryCreator::RowPlayerWeapons_InventorySlotsUpdate(*DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(weaponsList),"Equipment");
InventoryCreator::RowPlayerArmor_InventorySlotsUpdate(*DYNAMIC_POINTER_CAST<InventoryScrollableWindowComponent>(armorList),"Equipment");
}

@ -210,6 +210,7 @@ public:
const bool CanBeSold()const;
const bool CanBePurchased()const;
const Stats&RandomStats()const;
const std::string&GetClass()const;
void RandomizeStats();
const bool HasRandomizedStats()const;
const EnhancementInfo&GetEnhancementInfo()const;
@ -229,6 +230,7 @@ class Inventory{
friend class ItemInfo;
friend class Item;
friend class SaveFile;
friend class InventoryCreator;
public:
static std::weak_ptr<Item>AddItem(IT it,uint32_t amt=1,bool monsterDrop=false);
//Returns the actual amount available in your main inventory.
@ -249,6 +251,7 @@ public:
static const std::map<ItemSet,int>GetEquippedItemSets();
//Gets all items currently on inventory (Ignores Stage Loot and Monster Loot Inventories)
static const std::vector<std::shared_ptr<Item>>GetInventory();
static void UpdateBlacksmithInventoryLists();
static bool SwapItems(ITCategory itemCategory,uint32_t slot1,uint32_t slot2);
//Makes sure this is a valid category. Will error out if it doesn't exist! Use for ERROR HANDLING!
@ -261,6 +264,7 @@ private:
static void InsertIntoStageInventoryCategory(std::shared_ptr<Item>itemRef,const bool monsterDrop);
static bool ExecuteAction(IT item);
static std::multimap<IT,std::shared_ptr<Item>>_inventory;
static std::vector<std::shared_ptr<Item>>blacksmithInventory;
static std::map<EquipSlot,std::weak_ptr<Item>>equipment;
//Only contains "1" of every item, as this is a map to index items and not the actual storage of items!
static std::map<ITCategory,std::vector<std::shared_ptr<Item>>>sortedInv;
@ -300,6 +304,8 @@ class ItemInfo{
uint32_t sellValue=0;
//If true, this item's action is activated at the beginning of the cast instead of after the cast completes.
bool useDuringCast=false;
//If blank, any class can equip this item.
std::string equippableClass="";
Stats minStats;
Stats maxStats;
private:
@ -338,6 +344,8 @@ public:
const bool IsAccessory()const;
const Stats GetMinStats()const;
const Stats GetMaxStats()const;
//Get the class that can equip this item.
const std::string&GetClass()const;
Stats RandomizeStats();
};

@ -259,3 +259,6 @@ void MenuComponent::Click(){
}
}
void MenuComponent::SetLabel(std::string newLabel){
label=newLabel;
}

@ -155,4 +155,5 @@ public:
virtual void OnPlayerMoneyUpdate(uint32_t newMoney);
virtual void OnChapterUpdate(uint8_t newChapter);
virtual void Click();
virtual void SetLabel(std::string newLabel);
};

@ -123,6 +123,7 @@ class GameEvent;
class Monster:IAttributable{
friend struct STRATEGY;
friend class AiL;
friend class InventoryCreator;
public:
Monster()=delete;
Monster(vf2d pos,MonsterData data,bool upperLevel=false,bool bossMob=false);

@ -42,7 +42,8 @@ All rights reserved.
#include "util.h"
#include "Menu.h"
#include "Unlock.h"
#include "MenuComponent.h"
#include "RowInventoryScrollableWindowComponent.h"
#include "InventoryCreator.h"
using A=Attribute;
@ -67,10 +68,17 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
if(game->KEY_CONFIRM.Released()&&Menu::stack.size()==0){
if(m.npcData.function=="Blacksmith"){
Menu::OpenMenu(MenuType::BLACKSMITH);
//First reset all items displayed in the blacksmith's shop (showing only our equipment.)
Inventory::UpdateBlacksmithInventoryLists();
}else
if(m.npcData.function=="PotionCrafting"){
Menu::OpenMenu(MenuType::SHERMAN);
Component<MenuComponent>(SHERMAN,"Consumable Crafting Button")->SetGrayedOut(!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S));
bool locked=!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S);
std::string craftingButtonLabel="Consumable Crafting";
if(locked)craftingButtonLabel="???";
Component<MenuComponent>(SHERMAN,"Consumable Crafting Button")->SetGrayedOut(locked);
Component<MenuComponent>(SHERMAN,"Consumable Crafting Button")->SetLabel(craftingButtonLabel);
}else
if(m.npcData.function=="TravelingMerchant"){
Menu::OpenMenu(MenuType::MERCHANT);

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

@ -4,6 +4,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Warrior
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -109,6 +110,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Ranger
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -203,6 +205,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Wizard
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -297,6 +300,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Warrior
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -382,6 +386,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Ranger
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -467,6 +472,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Wizard
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -552,6 +558,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Warrior
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -637,6 +644,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Ranger
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -722,6 +730,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Wizard
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -807,6 +816,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Warrior
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -892,6 +902,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Ranger
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -977,6 +988,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Wizard
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -1062,6 +1074,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Warrior
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -1148,6 +1161,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Ranger
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names
@ -1234,6 +1248,7 @@ Equipment
{
Slot = Weapon
ItemCategory = Equipment
Class = Wizard
# Stat Values of the item based on Enhancement level.
# See ItemStats.txt for valid stat names

Loading…
Cancel
Save