Randomiser Script

Post » Sat May 28, 2011 6:24 pm

Afternoon guys and girls,

I'm currently pulling my hair out as one of the core features of my project has given up the ghost.

What Im trying to do from the below is have it so that every 15 seconds, the timer will get a random number, then if that random number equals to one of the conditions below, it runs the 'event'.

Seems simple in principle.

But yesterday, when tweaking, I added another of these 'events' only for the whole script to decide to stop working.

I can't fathom exactly what I've done wrong, and was hoping someone with a fresh perspective could look at it and give me a helping hand?

scn TARDISrandomEncounter SCRIPTshort deathTrueshort vortexencounterfloat Encounterbegin GameMode		If Encounter == 1				; Initialises the TARDISrandomTimer between random events			set deathTrue to 0			if TARDISrandomTimer < 15				set TARDISrandomTimer to TARDISrandomTimer + GetSecondsPassed			else				set vortexencounter to getrandompercent				showMessage TARDISbroke vortexencounter				set TARDISrandomTimer to 0				set Encounter to 2			endif		endif		If Encounter == 2			Set Encounter to 0			if vortexencounter >= 95				;Big bad explosion				set TARDISrandomTimer to 0				showMessage TARDISemergency				imod MegatonNukeISFX				;set tardiscode to 2				set tardisshields to tardisshields - 25				set tardisalert to 1				tardisemerg.enable				TriggerHitShader 15				consolefire1.enable				consolefire2.enable				consolefire3.enable				consolefire4.enable				consolefire5.enable				consolefire6.enable				set Encounter to 1			elseif vortexencounter >= 25 && <= 94		;minor turbulence				set TARDISrandomTimer to 0				set tardisshields to tardisshields - 5				TriggerHitShader 30				PlaySound FXExplosionGrenadePlasmaLow				set Encounter to 1			elseif vortexencounter >= 0 && <= 24			;nothing				set TARDISrandomTimer to 0				set Encounter to 1			endif		endif	if deathTrue == 0		if tardisshields <= 0			set deathTrue to 1			player.killActor			imod FadeToWhiteISFX			PlaySound FXExplosionNukeSmall3D			PlaySound FXExplosionNukeSmall2D			PlaySound TARDIScloisterBell		endif	endifend


Cheers

Kris
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm

Post » Sat May 28, 2011 5:34 pm

You can't do this:
elseif vortexencounter >= 25 && <= 94
Instead, you need to use something like this:
elseif vortexencounter >= 25 && vortexencounter <= 94
Perhaps that's what your problem is? To be honest, I'm quite surprised the [acronym="Garden of Eden Creation Kit"]GECK[/url]'s compiler didn't give you any errors about this or the invalid "ScriptName" declaration (the name can't contain a space).

Cipscis
User avatar
k a t e
 
Posts: 3378
Joined: Fri Jan 19, 2007 9:00 am

Post » Sat May 28, 2011 6:23 pm

You can't do this:
elseif vortexencounter >= 25 && <= 94
Instead, you need to use something like this:
elseif vortexencounter >= 25 && vortexencounter <= 94
Perhaps that's what your problem is? To be honest, I'm quite surprised the [acronym="Garden of Eden Creation Kit"]GECK[/url]'s compiler didn't give you any errors about this or the invalid "ScriptName" declaration (the name can't contain a space).

Cipscis


Bloody norah, how stupid am I! Cipscis to the rescue yet AGAIN... honestly mate, I'm going to have draft up a specific note of thanks to you in mod :P Cheers buddy, this undoubtedly is what's been causing my problems!
User avatar
kat no x
 
Posts: 3247
Joined: Mon Apr 16, 2007 5:39 pm

Post » Sat May 28, 2011 5:46 am

It makes more sense to me to code your if conditions the other way around...

if vortexencounter <= 24...elseif vortexencounter <= 94...else...

With this method, you dont need to check for greater and less than in the same check and might be a bit more effecient.
User avatar
Lisha Boo
 
Posts: 3378
Joined: Fri Aug 18, 2006 2:56 pm

Post » Sat May 28, 2011 6:15 am

nevermind.
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm

Post » Sat May 28, 2011 4:46 am

As willieSea said
if vortexencounter <= 24elseif vortexencounter <= 94else

The above is good. When i code games,websites ect.. is use an if,elseif,else loop all the time, in an if elseif else you can have lots of elseif syntax but nor if or else

Hope it Helps

Maybe it would be easier if you read http://www.w3schools.com/php/php_if_else.asp about loops

Thanks Persidon
User avatar
Bloomer
 
Posts: 3435
Joined: Sun May 27, 2007 9:23 pm


Return to Fallout 3

cron