I'm trying to capture the moment where a Great Person is expended. What I tried was:
...and so forth, using UnitType and IsDead to determine which type of Great Person was expended (I am aware this would trigger on Great People that were actually killed, but I'm okay with that).
The problem I encountered: when I try to retrieve the Unit from its UnitID, it will fail as the unit is dead and can no longer be found. I can't find any other event that might help me, and I don't think the one I'm currently using will get me anywhere either.
Does anyone know a way to do this?
Code:
function MyFunction(iPlayer, iUnit)
local pPlayer = Players[iPlayer]
local pUnit = pPlayer:GetUnitByID(iUnit)
print("EVENT TRIGGERED: ", pPlayer:GetName(), " - ", pUnit:GetUnitType(), " - ", pUnit:IsDead())
end
Events.SerialEventUnitDestroyed.Add(MyFunction)
...and so forth, using UnitType and IsDead to determine which type of Great Person was expended (I am aware this would trigger on Great People that were actually killed, but I'm okay with that).
The problem I encountered: when I try to retrieve the Unit from its UnitID, it will fail as the unit is dead and can no longer be found. I can't find any other event that might help me, and I don't think the one I'm currently using will get me anywhere either.
Does anyone know a way to do this?