Jump to content
masterantony

Music in the Mission - Help Me.

Recommended Posts

Hi guys.

I want to know, as I put the music in my mission when the player is in BASE or when the situation is calm, there aren't shots ext .... ?

Thanks to all.

Edited by MasterAntony

Share this post


Link to post
Share on other sites
Hi guys.

I want to know, as I put the music in my mission when the player is in BASE or when the situation is calm, there aren't shots ext .... ?

Thanks to all.

EDIT:

Latest solution: https://www.dropbox.com/s/bk1f17l04w4cyt0/ANTONY_musicScript.sqf?dl=0

Example mission: https://www.dropbox.com/s/xy6d1klsfkftxxs/ANTONY_testMission3.Altis.pbo?dl=0

-----------

Original reply:

Something like this will work, to schedule when it is safe/not safe to play music.

// initPlayerLocal.sqf
player setBehaviour 'SAFE';
player addEventHandler ['Fired',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
player addEventHandler ['FiredNear',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
player addEventHandler ['Explosion',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
ANTONY_combatDecay = 0;
while {TRUE} do {

if ((behaviour player) isEqualTo 'COMBAT') then {

	/* its not okay to play music */

	if (time > ANTONY_combatDecay) then {

		player setBehaviour 'SAFE';

	};

} else {

	/* its okay to play music */

	if (player call BIS_fnc_enemyDetected) then {

		ANTONY_combatDecay = time + 300;
		player setBehaviour 'COMBAT';

	};

};

sleep 5;

};

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites
Something like this will work, to schedule when it is safe/not safe to play music.

// initPlayerLocal.sqf
player setBehaviour 'SAFE';
player addEventHandler ['Fired',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
player addEventHandler ['FiredNear',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
player addEventHandler ['Explosion',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 300;}];
ANTONY_combatDecay = 0;
while {TRUE} do {

if ((behaviour player) isEqualTo 'COMBAT') then {

	/* its not okay to play music */

	if (time > ANTONY_combatDecay) then {

		player setBehaviour 'SAFE';

	};

} else {

	/* its okay to play music */

	if (player call BIS_fnc_enemyDetected) then {

		ANTONY_combatDecay = time + 300;
		player setBehaviour 'COMBAT';

	};

};

sleep 5;

};

So this activate music when player detected enemy.

Right?

What is ANTONY_combatDecay ? what function does it have?

I don't understand your CODE sorry, but if ANTONY_combatDecay = time + 300 will be foreven ANTONY_combatDecay > time , then time > ANTONY_combatDecay is no sense.

My mission is a COOP 32 versus AI .

Then there aren't AI in my TEAM.

Edited by MasterAntony

Share this post


Link to post
Share on other sites

Apologies for it not being clear.

What exactly are you trying to simulate? Do you have the script/code which plays the music? I had assumed you did and were wondering how to determine when safe/not safe to play it.

When the player:

- Fires a shot

- Has shots fired nearby

- Has explosion nearby

- Detects a nearby enemy

The player will be set to 'COMBAT' behaviour.

If 300 seconds (5 minutes) pass with no shots, no explosions, the player will return to 'SAFE' behaviour.

While the player is in 'SAFE' behaviour, you can run your playMusic code.

While in 'SAFE' behaviour, if the player detects a nearby enemy, the player will exit 'SAFE' behaviour and return to 'COMBAT' behaviour, and the 5 minute timer described above will re-commence.

The code merely provides a structure to determine when it is SAFE or NOT SAFE to play music.

...

ANTONY_combatDecay = time + 300.

Lets say time = 600.

So ANTONY_combatDecay = 900.

In 6 minutes, time = 960. (600 + 360)

So in 6 minutes, time > ANTONY_combatDecay, and player will return to 'SAFE' behaviour if no more shots have been fired/etc.

Share this post


Link to post
Share on other sites
Apologies for it not being clear.

What exactly are you trying to simulate? Do you have the script/code which plays the music? I had assumed you did and were wondering how to determine when safe/not safe to play it.

When the player:

- Fires a shot

- Has shots fired nearby

- Has explosion nearby

- Detects a nearby enemy

The player will be set to 'COMBAT' behaviour.

If 300 seconds (5 minutes) pass with no shots, no explosions, the player will return to 'SAFE' behaviour.

While the player is in 'SAFE' behaviour, you can run your playMusic code.

While in 'SAFE' behaviour, if the player detects a nearby enemy, the player will exit 'SAFE' behaviour and return to 'COMBAT' behaviour, and the 5 minute timer described above will re-commence.

The code merely provides a structure to determine when it is SAFE or NOT SAFE to play music.

...

ANTONY_combatDecay = time + 300.

Lets say time = 600.

So ANTONY_combatDecay = 900.

In 6 minutes, time = 960. (600 + 360)

So in 6 minutes, time > ANTONY_combatDecay, and player will return to 'SAFE' behaviour if no more shots have been fired/etc.

Now i created class CfgMusic in description.ext of my mission.

To play I thought to triggers.

Is not it easier using the trigger in the editor?

It is not enough to just put the condition in the trigger?

Edited by MasterAntony

Share this post


Link to post
Share on other sites
Now i created class CfgMusic in description.ext of my mission.

To play I thought to triggers.

Is not it easier using the trigger in the editor?

It is not enough to just put the condition in the trigger?

I don't know anything about the editor triggers, sorry. Perhaps someone else with better knowledge can assist

Share this post


Link to post
Share on other sites

To play music there is comand playMusic "Name" ;

I need the script to start the music when the situation is calm.

Your work or should I change something?

Edited by MasterAntony

Share this post


Link to post
Share on other sites
To play music there is comand playMusic "Name" ;

I need the script to start the music when the situation is calm.

Your work or should I change something?

Is it just one music event or is it just whenever situation is calm?

Share this post


Link to post
Share on other sites

this may help. keep in mind music files are large making the mission DL larger than normal... also if you have more than 1 music file..... the larger it will be...

Share this post


Link to post
Share on other sites
Is it just one music event or is it just whenever situation is calm?

playMusic "Name";

is a comand from Bohemia to play Music.

I don't understand you.

I have to play music when the situation is calm.

Your script is complete?

Should I change it?

---------- Post added at 09:02 ---------- Previous post was at 09:01 ----------

this may help. keep in mind music files are large making the mission DL larger than normal... also if you have more than 1 music file..... the larger it will be...

Thanks but These things already know and do not respond to my question.

Share this post


Link to post
Share on other sites
playMusic "Name";

is a comand from Bohemia to play Music.

I don't understand you.

I have to play music when the situation is calm.

Your script is complete?

Should I change it?

---------- Post added at 09:02 ---------- Previous post was at 09:01 ----------

Thanks but These things already know and do not respond to my question.

will playMusic be run once or do you want it to run repeatedly whenever the conditions are right?

Because, when the players first enter the scenario, the situation is probably calm right? The music will play right then if thats the case.

The script is not complete, its just a structure to determine when the player is in danger or not.

Is it one music clip or are there several music clips? Would need to know the track length (music duration) of each clip.

Need more description :)

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites
Is it just one music event or is it just whenever situation is calm?

I tried your script but there is one problem.

The music is activated from the beginning , As soon as start the mission.

I have 7-8 soundtracks.

One play when you join on missions ( Intro ) ... already done .

Other will play when will be completed one task of mission.

The others will be as background while you play ( in fact, when the situation is calm , when the player is not doing anything ) .

player setBehaviour 'SAFE';

player addEventHandler ['Fired',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 10;}];

player addEventHandler ['FiredNear',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 10;}];

player addEventHandler ['Explosion',{player setBehaviour 'COMBAT';ANTONY_combatDecay = time + 10;}];

ANTONY_combatDecay = 0;

while {TRUE} do {

if ((behaviour player) isEqualTo 'COMBAT') then {

/* its not okay to play music */

if (time > ANTONY_combatDecay) then {

player setBehaviour 'SAFE';

};

} else {

playMusic "Black and Grey" ||

playMusic "Destiny" ||

playMusic "Sacrifice" ||

playMusic "We Fight Together" ;

if (player call BIS_fnc_enemyDetected) then {

ANTONY_combatDecay = time + 10;

player setBehaviour 'COMBAT';

};

};

sleep 5;

};

Edited by MasterAntony

Share this post


Link to post
Share on other sites
what are the durations of each song?

From 1.51 minutes to 4.15 .

Edited by MasterAntony

Share this post


Link to post
Share on other sites

Ok, here is an updated version:

I have not tested it but it should work as intended. If not let me know and I'll test it out on my end.

https://www.dropbox.com/s/bk1f17l04w4cyt0/ANTONY_musicScript.sqf?dl=0

It was changed slightly to better meet the needs:

- Will handle the background music, not task-specific music.

- You can delay the script from starting for the desired time.

- Music is selected and played from the list in the scripts config.

- Combat behaviour/mode merely adjusts the volume.

- The music is playing according to its schedule always, but the music volume fades to the desired volume when player in combat, such as zero (0) music volume.

- There is provided space to set the duration of each track, and track name, in list form.

- The script selects a track, and does not play another track until the associated track duration has elapsed.

- Once all tracks have been played, you can set the track list to be shuffled (or not), and it starts again from the top of the list.

- You can set a delay between songs if you like. If you do, once the track duration has finished, it will not play another track for the specified amount of time.

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites
Ok, here is an updated version:

I have not tested it but it should work as intended. If not let me know and I'll test it out on my end.

https://www.dropbox.com/s/bk1f17l04w4cyt0/ANTONY_musicScript.sqf?dl=0

It was changed slightly to better meet the needs:

- Will handle the background music, not task-specific music.

- You can delay the script from starting for the desired time.

- Music is selected and played from the list in the scripts config.

- Combat behaviour/mode merely adjusts the volume.

- The music is playing according to its schedule always, but the music volume fades to the desired volume when player in combat, such as zero (0) music volume.

- There is provided space to set the duration of each track, and track name, in list form.

- The script selects a track, and does not play another track until the associated track duration has elapsed.

- Once all tracks have been played, you can set the track list to be shuffled (or not), and it starts again from the top of the list.

- You can set a delay between songs if you like. If you do, once the track duration has finished, it will not play another track for the specified amount of time.

Script don't work.

Does not change even the state from Safe to Combat ext ext.

In initPlayerLocal.sqf i wrote this [] execVM "ANTONY_musicScript.sqf"; .

I tried also to execute the script in match .

Nothing.

There must be some mistake.

Script compiled.

http://ge.tt/api/1/files/5sUny6J2/0/blob?download

My class on description.ext for music .

class CfgMusic

{

tracks[]=

{

Intro, BlackandGrey, Destiny, DontDie, Sacrifice, SecondChances, Victory_Task, WeFightTogether

};

class Intro

{

name = "Intro";

sound[] = {"music\Intro.ogg", db+0, 1.0};

};

class BlackandGrey

{

name = "Black and Grey";

sound[] = {"music\Black and Grey.ogg", db+0, 1.0};

};

class Destiny

{

name = "Destiny";

sound[] = {"music\Destiny.ogg", db+0, 1.0};

};

class DontDie

{

name = "Don't Die";

sound[] = {"music\Don't Die.ogg", db+0, 1.0};

};

class Sacrifice

{

name = "Sacrifice";

sound[] = {"music\Sacrifice.ogg", db+0, 1.0};

};

class SecondChances

{

name = "Second Chances";

sound[] = {"music\Second Chances.ogg", db+0, 1.0};

};

class Victory_Task

{

name = "Victory_Task";

sound[] = {"music\Victory_Task.ogg", db+0, 1.0};

};

class WeFightTogether

{

name = "We Fight Together";

sound[] = {"music\We Fight Together.ogg", db+0, 1.0};

};

};

Share this post


Link to post
Share on other sites
Yes there was a script error.

I uploaded a fixed version to the same link. Also tested it myself, works fine now (i think :)).

