Allow waypoints to be manually activated. Removed entId from Battle (redundant).

This commit is contained in:
Steve 2016-04-04 11:23:32 +01:00
parent 77da136e75
commit 29d873d28a
15 changed files with 36 additions and 44 deletions

View File

@ -6,6 +6,7 @@
"planet" : "gfx/planets/torelli.png",
"music" : "music/battle/heroism.ogg",
"manualComplete" : 1,
"waypointAutoAdvance" : 1,
"objectives" : [
{
"description" : "Check all waypoints",
@ -42,12 +43,6 @@
}
],
"script" : [
{
"function" : "TIME 0",
"lines" : [
"ACTIVATE_NEXT_WAYPOINT"
]
},
{
"function" : "Waypoint #2",
"lines" : [

View File

@ -6,6 +6,7 @@
"planet" : "gfx/planets/torelli.png",
"music" : "music/battle/heroism.ogg",
"manualComplete" : 1,
"waypointAutoAdvance" : 1,
"objectives" : [
{
"description" : "Check all Waypoints",
@ -59,12 +60,6 @@
}
],
"script" : [
{
"function" : "TIME 0",
"lines" : [
"ACTIVATE_NEXT_WAYPOINT"
]
},
{
"function" : "Waypoint #3",
"lines" : [

View File

@ -9,6 +9,7 @@
"planet" : "gfx/planets/torelli.png",
"music" : "",
"manualComplete" : 1,
"waypointAutoAdvance" : 1,
"objectives" : [
{
"description" : "Check all Waypoints",
@ -45,12 +46,6 @@
}
],
"script" : [
{
"function" : "TIME 0",
"lines" : [
"ACTIVATE_NEXT_WAYPOINT"
]
},
{
"function" : "TIME 3",
"lines" : [

View File

@ -6,6 +6,7 @@
"planet" : "gfx/planets/bluePlanet.png",
"music" : "music/battle/determination.mp3",
"manualComplete" : 1,
"waypointAutoAdvance" : 1,
"objectives" : [
{
"description" : "Check all wayponts",
@ -126,12 +127,6 @@
}
],
"script" : [
{
"function" : "TIME 0",
"lines" : [
"ACTIVATE_NEXT_WAYPOINT"
]
},
{
"function" : "Waypoint #2",
"lines" : [

View File

@ -6,6 +6,7 @@
"planet" : "gfx/planets/bluePlanet.png",
"music" : "music/battle/determination.mp3",
"manualComplete" : 1,
"waypointAutoAdvance" : 1,
"player" : {
"pilot" : "Lt. Cdr. Daniel Carr",
"squadron" : "Iron Patriots",
@ -126,12 +127,6 @@
}
],
"script" : [
{
"function" : "TIME 0",
"lines" : [
"ACTIVATE_NEXT_WAYPOINT"
]
},
{
"function" : "Waypoint #1",
"lines" : [

View File

@ -50,7 +50,6 @@ Entity *spawnCapitalShip(char *name, int x, int y, int side)
memcpy(e, def, sizeof(Entity));
e->id = battle.entId;
e->next = NULL;
e->x = x;

View File

@ -59,7 +59,6 @@ Entity *spawnEntity(void)
{
Entity *e = malloc(sizeof(Entity));
memset(e, 0, sizeof(Entity));
e->id = battle.entId++;
e->active = 1;
battle.entityTail->next = e;
@ -291,7 +290,7 @@ static void resizeDrawList(void)
n = drawCapacity + INITIAL_ENTITY_DRAW_CAPACITY;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing entity draw capacity: %d -> %d\n", drawCapacity, n);
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing entity draw capacity: %d -> %d", drawCapacity, n);
entsToDraw = resize(entsToDraw, sizeof(Entity*) * drawCapacity, sizeof(Entity*) * n);

View File

@ -44,7 +44,6 @@ Entity *spawnFighter(char *name, int x, int y, int side)
memcpy(e, def, sizeof(Entity));
e->id = battle.entId;
e->next = NULL;
e->x = x;
@ -276,7 +275,7 @@ void doFighter(void)
if (self->alive == ALIVE_DEAD)
{
if (player != NULL && self == player)
if (player != NULL && self != player)
{
if (player->alive == ALIVE_ALIVE)
{

View File

@ -564,7 +564,7 @@ static void selectMissionTarget(void)
closest = dist;
}
}
else if (battle.missionTarget->type == ET_WAYPOINT && e->type == ET_WAYPOINT && e->id < battle.missionTarget->id)
else if (battle.missionTarget->type == ET_WAYPOINT && e->type == ET_WAYPOINT && e->id == battle.missionTarget->id)
{
battle.missionTarget = e;
}

View File

@ -162,7 +162,7 @@ static void executeNextLine(ScriptRunner *runner)
}
else if (strcmp(command, "ACTIVATE_NEXT_WAYPOINT") == 0)
{
activateNextWaypoint(0);
activateNextWaypoint();
}
else if (strcmp(command, "ACTIVATE_SPAWNERS") == 0)
{

View File

@ -34,7 +34,7 @@ extern void activateLocations(char *locations);
void activateObjectives(char *objectives);
extern int showingMessageBoxes(void);
extern char *getTranslatedString(char *string);
extern void activateNextWaypoint(int id);
extern void activateNextWaypoint(void);
extern void activateJumpgate(int activate);
extern void activateSpawner(char *name, int active);

View File

@ -23,20 +23,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void think(void);
static int teamMatesClose(void);
static int isCurrentObjective(void);
void activateNextWaypoint(int id);
void activateNextWaypoint(void);
static int waypointId;
static int currentWaypointId;
void resetWaypoints(void)
{
waypointId = 1;
currentWaypointId = 0;
}
Entity *spawnWaypoint(void)
{
Entity *waypoint = spawnEntity();
sprintf(waypoint->name, "Waypoint #%d", waypointId++);
sprintf(waypoint->name, "Waypoint #%d", waypointId);
waypoint->id = waypointId;
waypoint->type = ET_WAYPOINT;
waypoint->active = 0;
waypoint->health = waypoint->maxHealth = FPS;
@ -47,6 +50,8 @@ Entity *spawnWaypoint(void)
SDL_QueryTexture(waypoint->texture, NULL, NULL, &waypoint->w, &waypoint->h);
waypointId++;
return waypoint;
}
@ -71,7 +76,10 @@ static void think(void)
runScriptFunction(self->name);
activateNextWaypoint(self->id);
if (battle.waypointAutoAdvance)
{
activateNextWaypoint();
}
battle.stats[STAT_WAYPOINTS_VISITED]++;
}
@ -112,14 +120,16 @@ static int teamMatesClose(void)
return 1;
}
void activateNextWaypoint(int id)
void activateNextWaypoint(void)
{
Entity *e;
Entity *nextWaypoint = NULL;
currentWaypointId++;
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
if (e->type == ET_WAYPOINT && e->id > id && (nextWaypoint == NULL || e->id < nextWaypoint->id))
if (e->type == ET_WAYPOINT && e->id == currentWaypointId)
{
nextWaypoint = e;
}
@ -128,5 +138,7 @@ void activateNextWaypoint(int id)
if (nextWaypoint != NULL)
{
nextWaypoint->active = 1;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Activating %s", nextWaypoint->name);
}
}

View File

@ -167,6 +167,7 @@ void loadMission(char *filename)
battle.manualComplete = getJSONValue(root, "manualComplete", 0);
battle.unwinnable = getJSONValue(root, "unwinnable", 0);
battle.waypointAutoAdvance = getJSONValue(root, "waypointAutoAdvance", 0);
initScript(cJSON_GetObjectItem(root, "script"));
@ -218,6 +219,11 @@ void loadMission(char *filename)
{
battle.status = MS_IN_PROGRESS;
}
if (battle.waypointAutoAdvance)
{
activateNextWaypoint();
}
countNumEnemies();
@ -350,6 +356,7 @@ static void loadEntities(cJSON *node)
{
case ET_WAYPOINT:
e = spawnWaypoint();
active = 0;
break;
case ET_JUMPGATE:

View File

@ -58,6 +58,7 @@ extern void loadItems(cJSON *node);
extern void loadLocations(cJSON *node);
extern void loadSpawners(cJSON *node);
extern Entity *spawnMine(void);
extern void activateNextWaypoint(void);
extern Battle battle;
extern Dev dev;

View File

@ -325,7 +325,6 @@ struct Spawner {
};
typedef struct {
int entId;
SDL_Point camera;
int numAllies;
int numEnemies;
@ -336,6 +335,7 @@ typedef struct {
int playerSelect;
int manualComplete;
int unwinnable;
int waypointAutoAdvance;
int missionFinishedTimer;
int boostTimer;
int ecmTimer;