diff --git a/data/missions/clarke/06 - clarke defence #6.json b/data/missions/clarke/06 - clarke defence #6.json index f120ee5..4b1ef59 100644 --- a/data/missions/clarke/06 - clarke defence #6.json +++ b/data/missions/clarke/06 - clarke defence #6.json @@ -137,30 +137,6 @@ "MSG_BOX Wingmate;They're everywhere! I--" ] }, - { - "function" : "CAP_ENGINES_DESTROYED UNF Cleopatra", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Cleopatra;This is UNF Cleopatra. We are engine crippled. Please provide cover support!" - ] - }, - { - "function" : "CAP_HEALTH UNF Cleopatra 3", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Cleopatra;Mayday! Mayday! We are taking heavy damage! Please assist ASAP!" - ] - }, - { - "function" : "CAP_ENGINES_DESTROYED UNF Artemis", - "lines" : [ - "IMPORTANT_MSG_BOX Wing Commander;Artemis has lost her engines. We need to keep those Pandorans off her!" - ] - }, - { - "function" : "CAP_HEALTH UNF Artemis 3", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Artemis;All fighters, we're taking a pounding here, we don't know how much longer we can survive this." - ] - }, { "function" : "CAPITAL_SHIPS_LOST 1", "lines" : [ diff --git a/data/missions/india/02 - india defence #2.json b/data/missions/india/02 - india defence #2.json index 7531eaf..a92031b 100644 --- a/data/missions/india/02 - india defence #2.json +++ b/data/missions/india/02 - india defence #2.json @@ -107,30 +107,6 @@ "WAIT_MSG_BOX", "COMPLETE_MISSION" ] - }, - { - "function" : "CAP_ENGINES_DESTROYED UNF Hopper", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Hopper;Our engines have been shot out! We're a sitting duck!" - ] - }, - { - "function" : "CAP_HEALTH UNF Hopper 6", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Hopper;We're taking damage here, guys! Please step it up." - ] - }, - { - "function" : "CAP_HEALTH UNF Hopper 3", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Hopper;We're sustaining heavy damage! All fighters, please assist, ASAP!" - ] - }, - { - "function" : "CAP_HEALTH UNF Hopper 1", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Hopper;Mayday! Mayday! Defences are critical. We can't hold out much longer!" - ] } ] } diff --git a/data/missions/trilliack/02 - trilliack defence #2.json b/data/missions/trilliack/02 - trilliack defence #2.json index ec0949b..a78d1d6 100644 --- a/data/missions/trilliack/02 - trilliack defence #2.json +++ b/data/missions/trilliack/02 - trilliack defence #2.json @@ -100,30 +100,6 @@ "WAIT_MSG_BOX", "COMPLETE_MISSION" ] - }, - { - "function" : "CAP_ENGINES_DESTROYED UNF Lovelace", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Lovelace;Our engines have been shot out! We're a sitting duck!" - ] - }, - { - "function" : "CAP_HEALTH UNF Lovelace 6", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Lovelace;We're taking damage here, Sparrows. Please step it up." - ] - }, - { - "function" : "CAP_HEALTH UNF Lovelace 3", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Lovelace;We're sustaining heavy damage! All fighters, please assist, ASAP!" - ] - }, - { - "function" : "CAP_HEALTH UNF Lovelace 1", - "lines" : [ - "IMPORTANT_MSG_BOX UNF Lovelace;Mayday! Mayday! Defences are critical. We can't hold out much longer!" - ] } ] } diff --git a/src/battle/capitalShips.c b/src/battle/capitalShips.c index d3cecb9..8a03b61 100644 --- a/src/battle/capitalShips.c +++ b/src/battle/capitalShips.c @@ -34,6 +34,9 @@ static void loadComponents(Entity *parent, cJSON *components); static void loadGuns(Entity *parent, cJSON *guns); static void loadEngines(Entity *parent, cJSON *engines); static void disable(void); +static void issueEnginesDestroyedMessage(Entity *cap); +static void issueGunsDestroyedMessage(Entity *cap); +static void issueDamageMessage(Entity *cap); static Entity defHead, *defTail; @@ -252,6 +255,11 @@ static void componentDie(void) if (self->owner->health > 0) { runScriptFunction("CAP_HEALTH %s %d", self->owner->name, self->owner->health); + + if (self->side == player->side) + { + issueDamageMessage(self->owner); + } } } @@ -274,6 +282,11 @@ static void gunDie(void) runScriptFunction("CAP_GUNS_DESTROYED %s", self->owner->name); + if (self->side == player->side) + { + issueGunsDestroyedMessage(self->owner); + } + if (--self->owner->systemPower == 1) { disable(); @@ -312,6 +325,11 @@ static void engineDie(void) self->owner->dx = self->owner->dy = 0; runScriptFunction("CAP_ENGINES_DESTROYED %s", self->owner->name); + + if (self->side == player->side) + { + issueEnginesDestroyedMessage(self->owner); + } } if (--self->owner->systemPower == 1) @@ -729,6 +747,32 @@ void loadCapitalShips(cJSON *node) } } +static void issueEnginesDestroyedMessage(Entity *cap) +{ + addMessageBox(cap->name, _("We've lost engines! We're a sitting duck!"), 1); +} + +static void issueGunsDestroyedMessage(Entity *cap) +{ + addMessageBox(cap->name, _("Our guns have been shot out! We have no defences!"), 1); +} + +static void issueDamageMessage(Entity *cap) +{ + if (cap->health == cap->maxHealth - 1) + { + addMessageBox(cap->name, _("Be advised, we're taking damage here. Please step up support."), 1); + } + else if (cap->health == cap->maxHealth / 2) + { + addMessageBox(cap->name, _("We're sustaining heavy damage! All fighters, please assist, ASAP!"), 1); + } + else if (cap->health == 1) + { + addMessageBox(cap->name, _("Mayday! Mayday! Defences are critical. We can't hold out much longer!"), 1); + } +} + void destroyCapitalShipDefs(void) { Entity *e; diff --git a/src/battle/capitalShips.h b/src/battle/capitalShips.h index b69ad41..7a45729 100644 --- a/src/battle/capitalShips.h +++ b/src/battle/capitalShips.h @@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TURN_SPEED 0.1 #define TURN_THRESHOLD 2 -#define AVOID_FORCE 500 - #include "../common.h" #include "../json/cJSON.h" @@ -52,6 +50,8 @@ extern char *getTranslatedString(char *string); extern void addLargeExplosion(void); extern char **toTypeArray(char *types, int *numTypes); extern void updateCondition(char *name, int type); +extern void addMessageBox(char *title, char *body, int important); extern Battle battle; +extern Entity *player; extern Entity *self;