<?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=Hpl2%3ATutorials%3Ascript%3Aevents</id>
	<title>Hpl2:Tutorials:script:events - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Aevents"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:events&amp;action=history"/>
	<updated>2026-05-14T03:18:36Z</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=Hpl2:Tutorials:script:events&amp;diff=838&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:events&amp;diff=838&amp;oldid=prev"/>
		<updated>2020-07-09T13:48:41Z</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;= Scary events =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Today I (xtron) will show you! (the reader) how to make scary events that will yea…scare the player!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The door slam ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Door. ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
we will startoff this tutorial with the basic door slam!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Start with adding a door.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go to entities &amp;gt; Door &amp;gt; Choose a door that you want to slam. Change the name of it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now when you got the door added you need to change the open ammount.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the door &amp;gt; Entity &amp;gt; Look for &amp;quot;OpenAmount&amp;quot; and change it to 1. 1 is just a recommendation you can choose anything really.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you're done with the door. Let's get going to the Script Area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Script Area. ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Press on Area (8) &amp;gt; Script and make an area infront of the door like so:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://img705.imageshack.us/img705/4039/doorslam.png img705.imageshack.us/img705/4039/doorslam.png] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you're done with that you need to change it's name, pick anything just remember it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we're done with the Script Area, let's get going to the actuall scripting.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Script ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First off we will be needing to add an EntityCollideCallBack to the void OnStart()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
AddEntityCollideCallback(&amp;quot;Player&amp;quot;, &amp;quot;script_slam&amp;quot;, &amp;quot;func_slam&amp;quot;, true, 1);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you're done adding that we will need to start working on the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First function we're gonna add is the actuall slam!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
{&lt;br /&gt;
SetSwingDoorClosed(&amp;quot;door1&amp;quot;, true, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
That was the first function of a couple.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After the slam we want some sanity increase and maybe one or two sounds! (three actually).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void func_move_box1(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;{&lt;br /&gt;
SetSwingDoorClosed(&amp;quot;door1&amp;quot;, true, true);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_breath_slow.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_scare&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;close_door.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
GiveSanityDamage(5.0f, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we got the door slam setup. The result of this one should look like this&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void OnStart()&lt;br /&gt;
 &lt;br /&gt;
{&lt;br /&gt;
AddEntityCollideCallback(&amp;quot;Player&amp;quot;, &amp;quot;script_slam&amp;quot;, &amp;quot;func_slam&amp;quot;, true, 1);&lt;br /&gt;
} &lt;br /&gt;
 &lt;br /&gt;
void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
{&lt;br /&gt;
SetSwingDoorClosed(&amp;quot;door2&amp;quot;, true, true);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_breath_slow.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false); &lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_scare&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);  PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;close_door.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false); &lt;br /&gt;
 &lt;br /&gt;
GiveSanityDamage(5.0f, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The exploding door ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The exploding door! My favorite!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It's almost like the slaming door but with a few modifications.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Door ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need to go to the level editor:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the door &amp;gt; Entity &amp;gt; Change OpenAmount to 0. So it's closed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== The Script ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be using the same function as the door slam so copy&amp;amp;paste it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
{&lt;br /&gt;
SetSwingDoorClosed(&amp;quot;door2&amp;quot;, true, true);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_breath_slow.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_scare&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;close_door.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
GiveSanityDamage(5.0f, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What you now want to do is replace the SetSwingDoorClose with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
SetPropHealth(&amp;quot;door1&amp;quot;, 0.0f);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So it looks like this&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
{&lt;br /&gt;
SetPropHealth(&amp;quot;door1&amp;quot;, 0.0f);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_breath_slow.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_scare&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;close_door.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
GiveSanityDamage(5.0f, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we need to change the void OnStart abit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Replace&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;door1&amp;quot;, &amp;quot;func_slam&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And replace&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func_slam(string &amp;amp;in asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now we're done with the Exploding door!. The result should look something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void OnStart()&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
{&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;door1&amp;quot;, &amp;quot;func_slam&amp;quot;, true);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
void func_slam(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&lt;br /&gt;
{&lt;br /&gt;
SetPropHealth(&amp;quot;door1&amp;quot;, 0.0f);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_breath_slow.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;react_scare&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;close_door.snt&amp;quot;, &amp;quot;Player&amp;quot;, 0, false);&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
GiveSanityDamage(5.0f, true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is how you create some door events.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope you find this usefull. If you got any questions or requests on tutorials please send me a PM on the forum.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thanks for reading.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''&amp;lt;br /&amp;gt; '' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''tutorial by xtron''&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>