Use single variable to track mission type.

This commit is contained in:
Steve 2018-02-14 07:26:51 +00:00
parent 718b658a1a
commit d71bee6b11
10 changed files with 26 additions and 16 deletions

View File

@ -215,6 +215,14 @@ enum
MS_COMPLETE
};
enum
{
MT_NORMAL,
MT_TRAINING,
MT_OUTPOST,
MT_BOSS
};
enum
{
WS_START,

View File

@ -110,13 +110,13 @@ static void init(void)
static void tick(void)
{
if (world.isTrainingMission || dev.cheatHealth)
if (world.missionType == MT_TRAINING || dev.cheatHealth)
{
world.bob->alive = ALIVE_ALIVE;
world.bob->health = world.bob->healthMax;
}
if (world.isTrainingMission)
if (world.missionType == MT_TRAINING)
{
world.bob->power = MIN(world.bob->power + 0.01, world.bob->powerMax);
}
@ -387,7 +387,7 @@ void stunBob(void)
static void applyDamage(int damage)
{
if (!(world.bob->flags & EF_IMMUNE) && !world.isTrainingMission && !dev.cheatHealth && world.bob->alive != ALIVE_DEAD)
if (!(world.bob->flags & EF_IMMUNE) && world.missionType != MT_TRAINING && !dev.cheatHealth && world.bob->alive != ALIVE_DEAD)
{
if (world.bob->health < 0)
{

View File

@ -45,7 +45,7 @@ Unit *createUnit(void)
u->canCarryItem = rand() % 100 < 85;
if (world.isOutpostMission)
if (world.missionType == MT_OUTPOST)
{
u->canCarryItem = 1;
u->health = u->healthMax = rrnd(1, 4);

View File

@ -439,10 +439,8 @@ typedef struct {
int allObjectivesComplete;
int frameCounter;
int currentStatus;
int isTrainingMission;
int isBossMission;
int missionType;
int isBossActive;
int isOutpostMission;
int isReturnVisit;
int missionCompleteTimer;
int observationTimer;

View File

@ -33,11 +33,13 @@ void initAtlasTest(void)
initHub();
loadWorld("greenlands2");
loadWorld("greenlands4");
initWorld();
initMap();
initEntities();
saveConfig();
}

View File

@ -26,5 +26,6 @@ extern void initHub(void);
extern void initGame(void);
extern void initEntities(void);
extern void loadWorld(char *id);
extern void saveConfig(void);
extern Dev dev;

View File

@ -61,7 +61,7 @@ static int getRandomPlayerWeaponAt(int x, int y)
{
int type;
type = getRandomPlayerWeapon(world.isBossMission);
type = getRandomPlayerWeapon(world.missionType == MT_BOSS);
if (world.map.data[(x / MAP_TILE_SIZE)][(y / MAP_TILE_SIZE)] == MAP_TILE_WATER)
{
@ -69,7 +69,7 @@ static int getRandomPlayerWeaponAt(int x, int y)
}
else if (type == WPN_PISTOL && rand() % 100 < 25)
{
type = getRandomPlayerWeapon(world.isBossMission);
type = getRandomPlayerWeapon(world.missionType == MT_BOSS);
}
return type;

View File

@ -259,7 +259,7 @@ static void loadMapData(void)
{
sscanf(p, "%d", &i);
if (!world.isOutpostMission)
if (world.missionType != MT_OUTPOST)
{
if (i >= 4 && i <= 7)
{

View File

@ -67,7 +67,7 @@ void initWorld(void)
observationIndex = 0;
if (world.isBossMission)
if (world.missionType == MT_BOSS)
{
startMission();
hideAllWidgets();
@ -390,7 +390,7 @@ static void doCommon(void)
spawnEnemies();
}
if (world.isBossMission && --world.helperItemTimer <= 0)
if (world.missionType == MT_BOSS && --world.helperItemTimer <= 0)
{
addHelperItems();
}

View File

@ -61,9 +61,10 @@ void loadWorld(char *id)
STRNCPY(world.tileset, cJSON_GetObjectItem(root, "tileset")->valuestring, MAX_NAME_LENGTH);
STRNCPY(world.background, cJSON_GetObjectItem(root, "background")->valuestring, MAX_FILENAME_LENGTH);
world.entityCounter = cJSON_GetObjectItem(root, "entityCounter")->valueint;
world.isTrainingMission = strcmp(world.id, "beachApproach") == 0;
world.isBossMission = strncmp(world.id, "boss", 4) == 0;
world.isOutpostMission = strncmp(world.id, "outpost", 7) == 0;
world.missionType = strcmp(world.id, "beachApproach") == 0 ? MT_TRAINING : MT_NORMAL;
world.missionType = strncmp(world.id, "outpost", 7) == 0 ? MT_OUTPOST : world.missionType;
world.missionType = strncmp(world.id, "boss", 4) == 0 ? MT_BOSS : world.missionType;
loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring);