Trouble with a random spell script

Post » Fri May 27, 2011 11:30 am

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. 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. :banghead: The current script is:

scn BlahBlahBlahYackittySmackittyScriptfloat timershort readyshort disabledshort Randombegin 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	  endifendbegin 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	 endifendbegin onReset	  reset3DState	  end


So, what am I doing wrong here? :shrug:
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Fri May 27, 2011 5:14 am

Three possible causes I spot:
- a distance of ~700 is like four steps away. Unless you're standing close to the thing, you're probably too far away. Additionally if you just cross it's path, the timer will reset after you've left it.
- I'm not sure the timer will work as you want it to. Try a simpler timer.
- I'm quite sure that, due to the way it's set up, Random is never set to any other value except 0.
User avatar
Carys
 
Posts: 3369
Joined: Wed Aug 23, 2006 11:15 pm

Post » Thu May 26, 2011 10:11 pm

BG, you'vre given me a LOT of help since I became a member here and I really appreciate it. :foodndrink: Thanks.

Three possible causes I spot:
- a distance of ~700 is like four steps away. Unless you're standing close to the thing, you're probably too far away. Additionally if you just cross it's path, the timer will reset after you've left it.


I stood right at the base of it, so distance isn't a factor. :)

- I'm not sure the timer will work as you want it to. Try a simpler timer.


Should it be a Short instead of a Float?

- I'm quite sure that, due to the way it's set up, Random is never set to any other value except 0.


What do I need to change to get Random to be set to something between 0 & 99?
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Fri May 27, 2011 1:26 am

Solved. I put Set Random to GetRandomPercent in the wrong place. It should have been in the GameMode block.
User avatar
Alisha Clarke
 
Posts: 3461
Joined: Tue Jan 16, 2007 2:53 am

Post » Thu May 26, 2011 9:41 pm

Locked by request
User avatar
Elena Alina
 
Posts: 3415
Joined: Sun Apr 01, 2007 7:24 am


Return to IV - Oblivion