Battle music hardcoded?

Currently, HW2RM will automatically play the default battle music track when it detects a battle has started in multiplayer. This is unlike the ambient music, which will not play if none is set by default. Is there any way to change this functionality? It will override the currently playing ambient music.

I don’t know if you can disable the battle music behaviour altogether, but you can define what file will play on a per-map basis in the .level file, with the function setBattleMusic

The problem is that I have a functional random music script that will start and stop playing music during combat, and the hardcoded battle music player is overriding the script. I’m looking to disable it altogether.

See if you have anything different in your rule than this old random music script that works in HWR

  function PickRandomMusicTrackRule()
    	local randNum = 0
    	local musicDir = ""
    	mode = 0
    	dofilepath("data:scripts/scar/playlist.lua")
    	if(score_flag) then
    		if (mode == 0) then
    			tracks=track_count
    			randNum = random(tracks)
    			if (randNum < battleIDX) then
    				musicDir = "ambient/"
    			else
    				musicDir = "battle/"
    			end
    		elseif (mode == 1) then
    			tracks=battleIDX
    			randNum = random(tracks)
    			musicDir = "ambient/"
    		elseif (mode == 2) then
    			tracks=battleIDX-track_count
    			randNum = random(tracks)
    			musicDir = "battle/"
    		end
    		
    		local track_length = musicTable[randNum].length
    		local track_path = musicTable[randNum].path
    		local track_name = musicTable[randNum].name
    		Sound_MusicPlay(music_path .. musicDir .. track_path)
    		print([[Level music (]] .. randNum .. [[): "]] .. randNum .. [["]])
    		Rule_Remove("PickRandomMusicTrackRule")
    		Rule_AddInterval("PickRandomMusicTrackRule", track_length)
    		
    	else
    		local track_length = musicTable[1].length
    		local track_path = musicTable[1].path
    		local track_name = musicTable[1].name
    		Sound_MusicPlay(music_path .. musicDir .. track_path)
    	end
    	currenttrack=randNum
    end

I’m using the sound_musicplay function and it worked perfectly in HW2C. The problem is HW2RM will play the battle music overriding the sound_musicplay command. Once HW2RM decides the battle is over, I’ll hear the script’s music again. Does the function here not have that behavior?

I found a way to change the battle music, it is not perfect, but it gets the job done.

You can use setBattleMusic outside of a .level file.
Here is my script for dynamic battle music to give you an example:

function RandomBattleMusic()
	battleLength = 
	{
		223,
		149,
		150,
		246,
		220,
	}

	randomNumber = random(getn(battleLength))
	
	setBattleMusic("Data:sound/music/customBattle/battle" .. randomNumber)

	Rule_AddInterval("RandomBattleMusic", battleLength[randomNumber])
	Rule_Remove("RandomBattleMusic")
end
1 Like