Jump to content

My script is crashing the game


TheScallywag

Recommended Posts

this script crashes the game whenever i start the quest to activate it, the script type is Quest

 

scn PassOutScript

float timer

Begin GameMode

Label 1

set timer to 0

if player.GetHealthPercentage < 0.25
ApplyImageSpaceModifier FadeToWhiteISFX
player.ResetHealth
SetPCSleepHours 4
if timer < 5
set timer to timer + GetSecondsPassed
else
ApplyImageSpaceModifier FadeInFromWhiteISFX
set timer to 0
endif
else
if timer < 5
set timer to timer + GetSecondsPassed
else
set timer to 0
endif
Goto 1
endif

End

Link to comment
Share on other sites

It crashes because you produced an infinite loop there.

While HealthPercentage is >= 0.25 this construct will always jump back up to the label and the game will not be able to proceed a single frame. HealthPercentage can't change without the game proceeding, nor can any other condition outside the script ever change.

 

Using a timer will only work when you let the game proceed and wait for it to return back into your GameMode block after the "fQuestDelayTime" passed. Only then GetSecondsPassed will contain a different value, as it only contains the value of seconds passed since last execution of the script block.

 

Using Loop and Goto on the other hand will make the script loop during a single frame... effectively prolonging the frame and killing your frame rate as a result. In your case even, prolonging a single frame endlessly.

 

The GameMode block already is a looping construct. It gets executed again every "fQuestDelayTime" seconds after its last run. And you can use "set fQuestDelayTime to 5" right at the beginning of your GameMode block to make it wait 5 seconds after it's done with the current execution. As the name says it takes a "float"-type value, thus you can of course also wait only fractions of a second until next iteration. A certain 1-digit amount of seconds is default, if not set specifically to be otherwise in the script.

 

edit: Just rechecked FO3 scripting to be sure and it seems it isn't 'exactly' like ObScript. Seems there is no "fQuestDelayTime" variable, but you have to set the quest delay time differently, as explained here:

http://geck.bethsoft.com/index.php?title=Quest_scripts

Everything else from what I said apparently still applies though *phew*

Edited by DrakeTheDragon
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...