Need help with Script

Post » Wed Jul 21, 2010 8:24 pm

I need a Script that will cast a spell if the player/npc is in combate and ether in a cirtion worldspace or within a cirtion distence forom the activator. This is what I have so far:

Scn AALCStopTheFightBegin GameModeif ( getDistance player < 90000 ) && Player.IsInCombat == 1Protect.Cast AALCspell01 ProtectEndifEnd


--Thanks
-MNPred
User avatar
Betsy Humpledink
 
Posts: 3443
Joined: Wed Jun 28, 2006 11:56 am

Post » Thu Jul 22, 2010 2:00 am

what type of script is it? object? is it attatched to the activator?

also i recommend setting a loop check, currently the script will run every 5 seconds even if it's already succesfully passed
something like

Scn AALCStopTheFightshort fighstoppedBegin GameModeif fightstopped == 0          if ( getDistance player < 90000 ) && Player.IsInCombat == 1                    Protect.Cast AALCspell01 Protect                    Set fighstopped to 1          EndifEndIfEnd

User avatar
Joie Perez
 
Posts: 3410
Joined: Fri Sep 15, 2006 3:25 pm

Post » Wed Jul 21, 2010 11:37 pm

90 000 units? Wow, I wonder what you need that distance for...

This script looks like an object script(it's a reference script executed on an activator), so in current form it will be processed every frame(and spell will be cast every frame). With Mishaxhi's modification the spell will be cast only once. It would be good to add some timing which would control how often the spell should be cast.

Scn AALCStopTheFightshort fighstoppedfloat timerBegin GameModeif fightstopped == 0          if ( getDistance player < 90000 ) && Player.IsInCombat == 1                    Protect.Cast AALCspell01 Protect                    Set fighstopped to 1                    set timer to 0          Endifelse          set timer to timer + getsecondspassed          if timer >= 15     ;activator will be ready to cast the spell every 15 seconds                    set fighstopped to 0          endifEndIfEnd


cheers,
brucevayne
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Thu Jul 22, 2010 3:19 am

It looks like the Activator is set to cast the spell on itself: Protect.Cast AALCspell01 Protect
What is the intended target of the spell?
User avatar
kennedy
 
Posts: 3299
Joined: Mon Oct 16, 2006 1:53 am

Post » Thu Jul 22, 2010 2:10 am

he needs heartbeating too probably

@ mnpred : did it work ?
User avatar
le GraiN
 
Posts: 3436
Joined: Thu Mar 22, 2007 6:48 pm

Post » Thu Jul 22, 2010 10:13 am

Yes it did, but not exactly as I would like it to. The perpos of this script is to have the activator cast a spell at the player if the player is in combat in a certon world space, (that is why i have 90000 units). The activator is to cast the spell at the player untill the player yealds or dies.

The following script works, but only once. If I want it to work again i have to restart oblivion. It dosnt mater if i reload a save, if it has already run it this instance of oblivion then it wont run again untill i restart oblivion. Also it dosnt stop when the player yeilds, so the player allways ends up dead.

Scn AACLNOfightingTESTBegin GameModeIf (Protect.Getdistance Player<90000) && (Player.IsInCombat == 1)Source.Moveto Player 0,0,150Source.Cast AALCSpell PlayerEndifIf (Player.isincombat == 0)ReturnEndifEnd


--Any ideas?
-Thanks!
----MNPred
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Wed Jul 21, 2010 11:54 pm

Ah! Never-Mind, I have managed to make it work!! Hear is the script if anyone wants to use it,

Scn AACLNOfightingTESTBegin GameModeIf (Protect.Getdistance Player<90000) && (Player.IsInCombat == 1)EnableSource.Moveto Player 0,0,150Source.Cast AALCSpell PlayerEndifIf (Player.isincombat == 0)DisableEndifEnd


--Thanks for the help!!
-MNPred
User avatar
Zualett
 
Posts: 3567
Joined: Mon Aug 20, 2007 6:36 pm


Return to IV - Oblivion