skip to content
Frictional Game Wiki
User Tools
Register
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
Register
>
Recent Changes
Media Manager
Sitemap
Trace:
hpl2:tutorials:script:random_scares
<p> This is a script that allows you to make your scares to be randomized, meaning that each playthrough will have different scares. </p> <p> Let's get started! </p> <h3>Random Scares</h3> <div class="level3"> <pre class="code">void OnStart() { AddEntityCollideCallback("Player", "ScriptArea_1", "PlrCollideSwitch", true, 1); } </pre><p> </p> <p> This is the Entity-Collide callback which will start the script. </p> <p> If you already have the void OnStart() then just copy-paste the AddEntityCollideCallback line. </p> <p> Let's break this one on one. </p> <p> "Player" is the entity that collides the second entity. </p> <p> "ScriptArea_1" is the entity that gets collided by the first one. </p> <p> "PlrCollideSwitch" will be the function it will do. </p> <p> After that, wrote the following code at the bottom of the void OnStart(). </p> <pre class="code">void PlrCollideSwitch(string &in asParent, string &in asChild, int alState) { int x = RandInt(1, 5) switch(x) { case 1: //Scare 1 break; case 2: //Scare 2 break; case 3: //Scare 3 break; case 4: //Scare 4 break; case 5: //Scare 5 break; } </pre><p> </p> <p> This is the Switch-Statement that will determine what scare produced. In each Case #, write a specific code that will execute your scare. Make sure that piece of code is BEFORE the break; </p> <p> You don't need curly brackets ({}) to envelope each case. You need a break;. A code will be executed BEFORE it hit the break;. </p> <p> Hope this can make your custom story to be fully replayable and unique. </p> <p> You can find me at Frictional Games Forum under the same name. </p> <p> - JustAnotherPlayer </p> </div>
hpl2/tutorials/script/random_scares.txt
· Last modified: 2013/04/23 09:33 by
justanotherplayer
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Back to top