Let me know if any other issues.

https://www.dropbox.com/s/bk1f17l04w4cyt0/ANTONY_musicScript.sqf?dl=0

Nothing.

Don't work.

Same problems as before.

My music is in folder called music.

Is right this?

And in array I have to write the names of the classes , file names , how does it know which files to take?

Have you seen my CfgMusic?

_arrayOfMusic = [ // YOUR ARRAY OF TRACKS AND THEIR RESPECTIVE MUSIC DURATIONS IN SECONDS

["Black and Grey",155],

["Destiny",128],

["Sacrifice",178],

["We Fight Together",218] // ENSURE FINAL ENTRY DOES NOT HAVE A COMMA AFTER IT

];

Edited by MasterAntony

Share this post


Link to post
Share on other sites
Nothing.

Don't work.

Same problems as before.

My music is in folder called music.

Is right this?

Try with a few default tracks:

_arrayOfMusic = [
["Fallout",155],
["MAD",128],
["SkyNet",178],
["Wasteland",218]
];

I have tried it out on my machine, works fine.

Which folder is the script in?

Share this post


Link to post
Share on other sites

Root Folder of the mission.

Fallout? MAD? SkyNet? I'm on Arma 3 , no Arma 2.

The script not active.

People remain in Safe Mode.

Sure you've uploaded the version without error?

