[Add] Beam weapons require spfx and proper spfx usage.
This commit is contained in:
parent
1177685e62
commit
4cac5ba5b2
@ -163,6 +163,7 @@
|
|||||||
<turn>50</turn>
|
<turn>50</turn>
|
||||||
<energy>130</energy>
|
<energy>130</energy>
|
||||||
<damage type="energy">100</damage>
|
<damage type="energy">100</damage>
|
||||||
|
<spfx>ExpS</spfx>
|
||||||
<gfx>beam_ragnarok</gfx>
|
<gfx>beam_ragnarok</gfx>
|
||||||
</specific>
|
</specific>
|
||||||
</outfit>
|
</outfit>
|
||||||
|
@ -201,14 +201,6 @@ int CollideLineSprite(const Vec2* ap, double ad, double al,
|
|||||||
border[1].y = ep[1];
|
border[1].y = ep[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
crash[0].x = border[0].x;
|
|
||||||
crash[0].y = border[0].y;
|
|
||||||
crash[1].x = border[1].x;
|
|
||||||
crash[1].y = border[1].y;
|
|
||||||
return 1;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Now we do a pixel perfect approach. */
|
/* Now we do a pixel perfect approach. */
|
||||||
real_hits = 0;
|
real_hits = 0;
|
||||||
/* directional vector (normalised). */
|
/* directional vector (normalised). */
|
||||||
|
37
src/outfit.c
37
src/outfit.c
@ -282,7 +282,6 @@ glTexture* outfit_gfx(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.gfx_space;
|
if(outfit_isBolt(o)) return o->u.blt.gfx_space;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.gfx;
|
else if(outfit_isBeam(o)) return o->u.bem.gfx;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.gfx_space;
|
else if(outfit_isAmmo(o)) return o->u.amm.gfx_space;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.gfx_space;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,8 +293,8 @@ glTexture* outfit_gfx(const Outfit* o) {
|
|||||||
*/
|
*/
|
||||||
int outfit_spfx(const Outfit* o) {
|
int outfit_spfx(const Outfit* o) {
|
||||||
if(outfit_isBolt(o)) return o->u.blt.spfx;
|
if(outfit_isBolt(o)) return o->u.blt.spfx;
|
||||||
|
else if(outfit_isBeam(o)) return o->u.bem.spfx;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.spfx;
|
else if(outfit_isAmmo(o)) return o->u.amm.spfx;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.spfx;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +308,6 @@ double outfit_damage(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.damage;
|
if(outfit_isBolt(o)) return o->u.blt.damage;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.damage;
|
else if(outfit_isBeam(o)) return o->u.bem.damage;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.damage;
|
else if(outfit_isAmmo(o)) return o->u.amm.damage;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.damage;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +321,6 @@ DamageType outfit_damageType(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.dtype;
|
if(outfit_isBolt(o)) return o->u.blt.dtype;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.dtype;
|
else if(outfit_isBeam(o)) return o->u.bem.dtype;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.dtype;
|
else if(outfit_isAmmo(o)) return o->u.amm.dtype;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.dtype;
|
|
||||||
return DAMAGE_TYPE_NULL;
|
return DAMAGE_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +334,6 @@ int outfit_delay(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.delay;
|
if(outfit_isBolt(o)) return o->u.blt.delay;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.delay;
|
else if(outfit_isBeam(o)) return o->u.bem.delay;
|
||||||
else if(outfit_isLauncher(o)) return o->u.lau.delay;
|
else if(outfit_isLauncher(o)) return o->u.lau.delay;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.delay;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +347,6 @@ double outfit_energy(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.energy;
|
if(outfit_isBolt(o)) return o->u.blt.energy;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.energy;
|
else if(outfit_isBeam(o)) return o->u.bem.energy;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.energy;
|
else if(outfit_isAmmo(o)) return o->u.amm.energy;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.energy;
|
|
||||||
return -1.;
|
return -1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +360,6 @@ double outfit_range(const Outfit* o) {
|
|||||||
if(outfit_isBolt(o)) return o->u.blt.range;
|
if(outfit_isBolt(o)) return o->u.blt.range;
|
||||||
else if(outfit_isBeam(o)) return o->u.bem.range;
|
else if(outfit_isBeam(o)) return o->u.bem.range;
|
||||||
else if(outfit_isAmmo(o)) return 0.8*o->u.amm.speed*o->u.amm.duration;
|
else if(outfit_isAmmo(o)) return 0.8*o->u.amm.speed*o->u.amm.duration;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.range;
|
|
||||||
return -1.;
|
return -1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +372,6 @@ double outfit_range(const Outfit* o) {
|
|||||||
double outfit_speed(const Outfit* o) {
|
double outfit_speed(const Outfit* o) {
|
||||||
if(outfit_isBolt(o)) return o->u.blt.speed;
|
if(outfit_isBolt(o)) return o->u.blt.speed;
|
||||||
else if(outfit_isAmmo(o)) return o->u.amm.speed;
|
else if(outfit_isAmmo(o)) return o->u.amm.speed;
|
||||||
else if(outfit_isTurret(o)) return o->u.blt.speed;
|
|
||||||
return -1.;
|
return -1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +510,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.sound = -1;
|
tmp->u.blt.spfx = -1;
|
||||||
|
tmp->u.blt.sound = -1;
|
||||||
|
|
||||||
node = parent->xmlChildrenNode;
|
node = parent->xmlChildrenNode;
|
||||||
do {
|
do {
|
||||||
@ -532,18 +526,26 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10,
|
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10,
|
||||||
OUTFIT_GFX"space/%s.png", xml_get(node));
|
OUTFIT_GFX"space/%s.png", xml_get(node));
|
||||||
tmp->u.blt.gfx_space = gl_newSprite(str, 6, 6);
|
tmp->u.blt.gfx_space = gl_newSprite(str, 6, 6);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if(xml_isNode(node, "spfx"))
|
if(xml_isNode(node, "spfx")) {
|
||||||
tmp->u.blt.spfx = spfx_get(xml_get(node));
|
tmp->u.blt.spfx = spfx_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "sound"))
|
continue;
|
||||||
|
}
|
||||||
|
if(xml_isNode(node, "sound")) {
|
||||||
tmp->u.blt.sound = sound_get(xml_get(node));
|
tmp->u.blt.sound = sound_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "damage"))
|
continue;
|
||||||
|
}
|
||||||
|
if(xml_isNode(node, "damage")) {
|
||||||
outfit_parseDamage(&tmp->u.blt.dtype, &tmp->u.blt.damage, node);
|
outfit_parseDamage(&tmp->u.blt.dtype, &tmp->u.blt.damage, node);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
} while((node = node->next));
|
} while((node = node->next));
|
||||||
|
|
||||||
#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((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");
|
||||||
@ -565,6 +567,7 @@ 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.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;
|
||||||
@ -583,6 +586,7 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Graphics stuff. */
|
||||||
if(xml_isNode(node, "gfx")) {
|
if(xml_isNode(node, "gfx")) {
|
||||||
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10,
|
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10,
|
||||||
OUTFIT_GFX"space/%s.png", xml_get(node));
|
OUTFIT_GFX"space/%s.png", xml_get(node));
|
||||||
@ -590,6 +594,12 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(xml_isNode(node, "spfx")) {
|
||||||
|
tmp->u.bem.spfx = spfx_get(xml_get(node));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sound stuff. */
|
||||||
if(xml_isNode(node, "sound_warmup")) {
|
if(xml_isNode(node, "sound_warmup")) {
|
||||||
tmp->u.bem.sound_warmup = sound_get(xml_get(node));
|
tmp->u.bem.sound_warmup = sound_get(xml_get(node));
|
||||||
continue;
|
continue;
|
||||||
@ -608,7 +618,8 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) {
|
|||||||
} 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(tmp->u.bem.spfx==-1, "spfx");
|
||||||
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");
|
||||||
|
@ -79,6 +79,7 @@ typedef struct OutfitBeamData_ {
|
|||||||
|
|
||||||
/* Graphics and sound */
|
/* Graphics and sound */
|
||||||
glTexture* gfx; /**< Base texture. */
|
glTexture* gfx; /**< Base texture. */
|
||||||
|
int spfx; /**< 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. */
|
||||||
|
@ -575,6 +575,7 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
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(outfit_spfx(w->outfit), 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(w->lockon == -1.) {
|
else if(w->lockon == -1.) {
|
||||||
@ -582,6 +583,7 @@ static void weapon_hitBeam(Weapon* w, Pilot* p, WeaponLayer layer,
|
|||||||
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(outfit_spfx(w->outfit), 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inform the ship that it should take some damage. */
|
/* Inform the ship that it should take some damage. */
|
||||||
|
Loading…
Reference in New Issue
Block a user