Further capital ship tweaks.

This commit is contained in:
Steve 2015-12-09 07:25:24 +00:00
parent 91822f1ca3
commit c8eecdd316
3 changed files with 25 additions and 18 deletions

View File

@ -48,7 +48,7 @@
"x" : -110,
"y" : 20,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
@ -58,7 +58,7 @@
"x" : -110,
"y" : 100,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
@ -68,7 +68,7 @@
"x" : -110,
"y" : 180,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
@ -78,7 +78,7 @@
"x" : 110,
"y" : 20,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
@ -88,7 +88,7 @@
"x" : 110,
"y" : 100,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
},
@ -98,7 +98,7 @@
"x" : 110,
"y" : 180,
"reloadTime" : 10,
"type" : "BT_PARTICLE",
"type" : "BT_PLASMA",
"flags" : "EF_TAKES_DAMAGE+EF_STATIC",
"aiFlags" : "AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
}

View File

@ -35,7 +35,7 @@ Entity *spawnCapitalShip(char *name, int x, int y, int side)
for (def = defHead.next ; def != NULL ; def = def->next)
{
if (strcmp(def->name, name) == 0)
if ((strcmp(def->name, name) == 0) || (def->owner != NULL && strcmp(def->owner->name, name) == 0))
{
e = spawnEntity();
@ -69,7 +69,7 @@ static void think(void)
static void gunThink(void)
{
doAI();
/*doAI();*/
}
static void componentDie(void)
@ -78,8 +78,11 @@ static void componentDie(void)
addSmallExplosion();
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
if (self->type == ET_CAPITAL_SHIP_COMPONENT)
{
self->owner->health--;
}
}
static void die(void)
{
@ -167,8 +170,8 @@ static void loadComponents(Entity *parent, cJSON *components)
e->active = 1;
e->type = ET_CAPITAL_SHIP_COMPONENT;
STRNCPY(e->name, parent->name, MAX_NAME_LENGTH);
STRNCPY(e->defName, parent->defName, MAX_NAME_LENGTH);
sprintf(e->name, "%s (Component)", parent->name);
sprintf(e->defName, "%s (Component)", parent->defName);
e->health = e->maxHealth = cJSON_GetObjectItem(component, "health")->valueint;
e->offsetX = cJSON_GetObjectItem(component, "x")->valueint;
e->offsetY = cJSON_GetObjectItem(component, "y")->valueint;
@ -186,8 +189,12 @@ static void loadComponents(Entity *parent, cJSON *components)
e->flags = flagsToLong(cJSON_GetObjectItem(component, "flags")->valuestring);
}
e->systemPower = 100;
e->die = componentDie;
e->owner = parent;
component = component->next;
parent->health++;
@ -200,8 +207,6 @@ static void loadGuns(Entity *parent, cJSON *guns)
Entity *e;
cJSON *gun;
parent->health = 0;
if (guns)
{
gun = guns->child;
@ -216,8 +221,8 @@ static void loadGuns(Entity *parent, cJSON *guns)
e->active = 1;
e->type = ET_CAPITAL_SHIP_GUN;
STRNCPY(e->name, parent->name, MAX_NAME_LENGTH);
STRNCPY(e->defName, parent->defName, MAX_NAME_LENGTH);
sprintf(e->name, "%s (Cannon)", parent->name);
sprintf(e->defName, "%s (Cannon)", parent->defName);
e->health = e->maxHealth = cJSON_GetObjectItem(gun, "health")->valueint;
e->reloadTime = cJSON_GetObjectItem(gun, "reloadTime")->valueint;
e->offsetX = cJSON_GetObjectItem(gun, "x")->valueint;
@ -237,12 +242,14 @@ static void loadGuns(Entity *parent, cJSON *guns)
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
e->systemPower = 100;
e->action = gunThink;
e->die = componentDie;
gun = gun->next;
e->owner = parent;
parent->health++;
gun = gun->next;
}
}
}

View File

@ -363,7 +363,7 @@ static void selectTarget(void)
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
if (e->active && e != player && e->type == ET_FIGHTER && e->side != player->side && e->alive == ALIVE_ALIVE && (!(e->flags & EF_DISABLED)))
if (e->active && e != player && (e->flags & EF_TAKES_DAMAGE) && e->side != player->side && e->alive == ALIVE_ALIVE && (!(e->flags & EF_DISABLED)) && i < MAX_SELECTABLE_TARGETS)
{
dist = getDistance(self->x, self->y, e->x, e->y);
if (dist < closest)