| Next revision | Previous revision | ||
|
hpl2:tutorials:script:events [2011/07/14 13:41] xtron created |
hpl2:tutorials:script:events [2011/07/14 13:48] (current) xtron |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| - | Today I (xtron) will show you! (the reader) how to make scary events that will yea...scare the player!. | + | Today I (xtron) will show you! (the reader) how to make scary events that will yea…scare the player!. |
| Line 61: | Line 61: | ||
| - | <code cpp> | + | <code cpp>void func_slam(string &in asParent, string &in asChild, int alState) |
| - | void func_slam(string &in asParent, string &in asChild, int alState) | + | |
| { | { | ||
| SetSwingDoorClosed("door1", true, true); | SetSwingDoorClosed("door1", true, true); | ||
| Line 78: | Line 77: | ||
| - | <code cpp> | + | <code cpp>{ |
| - | + | ||
| - | + | ||
| - | { | + | |
| SetSwingDoorClosed("door1", true, true); | SetSwingDoorClosed("door1", true, true); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_scare", "Player", 0, false); | PlaySoundAtEntity("", "react_scare", "Player", 0, false); | ||
| - | + | ||
| PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | ||
| - | + | ||
| GiveSanityDamage(5.0f, true); | GiveSanityDamage(5.0f, true); | ||
| } | } | ||
| Line 102: | Line 94: | ||
| - | <code cpp> | + | <code cpp>void OnStart() |
| - | + | ||
| - | + | ||
| - | void OnStart() | + | |
| - | + | ||
| { | { | ||
| - | |||
| - | |||
| AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1); | AddEntityCollideCallback("Player", "script_slam", "func_slam", true, 1); | ||
| - | + | } | |
| - | + | ||
| - | } | + | |
| - | + | ||
| void func_slam(string &in asParent, string &in asChild, int alState) | void func_slam(string &in asParent, string &in asChild, int alState) | ||
| { | { | ||
| SetSwingDoorClosed("door2", true, true); | SetSwingDoorClosed("door2", true, true); | ||
| - | + | ||
| - | + | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | |
| - | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | + | |
| - | + | PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | |
| - | + | ||
| - | PlaySoundAtEntity("", "react_scare", "Player", 0, false); | + | |
| - | + | ||
| - | + | ||
| - | PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | + | |
| - | + | ||
| GiveSanityDamage(5.0f, true); | GiveSanityDamage(5.0f, true); | ||
| } | } | ||
| </code> | </code> | ||
| - | ===== | + | |
| - | The exploding door ===== | + | |
| + | ===== The exploding door ===== | ||
| Line 142: | Line 120: | ||
| It's almost like the slaming door but with a few modifications. | It's almost like the slaming door but with a few modifications. | ||
| + | |||
| + | |||
| + | ==== The Door ==== | ||
| Line 150: | Line 131: | ||
| - | We will be using the same function as the door slam so copy&paste it. | + | ==== The Script ==== |
| - | <code cpp> | + | We will be using the same function as the door slam so copy&paste it. |
| - | void func_slam(string &in asParent, string &in asChild, int alState) | + | <code cpp>void func_slam(string &in asParent, string &in asChild, int alState) |
| { | { | ||
| SetSwingDoorClosed("door2", true, true); | SetSwingDoorClosed("door2", true, true); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_scare", "Player", 0, false); | PlaySoundAtEntity("", "react_scare", "Player", 0, false); | ||
| - | + | ||
| PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | ||
| - | + | ||
| GiveSanityDamage(5.0f, true); | GiveSanityDamage(5.0f, true); | ||
| } | } | ||
| Line 175: | Line 152: | ||
| - | What you now want to do is replace the SetSwingDoorClose with | + | What you now want to do is replace the SetSwingDoorClose with |
| Line 186: | Line 163: | ||
| - | <code cpp> | + | <code cpp>void func_slam(string &in asParent, string &in asChild, int alState) |
| - | + | ||
| - | + | ||
| - | void func_slam(string &in asParent, string &in asChild, int alState) | + | |
| { | { | ||
| SetPropHealth("door1", 0.0f); | SetPropHealth("door1", 0.0f); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | ||
| - | + | ||
| PlaySoundAtEntity("", "react_scare", "Player", 0, false); | PlaySoundAtEntity("", "react_scare", "Player", 0, false); | ||
| - | + | ||
| + | |||
| + | |||
| PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | ||
| - | + | ||
| + | |||
| GiveSanityDamage(5.0f, true); | GiveSanityDamage(5.0f, true); | ||
| } | } | ||
| Line 211: | Line 184: | ||
| - | Replace | + | Replace |
| Line 222: | Line 195: | ||
| - | <code cpp> | + | <code cpp>void func_slam(string &in asParent, string &in asChild, int alState) |
| - | void func_slam(string &in asParent, string &in asChild, int alState) | + | |
| </code> | </code> | ||
| Line 230: | Line 202: | ||
| - | <code cpp> | + | <code cpp>void func_slam(string &in asEntity) |
| - | void func_slam(string &in asEntity) | + | |
| </code> | </code> | ||
| Line 238: | Line 209: | ||
| - | <code cpp> | + | <code cpp>void OnStart() |
| - | + | ||
| - | + | ||
| - | void OnStart() | + | |
| - | + | ||
| { | { | ||
| SetEntityPlayerInteractCallback("door1", "func_slam", true); | SetEntityPlayerInteractCallback("door1", "func_slam", true); | ||
| } | } | ||
| - | + | ||
| + | |||
| void func_slam(string &in asParent, string &in asChild, int alState) | void func_slam(string &in asParent, string &in asChild, int alState) | ||
| { | { | ||
| SetPropHealth("door1", 0.0f); | SetPropHealth("door1", 0.0f); | ||
| - | + | ||
| + | |||
| PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false); | ||
| - | + | ||
| + | |||
| PlaySoundAtEntity("", "react_scare", "Player", 0, false); | PlaySoundAtEntity("", "react_scare", "Player", 0, false); | ||
| - | + | ||
| + | |||
| PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | PlaySoundAtEntity("", "close_door.snt", "Player", 0, false); | ||
| - | + | ||
| + | |||
| GiveSanityDamage(5.0f, true); | GiveSanityDamage(5.0f, true); | ||
| } | } | ||