Handle multiple connection points with the same map names all being handled correctly when dealing with visit notifications. Release Build 11361. Prepare framework for Artificer unlocks.

pull/65/head
sigonasr2 3 months ago
parent e0d58aef04
commit 517f81c03f
  1. 8
      Adventures in Lestoria/ArtificerWindow.cpp
  2. 2
      Adventures in Lestoria/ConnectionPoint.cpp
  3. 6
      Adventures in Lestoria/NPC.cpp
  4. 18
      Adventures in Lestoria/SaveFile.cpp
  5. 17
      Adventures in Lestoria/State_OverworldMap.cpp
  6. 3
      Adventures in Lestoria/State_OverworldMap.h
  7. 9
      Adventures in Lestoria/Unlock.cpp
  8. 2
      Adventures in Lestoria/Version.h
  9. 4
      Adventures in Lestoria/VisualNovel.cpp
  10. 2
      Adventures in Lestoria/assets/config/NPCs.txt
  11. BIN
      x64/Release/Adventures in Lestoria.exe

@ -49,12 +49,12 @@ INCLUDE_game
void Menu::InitializeArtificerWindow(){
Menu*artificerWindow=CreateMenu(ARTIFICER,CENTERED,vi2d{144,144});
artificerWindow->ADD("Refine Button",MenuComponent)(geom2d::rect<float>{{0.f,4.f},{144.f,24.f}},"Refine",[](MenuFuncData data){
Menu::OpenMenu(MenuType::ARTIFICER_REFINE);
artificerWindow->ADD("Disassemble Button",MenuComponent)(geom2d::rect<float>{{0.f,4.f},{144.f,24.f}},"Disassemble",[](MenuFuncData data){
Menu::OpenMenu(MenuType::ARTIFICER_DISASSEMBLE);
return true;
},vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END;
artificerWindow->ADD("Disassemble Button",MenuComponent)(geom2d::rect<float>{{0.f,32.f},{144.f,24.f}},"Disassemble",[](MenuFuncData data){
Menu::OpenMenu(MenuType::ARTIFICER_DISASSEMBLE);
artificerWindow->ADD("Refine Button",MenuComponent)(geom2d::rect<float>{{0.f,32.f},{144.f,24.f}},"Refine",[](MenuFuncData data){
Menu::OpenMenu(MenuType::ARTIFICER_REFINE);
return true;
},vf2d{2.f,2.f},ButtonAttr::FIT_TO_LABEL)END;
artificerWindow->ADD("Enchant Button",MenuComponent)(geom2d::rect<float>{{0.f,60.f},{144.f,24.f}},"Enchant",[](MenuFuncData data){

@ -55,6 +55,6 @@ void ConnectionPoint::ResetVisitedFlag(){
visited=false;
}
const bool ConnectionPoint::Visited()const{
[[nodiscard]]const bool ConnectionPoint::Visited()const{
return visited;
}

@ -91,6 +91,12 @@ void Monster::STRATEGY::NPC(Monster&m,float fElapsedTime,std::string strategy){
VisualNovel::LoadDialog("ARTIFICER_INTRO",[](){Menu::OpenMenu(MenuType::ARTIFICER);});
}else{
Menu::OpenMenu(MenuType::ARTIFICER);
bool locked=!Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S);
std::string enchantButtonLabel="Enchant";
if(locked)enchantButtonLabel="???";
Component<MenuComponent>(ARTIFICER,"Enchant Button")->SetGrayedOut(locked);
Component<MenuComponent>(ARTIFICER,"Enchant Button")->SetLabel(enchantButtonLabel);
}
}
}

@ -126,9 +126,16 @@ const void SaveFile::SaveGame(){
if(unlockName=="WORLD_MAP")continue; //This is a special exception, because the world map is not an actual stage.
saveFile["Unlocks"][unlockName].SetString("True");
auto opt_cp=State_OverworldMap::ConnectionPointFromString(unlockName);
if(!opt_cp.has_value())continue; //Harmless, we probably just deleted the map.
if(opt_cp.value()->Visited()){
auto cps=State_OverworldMap::ConnectionPointsFromString(unlockName);
if(cps.empty())continue; //Harmless, we probably just deleted the map.
bool visited{false};
for(const ConnectionPoint&cp:cps){
if(cp.Visited()){
visited=true;
break;
}
}
if(visited){
saveFile["Unlocks"][unlockName].SetString("True",1U);
}else{
saveFile["Unlocks"][unlockName].SetString("False",1U);
@ -412,9 +419,8 @@ void SaveFile::LoadFile(){
for(const auto&[key,data]:loadFile["Unlocks"].GetOrderedKeys()){
Unlock::UnlockArea(key);
if(data.GetValueCount()>1&&data.GetBool(1U)){
auto opt_cp=State_OverworldMap::ConnectionPointFromString(key);
if(!opt_cp)continue; //Harmless, it just means the connection point used to exist and doesn't anymore.
else opt_cp.value()->SetVisited();
auto cps=State_OverworldMap::ConnectionPointsFromString(key);
for(ConnectionPoint&cp:cps)cp.SetVisited();
}
}
}

@ -253,7 +253,8 @@ ConnectionPoint&State_OverworldMap::GetCurrentConnectionPoint(){
void State_OverworldMap::StartLevel(){
game->UpdateDiscordStatus(State_OverworldMap::GetCurrentConnectionPoint().name,game->GetPlayer()->GetClassName());
SaveFile::SaveGame();
State_OverworldMap::GetCurrentConnectionPoint().SetVisited();
auto connectionPoints{State_OverworldMap::ConnectionPointsFromString(State_OverworldMap::GetCurrentConnectionPoint().map)};
for(ConnectionPoint&cp:connectionPoints)cp.SetVisited();
if(State_OverworldMap::GetCurrentConnectionPoint().type.starts_with("STORY")){
VisualNovel::LoadVisualNovel(State_OverworldMap::GetCurrentConnectionPoint().map);
}else
@ -277,10 +278,16 @@ void State_OverworldMap::UpdateCurrentConnectionPoint(const ConnectionPoint&conn
}
}
std::optional<ConnectionPoint*>State_OverworldMap::ConnectionPointFromString(std::string_view mapName){
auto foundItem=std::find_if(connections.begin(),connections.end(),[&](ConnectionPoint&cp){return cp.map==mapName;});
if(foundItem!=connections.end())return &*foundItem;
return {};
std::vector<std::reference_wrapper<ConnectionPoint>>State_OverworldMap::ConnectionPointsFromString(std::string_view mapName){
std::vector<std::reference_wrapper<ConnectionPoint>>matchedConnections;
std::copy_if(connections.begin(),connections.end(),std::back_inserter(matchedConnections),[&mapName](const ConnectionPoint&cp){return cp.map==mapName;});
return matchedConnections;
}
void State_OverworldMap::ResetConnectionPointsWithMapName(std::string_view mapName){
auto matchedConnectionPoints{State_OverworldMap::ConnectionPointsFromString(mapName)};
if(matchedConnectionPoints.size()==0)ERR(std::format("WARNING! Could not find any connection points with name {} for resetting! THIS SHOULD NOT BE HAPPENING!",mapName));
for(ConnectionPoint&cp:matchedConnectionPoints)cp.ResetVisitedFlag();
}
void State_OverworldMap::ResetConnectionPoints(){

@ -56,7 +56,8 @@ public:
static bool HasStageMarker(std::string connectionName);
static void SetStageMarker(std::string connectionName);
static ConnectionPoint&ConnectionPointFromIndex(int ind);
static std::optional<ConnectionPoint*>ConnectionPointFromString(std::string_view mapName);
static std::vector<std::reference_wrapper<ConnectionPoint>>ConnectionPointsFromString(std::string_view mapName);
static void ResetConnectionPointsWithMapName(std::string_view mapName);
static void ResetConnectionPoints();
virtual void OnStateChange(GameState*prevState)override final;
virtual void OnUserUpdate(AiL*game)override final;

@ -57,7 +57,14 @@ void Unlock::Initialize(){
void Unlock::UnlockArea(std::string mapName){
if(mapName=="NPCs.Sherman.Potion Crafting Unlock Condition"_S&& //When we beat the bonus chapter 1 fight, before sherman's potion crafting is unlocked, if the current map we just unlocked for is the bonus boss stage we will notify the Hub connection point and reset it so the player has a notification to go there again.
!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag();
!Unlock::IsUnlocked("NPCs.Sherman.Potion Crafting Unlock Condition"_S)||
mapName=="NPCs.Artificer.Enchant Crafting Unlock Condition"_S&& //When we beat the bonus chapter 2 fight, set the hub with a notification again.
!Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S)||
mapName=="NPCs.Artificer.Enchant Crafting Unlock Condition"_S&& //When we beat the bonus chapter 3 fight, set the hub with a notification again.
!Unlock::IsUnlocked("NPCs.Artificer.Enchant Crafting Unlock Condition"_S)
){
State_OverworldMap::ResetConnectionPointsWithMapName("HUB");
}
STEAMUSERSTATS(
datafile&areaUnlocks=DATA.GetProperty("Achievement.Area Unlocks");
for(auto&[key,size]:areaUnlocks){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 5
#define VERSION_BUILD 11357
#define VERSION_BUILD 11361
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -243,7 +243,9 @@ void VisualNovel::ExecuteNextCommand(){
dialogFinishedCallbackFunc();
}else{
if(game->GetCurrentMapName()=="NPCs.Greg.Camp Notification Unlock Condition"_S&&
!Unlock::IsUnlocked("NPCs.Greg.Camp Notification Unlock Condition"_S))State_OverworldMap::ConnectionPointFromString("HUB").value()->ResetVisitedFlag();
!Unlock::IsUnlocked("NPCs.Greg.Camp Notification Unlock Condition"_S)){
State_OverworldMap::ResetConnectionPointsWithMapName("HUB");
}
Unlock::UnlockCurrentMap();
Menu::themeSelection=novel.prevTheme;
GameState::ChangeState(States::OVERWORLD_MAP,0.5f);

@ -83,6 +83,8 @@ NPCs
{
Strategy = NPC
Enchant Crafting Unlock Condition = BOSS_3_B
#Size of each animation frame
SheetFrameSize = 24,24

Loading…
Cancel
Save