Merge branch 'dev'
This commit is contained in:
commit
ddaef2556b
65
src/outfit.c
65
src/outfit.c
@ -331,10 +331,21 @@ glTexture* outfit_gfx(const Outfit* o) {
|
|||||||
* @brief Get the outfits sound effect.
|
* @brief Get the outfits sound effect.
|
||||||
* @param o Outfit to get information from.
|
* @param o Outfit to get information from.
|
||||||
*/
|
*/
|
||||||
int outfit_spfx(const Outfit* o) {
|
int outfit_spfxArmour(const Outfit* o) {
|
||||||
if(outfit_isBolt(o)) return o->u.blt.spfx;
|
if(outfit_isBolt(o)) return o->u.blt.spfx_armour;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.spfx;
|
else if(outfit_isBeam(o)) return o->u.bem.spfx_armour;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.spfx;
|
else if(outfit_isAmmo(o)) return o->u.amm.spfx_armour;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the outfits sound effect.
|
||||||
|
* @param o Outfit to get information from.
|
||||||
|
*/
|
||||||
|
int outfit_spfxShield(const Outfit* o) {
|
||||||
|
if(outfit_isBolt(o)) return o->u.blt.spfx_shield;
|
||||||
|
else if(outfit_isBeam(o)) return o->u.bem.spfx_shield;
|
||||||
|
else if(outfit_isAmmo(o)) return o->u.amm.spfx_shield;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,7 +565,8 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
char str[PATH_MAX] = "\0";
|
char str[PATH_MAX] = "\0";
|
||||||
|
|
||||||
/* Defaults. */
|
/* Defaults. */
|
||||||
tmp->u.blt.spfx = -1;
|
tmp->u.blt.spfx_armour = -1;
|
||||||
|
tmp->u.blt.spfx_shield = -1;
|
||||||
tmp->u.blt.sound = -1;
|
tmp->u.blt.sound = -1;
|
||||||
|
|
||||||
node = parent->xmlChildrenNode;
|
node = parent->xmlChildrenNode;
|
||||||
@ -571,8 +583,12 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
tmp->u.blt.gfx_space = gl_newSprite(str, 6, 6);
|
tmp->u.blt.gfx_space = gl_newSprite(str, 6, 6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(xml_isNode(node, "spfx")) {
|
if(xml_isNode(node, "spfx_shield")) {
|
||||||
tmp->u.blt.spfx = spfx_get(xml_get(node));
|
tmp->u.blt.spfx_shield = spfx_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(xml_isNode(node, "spfx_armour")) {
|
||||||
|
tmp->u.blt.spfx_armour = spfx_get(xml_get(node));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(xml_isNode(node, "sound")) {
|
if(xml_isNode(node, "sound")) {
|
||||||
@ -583,12 +599,13 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
outfit_parseDamage(&tmp->u.blt.dtype, &tmp->u.blt.damage, node);
|
outfit_parseDamage(&tmp->u.blt.dtype, &tmp->u.blt.damage, node);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} while((node = node->next));
|
} while(xml_nextNode(node));
|
||||||
|
|
||||||
#define MELEMENT(o,s) \
|
#define MELEMENT(o,s) \
|
||||||
if (o) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
if (o) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.blt.gfx_space==NULL, "gfx");
|
MELEMENT(tmp->u.blt.gfx_space==NULL, "gfx");
|
||||||
MELEMENT(tmp->u.blt.spfx==-1, "spfx");
|
MELEMENT(tmp->u.blt.spfx_shield==-1, "spfx_shield");
|
||||||
|
MELEMENT(tmp->u.blt.spfx_armour==-1, "spfx_armour");
|
||||||
MELEMENT((sound_disabled!=0) && (tmp->u.blt.sound<0), "sound");
|
MELEMENT((sound_disabled!=0) && (tmp->u.blt.sound<0), "sound");
|
||||||
MELEMENT(tmp->u.blt.delay==0, "delay");
|
MELEMENT(tmp->u.blt.delay==0, "delay");
|
||||||
MELEMENT(tmp->u.blt.speed==0, "speed");
|
MELEMENT(tmp->u.blt.speed==0, "speed");
|
||||||
@ -610,7 +627,8 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
char str[PATH_MAX] = "\0";
|
char str[PATH_MAX] = "\0";
|
||||||
|
|
||||||
/* Defaults. */
|
/* Defaults. */
|
||||||
tmp->u.bem.spfx = -1;
|
tmp->u.bem.spfx_armour = -1;
|
||||||
|
tmp->u.bem.spfx_shield = -1;
|
||||||
tmp->u.bem.sound_warmup = -1;
|
tmp->u.bem.sound_warmup = -1;
|
||||||
tmp->u.bem.sound = -1;
|
tmp->u.bem.sound = -1;
|
||||||
tmp->u.bem.sound_off = -1;
|
tmp->u.bem.sound_off = -1;
|
||||||
@ -636,8 +654,13 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(xml_isNode(node, "spfx")) {
|
if(xml_isNode(node, "spfx_armour")) {
|
||||||
tmp->u.bem.spfx = spfx_get(xml_get(node));
|
tmp->u.bem.spfx_armour = spfx_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xml_isNode(node, "spfx_shield")) {
|
||||||
|
tmp->u.bem.spfx_shield = spfx_get(xml_get(node));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +684,8 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
|
|
||||||
#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(tmp->u.bem.spfx==-1, "spfx");
|
MELEMENT(tmp->u.bem.spfx_shield==-1, "spfx_shield");
|
||||||
|
MELEMENT(tmp->u.bem.spfx_armour==-1, "spfx_armour");
|
||||||
MELEMENT((sound_disabled!=0) && (tmp->u.bem.warmup > 0.) && (tmp->u.bem.sound<0),"sound_warmup");
|
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 < 0), "sound");
|
||||||
MELEMENT((sound_disabled!=0) && (tmp->u.bem.sound_off < 0), "sound_off");
|
MELEMENT((sound_disabled!=0) && (tmp->u.bem.sound_off < 0), "sound_off");
|
||||||
@ -699,6 +723,11 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
|
|
||||||
char str[PATH_MAX] = "\0";
|
char str[PATH_MAX] = "\0";
|
||||||
|
|
||||||
|
/* Defaults. */
|
||||||
|
tmp->u.amm.spfx_armour = -1;
|
||||||
|
tmp->u.amm.spfx_shield = -1;
|
||||||
|
tmp->u.amm.sound = -1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
/* Basic. */
|
/* Basic. */
|
||||||
xmlr_float(node, "duration", tmp->u.amm.duration);
|
xmlr_float(node, "duration", tmp->u.amm.duration);
|
||||||
@ -714,19 +743,23 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
tmp->u.amm.gfx_space = gl_newSprite(str, 6, 6);
|
tmp->u.amm.gfx_space = gl_newSprite(str, 6, 6);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(xml_isNode(node, "spfx"))
|
else if(xml_isNode(node, "spfx_armour"))
|
||||||
tmp->u.amm.spfx = spfx_get(xml_get(node));
|
tmp->u.amm.spfx_armour = spfx_get(xml_get(node));
|
||||||
|
else if(xml_isNode(node, "spfx_shield"))
|
||||||
|
tmp->u.amm.spfx_shield = spfx_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "sound"))
|
else if(xml_isNode(node, "sound"))
|
||||||
tmp->u.amm.sound = sound_get(xml_get(node));
|
tmp->u.amm.sound = sound_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "damage"))
|
else if(xml_isNode(node, "damage"))
|
||||||
outfit_parseDamage(&tmp->u.amm.dtype, &tmp->u.amm.damage, node);
|
outfit_parseDamage(&tmp->u.amm.dtype, &tmp->u.amm.damage, node);
|
||||||
} while((node = node->next));
|
} while(xml_nextNode(node));
|
||||||
|
|
||||||
/* Post-processing. */
|
/* Post-processing. */
|
||||||
tmp->u.amm.resist /= 100.; /* Set it in per one. */
|
tmp->u.amm.resist /= 100.; /* Set it in per one. */
|
||||||
|
|
||||||
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
#define MELEMENT(o,s) if(o) WARN("Outfit '%s' missing '"s"' element", tmp->name)
|
||||||
MELEMENT(tmp->u.amm.gfx_space == NULL, "gfx");
|
MELEMENT(tmp->u.amm.gfx_space == NULL, "gfx");
|
||||||
|
MELEMENT(tmp->u.amm.spfx_shield==-1, "spfx_shield");
|
||||||
|
MELEMENT(tmp->u.amm.spfx_armour==-1, "spfx_armour");
|
||||||
MELEMENT((sound_disabled != 0) && (tmp->u.amm.sound < 0), "sound");
|
MELEMENT((sound_disabled != 0) && (tmp->u.amm.sound < 0), "sound");
|
||||||
MELEMENT(tmp->u.amm.thrust==0, "thrust");
|
MELEMENT(tmp->u.amm.thrust==0, "thrust");
|
||||||
/* Dumb missiles don't need everything. */
|
/* Dumb missiles don't need everything. */
|
||||||
|
@ -71,7 +71,8 @@ typedef struct OutfitBoltData_ {
|
|||||||
/* Sound and graphics. */
|
/* Sound and graphics. */
|
||||||
glTexture* gfx_space; /**< Graphic. */
|
glTexture* gfx_space; /**< Graphic. */
|
||||||
int sound; /**< Sound to play. */
|
int sound; /**< Sound to play. */
|
||||||
int spfx; /**< Special effect on hit. */
|
int spfx_armour; /**< Special effect on hit. */
|
||||||
|
int spfx_shield; /**< Special effect on hit. */
|
||||||
} OutfitBoltData;
|
} OutfitBoltData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,7 +96,8 @@ typedef struct OutfitBeamData_ {
|
|||||||
|
|
||||||
/* Graphics and sound */
|
/* Graphics and sound */
|
||||||
glTexture* gfx; /**< Base texture. */
|
glTexture* gfx; /**< Base texture. */
|
||||||
int spfx; /**< Special effect on hit. */
|
int spfx_armour; /**< Special effect on hit. */
|
||||||
|
int spfx_shield; /**< Special effect on hit. */
|
||||||
int sound_warmup; /**< Sound to play when warming up. @todo use. */
|
int sound_warmup; /**< Sound to play when warming up. @todo use. */
|
||||||
int sound; /**< Sound to play. */
|
int sound; /**< Sound to play. */
|
||||||
int sound_off; /**< Sound to play when turning off. */
|
int sound_off; /**< Sound to play when turning off. */
|
||||||
@ -133,7 +135,8 @@ typedef struct OutfitAmmoData_ {
|
|||||||
|
|
||||||
glTexture* gfx_space; /**< Graphic. */
|
glTexture* gfx_space; /**< Graphic. */
|
||||||
int sound; /**< Sound to play. */
|
int sound; /**< Sound to play. */
|
||||||
int spfx; /**< Special effect on hit. */
|
int spfx_armour; /**< Special effect on hit. */
|
||||||
|
int spfx_shield; /**< Special effect on hit. */
|
||||||
} OutfitAmmoData;
|
} OutfitAmmoData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
26
src/weapon.c
26
src/weapon.c
@ -609,6 +609,13 @@ static void weapon_update(Weapon* w, const double dt, WeaponLayer layer) {
|
|||||||
*/
|
*/
|
||||||
static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
||||||
Pilot* parent;
|
Pilot* parent;
|
||||||
|
int spfx;
|
||||||
|
|
||||||
|
/* Choose spfx. */
|
||||||
|
if(p->shield > 0.)
|
||||||
|
spfx = outfit_spfxShield(w->outfit);
|
||||||
|
else
|
||||||
|
spfx = outfit_spfxArmour(w->outfit);
|
||||||
|
|
||||||
/* Someone should let the ai know it's been attacked. */
|
/* Someone should let the ai know it's been attacked. */
|
||||||
if(!pilot_isPlayer(p)) {
|
if(!pilot_isPlayer(p)) {
|
||||||
@ -623,10 +630,10 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer, Vec2* pos) {
|
|||||||
pilot_rmFlag(p, PILOT_BRIBED);
|
pilot_rmFlag(p, PILOT_BRIBED);
|
||||||
ai_attacked(p, w->parent);
|
ai_attacked(p, w->parent);
|
||||||
}
|
}
|
||||||
spfx_add(outfit_spfx(w->outfit), pos->x, pos->y,
|
spfx_add(spfx, pos->x, pos->y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
||||||
} else
|
} else
|
||||||
spfx_add(outfit_spfx(w->outfit), pos->x, pos->y,
|
spfx_add(spfx, pos->x, pos->y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
||||||
|
|
||||||
/* Let the ship know that is should take some kind of damage. */
|
/* Let the ship know that is should take some kind of damage. */
|
||||||
@ -652,6 +659,13 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
|
|
||||||
(void)layer;
|
(void)layer;
|
||||||
Pilot* parent;
|
Pilot* parent;
|
||||||
|
int spfx;
|
||||||
|
|
||||||
|
/* Choose spfx. */
|
||||||
|
if(p->shield > 0.)
|
||||||
|
spfx = outfit_spfxShield(w->outfit);
|
||||||
|
else
|
||||||
|
spfx = outfit_spfxArmour(w->outfit);
|
||||||
|
|
||||||
/* Inform the ai it has been attacked, useless if player. */
|
/* Inform the ai it has been attacked, useless if player. */
|
||||||
if(!pilot_isPlayer(p)) {
|
if(!pilot_isPlayer(p)) {
|
||||||
@ -667,17 +681,17 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
ai_attacked(p, w->parent);
|
ai_attacked(p, w->parent);
|
||||||
}
|
}
|
||||||
if(w->lockon == -1.) { /* Code to signal create explosions. */
|
if(w->lockon == -1.) { /* Code to signal create explosions. */
|
||||||
spfx_add(outfit_spfx(w->outfit), pos[0].x, pos[0].y,
|
spfx_add(spfx, pos[0].x, pos[0].y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
||||||
spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y,
|
spfx_add(spfx, pos[1].x, pos[1].y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK);
|
||||||
w->lockon = -2;
|
w->lockon = -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(w->lockon == -1.) {
|
else if(w->lockon == -1.) {
|
||||||
spfx_add(outfit_spfx(w->outfit), pos[0].x, pos[0].y,
|
spfx_add(spfx, pos[0].x, pos[0].y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
||||||
spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y,
|
spfx_add(spfx, pos[1].x, pos[1].y,
|
||||||
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT);
|
||||||
w->lockon = -2;
|
w->lockon = -2;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user