From 58ae7e7b0dbd16db757cb8bf967148cf19b9cc35 Mon Sep 17 00:00:00 2001 From: Detanup01 <91248446+Detanup01@users.noreply.github.com> Date: Mon, 30 Sep 2024 09:45:44 +0200 Subject: [PATCH] updateing stat check for (progress - last_notified) >= min_diff setting min diff for float to 0.1 instead of 1 adding last_notified_progress into achievement_stat_trigger --- dll/dll/settings.h | 2 +- dll/dll/steam_user_stats.h | 1 + dll/steam_user_stats.cpp | 1 + dll/steam_user_stats_stats.cpp | 9 ++++++--- .../steam_settings.EXAMPLE/configs.main.EXAMPLE.ini | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 32319e591..dfde1d5ae 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -260,7 +260,7 @@ class Settings { bool save_only_higher_stat_achievement_progress = true; // Minimum value to indicate progress being made for the user. int stat_int_min_diff_progress = 1; - float stat_float_min_diff_progress = 1; + float stat_float_min_diff_progress = 0.1; // the emulator loads the achievements icons is memory mainly for `ISteamUserStats::GetAchievementIcon()` // this defines how many icons to load each iteration when the periodic callback in `Steam_User_Stats` is triggered // or when the app calls `SteamAPI_RunCallbacks()` diff --git a/dll/dll/steam_user_stats.h b/dll/dll/steam_user_stats.h index 30be4cfc3..20fd8ddf9 100644 --- a/dll/dll/steam_user_stats.h +++ b/dll/dll/steam_user_stats.h @@ -49,6 +49,7 @@ struct achievement_trigger { std::string value_operation{}; std::string min_value{}; // min progress std::string max_value{}; // max progress + std::string last_notified_progress{}; bool should_unlock_ach(float stat) const; bool should_unlock_ach(int32 stat) const; diff --git a/dll/steam_user_stats.cpp b/dll/steam_user_stats.cpp index c804b087a..e32582cf7 100644 --- a/dll/steam_user_stats.cpp +++ b/dll/steam_user_stats.cpp @@ -72,6 +72,7 @@ Steam_User_Stats::Steam_User_Stats(Settings *settings, class Networking *network std::string stat_name = common_helpers::ascii_to_lowercase(static_cast(it["progress"]["value"]["operand1"])); trig.min_value = static_cast(it["progress"]["min_val"]); trig.max_value = static_cast(it["progress"]["max_val"]); + trig.last_notified_progress = static_cast(it["progress"]["min_val"]); achievement_stat_trigger[stat_name].push_back(trig); } catch(...) {} diff --git a/dll/steam_user_stats_stats.cpp b/dll/steam_user_stats_stats.cpp index a2154ab7b..ddf34a587 100644 --- a/dll/steam_user_stats_stats.cpp +++ b/dll/steam_user_stats_stats.cpp @@ -127,9 +127,11 @@ Steam_User_Stats::InternalSetResult Steam_User_Stats::set_stat_internal( } } catch(...){} } - - if (indicate_progress && (stats_data->second.default_value_int + settings->stat_int_min_diff_progress) >= nData) { + // Alternative progress based on %: + // ((nData - std:stoi(t.last_notified_progress)) / std::stoi(t.max_value)) >= settings->stat_int_min_diff_progress_presentage + if (indicate_progress && (nData - std:stoi(t.last_notified_progress)) >= settings->stat_int_min_diff_progress) { IndicateAchievementProgress(t.name.c_str(), nData, std::stoi(t.max_value)); + t.last_notified_progress = std::to_string(nData); } } } @@ -202,8 +204,9 @@ Steam_User_Stats::InternalSetResultsecond.default_value_float + settings->stat_float_min_diff_progress) >= fData) { + if (indicate_progress && ((nData - std:stof(t.last_notified_progress)) >= settings->stat_float_min_diff_progress) { IndicateAchievementProgress(t.name.c_str(), (uint32)fData, (uint32)std::stof(t.max_value)); + t.last_notified_progress = std::to_string(nData); } } } diff --git a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini index abdc4f979..696c6d2e3 100644 --- a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini +++ b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini @@ -74,8 +74,8 @@ paginated_achievements_icons=10 # Usually good for achievement that use stat values and contains high number (ie: kill 200 cops) # default=1 stat_int_min_diff_progress=1 -# default=1 -stat_float_min_diff_progress=1 +# default=0.1 +stat_float_min_diff_progress=0.1 [main::connectivity] # 1=prevent hooking OS networking APIs and allow any external requests