Scripting - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: Scripting (/thread-6046.html) |
Scripting - Russ Money - 01-04-2011 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. RE: Scripting - Equil - 01-04-2011 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); } RE: Scripting - Russ Money - 01-05-2011 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? Code: void OnStart() If this is right, the player would hit the trigger and the sound plays while fading after 2 seconds. RE: Scripting - Equil - 01-05-2011 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. RE: Scripting - Russ Money - 01-05-2011 Very much so! Thanks, I understand it's functionality fully now, and quite a bit about scripting now. Thank you again! RE: Scripting - Equil - 01-05-2011 Glad I could help. ^^ |