Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a scream play when player enters a room?
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#1
Making a scream play when player enters a room?

Hi all! I have absolutely no clue about the first thing to do with scripting. I tried reading tutorials on the wiki, but alas, it all just goes over my head. I was so used to using the Hammer SDK to make Source maps, that I took the easy scripting for granted.

Anyways, what I'm trying to do is have it so that when the player enters a particular room, he'll walk around for a second and a scream will play (the woman from the game) and the camera will forcibly move to the direction of the door the player just came through.

Could someone please help me? I looked through the "Scripts Recollection" and I'm just not sure where to start or what to do. Undecided
03-22-2011, 06:04 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#2
RE: Making a scream play when player enters a room?

For the scream, you would first put an AddTimer if you want to wait a few seconds before the scream is heard. So you would make a script area in your level, probably right on the door into the room. You would also put another script area around the same place for the player to look there after. Anyway, in your .hps script, you would put in a function which has the same name as the script area, say Scream. So you would put "void Scream" as your function. In there, you put a new line, AddTimer. The 3 parameters are the name (doesn't really matter what this is I don't think), the time waited, and the function name. What this does is wait a certain amount of time, and then call a new function (whatever name you put for function name). So in the new function, you would use StartPlayerLookAt to make the player look at a script area for a certain amount of time, and (I'm pretty sure, haven't used it yet) PlaySoundAtEntity to play the scream. Of course, you would need to know how to link a collide to your Scream function. A tutorial is here for it: http://wiki.frictionalgames.com/hpl2/tut...t_beginner

It's near the bottom. Timer is there as well.
(This post was last modified: 03-22-2011, 06:24 PM by MrBigzy.)
03-22-2011, 06:23 PM
Find
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#3
RE: Making a scream play when player enters a room?

Thank you for replying, but this just makes no sense to me no matter how many times I read it >_<

Am I starting the script right?


I mean, I got the area scripts down, buuut... After that I'm lost. I named my look script "LookArea_1" and my scream script "Scream_1" if that would help anyone.


Attached Files
.png   Untitled.png (Size: 38.64 KB / Downloads: 129)
(This post was last modified: 03-22-2011, 06:40 PM by Austums.)
03-22-2011, 06:39 PM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#4
RE: Making a scream play when player enters a room?

Scratch what I said before about script area and function name, they don't have to be the same.

Here, I'll write the code for it. Hopefully you can follow what I'm doing. \\ Means a comment, it isn't part of the code.

AddEntityCollideCallback("Player", "Scream", "Scream_1", true, 1);  \\Put this in OnStart, Player is who is going to collide with area to make it start (could be a grunt), Scream is script area name, Scream_1 is function name (below), true means the collide will disappear when you contact it, if it was false it would mean it would stay and would run the function everytime you colide into the area, 1 means...I'm not sure, something about states

void Scream_1(string &in asParent, string &in asChild, int alStates)  \\You need to put those 3 parameters to link to the collide
{
   AddTimer("Somenamedoesntreallymatter", 5.0f, "Scream_Trigger")   \\So, first is some name, then the time to wait, then the function to call after you wait
}

void Scream_Trigger(string &in asTimer)  \\need that parameter to link to timer
{
   \\Put in the playsound functions here
   PlayerStartLookAt("AreaLook_1", 1, 1, "") //First the script area name, then a speed multiplier, then max look speed, and then a target callback which is blank in this case
}
(This post was last modified: 03-22-2011, 07:30 PM by MrBigzy.)
03-22-2011, 07:29 PM
Find
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#5
RE: Making a scream play when player enters a room?

Thank you so much for all of your help so far!

But what do I do for PlaySound functions?

Also, so this looks right then?
Or is this more on the right track?

I've tried my best, but I still get an error.


Attached Files
.png   Untitled.png (Size: 24.59 KB / Downloads: 107)
.png   Untitled.png (Size: 29.86 KB / Downloads: 112)
(This post was last modified: 03-23-2011, 01:10 AM by Austums.)
03-23-2011, 12:16 AM
Find
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#6
RE: Making a scream play when player enters a room?

Update:

I have my code set up to look like this:

void OnStart()
{
AddEntityCollideCallback("Player", "Scream", "Scream_1", true, 1);  \\Put this in OnStart, Player is who is going to collide with area to make it start (could be a grunt), Scream is script area name, Scream_1 is function name (below), true means the collide will disappear when you contact it, if it was false it would mean it would stay and would run the function everytime you colide into the area, 1 means...I'm not sure, something about states
}
void Scream_1(string &in asParent, string &in asChild, int alStates)  \\You need to put those 3 parameters to link to the collide
{
   AddTimer("Somenamedoesntreallymatter", 2.0f, "Scream_Trigger")   \\So, first is some name, then the time to wait, then the function to call after you wait
}

void Scream_Trigger(string &in asTimer)  \\need that parameter to link to timer
{
   PlaySoundAtEntity("Scream_1", "04_scream.snt", "Scream_1", 0, false);
   PlayerStartLookAt("LookArea_1", 1, 1, "") //First the script area name, then a speed multiplier, then max look speed, and then a target callback which is blank in this case
}


but when I try to run my map, it gives me an error saying that the script unexpectedly ends at 14,2

Did I even set the script up correctly?
03-23-2011, 03:06 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#7
RE: Making a scream play when player enters a room?

Well, delete my comments for now, if they're going to the next line it's gonna screw up your code. 14,2 refers to line 14, space 2. Gimme the new error if you get one after you delete the comments.
(This post was last modified: 03-23-2011, 03:15 AM by MrBigzy.)
03-23-2011, 03:14 AM
Find
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#8
RE: Making a scream play when player enters a room?

FATAL ERROR: Could not load script file

main (8,1) : ERR : Expected ';'
main (14,1) : ERR: Expected ';'
And here's the code

void OnStart()
{
AddEntityCollideCallback("Player", "Scream", "Scream_1", true, 1);
}
void Scream_1(string &in asParent, string &in asChild, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 2.0f, "Scream_Trigger")
}

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "04_scream.snt", "Scream_1", 0, false);
   PlayerStartLookAt("LookArea_1", 1, 1, "")
}

My script areas are called

"Scream_1" for the scream
"Look_Area_1" for the look

I'm not sure if I did the PlaySoundAtEntity right or not >_>
(This post was last modified: 03-23-2011, 03:19 AM by Austums.)
03-23-2011, 03:17 AM
Find
MrBigzy Offline
Senior Member

Posts: 616
Threads: 18
Joined: Mar 2011
Reputation: 8
#9
RE: Making a scream play when player enters a room?

Can you copy the script here? Just so I know what line is what now. Edit: Oh I see it now.

You don't have a ; after the AddTimer function. Or the PlayerLook one.
(This post was last modified: 03-23-2011, 03:22 AM by MrBigzy.)
03-23-2011, 03:20 AM
Find
Austums Offline
Member

Posts: 60
Threads: 11
Joined: Mar 2011
Reputation: 0
#10
RE: Making a scream play when player enters a room?

I'm sorry, the Look area is called "LookArea_1" not, "Look_Area_1"
I added the ; to the end of what you said and got this

main (13,4) : ERR : No matching signatures to 'PlayerStartLookAt(string@&, const uint, string@&)'
(This post was last modified: 03-23-2011, 03:27 AM by Austums.)
03-23-2011, 03:21 AM
Find




Users browsing this thread: 1 Guest(s)