[Change] Define special effects per outfit.
This commit is contained in:
parent
80d78756ad
commit
f603df48cc
@ -9,6 +9,7 @@
|
|||||||
<specific type="1">
|
<specific type="1">
|
||||||
<gfx>lasergreen</gfx>
|
<gfx>lasergreen</gfx>
|
||||||
<sound>laser</sound>
|
<sound>laser</sound>
|
||||||
|
<spfx>ExpS</spfx>
|
||||||
<delay>500</delay>
|
<delay>500</delay>
|
||||||
<speed>550</speed>
|
<speed>550</speed>
|
||||||
<range>300</range>
|
<range>300</range>
|
||||||
@ -39,6 +40,7 @@
|
|||||||
<specific type="6">
|
<specific type="6">
|
||||||
<gfx>missile</gfx>
|
<gfx>missile</gfx>
|
||||||
<sound>missile</sound>
|
<sound>missile</sound>
|
||||||
|
<spfx>ExmM</spfx>
|
||||||
<duration>5</duration>
|
<duration>5</duration>
|
||||||
<thrust>1200</thrust>
|
<thrust>1200</thrust>
|
||||||
<turn>200</turn>
|
<turn>200</turn>
|
||||||
|
BIN
gfx/spfx/expl.png
Normal file
BIN
gfx/spfx/expl.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
BIN
gfx/spfx/expm.png
Normal file
BIN
gfx/spfx/expm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
@ -7,6 +7,7 @@
|
|||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "pack.h"
|
#include "pack.h"
|
||||||
#include "xml.h"
|
#include "xml.h"
|
||||||
|
#include "spfx.h"
|
||||||
#include "outfit.h"
|
#include "outfit.h"
|
||||||
|
|
||||||
#define outfit_setProp(o,p) ((o)->properties |= p)
|
#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));
|
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);
|
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"))
|
else if(xml_isNode(node, "sound"))
|
||||||
tmp->sound = sound_get(xml_get(node));
|
tmp->sound = sound_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "damage")) {
|
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));
|
OUTFIT_GFX"%s.png", xml_get(node));
|
||||||
tmp->gfx_space = gl_newSprite(str, 6, 6);
|
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"))
|
else if(xml_isNode(node, "sound"))
|
||||||
tmp->sound = sound_get(xml_get(node));
|
tmp->sound = sound_get(xml_get(node));
|
||||||
else if(xml_isNode(node, "damage")) {
|
else if(xml_isNode(node, "damage")) {
|
||||||
|
@ -48,6 +48,7 @@ typedef struct Outfit_ {
|
|||||||
|
|
||||||
glTexture* gfx_space;
|
glTexture* gfx_space;
|
||||||
ALuint sound; // Sound to play.
|
ALuint sound; // Sound to play.
|
||||||
|
int spfx; // Special effect on hit.
|
||||||
};
|
};
|
||||||
struct { // Launcher.
|
struct { // Launcher.
|
||||||
//unsigned int delay; // Delay between shots.
|
//unsigned int delay; // Delay between shots.
|
||||||
|
13
src/spfx.c
13
src/spfx.c
@ -66,9 +66,20 @@ static void spfx_base_free(SPFX_Base* effect) {
|
|||||||
if(effect->gfx) gl_freeTexture(effect->gfx);
|
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.
|
// Load/Unload.
|
||||||
int spfx_load(void) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
#define SPFX_LAYER_FRONT 0
|
#define SPFX_LAYER_FRONT 0
|
||||||
#define SPFX_LAYER_BACK 1
|
#define SPFX_LAYER_BACK 1
|
||||||
|
|
||||||
|
// Stack manipulation.
|
||||||
|
int spfx_get(char* name);
|
||||||
void spfx_add(const int effect,
|
void spfx_add(const int effect,
|
||||||
const Vec2* pos, const Vec2* vel, const int layer);
|
const Vec2* pos, const Vec2* vel, const int layer);
|
||||||
|
|
||||||
// Stack manipulation functions.
|
// Stack mass manipulation functions.
|
||||||
void spfx_update(const double dt);
|
void spfx_update(const double dt);
|
||||||
void spfx_render(const int layer);
|
void spfx_render(const int layer);
|
||||||
void spfx_clear(void);
|
void spfx_clear(void);
|
||||||
|
@ -239,9 +239,9 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer) {
|
|||||||
// 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)) {
|
||||||
ai_attacked(p, w->parent);
|
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
|
} 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)
|
if(w->parent == PLAYER_ID)
|
||||||
// Make hostile to player.
|
// Make hostile to player.
|
||||||
pilot_setFlag(p, PILOT_HOSTILE);
|
pilot_setFlag(p, PILOT_HOSTILE);
|
||||||
|
Loading…
Reference in New Issue
Block a user