From 4cac5ba5b23be590b8220cd049c88ff319a34752 Mon Sep 17 00:00:00 2001 From: Allanis Date: Fri, 4 Oct 2013 01:07:12 +0100 Subject: [PATCH] [Add] Beam weapons require spfx and proper spfx usage. --- dat/outfit.xml | 1 + src/collision.c | 8 -------- src/outfit.c | 37 ++++++++++++++++++++++++------------- src/outfit.h | 1 + src/weapon.c | 2 ++ 5 files changed, 28 insertions(+), 21 deletions(-) diff --git a/dat/outfit.xml b/dat/outfit.xml index 5a225e2..0d0ee84 100644 --- a/dat/outfit.xml +++ b/dat/outfit.xml @@ -163,6 +163,7 @@ 50 130 100 + ExpS beam_ragnarok diff --git a/src/collision.c b/src/collision.c index 0544505..102caa5 100644 --- a/src/collision.c +++ b/src/collision.c @@ -201,14 +201,6 @@ int CollideLineSprite(const Vec2* ap, double ad, double al, 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. */ real_hits = 0; /* directional vector (normalised). */ diff --git a/src/outfit.c b/src/outfit.c index c5e6c2a..9b16f14 100644 --- a/src/outfit.c +++ b/src/outfit.c @@ -282,7 +282,6 @@ glTexture* outfit_gfx(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.gfx_space; else if(outfit_isBeam(o)) return o->u.bem.gfx; else if(outfit_isAmmo(o)) return o->u.amm.gfx_space; - else if(outfit_isTurret(o)) return o->u.blt.gfx_space; return NULL; } @@ -294,8 +293,8 @@ glTexture* outfit_gfx(const Outfit* o) { */ int outfit_spfx(const Outfit* o) { 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_isTurret(o)) return o->u.blt.spfx; return -1; } @@ -309,7 +308,6 @@ double outfit_damage(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.damage; else if(outfit_isBeam(o)) return o->u.bem.damage; else if(outfit_isAmmo(o)) return o->u.amm.damage; - else if(outfit_isTurret(o)) return o->u.blt.damage; return -1; } @@ -323,7 +321,6 @@ DamageType outfit_damageType(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.dtype; else if(outfit_isBeam(o)) return o->u.bem.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; } @@ -337,7 +334,6 @@ int outfit_delay(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.delay; else if(outfit_isBeam(o)) return o->u.bem.delay; else if(outfit_isLauncher(o)) return o->u.lau.delay; - else if(outfit_isTurret(o)) return o->u.blt.delay; return -1; } @@ -351,7 +347,6 @@ double outfit_energy(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.energy; else if(outfit_isBeam(o)) return o->u.bem.energy; else if(outfit_isAmmo(o)) return o->u.amm.energy; - else if(outfit_isTurret(o)) return o->u.blt.energy; return -1.; } @@ -365,7 +360,6 @@ double outfit_range(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.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_isTurret(o)) return o->u.blt.range; return -1.; } @@ -378,7 +372,6 @@ double outfit_range(const Outfit* o) { double outfit_speed(const Outfit* o) { if(outfit_isBolt(o)) return o->u.blt.speed; else if(outfit_isAmmo(o)) return o->u.amm.speed; - else if(outfit_isTurret(o)) return o->u.blt.speed; return -1.; } @@ -517,7 +510,8 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) { char str[PATH_MAX] = "\0"; /* Defaults. */ - tmp->u.blt.sound = -1; + tmp->u.blt.spfx = -1; + tmp->u.blt.sound = -1; node = parent->xmlChildrenNode; do { @@ -532,18 +526,26 @@ static void outfit_parseSBolt(Outfit* tmp, const xmlNodePtr parent) { snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10, OUTFIT_GFX"space/%s.png", xml_get(node)); 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)); - else if(xml_isNode(node, "sound")) + continue; + } + if(xml_isNode(node, "sound")) { 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); + continue; + } } while((node = node->next)); #define MELEMENT(o,s) \ if (o) WARN("Outfit '%s' missing/invalid '"s"' element", tmp->name) 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(tmp->u.blt.delay==0, "delay"); 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"; /* Defaults. */ + tmp->u.bem.spfx = -1; tmp->u.bem.sound_warmup = -1; tmp->u.bem.sound = -1; tmp->u.bem.sound_off = -1; @@ -583,6 +586,7 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) { continue; } + /* Graphics stuff. */ if(xml_isNode(node, "gfx")) { snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+10, OUTFIT_GFX"space/%s.png", xml_get(node)); @@ -590,6 +594,12 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) { continue; } + if(xml_isNode(node, "spfx")) { + tmp->u.bem.spfx = spfx_get(xml_get(node)); + continue; + } + + /* Sound stuff. */ if(xml_isNode(node, "sound_warmup")) { tmp->u.bem.sound_warmup = sound_get(xml_get(node)); continue; @@ -608,7 +618,8 @@ static void outfit_parseSBeam(Outfit* tmp, const xmlNodePtr parent) { } while(xml_nextNode(node)); #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.sound < 0), "sound"); MELEMENT((sound_disabled!=0) && (tmp->u.bem.sound_off < 0), "sound_off"); diff --git a/src/outfit.h b/src/outfit.h index f28bbdf..30d9cc6 100644 --- a/src/outfit.h +++ b/src/outfit.h @@ -79,6 +79,7 @@ typedef struct OutfitBeamData_ { /* Graphics and sound */ glTexture* gfx; /**< Base texture. */ + int spfx; /**< Special effect on hit. */ 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. */ diff --git a/src/weapon.c b/src/weapon.c index 856432b..d4bc2c0 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -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); spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y, VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_BACK); + w->lockon = -2; } } 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); spfx_add(outfit_spfx(w->outfit), pos[1].x, pos[1].y, VX(p->solid->vel), VY(p->solid->vel), SPFX_LAYER_FRONT); + w->lockon = -2; } /* Inform the ship that it should take some damage. */