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
Scripting
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#1
Scripting

I have a fair understanding of how some triggers work with scripting but I've run into an issue.

I'll lay it out easy for those knowledgeable.

I have an area named "monsterspawn", a grunt named "monster" and an area over the enemy named "monsterlook"
Now when the player collides with the area trigger, I want the following to happen:
The monster spawns
A sound is played, the monster's loud howl
The player focuses on "monsterlook" for 2 moments and the velocity can be 2 as well
Lastly the player loses focus on "monsterlook" after the allotted time.

I can get the player's focus on start but, the camera is locked and it's not when he hits the trigger.

Using the areas I have, can anyone show me how the script should look?

Much appreciated from the help I've gotten so far.
(This post was last modified: 01-04-2011, 01:35 PM by Russ Money.)
01-04-2011, 01:34 PM
Find
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#2
RE: Scripting

void monsterspawn1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("monster", true);
//Don't really need to add a sound to play since grunts make loud sounds when they spawn already
StartPlayerLookAt("monsterlook", 4, 2, "");
//A timer to stop the player looking
AddTimer("", 1.0, "PlayerStopLook");
}

void PlayerStopLook(string &in asTimer)
{
StopPlayerLookAt();
}

I think this is how it should look. Give it a try.

EDIT: Oh, you'll also need the collide callback in the OnStart() section.

void OnStart()
{
AddEntityCollideCallback("Player", "monsterspawn", "monsterspawn1", true, 1);
}
(This post was last modified: 01-04-2011, 06:06 PM by Equil.)
01-04-2011, 06:04 PM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#3
RE: Scripting

Awesome, it worked. Of course I had to tweak the player look time and the velocity, as I had no real concept on their strength.

My next question is, say I want to use the an area, lets call it "area_trigger" and when the player collides with it and I want it to play a sound called "monster" on the player. Would the code look something like this?

void OnStart()
{
AddEntityCollideCallback("Player", "area_trigger", "playmonster1", true, 1);
}
void playmonster1(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("", "monster", "Player", 2.0, false);
}

If this is right, the player would hit the trigger and the sound plays while fading after 2 seconds.
(This post was last modified: 01-05-2011, 01:25 AM by Russ Money.)
01-05-2011, 01:21 AM
Find
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#4
RE: Scripting

Correct, except you need to designate the sound file to be played in the "PlaySoundAtEntity" function. I don't think "monster" is a valid file.

Try:

PlaySoundAtEntity("", "03_amb_idle.snt", "Player", 2.0, false);

I'll try explain the entire function.

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

string& asSoundName - The name of the sound. This is optional, only really used if you want to call the function again later or something.

string& asSoundFile - The sound file to be used, I just browse through the sound in the editor to find what sounds I want to use, as it has a preview button which is handy.

string& asEntity - The entity the sound should be played at.

float afFadeTime - Self Explanatory, how long the sound takes to Fade in. Haven't played around with this much though.

bool abSaveSound - If you want the sound to be played later again, it really depends on the sound you're using for this one.

Hope this helps.
01-05-2011, 02:21 AM
Find
Russ Money Offline
Senior Member

Posts: 360
Threads: 25
Joined: Dec 2010
Reputation: 4
#5
RE: Scripting

Very much so! Thanks, I understand it's functionality fully now, and quite a bit about scripting now. Thank you again!
01-05-2011, 02:48 AM
Find
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#6
RE: Scripting

Glad I could help. ^^
01-05-2011, 03:17 AM
Find




Users browsing this thread: 1 Guest(s)