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...

While Loops


JulianSull
 Share

Recommended Posts

You cannot 'loop' in vanilla scripts in the same execution frame.

You 'can' loop once per exectution frame.

An execution frame is one FPS cycle.

A GameMode block can be used to run once every FPS cycle. This can be used to simulate a looping structure. You can use a variable to determine when to run the loop, and when not to.

short doOnce
short myVal
Begin GameMode
if doOnce == 0
player.PlaceAtMe Gold001 1
set myVal to myVal + 1
if myVal > 10
set doOnce to 1
endif
endif
End[/code]

This will run 10 times and then quit running.

Link to comment
Share on other sites

Hmmm, Well what I am trying to do is have the script select a random target that was NOT the target before. My current script is:


scn aaaRunArcheryChallengeScript


float timer

short times

short thing

short rand


begin GameMode


	if (aaaACisStarted == 0)

		return

	else

		set timer to timer + getSecondsPassed

		set rand to 1 + GetRandomPercent * (5-1) / 99


		if  (rand == aaaLastShot)

			set rand to 1 + GetRandomPercent * (5-1) / 99 ;<-----------This where I try to get a new random location

		endif


		if (times < 10)

			set thing to 5

		elseif (times < 20)

			set thing to 4

		else if (times < 30)

			set thing to 3

		endif


		if (times > 30)

			aaaTCLight1.disable

			aaaTCLight2.disable

			aaaTCLight3.disable

			aaaTCLight4.disable

			aaaTCLight5.disable

			aaaTrigZoneAC1.disable

			aaaTrigZoneAC2.disable

			aaaTrigZoneAC3.disable

			aaaTrigZoneAC4.disable

			aaaTrigZoneAC5.disable

			set aaaACisStarted to 0

			set times to 0

			MessageBox "Total Score = %.0f" aaaACTotalScore

			if (aaaACTotalScore > aaaACHighScore)

				set aaaACHighScore to aaaACTotalScore

				MessageBox "New High Score!"

			endif

			set aaaACTotalScore to 0

		elseif (timer > thing)

			set times to times + 1

			set timer to 0

			aaaTCLight1.disable

			aaaTCLight2.disable

			aaaTCLight3.disable

			aaaTCLight4.disable

			aaaTCLight5.disable

			aaaTrigZoneAC1.disable

			aaaTrigZoneAC2.disable

			aaaTrigZoneAC3.disable

			aaaTrigZoneAC4.disable

			aaaTrigZoneAC5.disable

			if (rand == 1)

				aaaTCLight1.enable

				aaaTrigZoneAC1.disable

			elseif (rand == 2)

				aaaTCLight2.enable

				aaaTrigZoneAC2.disable

			elseif (rand == 3)

				aaaTCLight3.enable

				aaaTrigZoneAC3.disable

			elseif (rand == 4)

				aaaTCLight4.enable

				aaaTrigZoneAC4.disable

			elseif (rand == 5)

				aaaTCLight5.enable

				aaaTrigZoneAC5.disable

			endif

			set aaaLastShot to rand

		endif

	endif

endif


end

Basically, after a certain number of targets switch, the time that the shot is open decreases. Also, I wanted to add a section where the time to hit goes up to 6 and the player gets two open targets, but how could I script that without having to use a while loop? And is using OBSE a big thing for some people? I mean like does it slow some computers down a lot?

Link to comment
Share on other sites

Basically, after a certain number of targets switch, the time that the shot is open decreases. Also, I wanted to add a section where the time to hit goes up to 6 and the player gets two open targets, but how could I script that without having to use a while loop? And is using OBSE a big thing for some people? I mean like does it slow some computers down a lot?

If you really need OBSE I think you should use it. OBSE doesn't cause any performance hit on its own, but if a modder uses a CPU intensive function over and over again then it would possibly cause a performance hit.

Link to comment
Share on other sites

I just tried to get OBSE to work...but I have no idea how to make the CS recognize that I have it. I checked the documentation...ReadMes and all that but nothing. Anyone know how to get it up and running? Also even more importantly how do I get extra things such as "Enhanced Music Control" to work which is basically an extension of OBSE. I put it in the OBSE--> Plugins folder but still nothing.

Link to comment
Share on other sites

I do not cover OBSE scripting in this forum. I do not use it so would be of little help setting it up.

If I understand what you are trying to do, the below fixes might help make it work the way you want it to.

scn aaaRunArcheryChallengeScript

float timer
short numTimes
short maxTime
short rand

begin GameMode

if (aaaACisStarted == 0)
return
endif

set timer to timer + getSecondsPassed
set rand to 1 + GetRandomPercent * (5-1) / 99

if (rand == aaaLastShot)
return
endif

if (numTimes < 10)
set maxTime to 5
elseif (numTimes < 20)
set maxTime to 4
else
set maxTime to 3
endif

if (numTimes > 30)
aaaTCLight1.disable
aaaTCLight2.disable
aaaTCLight3.disable
aaaTCLight4.disable
aaaTCLight5.disable
aaaTrigZoneAC1.disable
aaaTrigZoneAC2.disable
aaaTrigZoneAC3.disable
aaaTrigZoneAC4.disable
aaaTrigZoneAC5.disable
set aaaACisStarted to 0
set numTimes to 0
MessageBox "Total Score = %.0f" aaaACTotalScore
if (aaaACTotalScore > aaaACHighScore)
set aaaACHighScore to aaaACTotalScore
MessageBox "New High Score!"
endif
set aaaACTotalScore to 0
return
endif

if (timer > maxTime)
set numTimes to numTimes + 1
set timer to 0
aaaTCLight1.disable
aaaTCLight2.disable
aaaTCLight3.disable
aaaTCLight4.disable
aaaTCLight5.disable
aaaTrigZoneAC1.disable
aaaTrigZoneAC2.disable
aaaTrigZoneAC3.disable
aaaTrigZoneAC4.disable
aaaTrigZoneAC5.disable
if (rand == 1)
aaaTCLight1.enable
aaaTrigZoneAC1.disable
elseif (rand == 2)
aaaTCLight2.enable
aaaTrigZoneAC2.disable
elseif (rand == 3)
aaaTCLight3.enable
aaaTrigZoneAC3.disable
elseif (rand == 4)
aaaTCLight4.enable
aaaTrigZoneAC4.disable
elseif (rand == 5)
aaaTCLight5.enable
aaaTrigZoneAC5.disable
endif
set aaaLastShot to rand
endif
end
[/code]

The biggest thing I changed is a 'return' if the current number is the same as the last number.

You also had an 'else if' that had a space in it, changing the whole structure of that line of code.

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...