Added 'combined guns' to allow for weapons to be fired together.

This commit is contained in:
Steve 2015-10-29 10:14:21 +00:00
parent 483768fe79
commit f197d656c4
10 changed files with 111 additions and 59 deletions

View File

@ -18,11 +18,12 @@
"y" : -2
},
{
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"x" : 0,
"y" : -4
}
],
"combinedGuns" : 1,
"missiles" : {
"type" : "MISSILE_MISSILE",
"ammo" : 3

View File

@ -0,0 +1,52 @@
{
"name" : "Patrol #2",
"description" : "Patrols so far have not uncovered anything unusual, and it seems as though the increase in military presense is reducing the amount of illegal activity in this sector, with reported incidents down 80%. Still, we cannot afford to become complacent, and must continue with our sweeps.",
"background" : "gfx/backgrounds/background03.jpg",
"planet" : "gfx/planets/torelli.png",
"music" : "music/heroism.ogg",
"requires" : "PREVIOUS",
"objectives" : [
{
"description" : "Check all Wayponts",
"targetName" : "Waypoint",
"targetValue" : 5,
"targetType" : "TT_WAYPOINT"
}
],
"player" : {
"type" : "Firefly",
"side" : "SIDE_ALLIES",
"pilot" : "Curtis Rice",
"squadron" : "Eightballers"
},
"fighterGroups" : [
{
"name" : "Ally",
"types" : "Firefly;Nymph",
"number" : 4,
"side" : "SIDE_ALLIES",
"x" : 640,
"y" : 1000,
"scatter" : 64
},
{
"name" : "Pandoran",
"types" : "Jackal",
"number" : 3,
"side" : "SIDE_PANDORAN",
"x" : 640,
"y" : 1000,
"scatter" : 64
}
],
"entityGroups" : [
{
"type" : "ET_WAYPOINT",
"number" : 5,
"x" : 640,
"y" : 480,
"scatter" : 7500
}
]
}

View File

@ -101,12 +101,7 @@ static void checkCollisions(Bullet *b)
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
{
if (!f->active)
{
continue;
}
if (f->type == ET_FIGHTER)
if (f->active && f->type == ET_FIGHTER)
{
SDL_QueryTexture(f->texture, NULL, NULL, &ew, &eh);
@ -221,7 +216,7 @@ static void huntTarget(Bullet *b)
}
}
Bullet *createBullet(int type, int x, int y, Entity *owner)
static Bullet *createBullet(int type, int x, int y, Entity *owner)
{
Bullet *b;
@ -255,7 +250,7 @@ void fireGuns(Entity *owner)
for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++)
{
if (owner->guns[i].type == owner->selectedGunType)
if (owner->guns[i].type == owner->selectedGunType || (owner->guns[i].type != BT_NONE && owner->combinedGuns))
{
s = sin(TO_RAIDANS(owner->angle));
c = cos(TO_RAIDANS(owner->angle));

View File

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "entities.h"
static void drawEntity(Entity *e);
static void doEntity(Entity *prev);
static void doEntity(void);
Entity *spawnEntity(void)
{
@ -46,69 +46,79 @@ void doEntities(void)
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
self = e;
if (!e->active)
{
continue;
}
self = e;
if (self->target != NULL && self->target->health <= 0)
if (e->target != NULL && e->target->health <= 0)
{
self->action = self->defaultAction;
self->target = NULL;
e->action = e->defaultAction;
e->target = NULL;
}
self->x += self->dx;
self->y += self->dy;
e->x += e->dx;
e->y += e->dy;
if (self != player)
if (e != player)
{
self->x -= battle.ssx;
self->y -= battle.ssy;
e->x -= battle.ssx;
e->y -= battle.ssy;
}
if (self->action != NULL)
if (e->action != NULL)
{
if (--self->thinkTime <= 0)
if (--e->thinkTime <= 0)
{
self->thinkTime = 0;
self->action();
e->thinkTime = 0;
e->action();
}
}
switch (self->type)
switch (e->type)
{
case ET_FIGHTER:
doFighter(prev);
doFighter();
break;
default:
doEntity(prev);
doEntity();
break;
}
prev = self;
}
}
static void doEntity(Entity *prev)
if (e->alive == ALIVE_DEAD)
{
if (self->health <= 0)
{
if (self == battle.entityTail)
if (e == battle.entityTail)
{
battle.entityTail = prev;
}
if (self == battle.missionTarget)
if (e == battle.missionTarget)
{
battle.missionTarget = NULL;
}
prev->next = self->next;
free(self);
self = prev;
if (e == player)
{
player = NULL;
}
prev->next = e->next;
free(e);
e = prev;
}
prev = e;
}
}
static void doEntity(void)
{
if (self->health <= 0)
{
self->alive = ALIVE_DEAD;
}
}

View File

@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern void blitRotated(SDL_Texture *t, int x, int y, int angle);
extern void drawFighter(Entity *e);
extern void doFighter(Entity *prev);
extern void doFighter(void);
extern Battle battle;
extern Entity *self;

View File

@ -106,6 +106,11 @@ static void loadFighterDef(char *filename)
exit(1);
}
}
if (cJSON_GetObjectItem(root, "combinedGuns"))
{
f->combinedGuns = cJSON_GetObjectItem(root, "combinedGuns")->valueint;
}
}
if (cJSON_GetObjectItem(root, "missiles"))

View File

@ -150,7 +150,7 @@ static void randomizeDartGuns(Entity *dart)
}
}
void doFighter(Entity *prev)
void doFighter(void)
{
if (player != NULL)
{
@ -251,20 +251,6 @@ void doFighter(Entity *prev)
checkTrigger(self->name, TRIGGER_KILLS);
}
if (self == battle.entityTail)
{
battle.entityTail = prev;
}
if (self == player)
{
player = NULL;
}
prev->next = self->next;
free(self);
self = prev;
}
}

View File

@ -48,6 +48,8 @@ void initPlayer(void)
}
}
}
STRNCPY(player->name, "Player", MAX_NAME_LENGTH);
}
void doPlayer(void)

View File

@ -56,7 +56,7 @@ static void think(void)
self->angle -= 360;
}
if (getDistance(player->x, player->y, self->x, self->y) <= 32 && teamMatesClose())
if (player != NULL && getDistance(player->x, player->y, self->x, self->y) <= 32 && teamMatesClose())
{
self->health = 0;

View File

@ -89,6 +89,7 @@ struct Entity {
int reload;
int reloadTime;
int selectedGunType;
int combinedGuns;
int shieldRecharge;
int shieldRechargeRate;
int systemPower;