Forcing attack targets for npcs.

Post » Thu Oct 24, 2013 6:23 am

I'd like to create a cloak effect that forces any hostile target to focus the actor with the cloak on over all others. What papyrus function could handle this? Can you think of one? Or perhaps something in the ck?

User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Thu Oct 24, 2013 5:24 pm

In the cloak effect's target spell script do something like this:

Event onEffectStart(Actor akTarget, Actor akCaster)  If akTarget.IsInCombat()    If akTarget.GetCombatTarget() != akCaster      akTarget.StopCombat()      akTarget.StartCombat(akCaster)    EndIf  EndIfEndEvent

Since cloak spells are continuously recast, even if the enemies switch targets, they won't get far before the cloak script forces them to retarget the cloak's caster. If they're not in combat, or are already fighting the target, it does nothing.

You may want to add a line to exclude the player character from the check, as IsInCombat often returns true for the PC even if you're not actually attacking anyway. The PC can't have its combat target set, though, so your debug log will fill up with errors.

User avatar
Daramis McGee
 
Posts: 3378
Joined: Mon Sep 03, 2007 10:47 am

Post » Thu Oct 24, 2013 5:36 am

Thanks!

Will I have a problem with this effect piling up on the target, or do cloak spells just refresh effects instead of layer them?

User avatar
Life long Observer
 
Posts: 3476
Joined: Fri Sep 08, 2006 7:07 pm


Return to V - Skyrim