From 30fa446006e56488bcab9c6922d6d60d3d281c4e Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 16 Mar 2016 06:53:49 +0000 Subject: [PATCH] Allow script to activate spawners. --- src/battle/script.c | 5 +++++ src/battle/script.h | 1 + src/battle/spawners.c | 25 ++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/battle/script.c b/src/battle/script.c index fd22259..8cd4a4b 100644 --- a/src/battle/script.c +++ b/src/battle/script.c @@ -164,6 +164,11 @@ static void executeNextLine(ScriptRunner *runner) { activateNextWaypoint(0); } + else if (strcmp(command, "ACTIVATE_SPAWNERS") == 0) + { + sscanf(line, "%*s %[^;] %d", strParam[0], &intParam[0]); + activateSpawner(strParam[0], intParam[0]); + } else if (strcmp(command, "MSG_BOX") == 0) { sscanf(line, "%*s %255[^;]%*c%255[^\n]", strParam[0], strParam[1]); diff --git a/src/battle/script.h b/src/battle/script.h index 1c92b56..7fb5f4c 100644 --- a/src/battle/script.h +++ b/src/battle/script.h @@ -36,6 +36,7 @@ extern int showingMessageBoxes(void); extern char *getTranslatedString(char *string); extern void activateNextWaypoint(int id); extern void activateJumpgate(int activate); +extern void activateSpawner(char *name, int active); extern Battle battle; extern Colors colors; diff --git a/src/battle/spawners.c b/src/battle/spawners.c index 326f161..82a0ecd 100644 --- a/src/battle/spawners.c +++ b/src/battle/spawners.c @@ -33,13 +33,15 @@ void doSpawners(void) { num = s->step; - if (s->limit) + if (s->total != -1) { num = MIN(s->step, s->total); s->total -= num; } + battle.numInitialEnemies += num; + for (i = 0 ; i < num ; i++) { type = s->types[rand() % s->numTypes]; @@ -67,3 +69,24 @@ void doSpawners(void) } } } + +void activateSpawner(char *names, int active) +{ + Spawner *s; + char *name; + + name = strtok(names, ";"); + + while (name) + { + for (s = battle.spawnerHead.next ; s != NULL ; s = s->next) + { + if (strcmp(s->name, name) == 0) + { + s->active = active; + } + } + + name = strtok(NULL, ";"); + } +}