GetCombatTarget and OnSpellCast with Actors...

Post » Sun Nov 18, 2012 10:20 am

I am curious to know, if I set up an event for OnSpellCast, then check GetCombatTarget, will the target reliably be the one the actor just cast at, even if they are technically in combat with multiple enemies?

This is for NPC's not the player.
User avatar
Jessie
 
Posts: 3343
Joined: Sat Oct 14, 2006 2:54 am

Post » Sun Nov 18, 2012 7:13 pm

Not sure what you are trying to do here, can you use IsSpellTarget instead?
User avatar
Marie
 
Posts: 3405
Joined: Thu Jun 29, 2006 12:05 am

Post » Sun Nov 18, 2012 2:24 pm

Nope, I need to be able to check from the actor casting the spell who it is they are casting it at. IsSpellTarget forces me to check from the target.
User avatar
Jonathan Egan
 
Posts: 3432
Joined: Fri Jun 22, 2007 3:27 pm

Post » Sun Nov 18, 2012 1:14 pm

I don't think so. May work most of the time, but a NPC could change it's target since the cast starts until the spell reach the objective. Keep also in mind that while getcombattarget returns the enemy the player is looking at, in the case of NPCs it's the enemy the NPC is engaged with, while it could be looking at another NPC.
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Sun Nov 18, 2012 12:20 pm

Because of the script lag you will have to just work with "most of the time". Can you "double check" the target after it hits by having the spell itself set an actor quest ref to the target then your script with getcombattarget check this as well to see if they match?
User avatar
Yung Prince
 
Posts: 3373
Joined: Thu Oct 11, 2007 10:45 pm

Post » Sun Nov 18, 2012 8:58 pm

Since OnSpellCast triggers immediately after the spell is cast, and not when it hits the target, it seems like as long as the actor only casts spells as its combat target, it is probably always going to work. I don't know if it's true that actors only cast spells at their combat targets though. You will have to test that. And of course it will not tell you who the spell actually hit unless it's a target actor spell, but you did not say you needed to know that, so...
User avatar
Chris Jones
 
Posts: 3435
Joined: Wed May 09, 2007 3:11 am


Return to V - Skyrim