Use single variable to track mission type.
This commit is contained in:
parent
718b658a1a
commit
d71bee6b11
|
@ -215,6 +215,14 @@ enum
|
||||||
MS_COMPLETE
|
MS_COMPLETE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MT_NORMAL,
|
||||||
|
MT_TRAINING,
|
||||||
|
MT_OUTPOST,
|
||||||
|
MT_BOSS
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
WS_START,
|
WS_START,
|
||||||
|
|
|
@ -110,13 +110,13 @@ static void init(void)
|
||||||
|
|
||||||
static void tick(void)
|
static void tick(void)
|
||||||
{
|
{
|
||||||
if (world.isTrainingMission || dev.cheatHealth)
|
if (world.missionType == MT_TRAINING || dev.cheatHealth)
|
||||||
{
|
{
|
||||||
world.bob->alive = ALIVE_ALIVE;
|
world.bob->alive = ALIVE_ALIVE;
|
||||||
world.bob->health = world.bob->healthMax;
|
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);
|
world.bob->power = MIN(world.bob->power + 0.01, world.bob->powerMax);
|
||||||
}
|
}
|
||||||
|
@ -387,7 +387,7 @@ void stunBob(void)
|
||||||
|
|
||||||
static void applyDamage(int damage)
|
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)
|
if (world.bob->health < 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,7 +45,7 @@ Unit *createUnit(void)
|
||||||
|
|
||||||
u->canCarryItem = rand() % 100 < 85;
|
u->canCarryItem = rand() % 100 < 85;
|
||||||
|
|
||||||
if (world.isOutpostMission)
|
if (world.missionType == MT_OUTPOST)
|
||||||
{
|
{
|
||||||
u->canCarryItem = 1;
|
u->canCarryItem = 1;
|
||||||
u->health = u->healthMax = rrnd(1, 4);
|
u->health = u->healthMax = rrnd(1, 4);
|
||||||
|
|
|
@ -439,10 +439,8 @@ typedef struct {
|
||||||
int allObjectivesComplete;
|
int allObjectivesComplete;
|
||||||
int frameCounter;
|
int frameCounter;
|
||||||
int currentStatus;
|
int currentStatus;
|
||||||
int isTrainingMission;
|
int missionType;
|
||||||
int isBossMission;
|
|
||||||
int isBossActive;
|
int isBossActive;
|
||||||
int isOutpostMission;
|
|
||||||
int isReturnVisit;
|
int isReturnVisit;
|
||||||
int missionCompleteTimer;
|
int missionCompleteTimer;
|
||||||
int observationTimer;
|
int observationTimer;
|
||||||
|
|
|
@ -33,11 +33,13 @@ void initAtlasTest(void)
|
||||||
|
|
||||||
initHub();
|
initHub();
|
||||||
|
|
||||||
loadWorld("greenlands2");
|
loadWorld("greenlands4");
|
||||||
|
|
||||||
initWorld();
|
initWorld();
|
||||||
|
|
||||||
initMap();
|
initMap();
|
||||||
|
|
||||||
initEntities();
|
initEntities();
|
||||||
|
|
||||||
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,5 +26,6 @@ extern void initHub(void);
|
||||||
extern void initGame(void);
|
extern void initGame(void);
|
||||||
extern void initEntities(void);
|
extern void initEntities(void);
|
||||||
extern void loadWorld(char *id);
|
extern void loadWorld(char *id);
|
||||||
|
extern void saveConfig(void);
|
||||||
|
|
||||||
extern Dev dev;
|
extern Dev dev;
|
||||||
|
|
|
@ -61,7 +61,7 @@ static int getRandomPlayerWeaponAt(int x, int y)
|
||||||
{
|
{
|
||||||
int type;
|
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)
|
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)
|
else if (type == WPN_PISTOL && rand() % 100 < 25)
|
||||||
{
|
{
|
||||||
type = getRandomPlayerWeapon(world.isBossMission);
|
type = getRandomPlayerWeapon(world.missionType == MT_BOSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
|
|
@ -259,7 +259,7 @@ static void loadMapData(void)
|
||||||
{
|
{
|
||||||
sscanf(p, "%d", &i);
|
sscanf(p, "%d", &i);
|
||||||
|
|
||||||
if (!world.isOutpostMission)
|
if (world.missionType != MT_OUTPOST)
|
||||||
{
|
{
|
||||||
if (i >= 4 && i <= 7)
|
if (i >= 4 && i <= 7)
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,7 @@ void initWorld(void)
|
||||||
|
|
||||||
observationIndex = 0;
|
observationIndex = 0;
|
||||||
|
|
||||||
if (world.isBossMission)
|
if (world.missionType == MT_BOSS)
|
||||||
{
|
{
|
||||||
startMission();
|
startMission();
|
||||||
hideAllWidgets();
|
hideAllWidgets();
|
||||||
|
@ -390,7 +390,7 @@ static void doCommon(void)
|
||||||
spawnEnemies();
|
spawnEnemies();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isBossMission && --world.helperItemTimer <= 0)
|
if (world.missionType == MT_BOSS && --world.helperItemTimer <= 0)
|
||||||
{
|
{
|
||||||
addHelperItems();
|
addHelperItems();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,10 @@ void loadWorld(char *id)
|
||||||
STRNCPY(world.tileset, cJSON_GetObjectItem(root, "tileset")->valuestring, MAX_NAME_LENGTH);
|
STRNCPY(world.tileset, cJSON_GetObjectItem(root, "tileset")->valuestring, MAX_NAME_LENGTH);
|
||||||
STRNCPY(world.background, cJSON_GetObjectItem(root, "background")->valuestring, MAX_FILENAME_LENGTH);
|
STRNCPY(world.background, cJSON_GetObjectItem(root, "background")->valuestring, MAX_FILENAME_LENGTH);
|
||||||
world.entityCounter = cJSON_GetObjectItem(root, "entityCounter")->valueint;
|
world.entityCounter = cJSON_GetObjectItem(root, "entityCounter")->valueint;
|
||||||
world.isTrainingMission = strcmp(world.id, "beachApproach") == 0;
|
|
||||||
world.isBossMission = strncmp(world.id, "boss", 4) == 0;
|
world.missionType = strcmp(world.id, "beachApproach") == 0 ? MT_TRAINING : MT_NORMAL;
|
||||||
world.isOutpostMission = strncmp(world.id, "outpost", 7) == 0;
|
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);
|
loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue