Removed script-based spawner. Redundant.

This commit is contained in:
Steve 2016-03-14 11:28:01 +00:00
parent edc18579ec
commit 4e8b85b6a1
6 changed files with 11 additions and 103 deletions

View File

@ -49,12 +49,16 @@
"y" : 25 "y" : 25
} }
], ],
"script" : [ "spawners" : [
{ {
"function" : "INTERVAL 30", "name" : "spawner",
"lines" : [ "types" : "Dart",
"SPAWN_FIGHTERS Dart SIDE_PIRATE 1 OFFSCREEN" "side" : "SIDE_PIRATE",
] "interval" : 30,
"limit" : 0,
"total" : 0,
"step" : 1,
"offscreen" : 1
} }
] ]
} }

View File

@ -164,7 +164,7 @@ static void doBattle(void)
if (battle.stats[STAT_TIME]++ % FPS == 0) if (battle.stats[STAT_TIME]++ % FPS == 0)
{ {
runScriptTimeFunctions(); runScriptFunction("TIME %d", battle.stats[STAT_TIME]);
} }
} }
} }

View File

@ -83,7 +83,7 @@ extern void destroyEffects(void);
extern void initChallengeHome(void); extern void initChallengeHome(void);
extern void updateAccuracyStats(unsigned int *stats); extern void updateAccuracyStats(unsigned int *stats);
extern void clearInput(void); extern void clearInput(void);
extern void runScriptTimeFunctions(void); extern void runScriptFunction(const char *format, ...);
extern void doSpawners(void); extern void doSpawners(void);
extern App app; extern App app;

View File

@ -99,42 +99,6 @@ Entity *spawnFighter(char *name, int x, int y, int side)
return e; return e;
} }
void spawnScriptFighter(char *fighterTypes, char *sideStr, int num, char *location)
{
Entity *e;
int i, numTypes, side, offscreen;
char **types, *type;
types = toTypeArray(fighterTypes, &numTypes);
side = lookup(sideStr);
offscreen = strcmp(location, "OFFSCREEN") == 0;
for (i = 0 ; i < num ; i++)
{
type = types[rand() % numTypes];
e = spawnFighter(type, 0, 0, side);
if (offscreen)
{
e->x = player->x;
e->y = player->y;
}
else
{
e->x = rand() % 2 ? 0 : BATTLE_AREA_WIDTH;
e->y = rand() % 2 ? 0 : BATTLE_AREA_HEIGHT;
}
e->x += (rand() % 2) ? -SCREEN_WIDTH : SCREEN_WIDTH;
e->y += (rand() % 2) ? -SCREEN_HEIGHT : SCREEN_HEIGHT;
e->aiFlags |= AIF_UNLIMITED_RANGE;
}
free(types);
}
static void randomizeDart(Entity *dart) static void randomizeDart(Entity *dart)
{ {
char texture[MAX_DESCRIPTION_LENGTH]; char texture[MAX_DESCRIPTION_LENGTH];

View File

@ -124,60 +124,6 @@ void runScriptFunction(const char *format, ...)
} }
} }
void runScriptTimeFunctions(void)
{
ScriptRunner *scriptRunner;
cJSON *function;
char *functionName;
char funcNameBuffer[MAX_NAME_LENGTH];
int intParam;
if (scriptJSON)
{
function = scriptJSON->child;
sprintf(funcNameBuffer, "TIME %d", battle.stats[STAT_TIME] / 60);
while (function)
{
functionName = cJSON_GetObjectItem(function, "function")->valuestring;
if (strcmp(functionName, funcNameBuffer) == 0)
{
scriptRunner = malloc(sizeof(ScriptRunner));
memset(scriptRunner, 0, sizeof(ScriptRunner));
scriptRunner->line = cJSON_GetObjectItem(function, "lines")->child;
tail->next = scriptRunner;
tail = scriptRunner;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Running script '%s'", funcNameBuffer);
}
if (strstr(functionName, "INTERVAL"))
{
sscanf(functionName, "%*s %d", &intParam);
if ((battle.stats[STAT_TIME] / 60) % intParam == 0)
{
scriptRunner = malloc(sizeof(ScriptRunner));
memset(scriptRunner, 0, sizeof(ScriptRunner));
scriptRunner->line = cJSON_GetObjectItem(function, "lines")->child;
tail->next = scriptRunner;
tail = scriptRunner;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Running script '%s'", funcNameBuffer);
}
}
function = function->next;
}
}
}
static void executeNextLine(ScriptRunner *runner) static void executeNextLine(ScriptRunner *runner)
{ {
char *line; char *line;
@ -256,11 +202,6 @@ static void executeNextLine(ScriptRunner *runner)
battle.isEpic = 0; battle.isEpic = 0;
retreatEnemies(); retreatEnemies();
} }
else if (strcmp(command, "SPAWN_FIGHTERS") == 0)
{
sscanf(line, "%*s %s %s %d %s", strParam[0], strParam[1], &intParam[0], strParam[2]);
spawnScriptFighter(strParam[0], strParam[1], intParam[0], strParam[2]);
}
else else
{ {
printf("ERROR: Unrecognised script command '%s'\n", command); printf("ERROR: Unrecognised script command '%s'\n", command);

View File

@ -34,7 +34,6 @@ extern void activateLocations(char *locations);
void activateObjectives(char *objectives); void activateObjectives(char *objectives);
extern int showingMessageBoxes(void); extern int showingMessageBoxes(void);
extern char *getTranslatedString(char *string); extern char *getTranslatedString(char *string);
extern void spawnScriptFighter(char *fighters, char *side, int num, char *location);
extern void activateNextWaypoint(int id); extern void activateNextWaypoint(int id);
extern void activateJumpgate(int activate); extern void activateJumpgate(int activate);