Page 1 of 1

[Tut] Custom Sound Looping [with distance restrictions]

Posted: November 1st, 2012, 1:21 am
by Drofder2004
Mapping
- Right-click < Script < Origin
- Add Key/Value
Key: targetname
Value: repect_radio (or anything else you want)

Scripting
Create a GSC called "my_map.gsc" and place inside folder "raw/maps/mp".

Code: Select all

main()
{
   maps\mp\_load::main();
 
   game["allies"] = "sas";
   game["axis"] = "russian";
   game["attackers"] = "axis";
   game["defenders"] = "allies";
   game["allies_soldiertype"] = "woodland";
   game["axis_soldiertype"] = "woodland";
 
   thread music_one_item();
   thread music_multiple_items();
}
 
music_one_item()
{
   respect_single = getent("respect_radio_single", "targetname") playLoopSound("respect");  // Soundalias = respect
}
 
music_multiple_items()
{
   respect_box = getentarray("respect_radio","targetname");
 
   for(i=0;i<respect_box.size;i++)
      respect_box[i] playLoopSound("respect"); // Soundalias = respect
}
SoundAlias
- Create a file called "my_map.csv" and place this inside folder "raw/soundaliases"
- Save the following text into your CSV file (in notepad) [Where you see the word [EDIT], please remove this and make a single line of text]
- Open the file in Excel (unless you understand csv structures)
- Change first column to the alias of the sound. You will replace these in the GSC above ( // Soundalias = respect )
- The third column is the location of the file. I recommend creating a folder "my_map" and then placing your files in there.
- The fourth column is the minimum volume the file can be when inside the max distance.
- The fifth column is the maximum the volume will be.
- Change the values 100 and 250 (250 is the furthest you will hear the sound from and 100 is the distance from the sound where volume starts to decrease)
- Leave all other values alone.

Code: Select all

name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,
[EDIT]compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
,,,,,,,,,,,,,,,,,,,,,,,,,,,,

#Respect,,,,,,,,,,,,,,,,,,,,,,,,,,,,
respect,,mp_respect/respect.mp3,0,1,,,,100,250,auto,streamed,,looping,,,,,,,,,,,,,,,
Sound
- When using an MP3 make sure to set the bitrate at 96kbps (the game most likely allows more, however this is the setting I used successfully), you can change the bitrate using Audacity or a similar program.
- Place the sound file inside folder "raw/sound/my_map"

Zone File
- Open "zone_source\my_map.csv"
- Add "sound,my_map,,all_mp" to the bottom line

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 1st, 2012, 2:20 am
by Rezil
I thought you were gonna keep this a secret! :(

Awesome tut by the way, I still have no clue why bitrate should have anything to do with the sound being able to loop or not.

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 1st, 2012, 1:50 pm
by F |Madness| U
Very nicely done Drofder.

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 1st, 2012, 10:41 pm
by Drofder2004
Rezil wrote:I thought you were gonna keep this a secret! :(

Awesome tut by the way, I still have no clue why bitrate should have anything to do with the sound being able to loop or not.
It is a secret. Only you, me and everyone else can see it, but we MUST keep it a secret, ok?

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 9th, 2012, 10:08 pm
by lZombieGodl
I Could really do with some help on this, i dont understand what you mean by "Remove this and replace with a line of text" and im not sure what i should put in the 3rd' column, can you help me :)

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 9th, 2012, 10:17 pm
by F |Madness| U
lZombieGodl wrote:
I Could really do with some help on this, i dont understand what you mean by "Remove this and replace with a line of text" and im not sure what i should put in the 3rd' column, can you help me :)

Code: Select all

name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,
[EDIT]compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
,,,,,,,,,,,,,,,,,,,,,,,,,,,,

#Respect,,,,,,,,,,,,,,,,,,,,,,,,,,,,
respect,,mp_respect/respect.mp3,0,1,,,,100,250,auto,streamed,,looping,,,,,,,,,,,,,,,
It means that when you put this code into your csv, delete the word [EDIT] along with the square brackets, to make a single line of text from that code.

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 9th, 2012, 10:55 pm
by lZombieGodl
F |Madness| U wrote:
lZombieGodl wrote:
I Could really do with some help on this, i dont understand what you mean by "Remove this and replace with a line of text" and im not sure what i should put in the 3rd' column, can you help me :)

Code: Select all

name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,
[EDIT]compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
,,,,,,,,,,,,,,,,,,,,,,,,,,,,

#Respect,,,,,,,,,,,,,,,,,,,,,,,,,,,,
respect,,mp_respect/respect.mp3,0,1,,,,100,250,auto,streamed,,looping,,,,,,,,,,,,,,,
It means that when you put this code into your csv, delete the word [EDIT] along with the square brackets, to make a single line of text from that code.
okay, ive done that, and im not getting an error anymore, but no musics playing, i think its because "- The third column is the location of the file. I recommend creating a folder "my_map" and then placing your files in there." i dont understand where im meant to put that folder, and what i write in the 3rd column

Re: [Tut] Custom Sound Looping [with distance restrictions]

Posted: November 10th, 2012, 2:40 pm
by Drofder2004
Sound
- When using an MP3 make sure to set the bitrate at 96kbps (the game most likely allows more, however this is the setting I used successfully), you can change the bitrate using Audacity or a similar program.
- Place the sound file inside folder "raw/sound/my_map"
Sorry, it isn't very clear. This is the folder I am referring to.

When you test you map, please use "/developer 1" (before laoding your map) and look for any errors in red text.