Switch monster kill count tracking to use steam stats progress tracking. Release Build 8551.

mac-build
sigonasr2 8 months ago
parent e7c7504e6d
commit 047819d548
  1. 8
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 3
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 4
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  5. 8
      Adventures in Lestoria/SaveFile.cpp
  6. 3
      Adventures in Lestoria/State_MainMenu.cpp
  7. 54
      Adventures in Lestoria/SteamStatsReceivedHandler.cpp
  8. 47
      Adventures in Lestoria/SteamStatsReceivedHandler.h
  9. 24
      Adventures in Lestoria/TODO.txt
  10. 13
      Adventures in Lestoria/Unlock.cpp
  11. 3
      Adventures in Lestoria/Unlock.h
  12. 2
      Adventures in Lestoria/Version.h
  13. 2
      Adventures in Lestoria/assets/Campaigns/1_1_v2.tmx
  14. 2
      Adventures in Lestoria/assets/config/Achievements.txt
  15. BIN
      x64/Release/Adventures in Lestoria.exe

@ -523,6 +523,10 @@
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="SteamStatsReceivedHandler.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="steam\isteamapps.h" />
<ClInclude Include="steam\isteamappticket.h" />
<ClInclude Include="steam\isteamclient.h" />
@ -820,6 +824,10 @@
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="SteamStatsReceivedHandler.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="SwordSlash.cpp">
<SubType>
</SubType>

