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 an on/off radio
TheGreatCthulhu Offline
Member

Posts: 213
Threads: 10
Joined: Oct 2010
Reputation: 32
#4
RE: Scripting an on/off radio

Because of the way sound entities work(the ones you place in the level editor), if you happen to spawn inside their area of audibility, they start their playback as soon as the level starts.

So, to have a more precise control of timing, use the PlaySoundAtEntity function
as explained above. You can also use PlaySoundAtEntity to play any snt file; you don't have to have a corresponding sound entity in the level (essentially, it dynamically creates one for you).

To control the volume, and how far the sound is audible, you have to uncheck the "use default" checkbox on the Sound tab, or the sound entity will use the values defined in the snt file. If that doesn't work by any chance, or if you want to make the sound loop, you'll have to create your own snt file, but that's not hard to do. These are just plain text files which contain some additional information about the sound. You can make a copy of an existing one, rename it, open it in a plain text editor such as Notepad, Notepad++, Geany, or similar, and then just change a few values.

Here's how 00_creak.snt looks like (in redist\sounds\00\) - note the PROPERTIES tag:
<SOUNDENTITY>
  <SOUNDS>
      <Main>
        <Sound File="00_creak" />
      </Main>
  </SOUNDS>
  <PROPERTIES Volume="0.5" MinDistance="10" MaxDistance="30" Random="1" Interval="0" FadeEnd="False" FadeStart="False" Stream="False" Loop="True" Use3D="False" Blockable="False" BlockVolumeMul="0.7" Priority="0" />
</SOUNDENTITY>

Here's just the PROPERTIES tag in a more readable format, so that I can tell you what each the attributes is for:
<PROPERTIES
    Volume="0.5"
    MinDistance="10"
    MaxDistance="30"
    Random="1"
    Interval="0"
    FadeEnd="False"
    FadeStart="False"
    Stream="False"
    Loop="True"
    Use3D="False"
    Blockable="False"
    BlockVolumeMul="0.7"
    Priority="0" />
  • Volume is - well, volume, where 1.0 is 100% (i think you can go over that, as well as below)
  • MinDistance - if > 0, then you can't hear the sound if you get too close
  • MaxDistance - how far the sound can be heard
  • Random - if, under the <Main> tag more than one snt file is specified, this will cause the game to randomly pick one for playback (see, for example, the file redist\sounds\03\03_rock_move.snt). You can leave this unchanged.
  • Interval - not sure; either the interval between looping sounds, or the time before you can replay it, or something like that
  • FadeStart/FadeEnd - I suppose it specifies at what "end" the sound should be faded in/out when fading is specified through the script.
  • Stream - memory management stuff, leave as is.
  • Loop - should the sound loop ("True") or not ("False")
  • Use3D - use 3D sound / surround ("True") or not ("False")
  • Blockable - based on HPL1, determines if the sound is blockable by walls and such, so that enemies can't react and to it, etc.
  • BlockVolumeMul - the volume multiplier for the blocked sound; that is, how much % of the normal volume the blocked sound should have. In the example above, 0.7 means 70% (where "normal" means the volume specified in Volume)
  • Priority - can be 0, 1, 2, 3... If the game encounters a situation where several sounds must be played back at the same time, if they are not the same priority, only the highest priority sound(s) will be audible.


P.S. In the code snippet in the previous post, there's a minor mistake, that you must correct for the code to work. In the SetEntityPlayerInteractCallback function call, one of the parameters says "RadioPlay", but the corresponding callback function, a few lines bellow, is named Radio.

The two must have the same name. So either change
PHP Code: (Select All)
void Radio(string &in asEntity
to
PHP Code: (Select All)
void RadioPlay(string &in asEntity

or leave it as is and change "RadioPlay" parameter to "Radio".
(This post was last modified: 05-04-2013, 10:14 AM by TheGreatCthulhu.)
05-04-2013, 10:12 AM
Find


Messages In This Thread
Scripting an on/off radio - by Kalidus - 05-03-2013, 05:48 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-03-2013, 06:45 PM
RE: Scripting an on/off radio - by Kalidus - 05-04-2013, 07:13 PM
RE: Scripting an on/off radio - by TheGreatCthulhu - 05-04-2013, 10:12 AM
RE: Scripting an on/off radio - by Daemian - 05-04-2013, 10:44 AM
RE: Scripting an on/off radio - by Daemian - 05-04-2013, 10:56 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-04-2013, 07:20 PM
RE: Scripting an on/off radio - by Tomato Cat - 05-04-2013, 08:36 PM
RE: Scripting an on/off radio - by Kalidus - 05-04-2013, 10:57 PM
RE: Scripting an on/off radio - by Daemian - 05-05-2013, 05:10 AM



Users browsing this thread: 1 Guest(s)