User Tools

Site Tools


Sidebar

hpl2:tutorials:scripting:scaresbyjenniferorange

This is an old revision of the document!


Scares

Ever wanted to throw the player through a doorway, have him collapse, or just want to scare the crap out of your players in general? You've come to the right place! Today I'll show you, in as much detail as possible, how to scare your players without dragging out the brutes/grunts/water monsters.

Scare 1 - Throwing The Player

I once played a custom story where, at totally random times, I(Daniel) would be thrown around the room. (Apologies, I can't remember the name.) This is a great scare!

First make sure you have a little area where you'd like this to happen. For mine, I chose the bottom of a staircase which leads into another open room. It's important to make sure the area the player gets pushed into is a rather open area, unless you'd like the player to run into something and say, knock it over. For my scare, we're going to push the player into the other room, then have the door slam and lock behind him.

  1. Place the script area. Once again, mine is right at the bottom of a staircase. Re-name the area to what ever you'd like. I named mine push. (See picture 2 at the bottom.)
  2. Now you need to open the door. In the Level Editor, click on the door. Under the Entity tab, there's an option called OpenAmount. Keep clicking the + button or simply type in the number 1. This will make the door all the way open. You can also re-name your door. Mine is called cellar_1.
  3. Now you need to make the area the player will run into that causes the door to slam. Where you put it depends on how far you want the player to be thrown. For mine, the distance between the script area and the door is about the width of the cabinet_nice or cabinet_simple. Make this area rather large to be certain the player will collide with it. I re-named that script area door_slam. (See picture 1 at the bottom.)
  4. Now it's time for scripting! Open the map's .hps file. We have to make 2 collides, one for push and one for door_slam.
void OnStart()
{ 
  AddEntityCollideCallback("Player", "push", "Push", true, 1);
  AddEntityCollideCallback("Player", "door_slam", "Slam", true, 1);
}

The Callback for push I named Push, and the Callback for door_slam I named Slam.

Now you have to make the Functions.

void OnStart()
{ 
  AddEntityCollideCallback("Player", "push", "Push", true, 1);
  AddEntityCollideCallback("Player", "door_slam", "Slam", true, 1);
}
 
 
void Push(string &in asParent, string &in asChild, int alState)
{
 PlaySoundAtEntity("", "react_pant.snt", "push", 0, false);
 AddPlayerBodyForce(30000, 0, 0, false);
}
 
 
void Slam(string &in asParent, string &in asChild, int alState)
{
 SetSwingDoorClosed("cellar_1", true, true);
 SetSwingDoorLocked("cellar_1", true, true);
 PlaySoundAtEntity("", "00_laugh.snt", "door_scare", 0, false);
}

Under the Push function, PlaySoundAtEntity is not necessary, but if you want that extra scare, you can keep it and Daniel will react with a gasp. The value I picked for the AddPlayerBodyForce is 30000. This will push the player as far as about the width of the cabinet_nice or cabinet_simple as mentioned above. I only wanted the player to be sent forward, but you might have to adjust your values based on where the door is (you might have to put it on the z one) Remember the values for AddPlayerBodyForce go X, Y, Z. Therefore the player will be pushed 30000 along the x axis. Y will send the player up or down. For Slam, I set the door to be closed, then locked. I also added a laugh to make it extra creepy.

Put all of that together and the scare should be a successful one! Good luck!

Pictures: 1 2

Scare 2 - Flying Jesus

Requested by Datguy5! Check out his profile on FG! http://www.frictionalgames.com/forum/user-18514.html

For the famous and most crap-your-pants scare called “Flying Jesus”, you'll need an area and a male corpse.

  1. Pick yourself a nice location for the script area. One of the best spots is in a long corridor. Keep in mind the script area is for, when the player hits it, the “Jesus” will fly down the corridor. So don't think he'll spawn there for something. Make sure you extend that sucker out to each end of the wall. There are some scared Players that try and sneak past the script areas. Re-name your Script Area. For this example, I'll name mine FlyingJesus_1. No pun intended. Don't forget to hit ENTER!
  2. Now the best way to do this, and get it right, is to have the corpse spawn and then add a prop force. If the corpse is already active, he'll be lying on the ground in a heap and when the prop force is added he might just slide on the floor. However if you think that's scary you can try that one too. Place your flying Jesus man a decent ways down the corridor, from the Script Area. The length of about 2 or 3 walls is good. Aim his face toward the direction the Player will come. Set him unactive and re-name him! I'll rename mine Jesus_1. (Don't forget, when you place him, to make him floating somewhat in the air to be sure he'll hit the player. See Picture 1.)
  3. Now we can script. Open your maps' .hps.
void OnStart()
{
AddEntityCollideCallback("Player", "FlyingJesus_1", "HolyJesus", true, 1);
AddEntityCollideCallback("Jesus_1", "FlyingJesus_1", "Sound", true, 1);
}
 
 
void HolyJesus(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Jesus_1");
AddPropForce("Jesus_1", 0, 0, 30000, "World");
}
 
 
void Sound(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "24_iron_maiden.snt", "FlyingJesus_1", 0, false);
}

I added the scary Iron Maiden sound to play when the corpse hit the Script Area. It adds a scarier jump effect, but it's optional of course. For the AddPropForce, you may have to tweak it. For me, 30000 was perfect, and whether it goes in X, Y, or Z depends on your map. For me it was Z. Here's one way to find out: Select a wall or object in the room. Click the + or - button under Position for X, Y, and Z and note which way the object goes. If it goes in the direction of the Script Area, (let's say it's X) then you put the 30000 under X.

Enjoy making your players freak out and pee their pants. :]

More pictures!

2 3

Created by JenniferOrange

IF YOU HAVE ANY OTHER REQUESTS FOR SCARES, PLEASE PM ME AT http://www.frictionalgames.com/forum/user-15434.html (YOU DO NEED TO BE EITHER REGISTERED/LOGGED IN TO FRICTIONALGAMES TO VIEW THIS PAGE!!)

hpl2/tutorials/scripting/scaresbyjenniferorange.1326495801.txt.gz · Last modified: 2012/01/13 23:03 by jenniferorange