Skip to content

Can we get a PlaySoundAtLocation function?

CalgacusCalgacus Member Posts: 273
edited September 2018 in General Discussions NWN:EE
Instead of needing a pre-placed soundobject or a monsters action queue we need to be able to play sounds from an arbitrary location and time so we can easily script sound effects relative to the location of whatever we want.

I was trying to make a zombie make a puke sound and couldn't see how to get it to work without some preplaced sound object and so thought this function might be useful.
Post edited by Calgacus on

Comments

  • Dark_AnsemDark_Ansem Member Posts: 992
    oh yes please!
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited September 2018
    You can do that in script by creating an invisible placeable and telling it to make the sound. Something like -
    object oSounder = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", lHere);
    AssignCommand(oSounder, PlaySound("make_noise_snd"));

    Where lHere is a predefined location and make_noise_snd is the resref of the sound.

    TR
  • Dark_AnsemDark_Ansem Member Posts: 992

    You can do that in script by creating an invisible placeable and telling it to make the sound. Something like -


    object oSounder = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_invisobj", lHere);
    AssignCommand(oSounder, PlaySound("make_noise_snd"));

    Where lHere is a predefined location and make_noise_snd is the resref of the sound.

    TR
    what do you mean by "predefined location"? Coordinates?
  • TarotRedhandTarotRedhand Member Posts: 1,481
    OK, a location is a built-in data type in NWScript. It consists of three parts. An area in your game expressed as an object, a vector (another built in data type you may not have heard of see below) and a facing expressed in degrees 0 - 360. A vector consists of three floats which together define a position in space. You define a vector like so -

    vector v2 = Vector(1.0f, 2.0f, 3.0f);//that's Vector(float x, float y, float z)
    But as I say that is just a position in space. It could be in any area. To define a position in a single area you need a location. To define a location you use something along the lines of -

    location loc = Location(objArea, vecPosition, fFacing);//Location(object area, vector position, float degrees)
    Does that help?

    TR
  • CalgacusCalgacus Member Posts: 273
    Thanks, I will try that out once i get back to my PC. I was thinking an approach like that might work but might be too slow if I am trying to time things to happen together - like zombie puking up a creeping doom effect and making a puke noise when I play its laugh animation.
  • Dark_AnsemDark_Ansem Member Posts: 992
    Of course it does, thanks.
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited September 2018
    Forgot to mention. The function CreateObject uses the location parameter to know where to create the object. Also the plc_invisobj is the resref for a vanilla invisible object found under (I think) miscellaneous in the blueprints. You might want or need to create a custom one.

    One other thing. If you are on windows or you can read .chm help files and you haven't got it, the downloadable version of the lexicon will tell you much more about the various data types (there's 10 built in ones in total).

    For links to a whole lot of links to tutorials follow this link.

    TR
  • TarotRedhandTarotRedhand Member Posts: 1,481
    If either of you have trouble with this just pm me and we'll get it sorted out.

    TR
Sign In or Register to comment.