s2client-api icon indicating copy to clipboard operation
s2client-api copied to clipboard

OnUnitCreated is not getting called for starting units in replays

Open KevinCalderone opened this issue 8 years ago • 5 comments

When playing you get this callback for your starting units. In replays you don't.

For some reason in replays, ObservationImp::UpdateObservation is getting called twice before ControlImp::IssueEvents.

KevinCalderone avatar Aug 08 '17 06:08 KevinCalderone

@KevinCalderone just a quick question regarding OnUnitCreated.

Is it called when the player has clicked "build this unit" or is it called after it has actually finished producing?

luka-papez avatar Oct 17 '17 10:10 luka-papez

It is called when it finishes producing.

KevinCalderone avatar Oct 17 '17 16:10 KevinCalderone

@KevinCalderone Is it possible to trigger an event upon issuing such a command?

luka-papez avatar Oct 17 '17 16:10 luka-papez

You can get it from Observation()->GetRawActions(). That is the list of all actions the user performed since the last gameloop.

That will contain more than just train actions through. To get what the train/build ability_id is for a specific unit, you can look it up at UnitTypeData::ability_id in Observation()->GetUnitTypeData().

KevinCalderone avatar Oct 17 '17 18:10 KevinCalderone

I see this issue was referenced in a PR which is already merged. Was this solved?

herodrigues avatar Apr 17 '18 09:04 herodrigues