[Change] Define special effects per outfit.

This commit is contained in:
Allanis 2013-02-26 23:43:07 +00:00
parent 80d78756ad
commit f603df48cc
8 changed files with 25 additions and 4 deletions

View File

@ -9,6 +9,7 @@
<specific type="1">
<gfx>lasergreen</gfx>
<sound>laser</sound>
<spfx>ExpS</spfx>
<delay>500</delay>
<speed>550</speed>
<range>300</range>
@ -39,6 +40,7 @@
<specific type="6">
<gfx>missile</gfx>
<sound>missile</sound>
<spfx>ExmM</spfx>
<duration>5</duration>
<thrust>1200</thrust>
<turn>200</turn>

BIN
gfx/spfx/expl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
gfx/spfx/expm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -7,6 +7,7 @@
#include "log.h"
#include "pack.h"
#include "xml.h"
#include "spfx.h"
#include "outfit.h"
#define outfit_setProp(o,p) ((o)->properties |= p)
@ -110,6 +111,8 @@ static void outfit_parseSWeapon(Outfit* tmp, const xmlNodePtr parent) {
snprintf(str, strlen(xml_get(node))+sizeof(OUTFIT_GFX)+4, OUTFIT_GFX"%s.png", xml_get(node));
tmp->gfx_space = gl_newSprite(str, 6, 6);
}
else if(xml_isNode(node, "spfx"))
tmp->spfx = spfx_get(xml_get(node));
else if(xml_isNode(node, "sound"))
tmp->sound = sound_get(xml_get(node));
else if(xml_isNode(node, "damage")) {
@ -167,6 +170,8 @@ static void outfit_parseSAmmo(Outfit* tmp, const xmlNodePtr parent) {
OUTFIT_GFX"%s.png", xml_get(node));
tmp->gfx_space = gl_newSprite(str, 6, 6);
}
else if(xml_isNode(node, "spfx"))
tmp->spfx = spfx_get(xml_get(node));
else if(xml_isNode(node, "sound"))
tmp->sound = sound_get(xml_get(node));
else if(xml_isNode(node, "damage")) {

View File

@ -48,6 +48,7 @@ typedef struct Outfit_ {
glTexture* gfx_space;
ALuint sound; // Sound to play.
int spfx; // Special effect on hit.
};
struct { // Launcher.
//unsigned int delay; // Delay between shots.

View File

@ -66,9 +66,20 @@ static void spfx_base_free(SPFX_Base* effect) {
if(effect->gfx) gl_freeTexture(effect->gfx);
}
int spfx_get(char* name) {
int i;
for(i = 0; i < spfx_neffects; i++)
if(strcmp(spfx_effects[i].name, name)==0)
return i;
WARN("SPFX '%s' not found!", name);
return 0;
}
// Load/Unload.
int spfx_load(void) {
spfx_base_load("ExpS", 600, "exps.png", 6, 5);
spfx_base_load("ExpS", 400, "exps.png", 6, 5);
spfx_base_load("ExpM", 450, "expm.png", 6, 5);
spfx_base_load("ExpL", 500, "expl.png", 6, 5);
return 0;
}

View File

@ -4,10 +4,12 @@
#define SPFX_LAYER_FRONT 0
#define SPFX_LAYER_BACK 1
// Stack manipulation.
int spfx_get(char* name);
void spfx_add(const int effect,
const Vec2* pos, const Vec2* vel, const int layer);
// Stack manipulation functions.
// Stack mass manipulation functions.
void spfx_update(const double dt);
void spfx_render(const int layer);
void spfx_clear(void);

View File

@ -239,9 +239,9 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer) {
// Someone should let the ai know it's been attacked.
if(!pilot_isPlayer(p)) {
ai_attacked(p, w->parent);
spfx_add(0, &w->solid->pos, &p->solid->vel, SPFX_LAYER_BACK);
spfx_add(w->outfit->spfx, &w->solid->pos, &p->solid->vel, SPFX_LAYER_BACK);
} else
spfx_add(0, &w->solid->pos, &p->solid->vel, SPFX_LAYER_FRONT);
spfx_add(w->outfit->spfx, &w->solid->pos, &p->solid->vel, SPFX_LAYER_FRONT);
if(w->parent == PLAYER_ID)
// Make hostile to player.
pilot_setFlag(p, PILOT_HOSTILE);