The GameEvents.UnitPrekill hook fires whenever a unit is removed from the game for whatever reason. This includes any
Unit:Convert(pOldUnit) as well as any
Unit:Kill(). Any time a settler is used to found a city, any time a settler or worker is captured and thereby converted to a new player, any time a Great Person is used, etc. It works for all civs and whether or not the player is AI or human. I can't remember at the moment though whether it is BNW-only.
DarkScythe wrote most of the following that you can use to set up a 'listener' which will spit info into the lua.log file or into Live Tuner so you can get a better idea of how the event works and what data it gives under various conditions.
Code:
function PreKiller(iOwner, iUnit, iUnitType, iX, iY, bDelay, iKiller)
print("iOwner: " .. iOwner)
print("iUnit: " .. iUnit)
print("iUnitType: " .. iUnitType .. " (" .. GameInfo.Units[iUnitType].Type .. ")")
print("iX: " .. iX)
print("iY: " .. iY)
print("bDelay: " .. tostring(bDelay))
-- bDelay returns true before unit is killed (before UnitKilledInCombat) and only has one unit on the plot
-- bDelay returns false after the unit is killed (after UnitKilledInCombat) and an enemy melee unit may be on the same plot at this point
print("iKiller: " .. iKiller)
end
GameEvents.UnitPrekill.Add(PreKiller)