skadistats / clarity-examples

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

Getting player to hero selection relationship #20

Closed TodorovicF closed 8 years ago

TodorovicF commented 8 years ago

So I posted something similar in the main Clarity issues page, but I had an additional problem I'd like to solve. Since CDOTA_DataDire's or CDOTA_DataRadiant's m_vecDataTeam.000X.m_nPissibleHeroSelection seems to be returning -1 for the entire match on new replays, I noticed that I can at least see what heroes are being used with CDOTA_Unit_Hero_X where X is the hero's CDOTA name. The problem is the index values of the CDOTA_Unit_Hero classes seem to always be different, so I would have to search all indexes and compare them against all heroes in Dota 2 to find which are being used. Is there a way to retrieve all classes that begin with "CDOTA_Unit_Hero_" so I don't have to iterate through them all?

spheenik commented 8 years ago

Entities has a method getAllByPredicate(predicate) which will pre-filter the list for you. Just write a predicate that'll return true if the entity.getDtClass().getName().startsWith(...)