Cast spell function at a target's direction via script?

Post » Mon Nov 19, 2012 6:02 am

Hello all!

I'm trying to make a new spell that sort of manually does a chain spell, but only affects hostile characters. Here's what I have so far:
Scriptname CastOnHostileScript extends activemagiceffect SPELL Property aaMagicToCast AutoActor Property aaPlayer AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)		aaPlayer = Game.GetPlayer() as Actor        while(akTarget != aaPlayer)				if(akTarget.IsHostileToActor(aaPlayer))				   ; cast magic to the target				endif		endwhileEndEvent

The script is attached to a cloak type magic effect and is supposed to "tag" an actor as a target if he/she/it is hostile to the player, and if so, the caster will cast magic at the tagged actor. I've gotten everything down except for the actual casting of the spell. I'm aware of the .cast(akSource, akTarget) function, unfortunately akTarget seems to only apply to "target" delivery spells and most offensive magic are "aimed". So is there a way to get the caster to cast an aimed spell at the intended target? Any help would be much appreciated.
User avatar
Stacyia
 
Posts: 3361
Joined: Mon Jul 24, 2006 12:48 am

Post » Mon Nov 19, 2012 4:12 am

GetPlayer returns tha player as an Actor w/o casting. Getting rid of aaPlayer in favor of a PlayerREF property would A) make your script more efficient and B) reduce the amount of code.
Spoiler
ScriptName CastOnHostileScript Extends ActiveMagicEffectSpell Property aaMagicToCast AutoActor Property PlayerREF AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)	While(akTarget != PlayerREF)		If akTarget.IsHostileToActor(PlayerREF)			; cast magic to the target		EndIf	EndWhileEndEvent
User avatar
Tamika Jett
 
Posts: 3301
Joined: Wed Jun 06, 2007 3:44 am

Post » Mon Nov 19, 2012 8:10 am

Thanks for helping improve the code. :) Though I'm still holding out for the solution to my current problem.
User avatar
patricia kris
 
Posts: 3348
Joined: Tue Feb 13, 2007 5:49 am

Post » Mon Nov 19, 2012 9:18 am

Spell.Cast(Actor C, Actor T)
User avatar
Rudy Paint fingers
 
Posts: 3416
Joined: Sun Nov 11, 2007 1:52 am

Post » Mon Nov 19, 2012 12:08 pm

I am having a similar problem, the actor will cast a spell at the player, but without the actual casting animation.
According to the papyrus wiki this script spell.Cast(Actor, target) "This is mainly desirable only for non-actors, because it will not animate an actor
Goes on to say to use a "UseMagic Procedure" which comes from a package. Ok well how do you make an actor start a package with a script that he's currently not using?
User avatar
Dewayne Quattlebaum
 
Posts: 3529
Joined: Thu Aug 30, 2007 12:29 pm


Return to V - Skyrim