Making this function loop

Post » Wed Jun 04, 2014 4:09 pm

I'm trying to simulate Skyrim-style sandboxing using script packages, and this is the script. In the section for actually choosing the package, though, the game freezes if a while loop is used. Does anyone have any ideas on how to make that section loop until a package is chosen?

scn VGMultiPackageSandboxingref Targetref Packageref Cellref Factionref PotentialPackage1ref PotentialPackage2ref PotentialPackage3ref PotentialPackage4ref PotentialPackage5ref PotentialPackage6ref PotentialPackage7short ChosenPackageref CurrentPackagebegin Function {Target};First, we define acceptable sandbox procedures.;This is based on faction for now.	if (Target.GetInFaction VGVampGuild == 1)	set Cell to VGVampGuildHQ	set Faction to VGVampGuild	set PotentialPackage1 to VGVampGuildDefaultPracticeTargetChainXx1	set PotentialPackage2 to VGVampGuildDefaultPracticeTargetHeavyXx1Location1	set PotentialPackage3 to VGVampGuildDefaultPracticeTargetHeavyXx1Location2	set PotentialPackage4 to VGVampGuildDefaultPracticeTargetRangedXx1	set PotentialPackage5 to VGVampGuildDefaultPracticeTargetHeavyMagicXx1	set PotentialPackage6 to VGVampGuildDefaultReadXx1Location1	set PotentialPackage7 to VGVampGuildDefaultReadXx1Location2endif;Next, we decide which package the actor is going to choose.MessageEx "%n is choosing a package." Targetset ChosenPackage to (1 + GetRandomPercent * 0.07)if (ChosenPackage == 1)	if (Target.GetInFaction VGSandboxingMeleePracticeAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingTargetChain == 0)			set VGVampGuildQ00General.UsingTargetChain to 1			set Package to PotentialPackage1		endif	endifelseif (ChosenPackage == 2)	if (Target.GetInFaction VGSandboxingMeleePracticeAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingTargetHeavy1 == 0)			set VGVampGuildQ00General.UsingTargetHeavy1 to 1			set Package to PotentialPackage2		endif	endif	elseif (ChosenPackage == 3)	if (Target.GetInFaction VGSandboxingMeleePracticeAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingTargetHeavy2 == 0)			set VGVampGuildQ00General.UsingTargetHeavy2 to 1			set Package to PotentialPackage3		endif	endifelseif (ChosenPackage == 4)	if (Target.GetInFaction VGSandboxingRangedPracticeAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingTargetRanged == 0)			set VGVampGuildQ00General.UsingTargetRanged to 1			set Package to PotentialPackage4		endif	endifelseif (ChosenPackage == 5)	if (Target.GetInFaction VGSandboxingMagicPracticeAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingTargetHeavy1 == 0) && (VGVampGuildQ00General.UsingTargetHeavy2 == 0)			set VGVampGuildQ00General.UsingTargetHeavy1 to 1			set VGVampGuildQ00General.UsingTargetHeavy2 to 1			set Package to PotentialPackage5		endif	endifelseif (ChosenPackage == 6)	if (Target.GetInFaction VGSandboxingReadingAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingReadingSpot1 == 0)			set VGVampGuildQ00General.UsingReadingSpot1 to 1			set Package to PotentialPackage6		endif	endifelseif (ChosenPackage == 7)	if (Target.GetInFaction VGSandboxingReadingAcceptable == 1)		if (Faction == VGVampGuild) && (VGVampGuildQ00General.UsingReadingSpot2 == 0)			set VGVampGuildQ00General.UsingReadingSpot2 to 1			set Package to PotentialPackage7		endif	endifendif	;Next, we see if it's appropriate to idle.if (Package != 0)	if (Target.GetDead == 0) && (Target.GetInFaction Faction == 1) && (Target.GetInCell Cell == 1) && (Target.GetCurrentAIPackage != 3) && (Target.GetCurrentAIPackage != 4)		if (Target.GetIsCurrentPackage PotentialPackage1 == 0) && (Target.GetIsCurrentPackage PotentialPackage2 == 0) && (Target.GetIsCurrentPackage PotentialPackage3 == 0) && (Target.GetIsCurrentPackage PotentialPackage4 == 0) && (Target.GetIsCurrentPackage PotentialPackage5 == 0) && (Target.GetIsCurrentPackage PotentialPackage6 == 0) && (Target.GetIsCurrentPackage PotentialPackage7 == 0)			set CurrentPackage to (Target.GetCurrentEditorPackage)			if (CurrentPackage.GetPackageSkipFalloutBehavior == 0) ;Simple check to avoid nulling quest-related script packages.				Target.AddScriptPackage Package				MessageEx "%n is running a package." Target			endif		endif	endifendifend
User avatar
Campbell
 
Posts: 3262
Joined: Tue Jun 05, 2007 8:54 am

Return to IV - Oblivion