Restore item loadout quantities on level restarts. Release Build 7674.

mac-build
sigonasr2 9 months ago
parent 78bc4585aa
commit e205fe9806
  1. 20
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 1
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 1
      Adventures in Lestoria/DeathMenu.cpp
  4. 24
      Adventures in Lestoria/Item.cpp
  5. 4
      Adventures in Lestoria/Item.h
  6. 5
      Adventures in Lestoria/TODO.txt
  7. 2
      Adventures in Lestoria/Version.h
  8. 28
      Adventures in Lestoria/assets/Campaigns/Intro_Map.tmx
  9. 1
      Adventures in Lestoria/assets/Campaigns/World_Map.tmx
  10. BIN
      x64/Release/Adventures in Lestoria.exe

@ -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_ptr<Item>AiL::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;i<loadout.size();i++){
for(int i=0;i<GetLoadoutSize();i++){
game->ClearLoadoutItem(i);
}
Unlock::unlocks.clear();
@ -3601,3 +3607,7 @@ void AiL::UpdateMonsters(){
}
game->monstersToBeSpawned.clear();
}
int AiL::GetLoadoutSize()const{
return loadout.size();
}

@ -268,6 +268,7 @@ public:
void SetChapter(int chapter);
const std::weak_ptr<Item>GetLoadoutItem(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.

@ -50,6 +50,7 @@ void Menu::InitializeDeathWindow(){
deathWindow->ADD("Retry Button",MenuComponent)(geom2d::rect<float>{{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;

@ -61,6 +61,7 @@ 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::array<std::pair<IT,int>,3U>Inventory::loadoutItemsUsed;
std::vector<ItemOverlay>ItemOverlay::items;
std::map<std::string,ItemSet>ItemSet::sets;
std::map<EquipSlot,std::weak_ptr<Item>>Inventory::equipment;
@ -1236,3 +1237,26 @@ uint16_t ItemSortRules::GetItemSortRanking(const std::weak_ptr<Item>&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;i<game->GetLoadoutSize();i++){
loadoutItemsUsed[i].first=""s;
loadoutItemsUsed[i].second=0;
}
}
void Inventory::GivePlayerLoadoutItemsUsed(){
for(int i=0;i<game->GetLoadoutSize();i++){
if(loadoutItemsUsed[i].second>0){
Inventory::AddItem(loadoutItemsUsed[i].first,loadoutItemsUsed[i].second);
game->SetLoadoutItem(i,loadoutItemsUsed[i].first);
}
}
ResetLoadoutItemsUsed();
}

@ -261,6 +261,9 @@ public:
//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 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<IT,std::shared_ptr<Item>>_inventory;
static std::vector<std::shared_ptr<Item>>blacksmithInventory;
static std::map<EquipSlot,std::weak_ptr<Item>>equipment;
static std::array<std::pair<IT,int>,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<ITCategory,std::vector<std::shared_ptr<Item>>>sortedInv;
};

@ -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

@ -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

@ -1310,13 +1310,6 @@
<object id="9" name="Spawn 15" type="SpawnGroup" x="2611" y="1915" width="1130" height="668">
<ellipse/>
</object>
<object id="10" name="Windhound" type="Monster" x="3142" y="2233">
<properties>
<property name="Type" propertytype="MonsterName" value="Windhound"/>
<property name="spawner" type="object" value="9"/>
</properties>
<point/>
</object>
<object id="11" name="Windhound" type="Monster" x="3260" y="2297.5">
<properties>
<property name="Type" propertytype="MonsterName" value="Windhound"/>
@ -1338,13 +1331,6 @@
</properties>
<point/>
</object>
<object id="14" name="Windhound" type="Monster" x="3021.5" y="2360">
<properties>
<property name="Type" propertytype="MonsterName" value="Windhound"/>
<property name="spawner" type="object" value="9"/>
</properties>
<point/>
</object>
<object id="15" name="Windhound" type="Monster" x="3108.5" y="2251.5">
<properties>
<property name="Type" propertytype="MonsterName" value="Windhound"/>
@ -1362,23 +1348,9 @@
</properties>
<point/>
</object>
<object id="23" name="Bear" type="Monster" x="2847" y="2232">
<properties>
<property name="Type" propertytype="MonsterName" value="Bear"/>
<property name="spawner" type="object" value="16"/>
</properties>
<point/>
</object>
<object id="24" name="Spawn 15" type="SpawnGroup" x="2638" y="1912" width="1072" height="664">
<ellipse/>
</object>
<object id="25" name="Bear" type="Monster" x="3471.5" y="2266.5">
<properties>
<property name="Type" propertytype="MonsterName" value="Bear"/>
<property name="spawner" type="object" value="24"/>
</properties>
<point/>
</object>
<object id="26" name="Bear" type="Monster" x="3570" y="2261">
<properties>
<property name="Type" propertytype="MonsterName" value="Bear"/>

@ -679,6 +679,7 @@
</object>
<object id="18" name="Boss B-I" type="StagePlate" x="192" y="516" width="32" height="24">
<properties>
<property name="Connection 1 - North" type="object" value="17"/>
<property name="Map" propertytype="Level" value="BOSS_1_B"/>
<property name="Type" propertytype="StageType" value="BOSS"/>
<property name="Unlock Condition" propertytype="Level" value="CAMPAIGN_1_B1"/>

Loading…
Cancel
Save