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.
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.)
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.
(This post was last modified: 03-22-2011, 06:40 PM by Austums.)
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.)
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
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.)