Start of extraction points.

This commit is contained in:
Steve 2015-11-09 22:46:57 +00:00
parent 3c43c15253
commit faf6c9890c
8 changed files with 109 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -20,7 +20,7 @@ OBJS += ai.o
OBJS += battle.o bullets.o OBJS += battle.o bullets.o
OBJS += challenges.o cJSON.o OBJS += challenges.o cJSON.o
OBJS += draw.o OBJS += draw.o
OBJS += effects.o entities.o OBJS += effects.o entities.o extractionPoint.o
OBJS += fighters.o fighterDefs.o OBJS += fighters.o fighterDefs.o
OBJS += galacticMap.o game.o grid.o OBJS += galacticMap.o game.o grid.o
OBJS += hud.o OBJS += hud.o

View File

@ -0,0 +1,68 @@
/*
Copyright (C) 2015 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "extractionPoint.h"
static void think(void);
static void handleFleeingEntities(void);
Entity *spawnExtractionPoint(void)
{
Entity *extractionPoint = spawnEntity();
extractionPoint->type = ET_EXTRACTION_POINT;
extractionPoint->health = extractionPoint->maxHealth = FPS;
extractionPoint->texture = getTexture("gfx/entities/extractionPoint.png");
extractionPoint->flags = EF_MISSION_TARGET;
extractionPoint->action = think;
extractionPoint->flags |= EF_NO_MT_BOX;
return extractionPoint;
}
static void think(void)
{
self->thinkTime = 4;
self->angle++;
if (self->angle >= 360)
{
self->angle -= 360;
}
handleFleeingEntities();
}
static void handleFleeingEntities(void)
{
Entity *e, **candidates;
int i;
candidates = getAllEntsWithin(self->x, self->y, self->w, self->h, self);
i = 0;
for (e = candidates[i] ; (e != NULL && i < MAX_GRID_CANDIDATES) ; i++)
{
if (e->health > 0 && e->flags & EF_FLEEING && getDistance(e->x, e->y, self->x, self->y) <= 64)
{
e->alive = ALIVE_DEAD;
}
}
}

View File

@ -0,0 +1,31 @@
/*
Copyright (C) 2015 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "SDL2/SDL.h"
#include "../defs.h"
#include "../structs.h"
extern SDL_Texture *getTexture(char *filename);
extern Entity *spawnEntity(void);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern int getDistance(int x1, int y1, int x2, int y2);
extern Entity *self;

View File

@ -65,11 +65,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EF_MISSION_TARGET (2 << 3) #define EF_MISSION_TARGET (2 << 3)
#define EF_FLEES (2 << 4) #define EF_FLEES (2 << 4)
#define EF_FLEEING (2 << 5) #define EF_FLEEING (2 << 5)
#define EF_NO_MT_BOX (2 << 6)
enum enum
{ {
ET_FIGHTER, ET_FIGHTER,
ET_WAYPOINT ET_WAYPOINT,
ET_EXTRACTION_POINT
}; };
enum enum

View File

@ -312,6 +312,10 @@ static void loadEntities(cJSON *node)
case ET_WAYPOINT: case ET_WAYPOINT:
e = spawnWaypoint(); e = spawnWaypoint();
break; break;
case ET_EXTRACTION_POINT:
e = spawnExtractionPoint();
break;
} }
if (cJSON_GetObjectItem(node, "name")) if (cJSON_GetObjectItem(node, "name"))

View File

@ -38,6 +38,7 @@ extern long flagsToLong(char *flags);
extern Entity *spawnWaypoint(void); extern Entity *spawnWaypoint(void);
extern void activateNextWaypoint(void); extern void activateNextWaypoint(void);
extern void selectWidget(const char *name, const char *group); extern void selectWidget(const char *name, const char *group);
extern Entity *spawnExtractionPoint(void);
extern Battle battle; extern Battle battle;
extern Entity *player; extern Entity *player;

View File

@ -31,6 +31,7 @@ void initLookups(void)
tail = &head; tail = &head;
addLookup("ET_WAYPOINT", ET_WAYPOINT); addLookup("ET_WAYPOINT", ET_WAYPOINT);
addLookup("ET_EXTRACTION_POINT", ET_EXTRACTION_POINT);
addLookup("EF_NO_KILL", EF_NO_KILL); addLookup("EF_NO_KILL", EF_NO_KILL);
addLookup("EF_DISABLE", EF_DISABLE); addLookup("EF_DISABLE", EF_DISABLE);