@ -998,6 +998,9 @@
<ClCompile Include="SteamKeyboardCallbackHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SteamStatsReceivedHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -80,6 +80,7 @@ All rights reserved.
#include "LoadingScreen.h"
#include "Tutorial.h"
#include "SteamKeyboardCallbackHandler.h"
#include "SteamStatsReceivedHandler.h"
INCLUDE_EMITTER_LIST
INCLUDE_ITEM_CATEGORIES
@ -337,6 +338,9 @@ bool AiL::OnUserCreate(){
if(steamKeyboardCallbackListener==nullptr){
steamKeyboardCallbackListener=new SteamKeyboardCallbackHandler();
}
if(steamStatsReceivedHandlerListener==nullptr){
steamStatsReceivedHandlerListener=new SteamStatsReceivedHandler();
}
#endif
utils::datafile::INITIAL_SETUP_COMPLETE=true;

@ -59,6 +59,7 @@ All rights reserved.
class SteamKeyboardCallbackHandler;
class SteamStatsReceivedHandler;
#define CreateBullet(type) BULLET_LIST.push_back(std::make_unique<type>(type
#define EndBullet ));
@ -189,6 +190,7 @@ private:
#endif
Audio audioEngine;
SteamKeyboardCallbackHandler*steamKeyboardCallbackListener=nullptr;
SteamStatsReceivedHandler*steamStatsReceivedHandlerListener=nullptr;
public:
AiL();
bool OnUserCreate() override;

@ -134,8 +134,6 @@ const void SaveFile::SaveGame(){
saveFile["Game Time"].SetReal(game->GetRuntime());
saveFile["TravelingMerchant"].SetString(std::string(Merchant::GetCurrentTravelingMerchant().GetKeyName()));
saveFile["Achievement"]["KillCount"].SetInt(Unlock::GetKillCount());
#pragma region Save Keyboard/Controller mappings
//NOTE: We are shadowing code from InputKeyboardWindow! If at some point the retrival method for getting input displays changes, we likely will be changing the code here as well!
//ALSO NOTE: The menu inputs are saved to the system file while gameplay inputs are per-character and saved to the character settings file!
@ -392,12 +390,6 @@ void SaveFile::LoadFile(){
}
}
#pragma region Achievement-related loading
if(loadFile.HasProperty("Achievement.KillCount")){
Unlock::SetKillCount(loadFile.GetProperty("Achievement.KillCount").GetInt());
}
#pragma endregion
GameState::ChangeState(States::OVERWORLD_MAP,0.5f);
}else{
LOG(std::format("WARNING! File {} does not exist for loading!","save_file_path"_S+std::format("save.{:04}",saveFileID)));

@ -42,6 +42,9 @@ All rights reserved.
#include "Key.h"
#include "ItemDrop.h"
#include "util.h"
#ifndef __EMSCRIPTEN__
#include <isteamuserstats.h>
#endif
INCLUDE_game

@ -0,0 +1,54 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "SteamStatsReceivedHandler.h"
#include "olcUTIL_DataFile.h"
#include "DEFINES.h"
#include "Unlock.h"
#include "config.h"
#include "Error.h"
INCLUDE_DATA
#ifndef __EMSCRIPTEN__
void SteamStatsReceivedHandler::SteamStatsReceived( UserStatsReceived_t* pCallback ){
if(pCallback->m_eResult==k_EResultOK){
SteamUserStats()->GetStat("Achievement.Kill Unlocks.Total Kill API Name"_S.c_str(),&Unlock::monsterKillCount);
LOG(std::format("Retried monster kill count: {}",Unlock::monsterKillCount));
}
}
#endif

@ -0,0 +1,47 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
#ifndef __EMSCRIPTEN__
#include "steam/steam_api.h"
#endif
#ifndef __EMSCRIPTEN__
class SteamStatsReceivedHandler{
STEAM_CALLBACK(SteamStatsReceivedHandler,SteamStatsReceived,UserStatsReceived_t);
};
#endif

@ -33,32 +33,8 @@ SetAchievement
File Hash on Save/Load.
Movement still possible when alt-tabbing
KILL_SLIME_1
KILL_SLIME_2
KILL_SLIME_3
CAMP_UNLOCK
BLACKSMITH_UNLOCK
CHAPTER1_COMPLETE
SLIME_KING
SLIME_KING_DESTROYER
URSULE
URSULE_DESTROYER
WARRIOR_LV5
RANGER_LV5
WIZARD_LV5
WEAPON_LV5
ARMOR_LV5
ARMOR_LV10
FULLY_DECKED_OUT
Include a Reset Achievements button in Settings
Enhancing can also trigger the "fully decked out" achievement
============================================
Consider a "killed by player" / "marked by player" flag for monsters to determine if a player gets credit for a monster kill (for achievements)
Make another actions config file for the main build (The app # is different)

@ -51,7 +51,6 @@ int Unlock::monsterKillCount=0;
void Unlock::Initialize(){
unlocks.clear();
monsterKillCount=0;
UnlockArea("WORLD_MAP");
}
@ -82,24 +81,16 @@ void Unlock::UnlockCurrentMap(){
void Unlock::IncreaseKillCount(){
monsterKillCount++;
if(SteamUserStats()){
SteamUserStats()->SetStat("Achievement.Kill Unlocks.Total Kill API Name"_S.c_str(),Unlock::monsterKillCount);
datafile&killUnlocks=DATA.GetProperty("Achievement.Kill Unlocks");
for(auto&[key,size]:killUnlocks){
if(key.starts_with("Kill Monsters")){
int killRequirement=killUnlocks[key]["Monster Kill Count"].GetInt();
if(monsterKillCount-1<killRequirement&& //These two checks make sure we're actually passing the kill requirement and not just over the kill requirement immediately.
if(monsterKillCount-1<killRequirement&& //These two checks make sure we've just reached the kill requirement, so we can send a more readily live update for the player.
monsterKillCount==killRequirement){
SteamUserStats()->SetAchievement(killUnlocks[key]["API Name"].GetString().c_str());
SteamUserStats()->StoreStats();
}
}
}
}
}
const int Unlock::GetKillCount(){
return monsterKillCount;
}
void Unlock::SetKillCount(int newKillCount){
monsterKillCount=newKillCount;
}

@ -43,10 +43,10 @@ All rights reserved.
class Unlock{
friend class AiL;
friend class SaveFile;
friend class SteamStatsReceivedHandler;
static std::set<std::string>unlocks;
static void Initialize();
static int monsterKillCount;
static void SetKillCount(int newKillCount);
public:
//Provide a map's actual name to trigger unlocks for all connected areas. You can get the current map you are on via State_OverworldMap::GetCurrentConnectionPoint().map
static void UnlockArea(std::string mapName);
@ -55,5 +55,4 @@ public:
static bool IsUnlocked(std::string mapName);
static bool IsUnlocked(ConnectionPoint&cp);
static void IncreaseKillCount();
static const int GetKillCount();
};

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 0
#define VERSION_PATCH 0
#define VERSION_BUILD 8548
#define VERSION_BUILD 8551
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="11" nextobjectid="393">
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="205" height="205" tilewidth="24" tileheight="24" infinite="0" backgroundcolor="#475500" nextlayerid="11" nextobjectid="507">
<properties>
<property name="Backdrop" propertytype="Backdrop" value="forest"/>
<property name="Background Music" propertytype="BGM" value="foresty1_1"/>

@ -21,6 +21,8 @@ Achievement
}
Kill Unlocks
{
Total Kill API Name = "MONSTER_KILL_COUNT"
# Achievements that start with "Kill Monsters" will be checked when a monster is killed.
Kill Monsters 1
{

Loading…
Cancel
Save