Depending on how it needs to be designed to work it can use either OnPerception or OnHeartbeat.
Sure, but if we use OnPerception, then it's the last entering enemy that will become the target. Or only the first if we decide to do nothing more if GetIsInCombat() returns TRUE.
The other it just to let its heartbeat handle things.
Yes, I had thought about that as well, but then the rock would be thrown only every 6 s, not each time the catapult attacks (I know there are ways to increase the frequency, but the idea is to just place the catapult in the area and everything works without any other tinkering).
Not sure why the lack of an OnAttack event is a problem.
Or am i misunderstanding the problem?
Basically, the "problem" is simple: how to throw a rock from the catapult towards the target?
The answer is sometimes as simple as the question: if it is during a cutscene, or decided by a trigger, all that is required is to set object oTarget = GetEnteringObject() (or the speaker, or GetObjectByTag, etc.)
For a stealthy approach that didn't work, the OnPerception event will do fine too I guess.
But how do I link the attack animation and the rock throw (simulated by a spell) automatically (i.e. the catapult is on the enemy side, which means the player doesn't select the target)?
GetTarget() and GetAttemptedTarget functions did sound nice, but are set to OBJECT_INVALID before the end of combat round event.
There's still an option I didn't try yet: change the combat stance from UNA to THRN, and see how it works.
But first, I'll check if I get better results with bkAcquireTarget (as it normally chooses the same target as the previous round, except if it's dead or gone, that should work for what I'm looking for).