Moved max suspicion reaction to scripts in missions.
This commit is contained in:
parent
67ad2f0cb5
commit
7e7b8c5454
|
@ -217,6 +217,17 @@
|
||||||
"ACTIVATE_JUMPGATE 0",
|
"ACTIVATE_JUMPGATE 0",
|
||||||
"MSG_BOX Hicks;They've shutdown the jumpgate ..."
|
"MSG_BOX Hicks;They've shutdown the jumpgate ..."
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function" : "MAX_SUSPICION_LEVEL",
|
||||||
|
"lines" : [
|
||||||
|
"UPDATE_ENTITY_SIDE SIDE_ALLIES Hicks",
|
||||||
|
"PANDORAN_MSG_BOX Pandoran;Intruder alert! We have an intruder! All units, target and destroy that fighter!",
|
||||||
|
"IMPORTANT_MSG_BOX Hicks;Hell! My cover's been blown, they're on to me!",
|
||||||
|
"ACTIVATE_JUMPGATE 0",
|
||||||
|
"WAIT_MSG_BOX",
|
||||||
|
"STOP_SCRIPT"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,18 @@
|
||||||
"ACTIVATE_JUMPGATE",
|
"ACTIVATE_JUMPGATE",
|
||||||
"RETREAT_ALLIES"
|
"RETREAT_ALLIES"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function" : "MAX_SUSPICION_LEVEL",
|
||||||
|
"lines" : [
|
||||||
|
"UPDATE_ENTITY_SIDE SIDE_ALLIES Hicks",
|
||||||
|
"PANDORAN_MSG_BOX Wing Commander;Intruder alert! We have an intruder! All units, target and destroy that fighter!",
|
||||||
|
"IMPORTANT_MSG_BOX Hicks;Hell! My cover's been blown, they're on to me!",
|
||||||
|
"ACTIVATE_JUMPGATE 0",
|
||||||
|
"ACTIVATE_TRESPASSER_SPAWNER",
|
||||||
|
"WAIT_MSG_BOX",
|
||||||
|
"STOP_SCRIPT"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,18 @@
|
||||||
"ACTIVATE_JUMPGATE",
|
"ACTIVATE_JUMPGATE",
|
||||||
"RETREAT_ALLIES"
|
"RETREAT_ALLIES"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function" : "MAX_SUSPICION_LEVEL",
|
||||||
|
"lines" : [
|
||||||
|
"UPDATE_ENTITY_SIDE SIDE_ALLIES Hicks",
|
||||||
|
"PANDORAN_MSG_BOX Wing Commander;Intruder alert! We have an intruder! All units, target and destroy that fighter!",
|
||||||
|
"IMPORTANT_MSG_BOX Hicks;Hell! My cover's been blown, they're on to me!",
|
||||||
|
"ACTIVATE_JUMPGATE 0",
|
||||||
|
"ACTIVATE_TRESPASSER_SPAWNER",
|
||||||
|
"WAIT_MSG_BOX",
|
||||||
|
"STOP_SCRIPT"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,18 @@
|
||||||
"WAIT 1",
|
"WAIT 1",
|
||||||
"PANDORAN_MSG_BOX Wing Commander;Mission complete. Prepare for extraction."
|
"PANDORAN_MSG_BOX Wing Commander;Mission complete. Prepare for extraction."
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function" : "MAX_SUSPICION_LEVEL",
|
||||||
|
"lines" : [
|
||||||
|
"UPDATE_ENTITY_SIDE SIDE_ALLIES Hicks",
|
||||||
|
"PANDORAN_MSG_BOX Wing Commander;Intruder alert! We have an intruder! All units, target and destroy that fighter!",
|
||||||
|
"IMPORTANT_MSG_BOX Hicks;Hell! My cover's been blown, they're on to me!",
|
||||||
|
"ACTIVATE_JUMPGATE 0",
|
||||||
|
"ACTIVATE_TRESPASSER_SPAWNER",
|
||||||
|
"WAIT_MSG_BOX",
|
||||||
|
"STOP_SCRIPT"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -968,12 +968,8 @@ static void wander(void)
|
||||||
*/
|
*/
|
||||||
void checkSuspicionLevel(void)
|
void checkSuspicionLevel(void)
|
||||||
{
|
{
|
||||||
battle.hasSuspicionLevel = 0;
|
|
||||||
|
|
||||||
if (battle.status == MS_IN_PROGRESS && player->side != SIDE_ALLIES)
|
if (battle.status == MS_IN_PROGRESS && player->side != SIDE_ALLIES)
|
||||||
{
|
{
|
||||||
battle.hasSuspicionLevel = 1;
|
|
||||||
|
|
||||||
battle.suspicionCoolOff = MAX(battle.suspicionCoolOff - 1, 0);
|
battle.suspicionCoolOff = MAX(battle.suspicionCoolOff - 1, 0);
|
||||||
|
|
||||||
/* raise if player is too far away and there are no enemies */
|
/* raise if player is too far away and there are no enemies */
|
||||||
|
@ -988,21 +984,6 @@ void checkSuspicionLevel(void)
|
||||||
battle.suspicionLevel++;
|
battle.suspicionLevel++;
|
||||||
battle.suspicionCoolOff = FPS * 30;
|
battle.suspicionCoolOff = FPS * 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (battle.suspicionLevel >= MAX_SUSPICION_LEVEL)
|
|
||||||
{
|
|
||||||
player->side = SIDE_ALLIES;
|
|
||||||
|
|
||||||
addMessageBox(self->name, "Intruder alert! We have an intruder! All units, target and destroy that fighter!", MB_PANDORAN);
|
|
||||||
|
|
||||||
addMessageBox(player->name, _("Hell! My cover's been blown, they're on to me!"), MB_IMPORTANT);
|
|
||||||
|
|
||||||
destroyScript();
|
|
||||||
|
|
||||||
activateJumpgate(0);
|
|
||||||
|
|
||||||
activateTrespasserSpawner();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore);
|
extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore);
|
||||||
extern char *getTranslatedString(char *string);
|
extern char *getTranslatedString(char *string);
|
||||||
extern Entity *spawnMine(int type);
|
extern Entity *spawnMine(int type);
|
||||||
extern void addMessageBox(char *title, char *body, int type);
|
|
||||||
extern void destroyScript(void);
|
|
||||||
extern void activateTrespasserSpawner(void);
|
|
||||||
extern void activateJumpgate(int activate);
|
|
||||||
extern void runScriptFunction(char *format, ...);
|
extern void runScriptFunction(char *format, ...);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
|
|
@ -34,6 +34,7 @@ static void retry(void);
|
||||||
static void start(void);
|
static void start(void);
|
||||||
static void options(void);
|
static void options(void);
|
||||||
static void returnFromOptions(void);
|
static void returnFromOptions(void);
|
||||||
|
static void checkSuspicionLevel(void);
|
||||||
|
|
||||||
static int show;
|
static int show;
|
||||||
static float ssx, ssy;
|
static float ssx, ssy;
|
||||||
|
@ -157,6 +158,8 @@ static void doBattle(void)
|
||||||
|
|
||||||
doPlayer();
|
doPlayer();
|
||||||
|
|
||||||
|
checkSuspicionLevel();
|
||||||
|
|
||||||
if (player->alive == ALIVE_ALIVE)
|
if (player->alive == ALIVE_ALIVE)
|
||||||
{
|
{
|
||||||
doSpawners();
|
doSpawners();
|
||||||
|
@ -398,6 +401,20 @@ static void postBattle(void)
|
||||||
app.saveGame = 1;
|
app.saveGame = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void checkSuspicionLevel(void)
|
||||||
|
{
|
||||||
|
if (battle.hasSuspicionLevel && battle.suspicionLevel >= MAX_SUSPICION_LEVEL)
|
||||||
|
{
|
||||||
|
cancelScript();
|
||||||
|
|
||||||
|
resetMessageBox();
|
||||||
|
|
||||||
|
runScriptFunction("MAX_SUSPICION_LEVEL");
|
||||||
|
|
||||||
|
battle.hasSuspicionLevel = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void destroyBattle(void)
|
void destroyBattle(void)
|
||||||
{
|
{
|
||||||
Entity *ent;
|
Entity *ent;
|
||||||
|
|
|
@ -87,6 +87,7 @@ extern void runScriptFunction(const char *format, ...);
|
||||||
extern void doSpawners(void);
|
extern void doSpawners(void);
|
||||||
extern void doTrophyAlerts(void);
|
extern void doTrophyAlerts(void);
|
||||||
extern void drawTrophyAlert(void);
|
extern void drawTrophyAlert(void);
|
||||||
|
extern void cancelScript(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
|
|
@ -39,6 +39,5 @@ extern int jumpgateEnabled(void);
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
extern Dev dev;
|
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
extern Game game;
|
extern Game game;
|
||||||
|
|
|
@ -21,10 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
static void executeNextLine(ScriptRunner *runner);
|
static void executeNextLine(ScriptRunner *runner);
|
||||||
|
void destroyScript(void);
|
||||||
|
|
||||||
static cJSON *scriptJSON, *rootJSON;
|
static cJSON *scriptJSON, *rootJSON;
|
||||||
static ScriptRunner head;
|
static ScriptRunner head;
|
||||||
static ScriptRunner *tail;
|
static ScriptRunner *tail;
|
||||||
|
static int runScript;
|
||||||
|
|
||||||
void initScript(cJSON *root)
|
void initScript(cJSON *root)
|
||||||
{
|
{
|
||||||
|
@ -35,6 +37,8 @@ void initScript(cJSON *root)
|
||||||
|
|
||||||
rootJSON = root;
|
rootJSON = root;
|
||||||
|
|
||||||
|
runScript = 0;
|
||||||
|
|
||||||
scriptJSON = cJSON_GetObjectItem(root, "script");
|
scriptJSON = cJSON_GetObjectItem(root, "script");
|
||||||
|
|
||||||
if (scriptJSON)
|
if (scriptJSON)
|
||||||
|
@ -47,6 +51,8 @@ void initScript(cJSON *root)
|
||||||
|
|
||||||
function = function->next;
|
function = function->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runScript = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +60,8 @@ void doScript(void)
|
||||||
{
|
{
|
||||||
ScriptRunner *runner, *prev;
|
ScriptRunner *runner, *prev;
|
||||||
|
|
||||||
|
if (runScript)
|
||||||
|
{
|
||||||
prev = &head;
|
prev = &head;
|
||||||
|
|
||||||
for (runner = head.next ; runner != NULL ; runner = runner->next)
|
for (runner = head.next ; runner != NULL ; runner = runner->next)
|
||||||
|
@ -85,6 +93,7 @@ void doScript(void)
|
||||||
prev = runner;
|
prev = runner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void runScriptFunction(const char *format, ...)
|
void runScriptFunction(const char *format, ...)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +103,7 @@ void runScriptFunction(const char *format, ...)
|
||||||
char funcNameBuffer[MAX_NAME_LENGTH];
|
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
if (scriptJSON)
|
if (scriptJSON && runScript)
|
||||||
{
|
{
|
||||||
memset(&funcNameBuffer, '\0', sizeof(funcNameBuffer));
|
memset(&funcNameBuffer, '\0', sizeof(funcNameBuffer));
|
||||||
|
|
||||||
|
@ -134,7 +143,7 @@ void runScriptTimeFunctions(void)
|
||||||
char funcNameBuffer[MAX_NAME_LENGTH];
|
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||||
int intParam;
|
int intParam;
|
||||||
|
|
||||||
if (scriptJSON)
|
if (scriptJSON && runScript)
|
||||||
{
|
{
|
||||||
function = scriptJSON->child;
|
function = scriptJSON->child;
|
||||||
|
|
||||||
|
@ -293,16 +302,37 @@ static void executeNextLine(ScriptRunner *runner)
|
||||||
sscanf(line, "%*s %s %[^\n]", strParam[0], strParam[1]);
|
sscanf(line, "%*s %s %[^\n]", strParam[0], strParam[1]);
|
||||||
updateEntitySide(strParam[0], strParam[1]);
|
updateEntitySide(strParam[0], strParam[1]);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(command, "ACTIVATE_TRESPASSER_SPAWNER") == 0)
|
||||||
|
{
|
||||||
|
activateTrespasserSpawner();
|
||||||
|
}
|
||||||
|
else if (strcmp(command, "STOP_SCRIPT") == 0)
|
||||||
|
{
|
||||||
|
runScript = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("ERROR: Unrecognised script command '%s'\n", command);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "ERROR: Unrecognised script command '%s'\n", command);
|
||||||
printf("ERROR: Offending line: '%s'\n", line);
|
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "ERROR: Offending line: '%s'\n", line);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
runner->line = runner->line->next;
|
runner->line = runner->line->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cancelScript(void)
|
||||||
|
{
|
||||||
|
ScriptRunner *runner;
|
||||||
|
|
||||||
|
while (head.next)
|
||||||
|
{
|
||||||
|
runner = head.next;
|
||||||
|
head.next = runner->next;
|
||||||
|
free(runner);
|
||||||
|
}
|
||||||
|
|
||||||
|
tail = &head;
|
||||||
|
}
|
||||||
|
|
||||||
void destroyScript(void)
|
void destroyScript(void)
|
||||||
{
|
{
|
||||||
ScriptRunner *scriptRunner;
|
ScriptRunner *scriptRunner;
|
||||||
|
|
|
@ -41,6 +41,7 @@ extern void completeAllObjectives(void);
|
||||||
extern void createChristabelLocation(void);
|
extern void createChristabelLocation(void);
|
||||||
extern void killEntity(char *name);
|
extern void killEntity(char *name);
|
||||||
extern void updateEntitySide(char *side, char *entity);
|
extern void updateEntitySide(char *side, char *entity);
|
||||||
|
extern void activateTrespasserSpawner(void);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
Loading…
Reference in New Issue