LFCChameleon_Silk Posted September 17, 2015 Posted September 17, 2015 (edited) Figured I'd share this, its a way of adding samples of music (the intro and the main loop of a composition) into a mission cutting down on the miz file size by reusing and rescheduling it to play as the sample ends, there is also another set of 2 samples that represent when hostile forces are in the range of a zone(s) you have placed in the editor.... I'm sure there are even more things you can do with this but for now this represents all the work I want to put into it at the moment.... with this its possible to have a sound track of music playing all the time that will change based on the threat in the mission which is an ode to old flight sims of the past that were a bit more 'gamey', enjoy. you need MIST on your mission file and the a few edits to the script as well as getting the samples cut and added as well as added into the mission file. *WARNING* MIST 3.7.51 has issue with flagfuncs and won't work *WARNING* MIST 3.6.44 has issue with flagfuncs and won't work 3.5.37 is the last version of MIST that seems to be working to use flagfuncs -- for music function Music = 1 -- you can use this variable to disable or enable music player Tension_Set = 0 -- default tension -- -- requires 4 samples, the intro to the relaxed track cut and matching in seconds length, and then the actual main music sample loop -- the same thing is done for the high tension track, use whatever length you feel makes it sound right and cut it to the exact seconds needed -- this will require some musical ear to make it sound 'proper' -- Now place the trigger zones in the mission editor and match the names in TensionZone up above in the format shown for any time an enemy enters these zones to change music to higher tension -- load MIST in your mission with a ONCE >> time more 5 >> do scriptfile and point to MIST -- add another trigger ONCE >> time more 6 >> do scriptfile and point it to this script -- you will also need to add the 4 samples sound loaded into some aircraft in your mission that is deactivated to get your music samples into the mission file -- DO NOT EDIT BELOW THIS LINE -- Music_Battle_Sample = 1 -- set to sample 1 Music_Relaxed_Sample = 1 -- set to sample 1 function Music_Poll(arg, time) -- this will be used to setup the triggers to make local Enemy = mist.makeUnitTable({'[red][plane]'}) local Friend = mist.makeUnitTable({'[blue][plane]'}) mist.flagFunc.units_in_moving_zones{ units = Enemy, zone_units = Friend, flag = 1, radius = 11000, --stopflag = 2, --req_num = 1, --zone_type = 'sphere', interval = 1, toggle = true, } timer.scheduleFunction(Play_Music, nil, timer.getTime() + 1) end function Play_Music(arg, time) local Return_Time = 1 local Old_Tension_Set = Tension_Set if Music == 1 then -- condition block only used if Music is enabled -- if trigger.misc.getUserFlag('1') == 0 then Tension_Set = 0 end if trigger.misc.getUserFlag('1') == 1 then Tension_Set = 1 end -- set tension level based off of enemy present in GCI zone -- if Tension_Set == 0 and Old_Tension_Set == 1 then Music_Relaxed_Sample = 1 end if Tension_Set == 1 and Old_Tension_Set == 0 then Music_Battle_Sample = 1 end -- set back to intro sample if the tension has changed local msg = {} msg.text = ' Music Setting: ' ..tostring(Tension_Set) msg.displayTime = 10 msg.msgFor = {coa = {'all'}} mist.message.add(msg) if Tension_Set == 0 and Music_Relaxed_Sample == 2 then -- play relaxed track trigger.action.outSoundForCoalition(coalition.side.BLUE, 'relaxed_mid_33sec.ogg') Return_Time = 33 -- sample is 10 seconds long end if Tension_Set == 0 and Music_Relaxed_Sample == 1 then -- play relaxed start trigger.action.outSoundForCoalition(coalition.side.BLUE, 'relaxed_start_12sec.ogg') Return_Time = 12 Music_Relaxed_Sample = 2 -- set to main sample end if Tension_Set == 1 and Music_Battle_Sample == 2 then -- play battle track trigger.action.outSoundForCoalition(coalition.side.BLUE, 'battle_mid_41sec.ogg') Return_Time = 41 -- sample is 41 seconds long end if Tension_Set == 1 and Music_Battle_Sample == 1 then -- play battle start trigger.action.outSoundForCoalition(coalition.side.BLUE, 'battle_start_15sec.ogg') Return_Time = 15 -- sample is 15 seconds long Music_Battle_Sample = 2 -- set to main sample end else -- do not play anything end return time + Return_Time -- return exactly same time sample ends end -- func end ------------------------------------------------------------------ timer.scheduleFunction(Music_Poll, nil, timer.getTime() + 10) ------------------------------------------------------------------ Edited September 17, 2015 by =LFC=Chameleon_Silk
LFCChameleon_Silk Posted September 17, 2015 Author Posted September 17, 2015 (edited) Ok so I updated the script/thread to be up to date with a working copy, the way the script works is it makes a moving zone on top of the blue planes and whenever red planes enter the blue planes radius the music will become the tense version. EDIT: Demo mission uploaded and updated to 4th version (the one that actually works :P, also documented issues with newer MIST versions)mist.luamusic_script.luaMusic Play Script Demo.miz Edited September 17, 2015 by =LFC=Chameleon_Silk 1
Grimes Posted September 17, 2015 Posted September 17, 2015 Try the latest mist rev 53. https://github.com/mrSkortch/MissionScriptingTools/blob/development/mist.lua The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
LFCChameleon_Silk Posted September 17, 2015 Author Posted September 17, 2015 will check it out Grimes after I get back from work. awesome if you have fixed the flagfuncs... I would love to update to latest revision in Operation Flagship however the latest versions create lots of problems. but will try out this revision later.
Grimes Posted September 17, 2015 Posted September 17, 2015 What kind of problems? The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
LFCChameleon_Silk Posted September 18, 2015 Author Posted September 18, 2015 have to investigate further for you sometime later tonight if I have time. I think its that things stop spawning, where the other version works fine. as long as I have working flagfuncs I will be happy, but I would also like to keep it able to stay on par with every MIST release.
Recommended Posts