Scripting woes - custom spells

Post » Mon Jun 18, 2012 2:56 pm

So I'm trying to figure out how to make a scripted spell that affects the actor casting it. My script extends the ActiveMagicEffect script.

My basic plan was along the lines of this:


Event OnSpellCast(Form *spell*)

Actor caster = X.GetCasterActor()

*Stuff happens to caster*

EndEvent

Where X is a number of different things I've tried putting there, from the spell ID, to the magic Effect ID, to properties, to variables. I'm not sure what I need to put there to make this work, or if I'm even on the right track to figuring out what the problem is. The problem being, I keep getting this error when I try to save:

"GetCasterActor is not a function or does not exist"

All around I've found the wiki's explanation of functions and the syntax of these functions and when to use them a bit vague and confusing. I did go over the papyrus tutorial, and think it actually left me with a rather different impression of the process than how it actually works. So if this is an entirely unhelpful explanation of my problem, I'd like to apologize in advance.
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Mon Jun 18, 2012 2:57 am

The X you are looking for is just there. "OnSpellCast" should be an event fired "on the caster" itself.

For example, if I wanted your spell to make the caster naked (and more), I'd just write

Event OnSpellCast(Form *spell*)    RemoveAllItems()EndEvent
User avatar
Ash
 
Posts: 3392
Joined: Tue Jun 13, 2006 8:59 am

Post » Mon Jun 18, 2012 5:26 am

Huh. Yeah, the wiki could definitely go into better detail with that. Thanks! I think I can figure out how to do what I want from here.
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm

Post » Mon Jun 18, 2012 9:20 am

indeed, nowhere near enough spell related stuff on the wiki, I'm slowly working my way through the bits and bobs I need to know, trail and error ftw! lol
User avatar
Shelby Huffman
 
Posts: 3454
Joined: Wed Aug 08, 2007 11:06 am

Post » Mon Jun 18, 2012 4:58 pm

In fact, if it is at all acceptable, I'd like to whack my own problem in here! Because it is certainly a spell related scripting woe!

In the below script, I would very much like to cast a spell instead of the current debug "test" line. The catch is, I want the effect to be the fortify heal rate that is used by the Histskin power. (I have made this script from modifying the dragonpriest ultra script)

Scriptname modArgonianProcEffect extends activemagiceffectactor property selfRef auto hiddenfloat property HPthreshold = 0.90 auto{Below this HP we have a chance of the special effects. }float property effectChance = 0.80 auto{effect may happen when HP is below this level. }spell  property SPELLEFFECTHERE autoEVENT OnEffectStart(Actor Target, Actor Caster)selfRef = casterendEVENTEVENT onHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)if (selfRef.getActorValuePercentage("Health") < HPthreshold) && \   !(selfRef.isDead())	float dice = utility.RandomFloat(0,1)		   if dice <= effectChance				debug.messagebox("test")  SPELLEFFECTHERE.cast(selfRef,selfRef)	endifendifendEVENT
User avatar
Andrea P
 
Posts: 3400
Joined: Mon Feb 12, 2007 7:45 am


Return to V - Skyrim