Repository navigation
feature: Player Management counts detailed community stats and per weapon totals - #286
Merged
Merged
Conversation
…e map, so the panel can keep a map's last kills on that map The roster sends the counts it had when a map ended in a sync of its own, before it holds through the map change, and every sync names the map. A map-end report the panel misses is sent again, and given up after the hold cap so it cannot hold up the reports after it. Panels that predate per-map sessions ignore the map.
…nd the map is read from the map load event A roster that changed over the map change differed from the pending report on every poll, so each poll became a sync until the report was taken. The map name now comes with SwiftlyS2's map load event, and a plugin only asks the engine for it on a hot reload, where it has missed that event and the engine has a map to answer with.
…and MVPs for the community stats Each connection now keeps running totals of assists, headshots, damage, rounds played, rounds won and MVPs next to its kills and deaths, and sends them on the roster and with every departure. Flash assists, team damage and warmup rounds do not count, a headshot only counts with a counted kill, and a lethal hit is credited only with the health the victim had left. Panels that predate the counters ignore them.
Kills, deaths, assists, headshots, damage and MVPs are now dropped while the game rules say warmup is on, the same way warmup rounds already were. The flag is read at each event, so it holds however long warmup runs and however it ends; a server without warmup counts everything.
…rades, objectives, the best killstreak and per weapon totals for the community stats Each connection now keeps 33 detailed counters, its best killstreak and per weapon totals (kills, headshots, shots, hits and damage) next to the counters it already had, reset with a new connection like those, and sends them as `stats` and `weapons` on every roster and departed entry. Zeros are left out and an empty map is not sent at all, so panels that predate the detailed stats see the report as before. The counters take the match stats' names and rules: shots are firearms only, a shotgun's pellets are one hit per victim and tick, a flash counts when it blinds an enemy for more than a second, a trade is the kill of a teammate's killer within 5 s in the same round, and utility damage is capped at the health the victim had. Every knife is one knife and a silenced gun is one gun with its silencer on or off. Nothing done in warmup counts, as before. Both plugins pass the kill facts on player_death and the weapon, hitgroup and tick on player_hurt, and hook weapon_fire, player_blind, bomb_planted, bomb_defused, hostage_rescued and round_start.
…, a shot that hits a bot is taken back, and a shared class gun is named by the gun in hand On a server with humans and bots, nothing a bot does counts and nothing done to a bot does: a bot's kill ends the victim's killstreak but is no death, helping a bot to a kill is no assist, and hits, damage and kills on a bot count for nobody. Everything between humans still counts, since each event names both players. A miss names no target, so a shot is still counted when fired and taken back when its bullet hits a bot, unless the same shot also hits a human enemy in that tick. player_hurt names a USP-S hkp2000, so a gun built on another's class had its hits and damage under the other gun's name. Hits and kills now read the gun in hand for those five names (M4A1-S, USP-S, CZ75, R8 and MP5-SD), as shots already did, and all three take it only when it is the event's gun or the one on its class, so a player who switched guns since keeps the event's name.
…end report, and a kill during the hold stays out of it
…r had, read off the pawn every second
…ts once its freeze time ends outside warmup
… next round's start, so a second round end before then adds nothing
…cks the new map's roster, not the snapshot taken at the map's end
…oo, so it closes the round's MVP like any other
… into up/community-detailed-stats # Conflicts: # apps/player-management-css/src/PlayerManagement.csproj # apps/player-management-css/src/PlayerManagementPlugin.cs # apps/player-management-sw/src/PlayerManagement.csproj # apps/player-management-sw/src/PlayerManagementPlugin.cs # apps/player-management-sw/test/FiveStack.Tests.csproj # shared/dotnet/FiveStack.Utilities/PlayerRoster.cs
Contributor
|
thanks @Flegma, the api stack is merged (#883 #885 #886 #891 #968). #281 and the web PRs go in once the api is live. left on the game-server side before #282 and #286 can go in:
|
…e-counters # Conflicts: # apps/player-management-css/src/PlayerManagementPlugin.cs # apps/player-management-sw/src/PlayerManagementPlugin.cs # apps/player-management-sw/test/PlayerRosterTests.cs # shared/dotnet/FiveStack.Utilities/PlayerRoster.cs
… side they spawned on, so sitting on a side or joining the winning one farms no rounds
… rules are looked up once a map rather than on every shot
…they claim, and leaving a side or the game restarting forgets it
…ailure in the rest of it leaves it current
…iled-stats # Conflicts: # apps/player-management-css/src/PlayerManagementPlugin.cs # apps/player-management-sw/src/PlayerManagementPlugin.cs
Collaborator
Author
|
thanks, all three code items are pushed:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Player Management counts the detailed community stats that 5stackgg/api#968 stores. Stacked on #282, which is stacked on #281: merge #281 and #282 first, then this PR shows only its own two commits.
The first commit adds the counters and the per weapon totals. The second makes them hold on servers that mix humans and bots, and names a gun built on another gun's class by the gun in hand. Everything is in Player Management, which only community servers load, and in the shared roster code compiled into it. The match plugin and the match stats are untouched.
What the plugin sends
Each roster entry and each departed entry gains two optional objects next to the counters from #282:
stats: running totals for the connection by key, the 33 counters below plusbest_streak, the best killstreak on the current map (a maximum, not a sum).weapons: running totals per weapon by weapon name, each withkills,headshots,shots,hitsanddamage.Like kills and deaths, both start empty with a new connection and stay with a departed entry. Zeros are left out, a weapon whose totals are all zero is left out, and an empty object is not sent at all, so a player who has done nothing sends exactly what #282 sends. An entry excerpt:
Weapon names are the ones the match stats keep in
player_kills."with": the event's weapon without itsweapon_prefix, in lower case, with every knife and the bayonet asknife, and a silenced gun with its silencer off (m4a1_silencer_off,usp_silencer_off) under the same name as with it on. Shots and hits are counted for the 34 CS2 guns only (CommunityWeapons, by item definition index); kills and damage for any weapon, soknife,taser,hegrenadeandinfernoget kills and damage but no shots. A connection keeps at most 48 weapons; a weapon beyond that still counts instats, only not per weapon.No plugin version bump and no new convars: the api reads the new data by its keys.
How each counter is decided
The counters take the match stats' names and rules. Only events between humans count (see Bots), and nothing in warmup counts, as in #282 (the game rules'
WarmupPeriodat the event). An enemy is a player on the other side, or anyone wheremp_teammates_are_enemiesis on. Team stats count only where teammates are not enemies.shots: aweapon_fireof a firearm by a human. A knife swing or a grenade throw is no shot. A shot whose bullet hits a bot is taken back (see Bots).hits, and by hitgrouphits_head,hits_neck,hits_chest,hits_stomach,hits_left_arm,hits_right_arm,hits_left_leg,hits_right_leg: a firearm hit on an enemy, once per attacker, victim and tick, so a shotgun's pellets in one victim are one hit, as the match stats count hits (shots that hit). Hitgroups are CS2's numbers (1 head, 2 chest, 3 stomach, 4 and 5 the arms, 6 and 7 the legs, 8 the neck); a generic (0) or gear (10) hit is a hit with no group.damage_taken: the damage an enemy dealt the player.team_damage: the damage a human deals a human who is not an enemy, themselves included (their own grenade), as on the match side.he_damageandmolotov_damage: enemy damage byhegrenade, and byinfernoormolotov. All damage is capped at the health the victim had, asdamagein feature: Player Management counts assists, headshots, damage, rounds and MVPs for the community stats #282 is.flash_assists:assistedflashonplayer_deathwith the assister an enemy of the victim. Such an assist does not also count inassists, as in feature: Player Management counts assists, headshots, damage, rounds and MVPs for the community stats #282.enemies_flashedandflash_duration_ms: aplayer_blindlonger than 1.0 s on a live enemy, and that blind time in milliseconds.team_flashed: the same on a teammate or on oneself. A spectator or a dead player who is blinded counts for nothing.knife_kills(any knife or the bayonet),zeus_kills(taser),he_kills(hegrenade) andmolotov_kills(infernoormolotov): by the counted kill's weapon.no_scope_kills,thru_smoke_kills,thru_wall_kills,blinded_killsandin_air_kills: thenoscope,thrusmoke,penetrated > 0,attackerblindandattackerinairflags of a counted kill'splayer_death.team_kills: killing a teammate (never oneself). The victim still gets a death and the killer no kill.suicides: a death by one's own hand or by the world, but not by the bomb (planted_c4). It is still a death.trade_kills: killing the killer of a teammate within 5 s of that teammate's death, in the same round, as the match stats' trade pairs count it. Each pair counts once, so killing a player who has just killed two teammates trades both, and a killer who dies in any way has paid for the kills they made, which also keeps a respawned killer from being traded twice. The kills are cleared atround_startand at a map start. Players are told apart by slot, and there are no trades where teammates are enemies.bomb_plants,bomb_defusesandhostage_rescues:bomb_planted,bomb_defusedandhostage_rescuedby a human.best_streak: the most counted kills in a row without dying on the current map, like the match stats' best streak. Any death ends a streak, a death at a bot's hands included; a round end does not. A map start resets both the streak and the best.Per weapon,
killsandheadshotscount with the counted kill,shotswithshots,hitswithhits, anddamagewith the enemy damage.Bots
On a server with humans and bots, nothing a bot does counts and nothing done to a bot counts. A bot's kill ends the victim's streak but is not a death, helping a bot to a kill is no assist, and hits, damage, flashes and kills on a bot count for nobody. Everything between humans still counts, since every event names both players. A miss names no target, so a shot counts when it is fired and is taken back when its bullet hits a bot, unless the same shot also hits a human enemy in that tick. A take-back never takes a weapon's shots below zero.
This changes two counters from before on such servers: a death at a bot's hands is no longer a death, and helping a bot to a kill is no longer an assist. Kills on bots and damage to or by bots did not count before either.
Guns built on another gun's class
CS2 builds five guns on another gun's class: the M4A1-S on the M4A4's, the USP-S on the P2000's, the CZ75-Auto on the P250's, the R8 on the Desert Eagle's and the MP5-SD on the MP7's. On a live server
player_hurtnamed a USP-Shkp2000, which put its hits and damage under the P2000. When an event names one of those five base guns, the plugin reads the item definition index of the gun in hand and takes it only when it is the event's gun or the gun built on its class, so a player who has switched guns since keeps the event's name. Shots, hits, damage and kills all go through this, so the five guns keep their own names (m4a1_silencer,usp_silencer,cz75a,revolver,mp5sd), the names the match stats use for kills.The api side
5stackgg/api#968 stores these. It uses the same key names (its
COMMUNITY_STAT_KEYSare these 33 counters, and it readsbest_streakfromstats), its roster validator keeps known keys only, and it keeps the 44 weapon names the match stats use. All 34 guns here are among them; any other name the plugin may send, such asworld, is dropped there. The plugin sends running totals per connection and the api works out the growth between reports, as it does for kills and deaths.Compatibility
statsorweapons, and the new columns and boards stay empty.Known limits
Tests
apps/player-management-sw/test: 340/340 inmcr.microsoft.com/dotnet/sdk:10.0(315 after the first commit, 158 on feature: Player Management counts assists, headshots, damage, rounds and MVPs for the community stats #282). The new tests cover each counter, hitgroups, pellets, warmup, teammates as enemies, bots (kills, assists, hits, the shot take-back and its restore), streaks, weapon names, the class rule, the 48 weapon cap, trades, copies on departed entries, and the JSON shape (zeros and empty objects left out).test.yamlpass (counterstrikesharp 304, swiftly 363, simulator 132), as do utility-sw (684) and the four script tests.