User Tools

Site Tools



This is a script that allows you to make your scares to be randomized, meaning that each playthrough will have different scares.

Let's get started!

Random Scares

void OnStart()
AddEntityCollideCallback("Player", "ScriptArea_1", "PlrCollideSwitch", true, 1);

This is the Entity-Collide callback which will start the script.

If you already have the void OnStart() then just copy-paste the AddEntityCollideCallback line.

Let's break this one on one.

“Player” is the entity that collides the second entity.

“ScriptArea_1” is the entity that gets collided by the first one.

“PlrCollideSwitch” will be the function it will do.

After that, wrote the following code at the bottom of the void OnStart().

void PlrCollideSwitch(string &in asParent, string &in asChild, int alState)
int x = RandInt(1, 5)
case 1:
//Scare 1
case 2:
//Scare 2
case 3:
//Scare 3
case 4:
//Scare 4
case 5:
//Scare 5

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;

You don't need curly brackets ({}) to envelope each case. You need a break;. A code will be executed BEFORE it hit the break;.

Hope this can make your custom story to be fully replayable and unique.

You can find me at Frictional Games Forum under the same name.

- JustAnotherPlayer

hpl2/tutorials/script/random_scares.txt · Last modified: 2013/04/23 09:33 by justanotherplayer