[SCRIPT] i need some help - 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 - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] i need some help (/thread-15666.html) Pages:
1
2
|
i need some help - TheIcyPickle - 05-28-2012 ok so, I receive an error upon making your corrections in the hps file. I want a sound to be made when a player walks past a script box thing, called "popout1" but it only plays once the player has a key called "scarykey_1" Also, if possible , add at the same time, that naked penis figure flys in. (that part may be a pain, so if you can't explain it, its fine.) here is my entire script. //////////////////////////// // Run first time starting map void OnStart() { GiveItemFromFile("lantern", "lantern.ent"); for(int i=0;i< 10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent"); AddUseItemCallback("", "scarykey_1", "door_1", "KeyOnDoor", true); AddEntityCollideCallback("popout1", string& "Player", "PlaySoundAtEntity", true); } void KeyOnDoor(string &in asItem, string &in asEntity) { SetSwingDoorLocked("door_1", false, true); PlaySoundAtEntity("", "unlock_door", "door_1", 0, false); RemoveItem("scarykey_1"); } void PlaySoundAtEntity(string &in asplayer, string &in aspopout1, bool HasItem("scarykey_1") { PlaySoundAtEntity1("", "21_screams", "popout1", 0, false); } thanks for the help
RE: i need some help - Putmalk - 05-28-2012 (05-28-2012, 04:24 AM)TheIcyPickle Wrote:No flying naked man. Absolutely not. Get that crap out of your custom story, and never implement it. Or get laughed at. Your choice. Anywho. Code: void PlaySoundAtEntity(string &in asplayer, string &in aspopout1, bool HasItem("scarykey_1"){ What is this? Can you please brush up on how functions work... In fact, just remove this stuff, it's worthless. You want to play a sound when passing an entity? Use an AddEntityCollideCallback So: Code: //place in OnStart That is the code basics. Replace wherever I wrote obvious placeholders with the names of your objects. And never implement a flying naked body. Get out with that stuff. It's sickening. RE: i need some help - TheIcyPickle - 05-28-2012 cool, good feedback guys! but would someone explain to me how the asparent and aschild things work? And yeah, the popout scare is cheesy. Thanks for feedback!!! RE: i need some help - Putmalk - 05-28-2012 When you use AddEntityCollideCallback, you specify the function parameters as follows: (string &in asParent, string &in asChild, string &in FunctionName, bool DeleteOnCollide, int alState) This is why we call the function as: AddEntityCollideCallback("Player", "Area", "Name", true, 0); In this situation, "Player" is asParent, and "Area" is asChild. Hence, when we make the function callback (this is the function that AddEntityCollideCallback creates), the parameters for this new function are (string &in asParent, string &in asChild, int alState) Where asParent is still "Player" and Area is still "asChild". This is particularly useful if inside the function callback you want to add effects to area, instead of hardcoding the area name you can simply use asChild as the location for your event. Also, if you use asChild instead of the area name, you can call the same function with different areas and have effects play at those respective areas! RE: i need some help - TheIcyPickle - 05-28-2012 Great! Everything is working except for 1 or 2 things. 1. Everytime I pass the script box, it makes a noise. I only want it to happen once. 2. Second, there a several different sounds that play each time I pass. I only want 21_scream10.ogg from 21_screams.snt to play. Here is the new script. AddEntityCollideCallback("Player", "popout1", "PlaySound", false, 0); then void PlaySound(string &in Player, string &in popout1, int alState) { if(HasItem("scarykey_1") == false) return; PlaySoundAtEntity("21_scream10.ogg", "21_screams.snt", "popout1", 0, false); } RE: i need some help - Putmalk - 05-28-2012 In AddEntityCollideCallback, change "false" to "true". The boolean argument specifies whether or not we delete the collision callback after one touch. (you don't always set this to true, but you have to be the judge on when you want it to happen every time or just once). In the PlaySoundAtEntity function, the first parameter is merely the name of the sound that is being played. This allows it to be identified by the game, so you could stop it using the StopSound function. The second parameter is the actual sound. Replace 21_screams.snt with 21_scream10.ogg. RE: i need some help - TheIcyPickle - 05-28-2012 ok, ok, so my new script should look like this: Code: AddEntityCollideCallback("Player", "popout1", "PlaySound", true, 0); because "scream" is my sound box thing in the editor and the second thing is the actual sound file and "popout1" is my script box where the sound area is. correction: Code: AddEntityCollideCallback("Player", "popout1", "PlaySound", true, 0); RE: i need some help - Putmalk - 05-28-2012 No. You need to learn how function parameters work. When you add a function via AddEntityCollideCallback (in this case, we are creating a function called PlaySound), the callbacks will always be (string &in asParent, string &in asChild, int alState). Those parameters are what you'll see in the engine scripts wiki page: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Look at the entry for the collide callback: Code: void AddEntityCollideCallback(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates); See that callback syntax? That is what the new function's parameters will always be! So in the end it should be: Code: void OnStart() Never change those parameters. If you wanted to effect something in the function, you could. Let's say I wanted a sound to play at the parent entity. Now this function is called by two different collide callbacks, with two different parent entities, but I always want it to play at the parent entity, then inside the callback function, I would write something like: Code: PlaySoundAtEntity("sound", "sound.snt", asParent, 0, false); //asParent == the parent entity. It may be a chair, it may be a player, it will change depending on what you want it to do. Hope this is clear for you. RE: i need some help - TheIcyPickle - 05-28-2012 sigh.. I feel like I have done what you said. Hmm, well. I have taken up enough of your time I'd say. But still... http://www.mediafire.com/?5psmbvpe5peeh0k is the link to the hps file. I know this wont be a learning experience for me, but could you look at it and see why I'm not doing it right and pretty please make the changes. I literally have exactly what you put and still, the sound does not play, but it did play w/ the .snt ext. oh and to send it back, heres my email jpghalio@yahoo.com this is probably the weirdest post you've seen so thank you for still being here lol RE: i need some help - Putmalk - 05-28-2012 Here, try this, see if it works. I am pretty sure .ogg files are acceptable in PlaySoundAtEntity. If not, you might want to try PlayGuiSound or something (non-3D sound effect). I edited around some of the script which should make it easier to code. I commented them so you know what I did. Code: //////////////////////////// |