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 boring stuff
below for who/where.
Currently exposed data:
- Sorted Player data
- For each player: LatestCPTime, CPCount, Cached Previous CP Times, Spawn Status, Best Time, Best CP Times, Best Lap Times, Time Lost to Respawns (in total and per CP), NbRespawns, RoundPoints, Points, TeamNum, IsMVP, CurrentLap
- Sort methods
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-loss
- Knockout data (for COTD / KO)
- Per-Player Alive and DNF status
- Total Rounds, Current Round, Alive Players, Number of KOs This Round, Next KO Milestone, Number of Players (originally)
- The last record set by the current player
- Ghost Data
- Which ghosts have been loaded, the name of the ghost, and the ghost's checkpoint times.
- Matchmaking data
- Clan (Team) Scores, current MVP, Players Finished, Points Limit, Points Repartition, Ranking mode, Round Number, Round Winning Clan, Start of round indicators, Team Populations, Teams Unbalanced flag, Warm Up flag
- Points calculation given current points repartition and a finish order.
Additional data exposure available upon request.
Some plugins already using MLFeed:
- https://github.com/XertroV/tm-cotd-buffer-time/
- https://github.com/XertroV/tm-race-stats/
- https://github.com/XertroV/tm-list-players-pbs/
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_V4()
auto KoData = MLFeed::GetKoData()
auto GhostData = MLFeed::GetGhostData()
auto TeamsData = MLFeed::GetTeamsMMData_V1()
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_V4
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_V4();
auto player = RaceData.GetPlayer_V4(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/Export.as)
Exported classes (https://github.com/XertroV/tm-mlfeed-race-data/blob/master/src/ExportShared.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
The 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.
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.
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.
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.)
Object exposing info about the current Matchmaking Teams game. Includes warm up, team points, when new rounds begin, current MVP, players finished, and points prediction.
The current server's GameTime, or 0 if not in a server
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.
Get a player's info
The number of checkpoints each lap. Linked checkpoints are counted as 1 checkpoint, and goal waypoints are not counted.
The number of waypoints a player needs to hit to finish the race.
In single lap races, this is 1 more than .CPCount
.
The number of checkpoints each lap. Linked checkpoints are counted as 1 checkpoint, and goal waypoints are not counted.
The number of laps for this map.
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();
The map UID
An array of PlayerCpInfo_V2
s sorted by most checkpoints to fewest.
Note: cast to PlayerCpInfo_V4
to access new properties.
An array of PlayerCpInfo_V2
s sorted by most checkpoints to fewest, accounting for player respawns.
Note: cast to PlayerCpInfo_V4
to access new properties.
An array of PlayerCpInfo_V2
s sorted by best time to worst time.
Note: cast to PlayerCpInfo_V4
to access new properties.
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.
Return's the players CSmPlayer object if it is available, otherwise null. The full list of players is searched each time.
Formatted as: "PlayerCpInfo(name, rr: 17, tr: 3, cp: 5 (0:43.231), Spawned, bt: 0:55.992)"
this player's CP times for their best lap this session
this player's CP times for their best performance this session (since the map loaded)
The player's best time this session
How many CPs that player currently has
The CP times of that player (including the 0th cp at the 0th index; which will always be 0)
The player's current lap.
This player's CurrentRaceTime with latency taken into account
This player's CurrentRaceTime without accounting for latency
whether this player corresponds to the physical player playing the game
Whether the player is currently the MVP (for MM / Ranked)
Whether the player is spawned
Player's last CP time OR their last respawn time if it is greater
Player's last CP time as on their chronometer
the last checkpoint that the player respawned at
the last time this player respawned (measure against CurrentRaceTime)
get the last CP time of the player minus time lost to respawns
The player's Login (note: if you can, use WebServicesUserId instead)
The player's name
number of times the player has respawned
The points total of this player. Updated with +RoundPoints on EndRound UI sequence (before RoundPoints is reset).
The player's rank as measured in a race (when all players would spawn at the same time).
The player's rank as measured in a race (when all players would spawn at the same time), accounting for respawns.
The points the player earned this round. Reset on Playing UI sequence.
The spawn index when the player spawned
The players's spawn status: NotSpawned, Spawning, or Spawned
when the player spawned (measured against GameTime)
The player's rank as measured in Time Attack (one more than their index in RaceData.SortedPlayers_TimeAttack
)
The team the player is on. 1 = Blue, 2 = Red.
get the current race time of this player minus time lost to respawns
The time lost due to respawning at each CP
the amount of time the player has lost due to respawns in total since the start of their current race/attempt
The player's WebServicesUserId
an estimate of the latency in ms between when a player passes a checkpoint and when we learn about it
The spawn status of a player.
NotSpawned
Spawning
Spawned
Main source of information about KO rounds.
Proxy for the internal type KoFeed::HookKoStatsEvents
.
Get a player's MLFeed::KoPlayerState.
It has only 3 properties: name
, isAlive
, and isDNF
.
The current division number. (Note: possibly inaccurate. Use with caution.)
The current game mode, e.g., TM_KnockoutDaily_Online
, or TM_TimeAttack_Online
, etc.
KOs per round will change when the number of players is <= KOsMilestone.
KOs per round.
The current map UID
The current round number for this map.
The total number of rounds for this map.
A string[]
of player names. It includes all players in the KO round, even if they've left.
The number of players participating.
The round number over all maps. (I think)
The total number of rounds over all maps. (I think)
A player's state in a KO match
Whether the player is still 'in'; false
implies they have been knocked out.
Whether the player DNF'd or not. This is set to false the round after that player DNFs.
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.
Array of GhostInfo_V2s
Number of currently loaded ghosts
Information about a currently loaded ghost.
Ghost.Result.Checkpoints
Ghost.IdName
Should be equiv to Ghost.Id.Value (experimental)
Whether this is the local player (sitting at this computer)
Whether this is a PB ghost (named: 'Personal best')
Ghost.Nickname
Ghost.Result.Score
Ghost.Result.Time
Info about MM: game state, team points, player points (this round and total), current MVP
ComputePoints -- void ComputePoints(const int[]@ finishedTeamOrder, int[]@ points, int[]@ teamPoints) const
Pass in a list of player.TeamNum for a finishing order, and 2 arrays that will be written to: the first will contain the points earned by each player for their team, the second contains the total points for each team (length 3).
Usage: teamPoints[player.TeamNum]
Implementation reference: ComputeLatestRaceScores
in Titles/Trackmania/Scripts/Libs/Nadeo/ModeLibs/TrackMania/Teams/TeamsCommon.Script.txt
Rounds won by team. Updated each round as soon as the last player despawns. Blue at index 1, Red at index 2. Length: 31.
Current MVP's account id. Updated with scores.
Current MVP's name. Updated with scores.
The last game time that a player finished and the corresponding lists were updated.
Player logins in finishing order. Updated when a player finishes and at the start of the race.
Player names in finishing order. Updated when a player finishes and at the start of the race.
A team wins when they reach this many points. Set after warmup.
The points available for each position, set after warmup and updated at the start of the next race (after a player leaves).
Ranking mode used. 0 = BestRace, 1 = CurrentRace. (MM uses 1)
The current round. Incremented at the completion of each round. (RoundNumber will end +1 more than StartNewRace.)
set to -1 on race start, and set to 1 or 2 at end of race indicating the winning team. 0 = draw.
Increments each race as a flag to reset state. 0 during warmup. 1 during first round, etc.
The number of players on each team. Length is always 31.
Whether the populations of the teams is unequal.
True when the warmup is active.