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
Two Unrelated Questions
Beargasm Offline
Junior Member

Posts: 1
Threads: 1
Joined: Jun 2011
Reputation: 0
#1
Two Unrelated Questions

Hello Frictional Games forums!

I just started working with the HLP2 engine yesterday, and the tutorials and wiki pages have been very helpful in teaching me how to use the editor. I usually don't post on forums asking for help, but after reading through many threads here over the past two days and seeing how helpful and friendly this community is, I figured I'd take a shot at it.

Question 1:
I'm very new to scripting and was hoping that somebody could tell me how to make it so that when a person steps into an area, it starts or stops playing a sound.

Question 2: I have put down six chairs in two rows, but when I open the game they are floating an inch or two off the ground. Was wondering if anybody knew how to fix this.

Thanks in advance.
06-02-2011, 12:34 AM
Find
Khyrpa Offline
Senior Member

Posts: 638
Threads: 10
Joined: Apr 2011
Reputation: 24
#2
RE: Two Unrelated Questions

I assume you know what OnStart() means...
Put this inside it:
AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates);

all those string & blablah weird names may look like gibberish but ima try to explain those here nao!

what AddEntityCollideCallback really does is = when specified 2 "things" go in, out or both, some function is called (those can be specified in it). So when you want the player step into area, you put "Player" in the string& asParentName and "*the name of your area*" in the string& asChildName, so this checks when you = player collide with the area.

string& asFunction is the name of the function you want to call. Every thing that has string before something the script functions page (http://wiki.frictionalgames.com/hpl2/amn...en_effects) must be put inside brackets "". That's one common and easy thing to follow and it makes reading the script functions page easier.
So in your case we could name the string& asFunction something like this: "blehblah"

bool abDeleteOnCollide - determines whether the callback after it was called
Swedes can't english so it means you have 2 options to put in that place: true or false.
Which one you wanna use depends on if you want the function to trigger AGAIN after the first collide with player and the area. true means it only happens once, false means you can step on it repeatedly to trigger lots of "blehblah" 's! I assume you want your thing to happen only once!

int alStates means when you want "blehblah" to trigger, when the player first hits the area is 1, when the player comes out from the area is -1 and 0 is both! I assume you want it to happen when the player hits the area.

So with these names I used your final callback would be this with the OnStart()

OnStart()
{
AddEntityCollideCallback("Player", "nameofyourearea", "blehblah", false, 1);
}
Then if you want to play a sound after the player hits the area, you have to use one of these:

PlaySoundAtEntity(string& asSoundName, string& asSoundFile, string& asEntity, float afFadeTime, bool abSaveSound);

FadeInSound(string& asSoundName, float afFadeTime, bool abPlayStart);

PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

PlayGuiSound(string& asSoundFile, float afVolume);

The one you need to use depends on how you want the sound to happen.
with PlaySoundAtEntity, you can only use .snt sounds (those are several sounds in a single file that picks one to play randomly every time, meaning it doesn't sound weird and can be used many times). Also PlaySoundAtEntity lets you pick the place where you want the sound to come from, area, entity or player himself are all usable. Also you can fade sounds out with this (pretty unnecessary).

FadeInSound is only for those sounds that you have already placed inside your level in level editor. Like this selected in this picture: http://imageshack.us/photo/my-images/714...utori.jpg/
Use FadeInSound with StopSound, they are practically the opposites of each other.

PlayMusic is only for the .ogg files that are mainly included in your music folder. The music can be set to loop with this and you can adjust the volume (use with StopMusic).

PlayGuiSound can be used with .ogg files, meaning you don't need .snt file for sounds. With this function you can't adjust the location of the sound. It always comes from both speakers.

I hope this isn't too much of a mess and actually helps...
(This post was last modified: 06-02-2011, 01:19 AM by Khyrpa.)
06-02-2011, 01:04 AM
Find




Users browsing this thread: 1 Guest(s)