SomeoneIknow Posted June 24, 2011 Share Posted June 24, 2011 So I'm trying to make a very basic repeatable that whenever the quest is reinitialized the quest stage loaded is recalculated using the GetRandomPercent function. However my issue is that everytime I reinitialize my quest the same quest stage is always set instead of being truly random. Here is the code that I have made in the quest script: Scn aaPracRepQuestSCRIPT short iniQuest ; This variable currently used to control if or when the script sets the quest to whatever stageshort rndmStage ; This var currently used to determine which quest stage the quest will be setshort doOnce Begin gamemode if getquestcompleted aaPracRepQuest == 0 && iniQuest == 0 set rndmStage to getrandompercent set iniQuest to 1 endif if rndmStage >= 0 || rndmStage <= 49 && iniQuest == 1 && doOnce == 0 setstage aaPracRepQuest 10 aaPracBadGuyREF.enable aaPracBadGuyREF.resurrect 0 aaPracBadGuyREF.moveto aaPracBadGuyXREF set doOnce to 1 endif elseif rndmStage >= 50 || rndmStage <= 99 && iniQuest == 1 && doOnce == 0 setstage aaPracRepQuest 20 aaPracBadGuy2REF.enable aaPracBadGuy2REF.resurrect 0 aaPracBadGuy2REF.moveto aaPracBadGuyXREF set doOnce to 1 endif if aaPracBadGuyREF.getdead == 1 || aaPracBadGuy2REF.getdead == 1 setstage aaPracRepQuest 100 set iniQuest to 0 set doOnce to 0 endif END And just to be clear the way I reset the quest in-game is through a message box prompt that I made when activating a particular object. For this purpose I make use of the function ResetQuest. This function takes the completed quest out of the pipboy's completed quest log and allows the quest to be reinitialized as a new uncompleted quest. So my issue is that for whatever reason whenever my quest is reinitialized the script always sets the quest stage to 10 even though I set up a 50% chance to setstage 10 or setstage 20. My best bet is that for whatever reason the GetRandomPercent function is constantly giving the same exact number in every instance of its call but I have no idea how to fix that. :( Link to comment Share on other sites More sharing options...
TheTalkieToaster Posted June 24, 2011 Share Posted June 24, 2011 (edited) Is that really surprising when you have the condition if(rndmStage >= 0) OR (X AND Y AND Z)?First, put brackets to get your conditions in order. Second, since random can only ever be between 0-99 the if <=99 and if >=0 conditions are pointless. Third, you've got an elseif with no preceding if, so something's liable to bugger up. Fourth, you're duplicating a lot of checks which just adds points where a cock up can occur and a good chunk of your conditions and variables are superfluous anyway. Fifth, it's always going to reset quest immediately as long as at least one of the NPCs is dead. Finally, if you're posting code, use the [code] tagsIt'd be best off rewritten entirely as:short currQuest begin gameMode if (currQuest) if ((aaPracBadGuyREF.getdead && currQuest == 1) || (aaPracBadGuy2REF.getdead && currQuest == 2)) setStage aaPracRepQuest 100 set currQuest to 0 end if else if(GetRandomPercent < 50) set currQuest to 1 ;Set up quest 1 else set currQuest to 2 ;Set up quest 2 end if end if endE: "end if" used in place of "endif" because of the [code] tag's highlighting. Edited June 24, 2011 by TheTalkieToaster Link to comment Share on other sites More sharing options...
SomeoneIknow Posted June 25, 2011 Author Share Posted June 25, 2011 Yeah ha, I made some very silly mistakes, especially with those or || statements. Well I got it working this time around so thanks for the reply and kudos! Link to comment Share on other sites More sharing options...
Recommended Posts