Don't fire objectives or conditions if no names.

This commit is contained in:
Steve 2016-05-05 14:06:51 +01:00
parent 9c18974a63
commit ef9ce45aed
1 changed files with 48 additions and 42 deletions

View File

@ -82,35 +82,49 @@ void updateObjective(char *name, int type)
Objective *o; Objective *o;
int completed, hasHidden; int completed, hasHidden;
completed = battle.numObjectivesComplete; if (strlen(name))
hasHidden = 0;
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{ {
if (o->active && o->status != OS_COMPLETE) completed = battle.numObjectivesComplete;
hasHidden = 0;
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{ {
if (!o->isEliminateAll && !o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0) if (o->active && o->status != OS_COMPLETE)
{ {
o->currentValue++; if (!o->isEliminateAll && !o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
if (!o->hideNumbers)
{ {
if (o->targetValue - o->currentValue <= 10) o->currentValue++;
if (!o->hideNumbers)
{ {
addHudMessage(colors.cyan, "%s - %d / %d", o->description, o->currentValue, o->targetValue); if (o->targetValue - o->currentValue <= 10)
{
addHudMessage(colors.cyan, "%s - %d / %d", o->description, o->currentValue, o->targetValue);
}
else if (o->currentValue % 10 == 0)
{
addHudMessage(colors.cyan, "%s - %d / %d", o->description, o->currentValue, o->targetValue);
}
} }
else if (o->currentValue % 10 == 0)
if (o->currentValue == o->targetValue)
{ {
addHudMessage(colors.cyan, "%s - %d / %d", o->description, o->currentValue, o->targetValue); addHudMessage(colors.green, _("%s - Objective Complete!"), o->description);
runScriptFunction(o->description);
o->status = OS_COMPLETE;
runScriptFunction("OBJECTIVES_COMPLETE %d", ++completed);
} }
} }
if (o->currentValue == o->targetValue) if (o->isEliminateAll && o->status != OS_COMPLETE && (battle.stats[STAT_ENEMIES_KILLED] + battle.stats[STAT_CAPITAL_SHIPS_DESTROYED]) == battle.numInitialEnemies)
{ {
addHudMessage(colors.green, _("%s - Objective Complete!"), o->description); addHudMessage(colors.green, _("%s - Objective Complete!"), o->description);
runScriptFunction(o->description); o->currentValue = o->targetValue;
o->status = OS_COMPLETE; o->status = OS_COMPLETE;
@ -118,28 +132,17 @@ void updateObjective(char *name, int type)
} }
} }
if (o->isEliminateAll && o->status != OS_COMPLETE && battle.stats[STAT_ENEMIES_KILLED] == battle.numInitialEnemies) if (!o->active)
{ {
addHudMessage(colors.green, _("%s - Objective Complete!"), o->description); hasHidden = 1;
o->currentValue = o->targetValue;
o->status = OS_COMPLETE;
runScriptFunction("OBJECTIVES_COMPLETE %d", ++completed);
} }
} }
if (!o->active) if (completed == battle.numObjectivesTotal && !hasHidden)
{ {
hasHidden = 1; runScriptFunction("ALL_OBJECTIVES_COMPLETE");
} }
} }
if (completed == battle.numObjectivesTotal && !hasHidden)
{
runScriptFunction("ALL_OBJECTIVES_COMPLETE");
}
} }
void adjustObjectiveTargetValue(char *name, int type, int amount) void adjustObjectiveTargetValue(char *name, int type, int amount)
@ -166,20 +169,23 @@ void updateCondition(char *name, int type)
{ {
Objective *o; Objective *o;
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next) if (strlen(name))
{ {
if (o->active && o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0) for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{ {
o->currentValue++; if (o->active && o->isCondition && o->targetType == type && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
if (o->currentValue == o->targetValue)
{ {
o->status = OS_FAILED; o->currentValue++;
addHudMessage(colors.red, _("%s - Objective Failed!"), o->description);
} if (o->currentValue == o->targetValue)
else if (!o->hideNumbers) {
{ o->status = OS_FAILED;
addHudMessage(colors.red, "%s - %d / %d", o->description, o->currentValue, o->targetValue); addHudMessage(colors.red, _("%s - Objective Failed!"), o->description);
}
else if (!o->hideNumbers)
{
addHudMessage(colors.red, "%s - %d / %d", o->description, o->currentValue, o->targetValue);
}
} }
} }
} }