<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl3%3AGame%3Ascripting%3Asequences</id>
	<title>Hpl3:Game:scripting:sequences - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl3%3AGame%3Ascripting%3Asequences"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl3:Game:scripting:sequences&amp;action=history"/>
	<updated>2026-05-15T09:41:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl3:Game:scripting:sequences&amp;diff=564&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl3:Game:scripting:sequences&amp;diff=564&amp;oldid=prev"/>
		<updated>2020-07-09T13:43:52Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Sequences =&lt;br /&gt;
&lt;br /&gt;
Many of the events that happen throughout SOMA are triggered sequences - a sound plays, then the player's FoV changes, then a light starts flashing etc. etc. We control all of those through a set of wrappers we call Sequences, which hide a bunch of timers away and make things easier to read.&lt;br /&gt;
&lt;br /&gt;
For each sequence you need a map property to store the state - a ''cSequenceStatesData'' property e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
cSequenceStatesData mSequenceAlert;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you create a sequence function. This will be repeatedly called until the whole sequence is over. It looks something like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
void Sequence_Alert(const tString&amp;amp; in asName)&lt;br /&gt;
{&lt;br /&gt;
    Sequence_Begin(&amp;quot;Sequence_Alert&amp;quot;, mSequenceAlert);&lt;br /&gt;
    &lt;br /&gt;
    if(Sequence_DoStepAndWait(1.0f))  // Do this step and then wait for 1 second&lt;br /&gt;
    {&lt;br /&gt;
        MakeALoudNoise();&lt;br /&gt;
    }&lt;br /&gt;
    else if (Sequence_DoStepAndWait(2.5f)) // Do this and then wait for 2.5 seconds&lt;br /&gt;
    {&lt;br /&gt;
        FlashABrightLight();&lt;br /&gt;
    }&lt;br /&gt;
    else if (Sequence_DoStepAndPause()) // Do this and then pause until told otherwise&lt;br /&gt;
    {&lt;br /&gt;
        SaySomethingAndCallBack(&amp;quot;OnSayingSomethingComplete&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else if (Sequence_DoStepAndWait(10.0f)) // Do this and then wait for 10s&lt;br /&gt;
    {&lt;br /&gt;
        CrushPlayerLikeAnAnt();&lt;br /&gt;
    }&lt;br /&gt;
    else if (Sequence_DoStepAndContinue()) // Do this and go on to the next step (in this case there isn't one)&lt;br /&gt;
    {&lt;br /&gt;
        ApologiseToPlayer();&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    Sequence_End();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void OnSayingSomethingComplete()&lt;br /&gt;
{&lt;br /&gt;
    // Saying something is now complete - poke the sequence to continue processing&lt;br /&gt;
    SequenceStates_Resume(&amp;quot;Sequence_Alert&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, ''Sequence_DoStepAndPause()'' in there actually pauses the whole sequence until some external event - in this case the callback from the voice playing code - calls ''SequenceStates_Resume()'' and asks it to continue.&lt;br /&gt;
&lt;br /&gt;
To start the sequence, you just call the sequence function '''once''' with an empty argument when you want it to trigger e.g.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
Sequence_Alert(&amp;quot;&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
no need to call it every frame or anything! Once started, timers will automatically make sure that the sequence steps get followed when they need to be.&lt;br /&gt;
&lt;br /&gt;
We use this a lot, all the way through SOMA, sometimes running multiple sequences in parallel, as they're totally independent of each other. (Which is perfectly possible, but can get very confusing - we really wouldn't recommend it, it more grew out of level complexity than anything else!)&lt;br /&gt;
&lt;br /&gt;
=== Important Functions ===&lt;br /&gt;
&lt;br /&gt;
==== Sequence_Begin ====&lt;br /&gt;
Mark the start of a sequence block.&lt;br /&gt;
==== Sequence_End ====&lt;br /&gt;
Mark the end of the current sequence block.&lt;br /&gt;
==== Sequence_Stop ====&lt;br /&gt;
Stop the current sequence immediately (sort of like an abort).&lt;br /&gt;
==== Sequence_DoStepAndWait ====&lt;br /&gt;
Do the step within the following brackets and then wait for the specified time.&lt;br /&gt;
==== Sequence_DoStepWaitAndRepeat ====&lt;br /&gt;
Do the step within the following brackets and then wait for the specified time; repeat for a number of iterations.&lt;br /&gt;
==== Sequence_DoStepAndContinue ====&lt;br /&gt;
Do the step within the following brackets and then immediately carry on to the next step.&lt;br /&gt;
==== Sequence_DoStepAndPause ====&lt;br /&gt;
Do the step within the following brackets and then pause until ''Sequence_Resume'' is called.&lt;br /&gt;
==== Sequence_Wait ====&lt;br /&gt;
Just wait for a set period of time (no step in brackets).&lt;br /&gt;
==== Sequence_Pause ====&lt;br /&gt;
Pause the sequence until ''Sequence_Resume'' is called.&lt;br /&gt;
==== Sequence_SkipNextSteps ====&lt;br /&gt;
Skip the specified number of sequence steps.&lt;br /&gt;
==== Sequence_SkipNextStep ====&lt;br /&gt;
Skip the next sequence step.&lt;br /&gt;
==== SequenceStates_Pause ====&lt;br /&gt;
Pause a specified sequence.&lt;br /&gt;
==== SequenceStates_Resume ====&lt;br /&gt;
Resume the specified sequence.&lt;br /&gt;
==== SequenceStates_Stop ====&lt;br /&gt;
Stop the specified sequence.&lt;br /&gt;
==== SequenceStates_IsActive ====&lt;br /&gt;
Returns true if a particular sequence is active.&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>