Hey I'm currently working on a script to cast a spell on a target actor when attacked by the players fists. This is what I have so far.
ACTOR Victim
Event OnEffectStart(Actor akTarget, Actor akCaster)
victim = akTarget
RegisterForHitEvent(victim)
EndEvent
Event OnHit(ObjectReference akTarget, ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked, string apMaterial)
if victim.IsEssential() == false && victim.IsHostileToActor(game.GetPlayer()) == true && akAggressor == game.GetPlayer() && akSource == None
victim.Kill()
endif
EndEvent
This sort of works but only on one combat target. If I remove akSource I can get it to target a group but I don't have to make contact with an attack for them to die and they all die at once. Plus once I do the initial attack they can then be killed by any attack from anyone?? Also to get the script to work at all I have to have the spell set to "Concentration" and "Target Actor". Which I think is causing issues too. Anyway any help would be great thanks.