skadistats / clarity-examples

Example code for clarity
BSD 3-Clause "New" or "Revised" License
115 stars 38 forks source link

Making showScoreboard() imitate the actual ingame scoreboard you see at matchend #19

Open Hareide opened 8 years ago

Hareide commented 8 years ago

Love that you can get the scoreboard from a replay in under a second just by building the example "Show stats at the end of the game" from https://github.com/skadistats/clarity-examples/

The ingame scoreboard also list additional detail such as:

Would you consider adding the above to the example? If not, would it be fairly simple to extend the example for someone with limited programming experience?

spheenik commented 8 years ago

Glad you like the example :)

I will consider adding it, but have to admit that I am very time constrained at the moment, with a lot of backlog. So I won't be able to do this quickly.

To implement this, I think you need more knowledge of where to find the data. Once you know that, it's a cakewalk to add that stuff to the scoreboard.

If you wanna try, I recommend looking at yasps parser.

Hareide commented 8 years ago

Thanks for the quick replay. By looking at the yasp site you pointed me to, I now almost have everything I need (and more): new ColumnDef("HeroID", new DefaultResolver("PlayerResource", "m_vecPlayerTeamData.%i.m_nSelectedHeroID")), new ColumnDef("Team", new DefaultResolver("PlayerResource", "m_vecPlayerData.%i.m_iPlayerTeam")), new ColumnDef("TeamSlot", new DefaultResolver("PlayerResource", "m_vecPlayerTeamData.%i.m_iTeamSlot")), new ColumnDef("SteamID", new DefaultResolver("PlayerResource", "m_vecPlayerData.%i.m_iPlayerSteamID"))

Do you know how I can find what team that won? I know the ingame console outputs the following line when a local server lobbygame ends: good_guys_win: true

I would guess that it should be returned by the parser as a boolean value.

spheenik commented 8 years ago

There is an entity "GameRulesProxy", it has a property:

"m_pGameRules.m_nGameWinner"

2 = Radiant 3 = Dire

iirc.

On 02/18/2016 09:19 PM, Hareide wrote:

Thanks for the quick replay. By looking at the yasp site you pointed me to, I now almost have everything I need (and more): new ColumnDef("HeroID", new DefaultResolver("PlayerResource", "m_vecPlayerTeamData.%i.m_nSelectedHeroID")), new ColumnDef("Team", new DefaultResolver("PlayerResource", "m_vecPlayerData.%i.m_iPlayerTeam")), new ColumnDef("TeamSlot", new DefaultResolver("PlayerResource", "m_vecPlayerTeamData.%i.m_iTeamSlot")), new ColumnDef("SteamID", new DefaultResolver("PlayerResource", "m_vecPlayerData.%i.m_iPlayerSteamID"))

Do you know how I can find what team that won? I know the ingame console outputs the following line when a local server lobbygame ends: good_guys_win: true

I would guess that it should be returned by the parser as a boolean value.

— Reply to this email directly or view it on GitHub https://github.com/skadistats/clarity-examples/issues/19#issuecomment-185897607.

redfish88 commented 3 years ago

excuse me,do you know how I can find what team that won? i try the following in skadistats.clarity.examples.matchend.Main ,but return null getEntity("GameRulesProxy").getDtClass().getFieldPathForName("m_pGameRules.m_nGameWinner")

spheenik commented 3 years ago

Just checked, and m_pGameRules.m_nGameWinner should be there. Your replay is from Dota 2, right? I think I'd need the replay.

redfish88 commented 3 years ago

Thank you for your reply,yes,it's Dota2 replay,how to send you my replay ? email ? image image

spheenik commented 3 years ago

Best to put it in some dropbox and share the link. I'm unsure if my mailserver will gobble it, but you can try: clarity@martin.schrodt.org

redfish88 commented 3 years ago

I have sent you an e-mail,and i still have the following questions

  1. Can i get the match id 、match start time、end time in matchend ?
  2. How to get the mapping relationship between heroId and heroName? or can i get the heroName from entity's field?
  3. How to get hero_damage、tower_damage 、killed_by and other info? Thank you again for your reply!
spheenik commented 3 years ago

Checked your replay: The property is there. It has value 5 up until tick ~56700, then changes to 2 (radiant). I ran the matchend-example, it spits out values. Since in your screenshot, you get GameRulesProxy = null, it seems that you did not seek to the end of the replay?

This code here https://github.com/skadistats/clarity-examples/blob/master/src/main/java/skadistats/clarity/examples/matchend/Main.java#L34-L36 is important!

redfish88 commented 3 years ago

I'm sure there are no changes elsewhere,because getEntity("PlayerResource") works . This my code https://gist.github.com/redfish88/223cbc5f120b2e5942e6684a4627948f#file-main-java-L67-L69

spheenik commented 3 years ago

Found the problem. The getEntity() function does not work, because it looks for CDOTA_GamerulesProxy. But in this case, the underscore is missing from the entity name (it should be CDOTAGamerulesProxy)

So you can look it up via runner.getContext().getProcessor(Entities.class).getByDtName("CDOTAGamerulesProxy")

redfish88 commented 3 years ago

Thank you very much,i get it!