Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Trouble with a random spell script


The Vyper
 Share

Recommended Posts

I'm working on an activator that will cast a random spell at the Player every 8 seconds as long as the Player is in range. :book: The activator in question is a Dark Welkynd Stone that will first glow, then cast the random spell. The stone does glow, but it won't cast a spell at all. aa_wall.gif The current script is:


scn BlahBlahBlahYackittySmackittyScript


float timer

short ready

short disabled

short Random


begin onActivate


      if isActionRef player == 0

            if disabled == 0

                 set disabled to 1

                 set timer to 0

                 set Random to GetRandomPercent

            else

                 set disabled to 0

            endif

      endif


end


begin gameMode


     if disabled == 0


           if getDistance player < 720 && timer <= 0

                 playgroup forward 0

                 set ready to 1

                 set timer to 8

           endif

     endif


     if timer <= 1 && ready == 1

         if getDistance player < 720

              if Random > 0 && Random <= 5

                   cast NARTF10 player

              elseif Random > 5 && Random <= 10

                   cast NARTF20 player

              elseif Random > 10 && Random <= 15

                   cast NARTF30 player

              elseif Random > 15 && Random <= 20

                   cast NARTF40 player

              elseif Random > 20 && Random <= 25

                   cast NARTF50 player

              elseif Random > 25 && Random <= 30

                   cast NARTFr10 player

              elseif Random > 30 && Random <= 35

                   cast NARTFr20 player

              elseif Random > 35 && Random <= 40

                   cast NARTFr30 player

              elseif Random > 40 && Random <= 45

                   cast NARTFr40 player

              elseif Random > 45 && Random <= 50

                   cast NARTFr50 player

              elseif Random > 50 && Random <= 55

                   cast NARTS10 player

              elseif Random > 55 && Random <= 60

                   cast NARTS20 player

              elseif Random > 60 && Random <= 65

                   cast NARTS30 player

              elseif Random > 65 && Random <= 70

                   cast NARTS40 player

              elseif Random > 70 && Random <= 75

                   cast NARTS50 player

              elseif Random > 75 && Random <= 80

                   cast NARTDH10 player

              elseif Random > 80 && Random <= 85

                   cast NARTDH20 player

              elseif Random > 85 && Random <= 90

                   cast NARTDH30 player

              elseif Random > 90 && Random <= 95

                   cast NARTDH40 player

              elseif Random > 95 && Random <= 99

                   cast NARTDH50 player

              endif

              set ready to 0


         endif


     endif


     if timer > 0

          set timer to timer - getSecondsPassed

     endif


end


begin onReset


      reset3DState



end


So, what am I doing wrong here? :D:thumbup:

Link to comment
Share on other sites

Not sure on the scripting end, but not all meshes have the ability to cast spells. There are dark welkynds in the CS that are meant to just glow, not cast, so are you sure the one you're using is one that can cast spells?

I used a stone that casts spells in Vanilla (just changed the EditorID and script), so it seems I did something wrong in the script. I just can't see what it is. :thumbup:

Link to comment
Share on other sites

1. Your 'Random' variable is only set when you physically Activate the stone. You need to set it in the GameMode block where you are setting the variables when the player is in range.

2. There is no need to double-check your 'Random' value in the IF block where you cast your spell. Do this instead:

             if Random <= 5
cast NARTF10 player
elseif Random <= 10
cast NARTF20 player
elseif Random <= 15
cast NARTF30 player
elseif Random <= 25
cast NARTF50 player[/code]

You may ask Why?

You do not need to check for the 'greater than' value since the first 'true' condition will be the only one executed.

Example: If your value is 14, the first two are false and the thrid one will be true (<= 15) so the spell NARTF30 will be cast at the player. And since this was true, the IF block will end and control passes to the 'EndIf' line.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...