Need Advanced Script Assistance

Post » Tue May 17, 2011 2:22 am

I want to adapt one of my really advanced scripted spells to work on a certain activator instead of just on NPCs/creatures. I have set the conditions for it to take effect but when cast at the activator all the "special effects" take place, however the player is only moved a very short distance. Shadowstep is the spell btw, it slowly moves the player toward a target (simplified).

Please take a look and see if you can identify why the update block and finish block aren't running properly.

scn TCShadowStepAllylong indexref NPCref selfref actref meref staticref sourceshort switchshort fatigueshort succeedfloat randnumfloat xpfloat xcfloat ypfloat ycfloat zpfloat zcfloat faceanglefloat anglefloat angleoriginalfloat anglecorrectfloat sinefloat cosinefloat fact2float fact3float fact4float fact5float fact6float fact7float fact8float fact9float x2float x3float x4float x5float x6float x7float x8float x9float newxfloat newyfloat newzfloat dummyint targetint doneint staggerfloat dfloat prevdfloat afloat angletargetfloat stopposxfloat stopposyBegin ScriptEffectStart    if act          act.RemoveMe    endif    set index to GetScriptActiveEffectIndex    set NPC to GetNthActiveEffectCaster index    set static to SKSSTarget    set self to GetSelf    set succeed  to (( rand 0 30 ) + 1) + ((NPC.getav luck / 10) + (NPC.getav Mysticism / 5) *3)        if(self.IsActor == 0 && self.getisid static == 0);        message "Missed!" ~ if you miss, reenable the player~        NPC.removespell TcStepping        NPC.removespell TcShadowFocusing        NPC.SetRestrained 0        NPC.SetUnconscious 0    endif    if (target == 1)    return    endif    if (target == 0)    set act to self.placeatme TcShadow 1,256,0    set target to 1    endif    if (((NPC.isSneaking == 1 && self.IsActor == 1) ||  self.getisid static == 1)); && self != NPC && isthirdperson == 0 && self.getdistance NPC > 200 && self.getdistance NPC < 1500)        NPC.addspell TcShadowFocusing ; add effects        if(succeed < 25 && succeed > -1 ) ; add effects of failed step            set fatigue to NPC.getav Fatigue            set fatigue to ( fatigue * -1 )+1                NPC.ModActorValue2 Fatigue fatigue            NPC.PlayGroup Stagger 1        else            set fatigue to NPC.GetBaseActorValue fatigue            set fatigue to ( fatigue * 30 /100)                NPC.ModActorValue2 Fatigue fatigue        endif        set succeed to -1        set faceangle to NPC.getangle z + NPC.GetHeadingAngle self        NPC.setangle z faceangle        set angleoriginal to NPC.GetAngle z        set angletarget to self.GetAngle z        if (angleoriginal >= 360)            set angleoriginal to angleoriginal - 360.0        endif        if (angletarget >= 360)            set angletarget to angletarget - 360.0        endif        set anglecorrect to angleoriginal        set angleoriginal to angleoriginal % 90        set angle to (angleoriginal / 57.29)        set fact2 to 2.0        set fact3 to 6.0        set fact4 to 24.0        set fact5 to 120.0        set fact6 to 720.0        set fact7 to 5040.0        set fact8 to 40320.0        set fact9 to 362880.0        set x2 to (angle * angle)        set x3 to (angle * angle * angle)        set x4 to (x2 * x2)        set x5 to (x2 * x3)        set x6 to (x3 * x3)        set x7 to (x3 * x4)        set x8 to (x4 * x4)        set x9 to (x5 * x4)        set sine to (angle - (x3 / fact3) + (x5 / fact5) - (x7 / fact7) + (x9 / fact9))        set cosine to (1.0 - (x2 / fact2) + (x4 / fact4) - (x6 / fact6) + (x8 / fact8))        set newx to sine * 1625 * GetSecondsPassed        set newy to cosine * 1625 * GetSecondsPassed        if (anglecorrect >= 270)            set dummy to newx            set newx to 0 - newy            set newy to dummy        elseif (anglecorrect >= 180)            set newx to 0 - newx            set newy to 0 - newy        elseif (anglecorrect >= 90)            set dummy to newy            set newy to 0 - newx            set newx to dummy        endif        set xc to NPC.getpos x        set xp to act.getpos x        set yc to NPC.getpos y        set yp to act.getpos y        set zc to NPC.getpos z        set zp to act.getpos z        set newz to (zc - zp) / 20        set done to 0        set stagger to 0        set anglecorrect to angletarget        set angleoriginal to angleoriginal % 90        set angle to (angleoriginal / 57.29)        set fact2 to 2.0        set fact3 to 6.0        set fact4 to 24.0        set fact5 to 120.0        set fact6 to 720.0        set fact7 to 5040.0        set fact8 to 40320.0        set fact9 to 362880.0        set x2 to (angle * angle)        set x3 to (angle * angle * angle)        set x4 to (x2 * x2)        set x5 to (x2 * x3)        set x6 to (x3 * x3)        set x7 to (x3 * x4)        set x8 to (x4 * x4)        set x9 to (x5 * x4)        set sine to (angle - (x3 / fact3) + (x5 / fact5) - (x7 / fact7) + (x9 / fact9))        set cosine to (1.0 - (x2 / fact2) + (x4 / fact4) - (x6 / fact6) + (x8 / fact8))        set stopposx to sine * -50        set stopposy to cosine * -50        if (anglecorrect >= 270)            set dummy to stopposx             set stopposx to 0 - stopposy             set stopposy to dummy        elseif (anglecorrect >= 180)            set stopposx to 0 - stopposx             set stopposy to 0 - stopposy         elseif (anglecorrect >= 90)            set dummy to stopposy             set stopposy to 0 - stopposx             set stopposx to dummy        endifelse        set done to 1        NPC.removespell TcStepping        Npc.removespell TcShadowFocusing        NPC.SetRestrained 0        NPC.SetUnconscious 0endif    set d to NPC.GetDistance act    set prevd to dEndBegin ScriptEffectUpdate    set xc to NPC.getpos x    set xp to act.getpos x    set yc to NPC.getpos y    set yp to act.getpos y    set zc to NPC.getpos z    set zp to act.getpos z    set d to NPC.GetDistance act    if (stagger > 0 && stagger < 30)        self.setangle z a        set stagger to stagger + 1    endif    if (NPC.GetDistance act < 300 && done == 0 && stagger == 0)        self.removespell TcStepping        Npc.removespell TcShadowFocusing        NPC.SetRestrained 0        NPC.SetUnconscious 0        set a to self.getangle z        self.setangle z a        NPC.setangle z a        set stopposx to stopposx + self.getpos x        set stopposy to stopposy + self.getpos y        NPC.setpos x stopposx        NPC.setpos y stopposy        set stagger to 1        set done to 1        NPC.removespell TcStepping    endif    if ((self.getisid static == 1 || (self.IsActor == 1 && self != NPC))&& done != 1)        message "Moving player"         set xc to xc + newx        set yc to yc + newy        if ((newz < 0 && zc < zp) || (newz > 0 && zc > zp))            set zc to zc - newz        endif        NPC.setpos x xc        NPC.setpos y yc        NPC.setpos z zc        NPC.TriggerHitShader 1    endif        set prevd to dEndBegin ScriptEffectFinish    self.removespell TcStepping    Npc.removespell TcShadowFocusing    NPC.SetRestrained 0    NPC.SetUnconscious 0    act.RemoveMeEnd

