I miscommunicated : I did a tutorial that create a button that print "hello world" in the main menu. What I'm looking for is what you provided : "how/where to hook my crap".
Thanks to your example I could do my goal : I had to use OnBeforeMissionBehaviourInitialize because I test in custom battle, and used CustomBattleAgentLogic as a base for mission behavior, no need for campaign behavior (but now I get a better idea of the differents parts)
I see, glad to help - at least we have a solution like thing now.
But for the future questions, it's better if you explain what you want to do - since CustomBattle's are different than Campaign Battles as you already figured it out and suggestions people can give will change based on that.
For further checking, since you are doing this only for getting statistics out of it, you can simply use Harmony and hook-up to game methods and do your counting/analysis without bothering with your custom logic. With this way you can take more information since some parts of the game are still and very much internal or private.
So I ran my test, 200v200 imperial infantry no player intervention. "On target" being "affected.GetTargetAgent() == affector" and not on target being the opposite. So that "onTarget" count how many time a soldier is hit by someone who he, himself, is targetting. The question I was asking is : "Does the troops get killed so fast in melee because their AI doesn't take into account attack from nearby units ?"
I understand what you are trying to measure but I don't think this approach is correct.
Because think about this scenario,
Agent A vs Agent B and Agent C. A targets B, meanwhile B and C target A. We will listen Agent A.
A hits B
C hits A ( registered as non target hit )
A switch targets to C since it got attacked by it
B hits A ( registered as non target hit )
in numbers, it will say A is hit by non target two times and died. But in reality, A did what human players do and actually engaged to enemy which damaged them.
So you can make it a more fair analysis for bots by keeping a temporary target list with timestamps and measure if the registered non-target was a previous target or not - so that you can see if AI initially considered this as a target but had to switch because of something else. If you see that it's the case, then you can search for reasons why AI is switching to wrong target.
Or you can measure this for each agent,
When agent picks a target, you can get enemy agents within a small radius and check how many of them are targeted this agent.
Keep them in list and when any of non-targets change stance from defense ( holding shield or blocking ) to attack, you can see if our main agent is able to pick this cue and change it's target for proper defence.
Because issue is ( not doing analysis like you do so it's a hunch based on gameplay experience ):
AI focusing on the same target until they get hit by some another target. This means they are ignoring the fact that agent C is lifting his weapon and about to hit because it's busy with targeting agent B which is defending himself. What agent A have to do in this scenario is turning to C and blocking that attack if possible.
And I guess that's also what you want to find out - with analysis and numbers.