Moved max suspicion reaction to scripts in missions.
This commit is contained in:
parent
67ad2f0cb5
commit
7e7b8c5454
|
@ -217,6 +217,17 @@
|
|||
"ACTIVATE_JUMPGATE 0",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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)
|
||||
{
|
||||
battle.hasSuspicionLevel = 0;
|
||||
|
||||
if (battle.status == MS_IN_PROGRESS && player->side != SIDE_ALLIES)
|
||||
{
|
||||
battle.hasSuspicionLevel = 1;
|
||||
|
||||
battle.suspicionCoolOff = MAX(battle.suspicionCoolOff - 1, 0);
|
||||
|
||||
/* raise if player is too far away and there are no enemies */
|
||||
|
@ -988,21 +984,6 @@ void checkSuspicionLevel(void)
|
|||
battle.suspicionLevel++;
|
||||
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 char *getTranslatedString(char *string);
|
||||
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 Battle battle;
|
||||
|
|
|
@ -34,6 +34,7 @@ static void retry(void);
|
|||
static void start(void);
|
||||
static void options(void);
|
||||
static void returnFromOptions(void);
|
||||
static void checkSuspicionLevel(void);
|
||||
|
||||
static int show;
|
||||
static float ssx, ssy;
|
||||
|
@ -156,6 +157,8 @@ static void doBattle(void)
|
|||
doDebris();
|
||||
|
||||
doPlayer();
|
||||
|
||||
checkSuspicionLevel();
|
||||
|
||||
if (player->alive == ALIVE_ALIVE)
|
||||
{
|
||||
|
@ -398,6 +401,20 @@ static void postBattle(void)
|
|||
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)
|
||||
{
|
||||
Entity *ent;
|
||||
|
|
|
@ -87,6 +87,7 @@ extern void runScriptFunction(const char *format, ...);
|
|||
extern void doSpawners(void);
|
||||
extern void doTrophyAlerts(void);
|
||||
extern void drawTrophyAlert(void);
|
||||
extern void cancelScript(void);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -39,6 +39,5 @@ extern int jumpgateEnabled(void);
|
|||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Dev dev;
|
||||
extern Entity *player;
|
||||
extern Game game;
|
||||
|
|
|
@ -21,10 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "script.h"
|
||||
|
||||
static void executeNextLine(ScriptRunner *runner);
|
||||
void destroyScript(void);
|
||||
|
||||
static cJSON *scriptJSON, *rootJSON;
|
||||
static ScriptRunner head;
|
||||
static ScriptRunner *tail;
|
||||
static int runScript;
|
||||
|
||||
void initScript(cJSON *root)
|
||||
{
|
||||
|
@ -34,6 +36,8 @@ void initScript(cJSON *root)
|
|||
tail = &head;
|
||||
|
||||
rootJSON = root;
|
||||
|
||||
runScript = 0;
|
||||
|
||||
scriptJSON = cJSON_GetObjectItem(root, "script");
|
||||
|
||||
|
@ -47,6 +51,8 @@ void initScript(cJSON *root)
|
|||
|
||||
function = function->next;
|
||||
}
|
||||
|
||||
runScript = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,35 +60,38 @@ void doScript(void)
|
|||
{
|
||||
ScriptRunner *runner, *prev;
|
||||
|
||||
prev = &head;
|
||||
|
||||
for (runner = head.next ; runner != NULL ; runner = runner->next)
|
||||
if (runScript)
|
||||
{
|
||||
runner->delay = MAX(0, runner->delay - 1);
|
||||
prev = &head;
|
||||
|
||||
if (runner->waitForMessageBox)
|
||||
for (runner = head.next ; runner != NULL ; runner = runner->next)
|
||||
{
|
||||
runner->waitForMessageBox = showingMessageBoxes();
|
||||
}
|
||||
runner->delay = MAX(0, runner->delay - 1);
|
||||
|
||||
if (!runner->delay && !runner->waitForMessageBox)
|
||||
{
|
||||
executeNextLine(runner);
|
||||
|
||||
if (!runner->line)
|
||||
if (runner->waitForMessageBox)
|
||||
{
|
||||
if (runner == tail)
|
||||
{
|
||||
tail = prev;
|
||||
}
|
||||
|
||||
prev->next = runner->next;
|
||||
free(runner);
|
||||
runner = prev;
|
||||
runner->waitForMessageBox = showingMessageBoxes();
|
||||
}
|
||||
}
|
||||
|
||||
prev = runner;
|
||||
if (!runner->delay && !runner->waitForMessageBox)
|
||||
{
|
||||
executeNextLine(runner);
|
||||
|
||||
if (!runner->line)
|
||||
{
|
||||
if (runner == tail)
|
||||
{
|
||||
tail = prev;
|
||||
}
|
||||
|
||||
prev->next = runner->next;
|
||||
free(runner);
|
||||
runner = prev;
|
||||
}
|
||||
}
|
||||
|
||||
prev = runner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +103,7 @@ void runScriptFunction(const char *format, ...)
|
|||
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||
va_list args;
|
||||
|
||||
if (scriptJSON)
|
||||
if (scriptJSON && runScript)
|
||||
{
|
||||
memset(&funcNameBuffer, '\0', sizeof(funcNameBuffer));
|
||||
|
||||
|
@ -134,7 +143,7 @@ void runScriptTimeFunctions(void)
|
|||
char funcNameBuffer[MAX_NAME_LENGTH];
|
||||
int intParam;
|
||||
|
||||
if (scriptJSON)
|
||||
if (scriptJSON && runScript)
|
||||
{
|
||||
function = scriptJSON->child;
|
||||
|
||||
|
@ -293,16 +302,37 @@ static void executeNextLine(ScriptRunner *runner)
|
|||
sscanf(line, "%*s %s %[^\n]", 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
|
||||
{
|
||||
printf("ERROR: Unrecognised script command '%s'\n", command);
|
||||
printf("ERROR: Offending line: '%s'\n", line);
|
||||
exit(1);
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "ERROR: Unrecognised script command '%s'\n", command);
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "ERROR: Offending line: '%s'\n", line);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
ScriptRunner *scriptRunner;
|
||||
|
|
|
@ -41,6 +41,7 @@ extern void completeAllObjectives(void);
|
|||
extern void createChristabelLocation(void);
|
||||
extern void killEntity(char *name);
|
||||
extern void updateEntitySide(char *side, char *entity);
|
||||
extern void activateTrespasserSpawner(void);
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
|
Loading…
Reference in New Issue