I'm trying to accomplish a Reflect Spell Damage script. Need

Post » Tue Jun 19, 2012 2:02 am

What I want to accomplish is the attacker to receive the damage from using these spells against me. So far only the opposite has happened, and the result is me being killed by my own script. I think my problem lies with the targeting variables? I don't quite understand that part yet..

 Scriptname FrostFxScript extends activemagiceffect  ;This entire spell currently adds 10 second shader to the player, in addition to having the ability to reflect spells.;============/;PROPERTIES;============/EffectShader Property AtronachFrostFXS auto; This will not add the Frost Atronach's shader, I didn't feel like changing the name. Instead it uses GhostEtherealFXSpell property IceStrike auto ; Spell - Icy SpikeSpell property IceStorm auto ; Spell - Ice StormSpell property IceSpear auto ;  Spell - Icy Spear;============/;VARIABLES;============/Actor TargetActorActor CasterActor;============/;EVENTS;============/Event OnEffectStart(Actor Target, Actor Caster)				TargetActor = Target				CasterActor = Caster		  				 AtronachFrostFXS.Play(caster)EndEvent ; This block adds the shader effect to the player.Event OnHit(ObjectReference akAggressor, Form akWeapon, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack,bool abBashAttack, bool abHitBlocked)   		if IceStrike			(akAggressor as Actor).DamageAV("health", 50)		endif				if IceStorm			(akAggressor as Actor).DamageAV("health", 50)		endif				if IceSpear			(akAggressor as Actor).DamageAV("health", 50)				   ;Random value I chose.				   ;In order for the attacker, the one who is attacking you to receive any damage or detrimental change,				    The actor has be to be the aggressor as per the above functions.		endifEndEvent ; This block defines how much damage the target recieves from the three spells specified from the properties.Event OnEffectFinish(Actor Target, Actor Caster)			   CasterActor = Caster			   AtronachFrostFXS.Stop(caster)EndEvent ; The ending block from the first event.
User avatar
Bigze Stacks
 
Posts: 3309
Joined: Sun May 20, 2007 5:07 pm

Post » Tue Jun 19, 2012 6:03 am

Is this a spell you are casting on yourself? To make yourself reflect these spells? If so the OnEffectStart event just give you as the target and caster I believe. I think in your OnHit event the akAggressor parameter is the actor who is hitting you, so if you did akAggressor.DamageAv("health", 50) that might work. You may need to cast the akAggressor parameter to an actor too '(akAggressor as Actor).DamageAV("health", 50)'. I'm not exactly sure though, I'm new to the creation kit.
User avatar
.X chantelle .x Smith
 
Posts: 3399
Joined: Thu Jun 15, 2006 6:25 pm

Post » Tue Jun 19, 2012 12:25 pm

YES!! Thanks alot!

I had to change the following code:

   if IceStrike			(akAggressor as Actor).DamageAV("health", 50)		endif				if IceStorm			(akAggressor as Actor).DamageAV("health", 50)		endif				if IceSpear			(akAggressor as Actor).DamageAV("health", 50)				   debug.trace("I should not be the one recieving this damage!")		endif

Now I can balance this to a more realistic value. And now I have more understanding of using OnHit.

I'm gonna add this script as an example on the wiki later when I have more time.

Edit: added the finished script to the opening post.

Those who come across may want to know if it's possible to apply this to all magic at once and not just property spells. I don't know if it can be done but this a good step in the right direction!
User avatar
Tammie Flint
 
Posts: 3336
Joined: Mon Aug 14, 2006 12:12 am


Return to V - Skyrim