diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index e49fdcd8..efe38a9f 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -2011,6 +2011,10 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ foregroundTileGroups.clear(); upperForegroundTileGroups.clear(); MONSTER_LIST.clear(); + BULLET_LIST.clear(); + DAMAGENUMBER_LIST.clear(); + backgroundEffects.clear(); + foregroundEffects.clear(); ZONE_LIST.clear(); ItemDrop::drops.clear(); GameEvent::events.clear(); @@ -2027,6 +2031,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){ totalBossEncounterMobs=0; Inventory::Clear("Monster Loot"); Inventory::Clear("Stage Loot"); + Inventory::ResetLoadoutItemsUsed(); GetPlayer()->hp=GetPlayer()->GetMaxHealth(); GetPlayer()->mana=GetPlayer()->GetMaxMana(); @@ -3176,12 +3181,12 @@ void AiL::SetChapter(int chapter){ } const std::weak_ptrAiL::GetLoadoutItem(int slot){ - if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); + if(slot<0||slot>GetLoadoutSize()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(GetLoadoutSize()-1)+")."); return loadout[slot]; } void AiL::SetLoadoutItem(int slot,std::string itemName){ - if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); + if(slot<0||slot>GetLoadoutSize()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(GetLoadoutSize()-1)+")."); if(Inventory::GetItemCount(itemName)>0){ if(loadout[slot]&&!ISBLANK(loadout[slot])&&loadout[slot]->Amt()>0){ //If the slot isn't blank, we should clear the item from being selected in the consumables list. @@ -3256,9 +3261,10 @@ void AiL::SetLoadoutItem(int slot,std::string itemName){ } bool AiL::UseLoadoutItem(int slot){ - if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); + if(slot<0||slot>GetLoadoutSize()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(GetLoadoutSize()-1)+")."); if(GetLoadoutItem(slot).lock()->Amt()>0){ Inventory::UseItem(GetLoadoutItem(slot).lock()->ActualName()); + Inventory::AddLoadoutItemUsed(GetLoadoutItem(slot).lock()->ActualName(),slot); GetLoadoutItem(slot).lock()->amt--; if(GetLoadoutItem(slot).lock()->UseSound().length()>0){ SoundEffect::PlaySFX(GetLoadoutItem(slot).lock()->UseSound(),SoundEffect::CENTERED); @@ -3269,7 +3275,7 @@ bool AiL::UseLoadoutItem(int slot){ } void AiL::ClearLoadoutItem(int slot){ - if(slot<0||slot>loadout.size()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(loadout.size()-1)+")."); + if(slot<0||slot>GetLoadoutSize()-1)ERR("Invalid inventory slot "+std::to_string(slot)+", please choose a slot in range (0-"+std::to_string(GetLoadoutSize()-1)+")."); loadout[slot].reset(); InputGroup*inputGroup=nullptr; switch(slot){ @@ -3429,7 +3435,7 @@ void AiL::ResetGame(){ player->ResetAccumulatedXP(); player->totalXPEarned=0; player->SetMoney(100U); - for(int i=0;iClearLoadoutItem(i); } Unlock::unlocks.clear(); @@ -3600,4 +3606,8 @@ void AiL::UpdateMonsters(){ MONSTER_LIST.push_back(m); } game->monstersToBeSpawned.clear(); +} + +int AiL::GetLoadoutSize()const{ + return loadout.size(); } \ No newline at end of file diff --git a/Adventures in Lestoria/AdventuresInLestoria.h b/Adventures in Lestoria/AdventuresInLestoria.h index b6c57d5e..5dfeb0ad 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.h +++ b/Adventures in Lestoria/AdventuresInLestoria.h @@ -268,6 +268,7 @@ public: void SetChapter(int chapter); const std::weak_ptrGetLoadoutItem(int slot); void SetLoadoutItem(int slot,std::string itemName); + int GetLoadoutSize()const; //Returns true if the item can be used (we have >0 of it) bool UseLoadoutItem(int slot); //Blanks out this loadout item. diff --git a/Adventures in Lestoria/DeathMenu.cpp b/Adventures in Lestoria/DeathMenu.cpp index 8f292e0e..eb3b22bb 100644 --- a/Adventures in Lestoria/DeathMenu.cpp +++ b/Adventures in Lestoria/DeathMenu.cpp @@ -50,6 +50,7 @@ void Menu::InitializeDeathWindow(){ deathWindow->ADD("Retry Button",MenuComponent)(geom2d::rect{{6.f,0.f},{84.f,24.f}},"Retry",[](MenuFuncData data){ Menu::CloseAllMenus(); + Inventory::GivePlayerLoadoutItemsUsed(); GameState::ChangeState(States::GAME_RUN); return true; },ButtonAttr::FIT_TO_LABEL)END; diff --git a/Adventures in Lestoria/Item.cpp b/Adventures in Lestoria/Item.cpp index d2fdd692..2289228c 100644 --- a/Adventures in Lestoria/Item.cpp +++ b/Adventures in Lestoria/Item.cpp @@ -61,6 +61,7 @@ std::shared_ptrItem::BLANK=std::make_shared(); std::multimap>Inventory::_inventory; std::vector>Inventory::blacksmithInventory; std::map>>Inventory::sortedInv; +std::array,3U>Inventory::loadoutItemsUsed; std::vectorItemOverlay::items; std::mapItemSet::sets; std::map>Inventory::equipment; @@ -1235,4 +1236,27 @@ uint16_t ItemSortRules::GetItemSortRanking(const std::weak_ptr&it){ uint16_t ItemSortRules::MaxSortRanking(){ return primarySort.size()*(secondarySort.size()+1)+secondarySort.size(); +} + +void Inventory::AddLoadoutItemUsed(IT item,int slot){ + if(slot<0||slot>game->GetLoadoutSize()-1)ERR(std::format("WARNING! Invalid loadout slot number {} provided! Range is (0-{})",slot,game->GetLoadoutSize()-1)); + loadoutItemsUsed[slot].first=item; + loadoutItemsUsed[slot].second++; +} + +void Inventory::ResetLoadoutItemsUsed(){ + for(int i=0;iGetLoadoutSize();i++){ + loadoutItemsUsed[i].first=""s; + loadoutItemsUsed[i].second=0; + } +} + +void Inventory::GivePlayerLoadoutItemsUsed(){ + for(int i=0;iGetLoadoutSize();i++){ + if(loadoutItemsUsed[i].second>0){ + Inventory::AddItem(loadoutItemsUsed[i].first,loadoutItemsUsed[i].second); + game->SetLoadoutItem(i,loadoutItemsUsed[i].first); + } + } + ResetLoadoutItemsUsed(); } \ No newline at end of file diff --git a/Adventures in Lestoria/Item.h b/Adventures in Lestoria/Item.h index 8cfafec8..a9b09d6e 100644 --- a/Adventures in Lestoria/Item.h +++ b/Adventures in Lestoria/Item.h @@ -261,6 +261,9 @@ public: //Gets all items currently on inventory (Ignores Stage Loot and Monster Loot Inventories) static const std::vector>GetInventory(); static void UpdateBlacksmithInventoryLists(); + static void AddLoadoutItemUsed(IT item,int slot); + static void ResetLoadoutItemsUsed(); + static void GivePlayerLoadoutItemsUsed(); 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! @@ -275,6 +278,7 @@ private: static std::multimap>_inventory; static std::vector>blacksmithInventory; static std::map>equipment; + static std::array,3U>loadoutItemsUsed; //Only contains "1" of every item, as this is a map to index items and not the actual storage of items! static std::map>>sortedInv; }; diff --git a/Adventures in Lestoria/TODO.txt b/Adventures in Lestoria/TODO.txt index 1cdd2a02..59c0d79e 100644 --- a/Adventures in Lestoria/TODO.txt +++ b/Adventures in Lestoria/TODO.txt @@ -2,11 +2,6 @@ February 28th -> Begin Internal Game Playtesting March 6th -> Discord/Friend Playtesting March 30th -> Public Demo Release - -- Add Death screen (Zoom in on fatal blow, slow time down... Display some game over text... Allow retry or return to world map.) - -- Track items used during a stage, on death, restore the loadout item quantities used. - - Mosaic transition on level load Add Bonus XP when completing a stage diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index ac368a96..e0cf076e 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 3 #define VERSION_PATCH 0 -#define VERSION_BUILD 7668 +#define VERSION_BUILD 7674 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx b/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx index 7a755b44..92c2d585 100644 --- a/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx @@ -1310,13 +1310,6 @@ - - - - - - - @@ -1338,13 +1331,6 @@ - - - - - - - @@ -1362,23 +1348,9 @@ - - - - - - - - - - - - - - diff --git a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx index 3f6a4166..362cf69a 100644 --- a/Adventures in Lestoria/assets/Campaigns/World_Map.tmx +++ b/Adventures in Lestoria/assets/Campaigns/World_Map.tmx @@ -679,6 +679,7 @@ + diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index 679bbf52..b53d058e 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