[Add] Use combat music on combat.
This commit is contained in:
parent
2c68677e81
commit
f346126976
@ -27,7 +27,7 @@ function choose(str)
|
|||||||
choose_ambient()
|
choose_ambient()
|
||||||
|
|
||||||
elseif str == "combat" then
|
elseif str == "combat" then
|
||||||
choose_battle()
|
choose_combat()
|
||||||
|
|
||||||
elseif str == "idle" and last ~= "idle" then
|
elseif str == "idle" and last ~= "idle" then
|
||||||
-- We'll play the same as last unless it was takeoff.
|
-- We'll play the same as last unless it was takeoff.
|
||||||
@ -174,8 +174,16 @@ function choose_ambient()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Battle songs.
|
-- Battle songs.
|
||||||
function choose_battle()
|
function choose_combat()
|
||||||
music.load("galacticbattle")
|
-- 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()
|
music.play()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
10
src/pilot.c
10
src/pilot.c
@ -20,6 +20,7 @@
|
|||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "explosion.h"
|
#include "explosion.h"
|
||||||
#include "escort.h"
|
#include "escort.h"
|
||||||
|
#include "music.h"
|
||||||
#include "pilot.h"
|
#include "pilot.h"
|
||||||
|
|
||||||
#define XML_ID "Fleets" /**< XML document identifier. */
|
#define XML_ID "Fleets" /**< XML document identifier. */
|
||||||
@ -223,6 +224,9 @@ double pilot_face(Pilot* p, const double dir) {
|
|||||||
*/
|
*/
|
||||||
void pilot_setHostile(Pilot* p) {
|
void pilot_setHostile(Pilot* p) {
|
||||||
if(!pilot_isFlag(p, PILOT_HOSTILE)) {
|
if(!pilot_isFlag(p, PILOT_HOSTILE)) {
|
||||||
|
/* Time to play combat music. */
|
||||||
|
if(player_enemies == 0)
|
||||||
|
music_choose("combat");
|
||||||
player_enemies++;
|
player_enemies++;
|
||||||
pilot_setFlag(p, PILOT_HOSTILE);
|
pilot_setFlag(p, PILOT_HOSTILE);
|
||||||
}
|
}
|
||||||
@ -233,9 +237,13 @@ void pilot_setHostile(Pilot* p) {
|
|||||||
* @param p Pilot to mark as neutral.
|
* @param p Pilot to mark as neutral.
|
||||||
*/
|
*/
|
||||||
void pilot_rmHostile(Pilot* p) {
|
void pilot_rmHostile(Pilot* p) {
|
||||||
if(pilot_isFlag(p, PILOT_HOSTILE)) {
|
if(pilot_isFlag(p, PILOT_HOSTILE)) {
|
||||||
player_enemies--;
|
player_enemies--;
|
||||||
pilot_rmFlag(p, PILOT_HOSTILE);
|
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