tbftss/src/battle/extractionPoint.c

69 lines
1.7 KiB
C
Raw Normal View History

2015-11-09 23:46:57 +01:00
/*
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->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();
battle.extractionPoint = self;
2015-11-09 23:46:57 +01:00
}
static void handleFleeingEntities(void)
{
Entity *e, **candidates;
int i;
candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self);
2015-11-09 23:46:57 +01:00
2015-11-14 00:35:51 +01:00
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
2015-11-09 23:46:57 +01:00
{
2015-11-21 18:32:39 +01:00
if (e->health > 0 && e->flags & EF_RETREATING && getDistance(self->x, self->y, e->x, e->y) <= 64)
2015-11-09 23:46:57 +01:00
{
e->alive = ALIVE_ESCAPED;
2015-11-09 23:46:57 +01:00
}
}
}