[Add] starting to add sound for beam weapons. Sound system could do with an overhaul tbh.
This commit is contained in:
parent
1a03c08672
commit
70d4987a00
@ -3,7 +3,7 @@
|
|||||||
* @brief Control all the music playing.
|
* @brief Control all the music playing.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <SDL_mixer.h>
|
#include <SDL/SDL_mixer.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "llua.h"
|
#include "llua.h"
|
||||||
|
24
src/outfit.c
24
src/outfit.c
@ -564,6 +564,11 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
char str[PATH_MAX] = "\0";
|
char str[PATH_MAX] = "\0";
|
||||||
|
|
||||||
|
/* Defaults. */
|
||||||
|
tmp->u.bem.sound_warmup = -1;
|
||||||
|
tmp->u.bem.sound = -1;
|
||||||
|
tmp->u.bem.sound_off = -1;
|
||||||
|
|
||||||
node = parent->xmlChildrenNode;
|
node = parent->xmlChildrenNode;
|
||||||
do { /* Load all the data. */
|
do { /* Load all the data. */
|
||||||
xmlr_float(node, "range", tmp->u.bem.range);
|
xmlr_float(node, "range", tmp->u.bem.range);
|
||||||
@ -584,10 +589,29 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
tmp->u.bem.gfx = gl_newSprite(str, 1, 1);
|
tmp->u.bem.gfx = gl_newSprite(str, 1, 1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(xml_isNode(node, "sound_warmup")) {
|
||||||
|
tmp->u.bem.sound_warmup = sound_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xml_isNode(node, "sound")) {
|
||||||
|
tmp->u.bem.sound = sound_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xml_isNode(node, "sound_off")) {
|
||||||
|
tmp->u.bem.sound_off = sound_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} while(xml_nextNode(node));
|
} while(xml_nextNode(node));
|
||||||
|
|
||||||
#define MELEMENT(o,s) if(0) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
#define MELEMENT(o,s) if(0) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.bem.gfx==NULL, "gfx");
|
MELEMENT(tmp->u.bem.gfx==NULL, "gfx");
|
||||||
|
MELEMENT((sound_disabled!=0) && (tmp->u.bem.warmup > 0.) && (tmp->u.bem.sound<0), "sound_warmup");
|
||||||
|
MELEMENT((sound_disabled!=0) && (tmp->u.bem.sound < 0), "sound");
|
||||||
|
MELEMENT((sound_disabled!=0) && (tmp->u.bem.sound_off < 0), "sound_off");
|
||||||
MELEMENT(tmp->u.bem.delay==0, "range");
|
MELEMENT(tmp->u.bem.delay==0, "range");
|
||||||
MELEMENT(tmp->u.bem.duration==0, "duration");
|
MELEMENT(tmp->u.bem.duration==0, "duration");
|
||||||
MELEMENT(tmp->u.bem.range==0, "range");
|
MELEMENT(tmp->u.bem.range==0, "range");
|
||||||
|
@ -77,8 +77,11 @@ typedef struct OutfitBeamData_ {
|
|||||||
DamageType dtype; /**< Damage type. */
|
DamageType dtype; /**< Damage type. */
|
||||||
double damage; /**< Damage amount. */
|
double damage; /**< Damage amount. */
|
||||||
|
|
||||||
/* Graphics */
|
/* Graphics and sound */
|
||||||
glTexture* gfx; /**< Base texture. */
|
glTexture* gfx; /**< Base texture. */
|
||||||
|
int sound_warmup; /**< Sound to play when warming up. @todo use. */
|
||||||
|
int sound; /**< Sound to play. */
|
||||||
|
int sound_off; /**< Sound to play when turning off. */
|
||||||
} OutfitBeamData;
|
} OutfitBeamData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -255,7 +255,7 @@ static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t) {
|
|||||||
/** @todo Handle warmup stage. */
|
/** @todo Handle warmup stage. */
|
||||||
w->state = PILOT_OUTFIT_ON;
|
w->state = PILOT_OUTFIT_ON;
|
||||||
weapon_add(w->outfit, p->solid->dir,
|
weapon_add(w->outfit, p->solid->dir,
|
||||||
&p->solid->pos, NULL, p->id, t);
|
&p->solid->pos, &p->solid->vel, p->id, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_mixer.h>
|
#include <SDL/SDL_mixer.h>
|
||||||
|
|
||||||
#include "lephisto.h"
|
#include "lephisto.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
@ -308,6 +308,9 @@ static void weapons_updateLayer(const double dt, const WeaponLayer layer) {
|
|||||||
case OUTFIT_TYPE_TURRET_BEAM:
|
case OUTFIT_TYPE_TURRET_BEAM:
|
||||||
wlayer[i]->timer -= dt;
|
wlayer[i]->timer -= dt;
|
||||||
if(wlayer[i]->timer < 0.) {
|
if(wlayer[i]->timer < 0.) {
|
||||||
|
sound_playPos(w->outfit->u.bem.sound_off,
|
||||||
|
w->solid->pos.x,
|
||||||
|
w->solid->pos.y);
|
||||||
weapon_destroy(wlayer[i],layer);
|
weapon_destroy(wlayer[i],layer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -639,6 +642,9 @@ static Weapon* weapon_create(const Outfit* outfit, const double dir, const Vec2*
|
|||||||
w->solid = solid_create(mass, rdir, pos, NULL);
|
w->solid = solid_create(mass, rdir, pos, NULL);
|
||||||
w->think = think_beam;
|
w->think = think_beam;
|
||||||
w->timer = outfit->u.bem.duration;
|
w->timer = outfit->u.bem.duration;
|
||||||
|
sound_playPos(w->outfit->u.bem.sound,
|
||||||
|
w->solid->pos.x + vel->x,
|
||||||
|
w->solid->pos.y + vel->y);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Treat seekers togther. */
|
/* Treat seekers togther. */
|
||||||
|
Loading…
Reference in New Issue
Block a user