Allow script to activate spawners.

This commit is contained in:
Steve 2016-03-16 06:53:49 +00:00
parent 0332e2fe20
commit 30fa446006
3 changed files with 30 additions and 1 deletions

View File

@ -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]);

View File

@ -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;

View File

@ -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, ";");
}
}