GraylinKim / sc2reader

A python library that extracts data from various Starcraft II resources to power tools and services for the SC2 community. Who doesn't want to hack on the games they play?
http://sc2reader.readthedocs.org
MIT License
411 stars 85 forks source link

Getting the source of an ability #170

Closed EHadoux closed 9 years ago

EHadoux commented 10 years ago

Hi,

it's currently possible to get the target of an ability but is it possible to get the source (the caster)? I tried with the SelectionTracker to get the current selection before casting the abality but, if there is more than one, say, Nexus, you cannot know which one casted the spell if both have enough energy. Indeed, the order in the selection tracker is not guarantee to be the same as in the real selection.

GraylinKim commented 10 years ago

It isn't strictly possible to get the source but depending on the context you can make a good guess.

For targeted abilities, the selected caster that is closest to the target is used so if you know the location of all the selected units you can pick the correct one (e.g. this works for buildings).

Unit production abilities use the first (in UI display order) available building tied for the lowest queue size. You are correct that the selection tracker order is not the same as the UI ordering. You can probably figure out how to generate the correct UI ordering from the selection tracker ordering though. If you can post that information I'd be happy to provide a second "UI Selection" view that is correctly ordered as part of sc2reader.

EHadoux commented 10 years ago

For targeted abilities, the selected caster that is closest to the target is used so if you know the location of all the selected units you can pick the correct one (e.g. this works for buildings).

You mean that for, e.g., Chronoboosts, the Nexus casting is the closest from the building and not the first in the selection? I didn't know that. Ofc we still need to check for energy, the closest doesn't necessarily have enough energy.

If you can post that information

I'll try that and come back to you for this particular point.

GraylinKim commented 10 years ago

Yeah, that is right. I believe that @dsjoerg uses an approach similar to the above for ggtracker.

GraylinKim commented 9 years ago

This is reasonably advanced functionality that I don't plan on integrating anytime soon. Now that ggtracker is open source anyone looking for this functionality can look at ggpyjobs.