Any way to know if an unit has made an interception ?

Gedemon

Modder
Super Moderator
Joined
Oct 4, 2004
Messages
12,800
Location
France
all is in the title...

I want to track units making interception to log combat statistic or give XP to the intercepting unit.
 
Well, there's Units:IsOutOfInterceptions(). Simple boolean telling you whether an interceptor has any interceptions left. So all you'd need to do is make an end-of-turn event that sees if a unit could make interceptions (fighter unit or AA with the right promotions), and if it's out, you'll know it did. The problem here is simply that if a unit could make 2 interceptions and it only did one, then it won't trip that flag.

Alternatively, just tie whatever logic you need into RunCombatSim or EndCombatSim. If the defending unit is an air unit, then it MUST be an interception. Unfortunately, the combatsim events have a few limitations (no Quick Combat, no Strategic View, some positional issues, no information if one of the two combatants was a city), but there you go.
 
hmm, it seems to me that there was only the attacker and the defending land unit (or city) that were shown here, not the intercepting unit.

anyway, I'll add another check in EndCombatSim, thanx.
 
hmm, it seems to me that there was only the attacker and the defending land unit (or city) that were shown here, not the intercepting unit.

Could be. I thought it was triggering twice, but if it's not then yeah, you've got a problem. Just another example of how we need better combat events. You MIGHT be able to work this by trapping the mission the fighter is assigned to, and if it's set to Intercept then watch to see what happens nearby, but that'd be horribly messy.

So again, I think your best option is to use the IsOutOfInterceptions function I mentioned (inside a CanIntercept check, of course); as long as a unit is capable of only one interception per turn, it'll work just fine for what you're trying to do.
 
yep, just when I had set all my fighters to have 2 interceptions chance from start :D

Ok, thank you, looks like I'll have to wait for this one, I really need the fighters to be able to do 2 or more interceptions / turn.
 
well, finally I may have something, using unit:IsFighting(), not as messy as I feared...

now I must test it in a game with big air battle, to see if it tracks the right units...
 
Back
Top Bottom