Tweaked AI, to help balance Epic battles.

This commit is contained in:
Steve 2015-11-19 08:30:45 +00:00
parent 245e42bd39
commit 32885b2111
3 changed files with 19 additions and 13 deletions

View File

@ -130,17 +130,17 @@ static void doFighterAI(void)
self->targetLocation.x = self->target->x + rand() % 500 - rand() % 500;
self->targetLocation.y = self->target->y + rand() % 500 - rand() % 500;
self->action = evade;
self->aiActionTime = FPS;
self->aiActionTime = FPS * 2;
}
else if (r <= getActionChance(AI_BOOST))
{
self->action = boost;
self->aiActionTime = FPS / 2;
self->aiActionTime = FPS;
}
else if (r <= getActionChance(AI_FALLBACK))
{
self->action = fallback;
self->aiActionTime = FPS / 2;
self->aiActionTime = FPS * 2;
}
else if (r <= getActionChance(AI_STRAIGHT))
{
@ -155,7 +155,7 @@ static void doFighterAI(void)
else
{
self->action = huntAndAttackTarget;
self->aiActionTime = FPS;
self->aiActionTime = FPS * 3;
}
}
@ -164,19 +164,19 @@ static int getActionChance(int type)
switch (type)
{
case AI_EVADE:
return 20 - (self->aiAggression * 3);
return 25 - (self->aiAggression * 3);
case AI_BOOST:
return 30 - (self->aiAggression * 4);
return 40 - (self->aiAggression * 4);
case AI_FALLBACK:
return 40 - (self->aiAggression * 5);
return 55 - (self->aiAggression * 5);
case AI_STRAIGHT:
return 50 - (self->aiAggression * 6);
return 70 - (self->aiAggression * 6);
case AI_HUNT:
return 60 - (self->aiAggression * 7);
return 85 - (self->aiAggression * 7);
}
return 100;

View File

@ -51,7 +51,7 @@ Entity *spawnFighter(char *name, int x, int y, int side)
switch (side)
{
case SIDE_ALLIES:
f->aiAggression = 2 + rand() % 3;
f->aiAggression = rand() % 3;
f->aiFlags |= AIF_FOLLOWS_PLAYER;
if (!(f->aiFlags & AIF_AVOIDS_COMBAT))
{
@ -421,7 +421,13 @@ void damageFighter(Entity *f, int amount, long flags)
{
if (f->shield > 0)
{
f->shield = MAX(0, f->shield - amount);
f->shield -= amount;
if (f->shield < 0)
{
f->health += f->shield;
f->shield = 0;
}
}
else
{

View File

@ -50,8 +50,8 @@ void loadMission(char *filename)
battle.background = getTexture(cJSON_GetObjectItem(root, "background")->valuestring);
battle.planetTexture = getTexture(cJSON_GetObjectItem(root, "planet")->valuestring);
battle.planet.x = rand() % SCREEN_WIDTH - rand() % SCREEN_WIDTH;
battle.planet.y = rand() % SCREEN_HEIGHT - rand() % SCREEN_HEIGHT;
battle.planet.x = ((200 + rand() % 100) / 10) * GRID_CELL_WIDTH;
battle.planet.y = ((200 + rand() % 100) / 10) * GRID_CELL_HEIGHT;
loadObjectives(cJSON_GetObjectItem(root, "objectives"));