Generate cap ship component names from parent name.
This commit is contained in:
parent
cfc0ed7cc8
commit
2d37460944
|
@ -222,7 +222,7 @@ static void componentDie(void)
|
||||||
self->alive = ALIVE_DEAD;
|
self->alive = ALIVE_DEAD;
|
||||||
addSmallExplosion();
|
addSmallExplosion();
|
||||||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||||
addDebris(self->x, self->y, rand() % 4);
|
addDebris(self->x, self->y, 3 + rand() % 4);
|
||||||
|
|
||||||
self->owner->health--;
|
self->owner->health--;
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ static void gunDie(void)
|
||||||
self->alive = ALIVE_DEAD;
|
self->alive = ALIVE_DEAD;
|
||||||
addSmallExplosion();
|
addSmallExplosion();
|
||||||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||||
addDebris(self->x, self->y, rand() % 4);
|
addDebris(self->x, self->y, 3 + rand() % 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void engineThink(void)
|
static void engineThink(void)
|
||||||
|
@ -288,6 +288,10 @@ static void die(void)
|
||||||
e->health = 0;
|
e->health = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateObjective(self->name, TT_DESTROY);
|
||||||
|
|
||||||
|
updateObjective(self->groupName, TT_DESTROY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCapitalShipDefs(void)
|
void loadCapitalShipDefs(void)
|
||||||
|
@ -376,8 +380,6 @@ static void loadComponents(Entity *parent, cJSON *components)
|
||||||
e->active = 1;
|
e->active = 1;
|
||||||
|
|
||||||
e->type = ET_CAPITAL_SHIP_COMPONENT;
|
e->type = ET_CAPITAL_SHIP_COMPONENT;
|
||||||
sprintf(e->name, "%s (Component)", parent->name);
|
|
||||||
sprintf(e->defName, "%s (Component)", parent->defName);
|
|
||||||
e->health = e->maxHealth = cJSON_GetObjectItem(component, "health")->valueint;
|
e->health = e->maxHealth = cJSON_GetObjectItem(component, "health")->valueint;
|
||||||
e->offsetX = cJSON_GetObjectItem(component, "x")->valueint;
|
e->offsetX = cJSON_GetObjectItem(component, "x")->valueint;
|
||||||
e->offsetY = cJSON_GetObjectItem(component, "y")->valueint;
|
e->offsetY = cJSON_GetObjectItem(component, "y")->valueint;
|
||||||
|
@ -429,8 +431,6 @@ static void loadGuns(Entity *parent, cJSON *guns)
|
||||||
e->active = 1;
|
e->active = 1;
|
||||||
|
|
||||||
e->type = ET_CAPITAL_SHIP_GUN;
|
e->type = ET_CAPITAL_SHIP_GUN;
|
||||||
sprintf(e->name, "%s (Cannon)", parent->name);
|
|
||||||
sprintf(e->defName, "%s (Cannon)", parent->defName);
|
|
||||||
e->health = e->maxHealth = cJSON_GetObjectItem(gun, "health")->valueint;
|
e->health = e->maxHealth = cJSON_GetObjectItem(gun, "health")->valueint;
|
||||||
e->reloadTime = cJSON_GetObjectItem(gun, "reloadTime")->valueint;
|
e->reloadTime = cJSON_GetObjectItem(gun, "reloadTime")->valueint;
|
||||||
e->offsetX = cJSON_GetObjectItem(gun, "x")->valueint;
|
e->offsetX = cJSON_GetObjectItem(gun, "x")->valueint;
|
||||||
|
@ -486,8 +486,6 @@ static void loadEngines(Entity *parent, cJSON *engines)
|
||||||
e->active = 1;
|
e->active = 1;
|
||||||
|
|
||||||
e->type = ET_CAPITAL_SHIP_ENGINE;
|
e->type = ET_CAPITAL_SHIP_ENGINE;
|
||||||
sprintf(e->name, "%s (Engine)", parent->name);
|
|
||||||
sprintf(e->defName, "%s (Engine)", parent->defName);
|
|
||||||
e->health = e->maxHealth = cJSON_GetObjectItem(engine, "health")->valueint;
|
e->health = e->maxHealth = cJSON_GetObjectItem(engine, "health")->valueint;
|
||||||
e->offsetX = cJSON_GetObjectItem(engine, "x")->valueint;
|
e->offsetX = cJSON_GetObjectItem(engine, "x")->valueint;
|
||||||
e->offsetY = cJSON_GetObjectItem(engine, "y")->valueint;
|
e->offsetY = cJSON_GetObjectItem(engine, "y")->valueint;
|
||||||
|
@ -512,6 +510,32 @@ static void loadEngines(Entity *parent, cJSON *engines)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateCapitalShipComponentNames(Entity *parent)
|
||||||
|
{
|
||||||
|
Entity *e;
|
||||||
|
|
||||||
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
|
{
|
||||||
|
if (e->owner == parent)
|
||||||
|
{
|
||||||
|
switch (e->type)
|
||||||
|
{
|
||||||
|
case ET_CAPITAL_SHIP_ENGINE:
|
||||||
|
sprintf(e->name, "%s (Engine)", parent->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ET_CAPITAL_SHIP_COMPONENT:
|
||||||
|
sprintf(e->name, "%s (Component)", parent->name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ET_CAPITAL_SHIP_GUN:
|
||||||
|
sprintf(e->name, "%s (Gun)", parent->name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void destroyCapitalShipDefs(void)
|
void destroyCapitalShipDefs(void)
|
||||||
{
|
{
|
||||||
Entity *e;
|
Entity *e;
|
||||||
|
|
|
@ -43,6 +43,7 @@ extern int getDistance(int x1, int y1, int x2, int y2);
|
||||||
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||||
extern void addDebris(int x, int y, int amount);
|
extern void addDebris(int x, int y, int amount);
|
||||||
extern void runScriptFunction(char *format, ...);
|
extern void runScriptFunction(char *format, ...);
|
||||||
|
extern void updateObjective(char *name, int type);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
|
|
@ -413,6 +413,8 @@ static void loadCapitalShips(cJSON *node)
|
||||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", e->name, e->defName);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", e->name, e->defName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCapitalShipComponentNames(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->next;
|
node = node->next;
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern void completeConditions(void);
|
||||||
extern void retreatEnemies(void);
|
extern void retreatEnemies(void);
|
||||||
extern void initScript(cJSON *missionJSON);
|
extern void initScript(cJSON *missionJSON);
|
||||||
extern char *getFileLocation(char *filename);
|
extern char *getFileLocation(char *filename);
|
||||||
|
extern void updateCapitalShipComponentNames(Entity *parent);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
|
|
Loading…
Reference in New Issue