From 484afee9efd1814a101b6684d26177ea0eef4fc9 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 15 Nov 2015 12:28:12 +0000 Subject: [PATCH] Consider centering when gathering entities. --- src/battle/ai.c | 6 +++--- src/battle/bullets.c | 2 +- src/battle/extractionPoint.c | 2 +- src/battle/fighters.c | 2 +- src/battle/rope.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle/ai.c b/src/battle/ai.c index aaadabc..1443dc5 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -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; diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 1cbc624..ac39846 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -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]) { diff --git a/src/battle/extractionPoint.c b/src/battle/extractionPoint.c index ebbc4b1..45c0cc0 100644 --- a/src/battle/extractionPoint.c +++ b/src/battle/extractionPoint.c @@ -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]) { diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 72407cd..aac58f8 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -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]) { diff --git a/src/battle/rope.c b/src/battle/rope.c index d14bde8..0614d48 100644 --- a/src/battle/rope.c +++ b/src/battle/rope.c @@ -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]) {