Because the first script ( version obsolete ) activated Combat mode ext ext.

So I guess there is some error in the current version.

Edited by MasterAntony

Share this post


Link to post
Share on other sites
Root Folder of the mission.

Fallout? MAD? SkyNet? I'm on Arma 3 , no Arma 2.

The script not active.

People remain in Safe Mode.

Sure you've uploaded the version without error?

EDIT:

Here is a sample mission. Put in your MPMissions folder, start a server in the MP browser and run it.

https://www.dropbox.com/s/xy6d1klsfkftxxs/ANTONY_testMission3.Altis.pbo?dl=0

Once ingame, hit Esc to open the console. Paste this:

ANTONY_musicScriptDelay = TRUE;

and 'Local Exec' it, to skip the starting delay.

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites

Now work ...

Thanks a lot .

Beautiful Community.

_musicVolumeSafe maximus is 1?

Edited by MasterAntony

Share this post


Link to post
Share on other sites
Now work ...

Thanks a lot .

Beautiful Community.

_musicVolumeSafe maximus is 1?

1 = max volume, yes.

https://community.bistudio.com/wiki/fadeMusic

Found and corrected another script error, in case you encounter any trouble with the one you're using:

https://www.dropbox.com/s/xy6d1klsfkftxxs/ANTONY_testMission3.Altis.pbo?dl=0

Edited by MDCCLXXVI

Share this post


Link to post
Share on other sites

Now i prove this, with old version i noticed that while we are in Combat Mode ( also if we shot ) , play music but It is stopped after 2-3 seconds.

Share this post


Link to post
Share on other sites
Now i prove this, with old version i noticed that while we are in Combat Mode ( also if we shot ) , play music but It is stopped after 2-3 seconds.

Yes there is some slight delay. This is due to the 'sleep 5' at the bottom of the script. Lower the number to reduce the delay, 'sleep 1' would probably be good too.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×