User avatar
Kill Bill
 
Posts: 3355
Joined: Wed Aug 30, 2006 2:22 am

Post » Tue May 17, 2011 1:42 am

figured it'd be too much for most of the modders here.. I'll just have to gut it down and build it back up I guess.
User avatar
Steven Hardman
 
Posts: 3323
Joined: Sun Jun 10, 2007 5:12 pm

Post » Tue May 17, 2011 7:48 am

Look at the Wiki. It says for magic effect scripts

Scripted spells will run on corpses, containers, doors, and furniture, but will simply run through the entire script once, regardless of the duration of the spell. All three blocktypes, ScriptEffectStart, ScriptEffectUpdate, and ScriptEffectFinish will run


Could this be your problem?
User avatar
Tom Flanagan
 
Posts: 3522
Joined: Sat Jul 21, 2007 1:51 am

Post » Tue May 17, 2011 3:26 am




figured it'd be too much for most of the modders here.. I'll just have to gut it down and build it back up I guess.


I understand your script just fine (Why are you using Fact variables just to hold a known value ? its not required to get a good result from the Taylor Series).

Everything seems fine although I suspect your problem is exactly what was mentioned below your running a magic effect off of an activator -> I personally started using Horse Creatures that I designed specifically to be Casters and Targets of Magic Effects its a much cleaner way to do things as you do not need to clean up the actor just kill it and leave it the game will clean it up -> I still have a few activators left but they are only for spells I can not do any other way like Breath of Fire/Frigid Breath as they both require the ability to script their XYRotations (that you can not do for Creatures).

Look at the Wiki. It says for magic effect scripts



Could this be your problem?

User avatar
Hannah Whitlock
 
Posts: 3485
Joined: Sat Oct 07, 2006 12:21 am

Post » Tue May 17, 2011 1:06 pm

Look at the Wiki. It says for magic effect scripts



Could this be your problem?


That does seem to be the problem. o.o Thanks for all the help. Now to figure out a way to reverse the effects of this spell hmmm.... I need a activator script that will upon being hit with the spell this one is tied to, instead pull the player towards the activator in the way this spell does.

Any ideas?
User avatar
Maria Leon
 
Posts: 3413
Joined: Tue Aug 14, 2007 12:39 am

Post » Tue May 17, 2011 2:56 am

That does seem to be the problem. o.o Thanks for all the help. Now to figure out a way to reverse the effects of this spell hmmm.... I need a activator script that will upon being hit with the spell this one is tied to, instead pull the player towards the activator in the way this spell does.

Any ideas?

Have the activator cast a spell on the player? You can use OBSE to get a reference to the activator from within the spell I think.
User avatar
Rachel Cafferty
 
Posts: 3442
Joined: Thu Jun 22, 2006 1:48 am

Post » Tue May 17, 2011 2:06 pm

Thanks for all the help, in the end I decided to just do a marker npc :( Lol but it gets the job done pretty nicely so I'm not upset :P
User avatar
Alexandra walker
 
Posts: 3441
Joined: Wed Sep 13, 2006 2:50 am


Return to IV - Oblivion