Skip to content

Dehardcode music

Andrei Kortunov requested to merge akortunov/openmw:dehardcode_music into master

Moves playlist logic from C++ to Lua.

Basically, it uses an approach from Skyrim - when you can have several active playlists in the same time with integer Priority. In this case engine plays a playlist with lowest Priority value. Also it is possible to add new custom playlists via Lua scripts:

-- Register ambient playlist for Balmora
I.Music.registerPlaylist({ id = "balmora", priority = 90, randomize = true, tracks = {...} });

-- Activate playlist if player is in Balmora
I.Music.setPlaylistActive("balmora", true);

A demo of such usage (adds an ambient music for Balmora and combat music for fighting mudcrabs): MusicTest.zip

Limitations:

  1. There is no way to get combat targets from Player script, so I have to attach local script to every actor and send events to Player script.
  2. There are no event handlers when AI packages are added or removed, so I have to get combat targets every frame, what is suboptimal.
Edited by Andrei Kortunov

Merge request reports