steam_set_stat_avg_rate()


Game Maker Language リファレンス > 組み込み関数 用途別 > Steam API > steam_set_stat_avg_rate

steam_set_stat_avg_rate

statisticの平均値を設定します

構文

steam_set_stat_avg_rate(stat_name, session_count, session_length);
stat_name
statistic名(文字列)
session_count
平均値(実数)
session_length
The time that has been taken since the last time the stat was set (a real number).

戻り値

N/A
なし

説明

この関数は"sliding window"の効果でstatisticの平均を設定することを許可します "session_count"の値は、平均化したい現在の値で、"session_length"は関数の最後の呼び出し以来のゲーム時間の量です。 これがどのように使用されるかは、以下の例を参照してください。

平均のstat関数を理解するのは複雑ですので、以下に使用方法と例を説明します。 "1時間あたりに稼いだポイント"の平均のstatisticを追跡したいとします。 1つのアプローチとしては2つのstatを用意します。整数値の"トータルポイント数"と、float値の"トータルプレイ時間"を用意します。これにより、トータルポイント数をトータルプレイ時間で除算することで、"1時間あたりに稼いだポイント"を算出することができます

However, once the player has accumulated a significant amount of playtime, the calculated average will change extremely slowly, and the more the user plays the game, the less responsive that average will be. If the user has spent 100 hours playing the game, the calculated average will "lag" by about 50 hours of that, and if they increase their skill, they will not see the increase in "Points Per Hour" that they expect. To get around that we can use a "sliding window" to only calculate the "Points per hour" for the last 10 hours played.

So, to use this function, we would need to create a Steam stat (in the control panel for the game on the Workshop) called "AvgPointsPerHour" and set its Window property to 10. Now in your game you would have to add some global variables into an instance at the start:

global.Points = 0;
global.Time = 0;

You would then have some controller object to count up the global "Time" variable in an alarm (for example) every second, while your game-play would affect the global "Points" variable. At regular intervals while playing (again, in a controller object, perhaps in an Alarm, or at intervals from polling the "Time" value) you would set the stat like this: steam_set_stat_avg_rate("AvgPointsPerHour", global.Points, (global.Time / 3600));

global.Points = 0;
global.Time = 0;

Note that we divide time by 3600 since we want the time in hours and not in seconds, and afterward we reset the global "Points" variable and the global "Time" variable to 0 so that the next time the function is called, we get a new average for the statistic. Now, what Steam will do is take this value that you have sent and create an average value over the time that was set for our "window".

Wiki内検索

#search(): You already view a search box

MENU

ドキュメント

GMLリファレンス

2ch

その他



最新の30件

2024-03-07 2023-08-09 2023-05-21 2023-05-20 2023-05-04 2022-10-13 2022-07-21 2022-07-02 2022-04-06 2021-11-30 2021-11-26 2021-10-03 2021-09-23 2021-08-15 2021-06-02 2021-01-23 2021-01-21 2021-01-19 2021-01-18 2021-01-16 2021-01-15

人気の10件

今日の10件



これまでの訪問者: 709
今日の訪問者: 1
昨日の訪問者: 0
閲覧者: 3