diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 32319e59..dfde1d5a 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -260,7 +260,7 @@ public: 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 30be4cfc..20fd8ddf 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 c804b087..e32582cf 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 a2154ab7..ddf34a58 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 abdc4f97..696c6d2e 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