Author |
Topic: cod4 ambient music with trigger use |
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Apr. 29, 2014 12:36 pm |
|
Hi ! i have a script for changin music in game by player
with trigger use, what triggers , values and keys or models i have to put in radiant, all the rest (sounalliases, zone,gsc) ive made.
i put trigger use (targetname music1) what else.....
HELP
Code:
#include maps\mp\_utility;
#include maps\mp\gametypes\_hud_util;
#include common_scripts\utility;
main()
{
maps\mp\_load::main();
setDvar("r_specularcolorscale", "1");
game["allies"] = "marines";
game["axis"] = "opfor";
game["attackers"] = "axis";
game["allies_soldiertype"] = "desert";
game["axis_soldiertype"] = "desert";
game["defenders"] = "allies";
thread musicTrigger1();
thread musicTrigger2();
thread musicTrigger3();
thread musicTrigger4();
thread musicOffTrigger();
thread onPlayerConnect();
}
onPlayerConnect()
{
level endon("game_ended");
for(;;)
{
level waittill("connected", player);
player.music1Playing = false;
player.music2Playing = false;
player.music3Playing = false;
player.music4Playing = false;
}
}
musicTrigger1()
{
trigger = getEnt("music1", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music1Playing)
{
player thread playMusic(1);
}
}
}
musicTrigger2()
{
trigger = getEnt("music2", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music2Playing)
{
player thread playMusic(2);
}
}
}
musicTrigger3()
{
trigger = getEnt("music3", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music3Playing)
{
player thread playMusic(3);
}
}
}
musicTrigger4()
{
trigger = getEnt("music4", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music4Playing)
{
player thread playMusic(4);
}
}
}
playMusic(num)
{
self endon("disconnect");
ambientStop(0);
switch(num)
{
case 1:
self iPrintLn("^3Now playing: ^1BAD STYLE - TIME BACK");
self playLocalSound("song1");
self.music1Playing = true;
self.music2Playing = false;
self.music3Playing = false;
self.music4Playing = false;
wait 156;
self.music1Playing = false;
break;
case 2:
self iPrintLn("^3Now playing: ^1REQUEM FOR A DREAM");
self playLocalSound("song2");
self.music1Playing = false;
self.music2Playing = true;
self.music3Playing = false;
self.music4Playing = false;
wait 192;
self.music2Playing = false;
break;
case 3:
self iPrintLn("^3Now playing: ^1ELLIPHANT - REVOLUTION");
self playLocalSound("song3");
self.music1Playing = false;
self.music2Playing = false;
self.music3Playing = true;
self.music4Playing = false;
wait 197;
self.music3Playing = false;
break;
case 4:
self iPrintLn("^3Now playing: ^1LINDSEY STIRLING - CRISTALLIZE");
self playLocalSound("song4");
self.music1Playing = false;
self.music2Playing = false;
self.music3Playing = false;
self.music4Playing = true;
wait 258;
self.music4Playing = false;
break;
default:
break;
}
}
musicOffTrigger()
{
trigger = getEnt("musicstop", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(player.music1Playing || player.music2Playing || player.music3Playing || player.music4Playing)
{
player playLocalSound("stop");
player iPrintLn("^3Music ^1Stoped");
player.music1Playing = false;
player.music2Playing = false;
player.music3Playing = false;
player.music4Playing = false;
}
}
}
edited on Apr. 29, 2014 12:57 pm by BUSH1DO |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Apr. 29, 2014 07:28 pm |
|
You need 5 triggers in your map. I would use "trigger_use_touch" NOT "trigger_use" unless you want them to trigger them in a different way. The 5 triggers should have the following targetnames.
Code:
targetname
music1
targetname
music2
targetname
music3
targetname
music4
targetname
musicstop
Those are the only triggers you need in your map. If your script works properly, and you have a sound alias with the correct alias defined IE (song1, song2, song3, song4, stop), the music should play. However, if you are using .mp3 files and not .wav. MP3 files need to be packed in your maps .iwd, with the correct file structure defined in your soundalias, as well as the same file structure in your COD directory. They need to match. You may also have to set your file to "streamed" in your alias. You may have to play with that value.
That is all you need for radiant, and your soundalias. I would have created a separate file (gsc) to run this script, outside of your main maps .gsc, but that is just me. It will still work how you have it.
Don't forget to reference your soundalias in your zone file:
Code:
sound,mp_mapname,,all_mp
Wave files need to be referenced in the zone file, MP3 files DO NOT.
You can also use the code button in the future so it is easier to read for others.
Code:
main()
{
maps\mp\_load::main();
setDvar("r_specularcolorscale", "1");
game["allies"] = "marines";
game["axis"] = "opfor";
game["attackers"] = "axis";
game["allies_soldiertype"] = "desert";
game["axis_soldiertype"] = "desert";
game["defenders"] = "allies";
thread musicTrigger1();
thread musicTrigger2();
thread musicTrigger3();
thread musicTrigger4();
thread musicOffTrigger();
thread onPlayerConnect();
}
onPlayerConnect()
{
level endon("game_ended");
for(;;)
{
level waittill("connected", player);
player.music1Playing = false;
player.music2Playing = false;
player.music3Playing = false;
player.music4Playing = false;
}
}
musicTrigger1()
{
trigger = getEnt("music1", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music1Playing)
{
player thread playMusic(1);
}
}
}
musicTrigger2()
{
trigger = getEnt("music2", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music2Playing)
{
player thread playMusic(2);
}
}
}
musicTrigger3()
{
trigger = getEnt("music3", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music3Playing)
{
player thread playMusic(3);
}
}
}
musicTrigger4()
{
trigger = getEnt("music4", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(!player.music4Playing)
{
player thread playMusic(4);
}
}
}
playMusic(num)
{
self endon("disconnect");
ambientStop(0);
switch(num)
{
case 1:
self iPrintLn("^3Now playing: ^1BAD STYLE - TIME BACK");
self playLocalSound("song1");
self.music1Playing = true;
self.music2Playing = false;
self.music3Playing = false;
self.music4Playing = false;
wait (156);
self.music1Playing = false;
break;
case 2:
self iPrintLn("^3Now playing: ^1REQUEM FOR A DREAM");
self playLocalSound("song2");
self.music1Playing = false;
self.music2Playing = true;
self.music3Playing = false;
self.music4Playing = false;
wait (192);
self.music2Playing = false;
break;
case 3:
self iPrintLn("^3Now playing: ^1ELLIPHANT - REVOLUTION");
self playLocalSound("song3");
self.music1Playing = false;
self.music2Playing = false;
self.music3Playing = true;
self.music4Playing = false;
wait (197);
self.music3Playing = false;
break;
case 4:
self iPrintLn("^3Now playing: ^1LINDSEY STIRLING - CRISTALLIZE");
self playLocalSound("song4");
self.music1Playing = false;
self.music2Playing = false;
self.music3Playing = false;
self.music4Playing = true;
wait (258);
self.music4Playing = false;
break;
default:
break;
}
}
musicOffTrigger()
{
trigger = getEnt("musicstop", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(player.music1Playing || player.music2Playing || player.music3Playing || player.music4Playing)
{
player playLocalSound("stop");
player iPrintLn("^3Music ^1Stoped");
player.music1Playing = false;
player.music2Playing = false;
player.music3Playing = false;
player.music4Playing = false;
}
}
}
|
|
|
|
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Apr. 29, 2014 08:31 pm |
|
thanks fo advices, can you chek maybe i do somthing wrong
1. my zone file
Code: ignore,code_post_gfx_mp
ignore,common_mp
ignore,localized_code_post_gfx_mp
ignore,localized_common_mp
col_map_mp,maps/mp/mp_easy.d3dbsp
rawfile,maps/mp/mp_easy.gsc
impactfx,mp_easy
rawfile,maps/mp/_teleport.gsc
rawfile,maps/mp/_rotate.gsc
rawfile,maps/mp/no_rpg.gsc
fx,misc/ui_pickup_available
include,mptypes_desert
sound,common,mp_easy,!all_mp
sound,generic,mp_easy,!all_mp
sound,voiceovers,mp_easy,!all_mp
sound,multiplayer,mp_easy,!all_mp
sound,mp_easy,!all_mp
2. mp_easy.csv (soundaliases fold)
Code: name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
#Music,,,,,,,,,,,,,,,,,,,,,,
song1,,mp_easy/song1.mp3,1,,music,,,150,6000,music,streamed,,looping,,,,,,,,,,,,,,
song2,,mp_easy/song2.mp3,1,,music,,,150,6000,music,streamed,,looping,,,,,,,,,,,,,,
song3,,mp_easy/song3.mp3,1,,music,,,150,6000,music,streamed,,looping,,,,,,,,,,,,,,
song4,,mp_easy/song4.mp3,1,,music,,,150,6000,music,streamed,,looping,,,,,,,,,,,,,,
3. in radiant i have 5 trigger use br. (w. key values)
4. path to songs /raw/sound/mp_easy/song1,song2...
5. during compiling i have no errors, and when i start map and try trigers original ambient stops (script is ok) but there is no music)
6. my mp3 are 128kbit 32bit float 44100Hz mono (maybe problem here)
i am confused about line in script
if(!player.music1Playing)
that means music should play throu player not speaker or script origin?(maybe need to put something more in zone file)
also iwd with /sound/music/song1.mp3....(maybe no need music folder)
ive tried different ways b4 postin this post
Any more ideas ?
thanks
mp3 i cleaned with id3wipe and shrink with freemake audio converter, i tried Audacity -no luck mp3 become big size
edited on Apr. 29, 2014 03:21 pm by BUSH1DO |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Apr. 29, 2014 09:53 pm |
|
Honestly, from what I see, it could be many things. If you could, attach a zip file with all 4 mp3 files. I will test here, get it to work, and then post results.
This:
if (!player.music1Playing)
It checks, if the player is NOT playing song 1, then, play song 1, but, if he is playing song 1, do nothing.
Actually, this line means, play music/song to player ONLY, "player is origin", only player can hear song:
self playLocalSound("song1"); |
|
|
|
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Tuesday, Apr. 29, 2014 11:18 pm |
|
I tried a few experiments on my end, with music that I know works in game and using your script, I could not get them to play. I think I remember trying this a long time ago in a map, and could NOT get music to play to any player, I could only get it to play to everyone using these two functions. (Using an MP3)
MusicPlay( "alias here", false );
MusicPlay( "music", timescale, overrideCheat ) <--- REFERENCE
MusicStop( 3 );
MusicStop( time, overrideCheat ) <--- REFERENCE
I'm not really sure how to help you on this one. I looked up some commands and I don't even see, playLocalSound as a COD4 scripting command. The closest I see is, PlaySoundToPlayer. You could check Here and have a look under the "sound" reference, and maybe you can find what you are looking for to create what you are trying to create. I'm not sure there is much more I can do, if the commands given are not playing the file. Also, your script needs a little work to actually stop the music. I think the game requires a command to actually stop music from playing, not just flipping a boolean.
If you decide to use these commands, you'll most likely have to rewrite your script completely. However, if you decide to convert your mp3 to wave files, you maybe be able to get away with using basic commands to play your files. The downside to this is that, you will have to pack your wave files into your map file thus adding a huge load of MB to your overall map file. It's a trade off. Maybe there is someone else here who knows better and can help you solve this the way you want. |
|
|
|
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Wednesday, Apr. 30, 2014 03:22 pm |
|
took this script from working map its working there
maybe need to do something more in radiant
or soundaliases not correct
|
|
|
|
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Thursday, May. 1, 2014 02:30 pm |
|
ok its working
so.....
1. script is ok
2. zone file
Code: sound,common,mp_easy,!all_mp
sound,generic,mp_easy,!all_mp
sound,voiceovers,mp_easy,!all_mp
sound,multiplayer,mp_easy,!all_mp
sound,mp_easy,,all_mp
3.soundaliases
Code: name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
#Music,,,,,,,,,,,,,,,,,,,,,,
song1,,music/song1.mp3,1,1,music,,,,,music,streamed,,,,all_mp,,,,,,music,,,,
song2,,music/song2.mp3,1,1,music,,,,,music,streamed,,,,all_mp,,,,,,music,,,,
song3,,music/song3.mp3,1,1,music,,,,,music,streamed,,,,all_mp,,,,,,music,,,,
song4,,music/song4.mp3,1,1,music,,,,,music,streamed,,,,all_mp,,,,,,music,,,,
4.my mp3 in /raw/sound/music/song1.mp3,...
also i have in /raw/mp_easy/song1.mp3,...
5. iwd /sound/music/song1.mp3,...
6. radiant only trigger use (5pcs) with targetnames music1,music2.....
there is still problem original ambient overlaping mp3, need to find way to swith off ambient
waiting someone to try and reply
edited on May. 1, 2014 09:41 am by BUSH1DO
edited on May. 1, 2014 11:04 am by BUSH1DO |
|
|
|
DeekCiti |
|
General Member Since: Mar 13, 2008 Posts: 1293 Last: Jul 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Thursday, May. 1, 2014 08:50 pm |
|
Good Job! I also got it working here, with your code and new code I wrote. I also noticed that your music stop thread doesn't actually stop the music. I edited your code to make it actually stop all or any song playing.
Code:
musicOffTrigger()
{
trigger = getEnt("musicstop", "targetname");
for(;;wait 0.05)
{
trigger waittill("trigger", player);
if(player.music1Playing || player.music2Playing || player.music3Playing || player.music4Playing)
{
player stopLocalSound("song1");
player stopLocalSound("song2");
player stopLocalSound("song3");
player stopLocalSound("song4");
player playLocalSound("stop");
player iPrintLn("^3Music ^1Stoped");
player.music1Playing = false;
player.music2Playing = false;
player.music3Playing = false;
player.music4Playing = false;
}
}
}
When you say overlapping original ambient mp3, what are you saying? This mp3?
Code: ambientPlay("ambient_audio");
|
|
|
|
BUSH1DO |
General Member Since: Apr 2, 2014 Posts: 40 Last: Sep 9, 2016 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Thursday, May. 1, 2014 09:03 pm |
|
hi for music stop also need stop.mp3 just 1 blank i mean
by owerlapping i mean i have my music and time after time plays background ambient from game
also i change directorie from music to ambient and my soundalliases is
Code: name,sequence,file,vol_min,vol_max,vol_mod,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle,compression,secondaryaliasname,volumefalloffcurve,startdelay,speakermap,reverb,lfe percentage,center percentage,platform,envelop_min,envelop_max,envelop percentage
so your trigger stop no need to have blank.mp3?
#Ambience,,,,,,,,,,,,,,,,,,,,,,,,,
song1,,ambient/song1.mp3,1,,ambience,,,,,ambient,streamed,,,master,all_mp,,,,,,,,,
song2,,ambient/song2.mp3,1,,ambience,,,,,ambient,streamed,,,master,all_mp,,,,,,,,,
song3,,ambient/song3.mp3,1,,ambience,,,,,ambient,streamed,,,master,all_mp,,,,,,,,,
song4,,ambient/song4.mp3,1,,ambience,,,,,ambient,streamed,,,master,all_mp,,,,,,,,,
stop,,ambient/stop.mp3,1,,ambience,,,,,ambient,streamed,,looping,master,all_mp,,,,,,,,,
also all mp3 now in raw/sound/ambient/
and iwd /sound/ ambient/
so for now need to get rid of background ambient by changin values in soundaliases
btw is it possible to combine musicstop script with lever trigger i am not good with scripts
Code: }
lever()
{
level endon("game_ended");
lever = getent("lever","targetname");
trigger = getent("levtrig","targetname");
while(1)
{
trigger waittill("trigger", player);
lever rotatepitch(90,2);
if(player.mod["music_plays"])
player thread musicstop();
else
player thread musicstart();
wait 4;
lever rotatepitch(-90,2);
wait 2;
}
}
musicstop()
{
self endon("disconnect");
wait 2;
self notify("music_stop");
self.mod["music_plays"] = false;
self playLocalSound("stop");
}
edited on May. 1, 2014 02:04 pm by BUSH1DO
edited on May. 1, 2014 02:18 pm by BUSH1DO
edited on May. 1, 2014 03:29 pm by BUSH1DO |
|
|
|