Consider centering when gathering entities.

This commit is contained in:
Steve 2015-11-15 12:28:12 +00:00
parent 3d90352fbc
commit 484afee9ef
5 changed files with 7 additions and 7 deletions

View File

@ -166,7 +166,7 @@ static void findTarget(void)
dist = closest = (!battle.epic) ? 2000 : MAX_TARGET_RANGE;
candidates = getAllEntsWithin(self->x - dist / 2, self->y - dist / 2, self->w + dist, self->h + dist, self);
candidates = getAllEntsWithin(self->x - (self->w / 2) - (dist / 2), self->y - (self->h / 2) - (dist / 2), self->w + dist, self->h + dist, self);
self->target = NULL;
@ -403,7 +403,7 @@ static int nearExtractionPoint(void)
int i;
Entity *e, **candidates;
candidates = getAllEntsWithin(self->x - 500, self->y - 500, 1000, 1000, self);
candidates = getAllEntsWithin(self->x - (self->w / 2) - 500, self->y - (self->h / 2) - 500, 1000, 1000, self);
self->target = NULL;
@ -435,7 +435,7 @@ static int nearEnemies(void)
int i, numEnemies;
Entity *e, **candidates;
candidates = getAllEntsWithin(self->x - 1000, self->y - 1000, 2000, 2000, self);
candidates = getAllEntsWithin(self->x - (self->w / 2) - 1000, self->y - (self->h / 2) - 1000, 2000, 2000, self);
self->target = NULL;
self->targetLocation.x = self->targetLocation.y = 0;

View File

@ -112,7 +112,7 @@ static void checkCollisions(Bullet *b)
Entity *e, **candidates;
int i;
candidates = getAllEntsWithin(b->x, b->y, b->w, b->h, NULL);
candidates = getAllEntsWithin(b->x - (b->w / 2), b->y - (b->h / 2), b->w, b->h, NULL);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{

View File

@ -56,7 +56,7 @@ 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);
candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{

View File

@ -300,7 +300,7 @@ static void separate(void)
count = 0;
force = 0;
candidates = getAllEntsWithin(self->x, self->y, self->w, self->h, self);
candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{

View File

@ -27,7 +27,7 @@ void attachRope(void)
if ((self->flags & EF_HAS_ROPE) && self->towing == NULL)
{
candidates = getAllEntsWithin(self->x, self->y, self->w, self->h, self);
candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self);
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{