- Add
.RequestsSpectate
on player - Add
.WarmupActive
and.WarmupEndTime
on RaceData
Downloads | 47,839 |
---|---|
Updated | 6 months ago |
Released | 2 years ago |
Created | 2 years ago |
Numeric ID | 255 |
Min. Openplanet | 1.26.0 |
This plugin provides other plugins with data about the current race. You might need to install it to make other plugins work.
Requires MLHook (you need to install that plugin too)
Please report performance issues! See bottom of page for who/where.
Currently exposed data:
TimeAttack
: sort by best timeRace
: sorted by race leaderRace_Respawns
: sorted by race leader, but updates ranking immediately when a player respawns to account for time-lossAdditional data exposure available upon request.
Some plugins already using MLFeed:
Include this in your info.toml
file:
[script]
dependencies = ["MLHook", "MLFeedRaceData"] # need both
see also: https://openplanet.dev/docs/reference/info-toml
Note: it is recommended that you use the Openplanet VSCode extension which will provide autocompletion and documentation for you when using MLFeed.
Several feeds are available that provide different information. The functions that provide the feeds are:
auto RaceData = MLFeed::GetRaceData_V2()
auto KoData = MLFeed::GetKoData()
auto GhostData = MLFeed::GetGhostData()
Full docs are below.
See the upgrade guide: https://github.com/XertroV/tm-mlfeed-race-data/blob/master/UPGRADE_v0.4.md
Main type: HookRaceStatsEventsBase_V2
Example usage: doing something on player respawn.
uint lastRespawnCount = 0;
void Update(float dt) {
if (GetApp().CurrentPlayground is null) return;
// Get race data and the local player
auto RaceData = MLFeed::GetRaceData_V2();
auto player = RaceData.GetPlayer_V2(MLFeed::LocalPlayersName);
if (player is null) return;
// check for respawns
if (player.NbRespawnsRequested != lastRespawnCount) {
lastRespawnCount = player.NbRespawnsRequested;
if (lastRespawnCount != 0) {
startnew(OnPlayerRespawn);
}
}
}
void OnPlayerRespawn() {
// do stuff
}
Docs at end
The Demo UIs available in (openplanet's) developer mode (via Scripts
menu) & associated source code in the repo.
Exported functions (https://github.com/XertroV/tm-mlfeed-race-data/blob/master/src/MLFeed_Export.as)
Example Usage - COTD Buffer Time
Example Optional Usage - List Players' PBs
Still curious about how to use something? Read the examples and use github search to find usages! Still not sure? Ask @XertroV on the Openplanet Discord
License: Public Domain
Authors: XertroV
Suggestions/feedback: @XertroV on Openplanet discord
Code/issues: https://github.com/XertroV/tm-mlfeed-race-data
GL HF
MLFeed::
DocsThe main exposed functions will get you the feeds.
Those then give you access data to each player/ghost.
Functions, properties, and types are exposed under the MLFeed::
namespace.
const SharedGhostDataHook_V2@ GetGhostData()
Object exposing GhostInfos for each loaded ghost. This includes record ghosts loaded through the UI, and personal best ghosts. When a ghost is unloaded from a map, its info is not removed (it remains cached). Therefore, duplicate ghost infos may be recorded (though measures are taken to prevent this). The list is cleared on map change.
const KoDataProxy@ GetKoData()
Your plugin's KoDataProxy@
that exposes KO round information, and each player's spawn info, and lists of players for each sorting method.
You can call this function as often as you like -- it will always return the same proxy instance based on plugin ID.
const HookRaceStatsEventsBase_V2@ GetRaceData_V2()
const HookRaceStatsEventsBase_V3@ GetRaceData_V3()
Exposes checkpoint data, spawn info, and lists of players for each sorting method. You can call this function as often as you like. Backwards compatible with RaceDataProxy (except that it's a different type; properties/methods are the same, though.)
uint GameTime
The current server's GameTime, or 0 if not in a server
const string LocalPlayersName
returns the name of the local player, or an empty string if this is not yet known
The main class used to access race data. It exposes 3 sorted lists of players, and general information about the map/race.
const PlayerCpInfo_V2@ GetPlayer_V2(const string &in name) const
const PlayerCpInfo_V3@ GetPlayer_V3(const string &in name) const
Get a player's info
uint CPCount
The number of checkpoints each lap. Linked checkpoints are counted as 1 checkpoint, and goal waypoints are not counted.
uint CPsToFinish
The number of waypoints a player needs to hit to finish the race.
In single lap races, this is 1 more than .CPCount
.
uint CpCount
The number of checkpoints each lap. Linked checkpoints are counted as 1 checkpoint, and goal waypoints are not counted.
uint LapCount
The number of laps for this map.
int LastRecordTime
When the player sets a new personal best, this is set to that time.
Reset to -1 at the start of each map.
Usage: if (lastRecordTime != RaceData.LastRecordTime) OnNewRecord();
const string Map
The map UID
const array<PlayerCpInfo_V2>@ SortedPlayers_Race
An array of PlayerCpInfo_V2
s sorted by most checkpoints to fewest.
Note: cast to PlayerCpInfo_V3
to access BestLapTimes
.
const array<PlayerCpInfo_V2>@ SortedPlayers_Race_Respawns
An array of PlayerCpInfo_V2
s sorted by most checkpoints to fewest, accounting for player respawns.
Note: cast to PlayerCpInfo_V3
to access BestLapTimes
.
const array<PlayerCpInfo_V2>@ SortedPlayers_TimeAttack
An array of PlayerCpInfo_V2
s sorted by best time to worst time.
Note: cast to PlayerCpInfo_V3
to access BestLapTimes
.
uint SpawnCounter
This increments by 1 each frame a player spawns. When players spawn simultaneously, their PlayerCpInfo.spawnIndex values are the same. This is useful for some sorting methods. This value is set to 0 on plugin load and never reset.
Each's players status in the race, with a focus on CP related info.
string ToString() const
Formatted as: "PlayerCpInfo(name, rr: 17, tr: 3, cp: 5 (0:43.231), Spawned, bt: 0:55.992)"
const array<uint>@ BestLapTimes
this player's CP times for their best lap this session
const array<uint>@ BestRaceTimes
this player's CP times for their best performance this session (since the map loaded)
int BestTime
The player's best time this session
int CpCount
How many CPs that player currently has
const array<int>@ CpTimes
The CP times of that player (including the 0th cp at the 0th index; which will always be 0)
int CurrentRaceTime
This player's CurrentRaceTime with latency taken into account
int CurrentRaceTimeRaw
This player's CurrentRaceTime without accounting for latency
bool IsLocalPlayer
whether this player corresponds to the physical player playing the game
bool IsSpawned
Whether the player is spawned
int LastCpOrRespawnTime
Player's last CP time OR their last respawn time if it is greater
int LastCpTime
Player's last CP time as on their chronometer
uint LastRespawnCheckpoint
the last checkpoint that the player respawned at
uint LastRespawnRaceTime
the last time this player respawned (measure against CurrentRaceTime)
int LastTheoreticalCpTime
get the last CP time of the player minus time lost to respawns
const string Name
The player's name
uint NbRespawnsRequested
number of times the player has respawned
uint RaceRank
The player's rank as measured in a race (when all players would spawn at the same time).
uint RaceRespawnRank
The player's rank as measured in a race (when all players would spawn at the same time), accounting for respawns.
uint SpawnIndex
The spawn index when the player spawned
SpawnStatus SpawnStatus
The players's spawn status: NotSpawned, Spawning, or Spawned
uint StartTime
when the player spawned (measured against GameTime)
uint TaRank
The player's rank as measured in Time Attack (one more than their index in RaceData.SortedPlayers_TimeAttack
)
int TheoreticalRaceTime
get the current race time of this player minus time lost to respawns
const array<int>@ TimeLostToRespawnByCp
The time lost due to respawning at each CP
uint TimeLostToRespawns
the amount of time the player has lost due to respawns in total since the start of their current race/attempt
float latencyEstimate
an estimate of the latency in ms between when a player passes a checkpoint and when we learn about it
string name
The player's name
The spawn status of a player.
NotSpawned
Spawning
Spawned
Main source of information about KO rounds.
Proxy for the internal type KoFeed::HookKoStatsEvents
.
const KoPlayerState@ GetPlayerState(const string &in name) const
Get a player's MLFeed::KoPlayerState.
It has only 3 properties: name
, isAlive
, and isDNF
.
int Division
The current division number. (Note: possibly inaccurate. Use with caution.)
const string GameMode
The current game mode, e.g., TM_KnockoutDaily_Online
, or TM_TimeAttack_Online
, etc.
int KOsMilestone
KOs per round will change when the number of players is <= KOsMilestone.
int KOsNumber
KOs per round.
const string Map
The current map UID
int MapRoundNb
The current round number for this map.
int MapRoundTotal
The total number of rounds for this map.
const array<string> Players
A string[]
of player names. It includes all players in the KO round, even if they've left.
int PlayersNb
The number of players participating.
int RoundNb
The round number over all maps. (I think)
int RoundTotal
The total number of rounds over all maps. (I think)
A player's state in a KO match
bool isAlive
Whether the player is still 'in'; false
implies they have been knocked out.
bool isDNF
Whether the player DNF'd or not. This is set to false the round after that player DNFs.
string name
The player's name.
Provides access to ghost info. This includes record ghosts loaded through the UI, and personal best ghosts. When a ghost is unloaded from a map, its info is not removed (it remains cached). Therefore, duplicate ghost infos may be recorded (though measures are taken to prevent this). V2 adds .IsLocalPlayer and .IsPersonalBest properties to GhostInfo objects.
const array<MLFeed::GhostInfo_V2> Ghosts_V2
Array of GhostInfo_V2s
uint NbGhosts
Number of currently loaded ghosts
Information about a currently loaded ghost.
const array<uint>@ Checkpoints
Ghost.Result.Checkpoints
const string IdName
Ghost.IdName
uint IdUint
Should be equiv to Ghost.Id.Value (experimental)
bool IsLocalPlayer
Whether this is the local player (sitting at this computer)
bool IsPersonalBest
Whether this is a PB ghost (named: 'Personal best')
const string Nickname
Ghost.Nickname
int Result_Score
Ghost.Result.Score
int Result_Time
Ghost.Result.Time
.RequestsSpectate
on player.WarmupActive
and .WarmupEndTime
on RaceDataadd to Player class:
uint[]@ NbRespawnsByCp
a count of respawns by CPuint[]@ RespawnTimes
array of the players respawn timesbool PlayerIsRacing
if the player is spawned and has not finishedbool Eliminated
if the player is not spawned and has not finished (indicates a DNF on teams, KO, etc)