[Add] Use combat music on combat.
This commit is contained in:
parent
2c68677e81
commit
f346126976
@ -27,7 +27,7 @@ function choose(str)
|
||||
choose_ambient()
|
||||
|
||||
elseif str == "combat" then
|
||||
choose_battle()
|
||||
choose_combat()
|
||||
|
||||
elseif str == "idle" and last ~= "idle" then
|
||||
-- We'll play the same as last unless it was takeoff.
|
||||
@ -174,8 +174,16 @@ function choose_ambient()
|
||||
end
|
||||
|
||||
-- Battle songs.
|
||||
function choose_battle()
|
||||
music.load("galacticbattle")
|
||||
function choose_combat()
|
||||
-- Stop music first, but since it'll get saved it'll run this next.
|
||||
if music.isPlaying() then
|
||||
music.stop()
|
||||
return
|
||||
end
|
||||
|
||||
combat = { "galacticbattle" }
|
||||
|
||||
music.load(combat[rnd.int(1, #combat)])
|
||||
music.play()
|
||||
end
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "map.h"
|
||||
#include "explosion.h"
|
||||
#include "escort.h"
|
||||
#include "music.h"
|
||||
#include "pilot.h"
|
||||
|
||||
#define XML_ID "Fleets" /**< XML document identifier. */
|
||||
@ -223,6 +224,9 @@ double pilot_face(Pilot* p, const double dir) {
|
||||
*/
|
||||
void pilot_setHostile(Pilot* p) {
|
||||
if(!pilot_isFlag(p, PILOT_HOSTILE)) {
|
||||
/* Time to play combat music. */
|
||||
if(player_enemies == 0)
|
||||
music_choose("combat");
|
||||
player_enemies++;
|
||||
pilot_setFlag(p, PILOT_HOSTILE);
|
||||
}
|
||||
@ -236,6 +240,10 @@ void pilot_rmHostile(Pilot* p) {
|
||||
if(pilot_isFlag(p, PILOT_HOSTILE)) {
|
||||
player_enemies--;
|
||||
pilot_rmFlag(p, PILOT_HOSTILE);
|
||||
|
||||
/* Change music back to ambient if no more enemies. */
|
||||
if(player_enemies == 0)
|
||||
music_choose("ambient");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user