Actually, I think ondamaged is superior to onattacked in this regard, as it sets a higher bar. FWIW, you're running into the same difficulties I've been juggling. I'll post our current code when I get home, as I think it forms a useful baseline.
Funky, I am using the ondamaged event to determine when a PC has participated in the combat, but I am not handing out XP with every damage event as the poster I responded to was suggesting.
I look forward to seeing your code.
Oh btw henesua, the DetermineCombatRound is not a good place to track whether NPC attacks a PC. Afaik, merely all physical attacks on npc will cause the DetermineCombatRound to trigger with the attacker in it. Or its only ranged+melee behavior, not 100% sure at this moment. But you should take a closer look at this (yes hard to test).
Hmm... I will have to look at this more carefully then. I did have my doubts. This is the part of the function I stuck my flags in:
// ----------------------------------------------------------------------------------------
// DetermineCombatRound: ACTIONS
// ----------------------------------------------------------------------------------------
if( GetIsObjectValid(oIntruder)
&&( GetObjectSeen(oIntruder) //1.71: AI passed an unseen intruder
||( GetHasFeat(2016) // Henesua - added ability for creatures with scent to sniff out an enemy
//&& GetObjectHeard(oIntruder)
)
)
)
{
// anyone who participates in combat is flagged as a particpant (for the reward of XP later)
if(GetIsPC(oIntruder))
SetLocalInt(OBJECT_SELF, "COMBATANT_"+ObjectToString(oIntruder), GetTimeCumulative());
else
SetLocalInt(OBJECT_SELF, "COMBATANT_"+ObjectToString(GetMaster(oIntruder)), GetTimeCumulative());