Integrated waypoints into objective system.
This commit is contained in:
parent
49832b114b
commit
5c7b2a24bf
|
@ -4,6 +4,14 @@
|
|||
"background" : "gfx/backgrounds/background03.jpg",
|
||||
"planet" : "gfx/planets/spirit.png",
|
||||
"music" : "",
|
||||
"objectives" : [
|
||||
{
|
||||
"description" : "Reach Waypoints",
|
||||
"targetName" : "Waypoint",
|
||||
"targetValue" : 5,
|
||||
"targetType" : "TT_WAYPOINT"
|
||||
}
|
||||
],
|
||||
"player" : {
|
||||
"type" : "Nymph",
|
||||
"side" : "SIDE_CSN"
|
||||
|
@ -17,14 +25,13 @@
|
|||
"y" : 200
|
||||
}
|
||||
],
|
||||
"entitiesGroups" : [
|
||||
"entityGroups" : [
|
||||
{
|
||||
"name" : "Waypoint",
|
||||
"type" : "ET_WAYPOINT",
|
||||
"number" : 10,
|
||||
"x" : 640,
|
||||
"y" : -10000,
|
||||
"scatter" : 10000
|
||||
"number" : 5,
|
||||
"x" : 0,
|
||||
"y" : 1000,
|
||||
"scatter" : 1000
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ static void findTarget(void)
|
|||
|
||||
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
|
||||
{
|
||||
if (f->type == ET_FIGHTER && f->side != self->side && f->health > 0 && canAttack(f))
|
||||
if (f->active && f->type == ET_FIGHTER && f->side != self->side && f->health > 0 && canAttack(f))
|
||||
{
|
||||
dist = getDistance(self->x, self->y, f->x, f->y);
|
||||
if (dist < closest)
|
||||
|
@ -257,7 +257,7 @@ static int hasClearShot(void)
|
|||
|
||||
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
|
||||
{
|
||||
if (f != self && f != self->target && (getDistance(self->x, self->y, f->x, f->y) < dist))
|
||||
if (f->active && f != self && f != self->target && (getDistance(self->x, self->y, f->x, f->y) < dist))
|
||||
{
|
||||
if (isInFOV(f, 8))
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ void initBattle(void)
|
|||
|
||||
initMissionInfo();
|
||||
|
||||
resetWaypoints();
|
||||
|
||||
show = SHOW_BATTLE;
|
||||
|
||||
getWidget("ok", "startBattle")->action = start;
|
||||
|
|
|
@ -61,6 +61,7 @@ extern void initOptions(void (*returnFromOptions)(void));
|
|||
extern void drawOptions(void);
|
||||
extern void playSound(int id);
|
||||
extern void checkTrigger(char *name, int type);
|
||||
extern void resetWaypoints(void);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -101,6 +101,11 @@ static void checkCollisions(Bullet *b)
|
|||
|
||||
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
|
||||
{
|
||||
if (!f->active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (f->type == ET_FIGHTER)
|
||||
{
|
||||
SDL_QueryTexture(f->texture, NULL, NULL, &ew, &eh);
|
||||
|
|
|
@ -28,6 +28,7 @@ Entity *spawnEntity(void)
|
|||
Entity *e = malloc(sizeof(Entity));
|
||||
memset(e, 0, sizeof(Entity));
|
||||
e->id = battle.entId++;
|
||||
e->active = 1;
|
||||
|
||||
battle.entityTail->next = e;
|
||||
battle.entityTail = e;
|
||||
|
@ -45,6 +46,11 @@ void doEntities(void)
|
|||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (!e->active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
self = e;
|
||||
|
||||
if (self->target != NULL && self->target->health <= 0)
|
||||
|
@ -71,7 +77,7 @@ void doEntities(void)
|
|||
}
|
||||
}
|
||||
|
||||
switch (e->type)
|
||||
switch (self->type)
|
||||
{
|
||||
case ET_FIGHTER:
|
||||
doFighter(prev);
|
||||
|
@ -112,6 +118,11 @@ void drawEntities(void)
|
|||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (!e->active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (e->type)
|
||||
{
|
||||
case ET_FIGHTER:
|
||||
|
|
|
@ -76,6 +76,8 @@ static void loadFighterDef(char *filename)
|
|||
defTail->next = f;
|
||||
defTail = f;
|
||||
|
||||
f->active = 1;
|
||||
|
||||
root = cJSON_Parse(text);
|
||||
|
||||
STRNCPY(f->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
|
|
|
@ -282,7 +282,7 @@ static void separate(void)
|
|||
|
||||
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
|
||||
{
|
||||
if (f != self)
|
||||
if (f != self && f->active)
|
||||
{
|
||||
distance = getDistance(f->x, f->y, self->x, self->y);
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ static void drawHealthBars(void);
|
|||
static void drawWeaponInfo(void);
|
||||
static void drawObjectives(void);
|
||||
static void drawTargetDistance(void);
|
||||
static void drawMissionTargetDistance(void);
|
||||
static void drawHudMessages(void);
|
||||
|
||||
static HudMessage hudMessageHead;
|
||||
|
@ -165,6 +166,11 @@ static void drawHealthBars(void)
|
|||
drawHealthShieldBar(player->target->shield, player->target->maxShield, SCREEN_WIDTH - 260, 30, 0, 200, 255);
|
||||
drawTargetDistance();
|
||||
}
|
||||
|
||||
if (battle.missionTarget)
|
||||
{
|
||||
drawMissionTargetDistance();
|
||||
}
|
||||
}
|
||||
|
||||
static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g, int b)
|
||||
|
@ -214,6 +220,20 @@ static void drawPlayerTargeter(void)
|
|||
float angle;
|
||||
int x, y;
|
||||
|
||||
if (player->target || battle.missionTarget)
|
||||
{
|
||||
if (player->target)
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle, 255, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetTextureColorMod(targetCircle, 0, 255, 0);
|
||||
}
|
||||
|
||||
blit(targetCircle, player->x, player->y, 1);
|
||||
}
|
||||
|
||||
if (player->target)
|
||||
{
|
||||
angle = getAngle(player->x, player->y, player->target->x, player->target->y);
|
||||
|
@ -224,10 +244,8 @@ static void drawPlayerTargeter(void)
|
|||
y += -cos(TO_RAIDANS(angle)) * 45;
|
||||
|
||||
SDL_SetTextureColorMod(targetPointer, 255, 0, 0);
|
||||
SDL_SetTextureColorMod(targetCircle, 255, 0, 0);
|
||||
|
||||
blitRotated(targetPointer, x, y, angle);
|
||||
blitRotated(targetCircle, player->x, player->y, angle);
|
||||
}
|
||||
|
||||
if (battle.missionTarget)
|
||||
|
@ -277,6 +295,11 @@ static void drawTargetDistance(void)
|
|||
|
||||
drawText(SCREEN_WIDTH - 15, 50, 14, TA_RIGHT, colors.red, "Target: %.2fkm", distance);
|
||||
}
|
||||
}
|
||||
|
||||
static void drawMissionTargetDistance(void)
|
||||
{
|
||||
float distance;
|
||||
|
||||
if (battle.missionTarget != NULL)
|
||||
{
|
||||
|
|
|
@ -148,6 +148,11 @@ static void selectTarget(void)
|
|||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (!e->active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e != player && e->type == ET_FIGHTER && e->side != player->side && e->alive == ALIVE_ALIVE)
|
||||
{
|
||||
dist = getDistance(self->x, self->y, e->x, e->y);
|
||||
|
@ -170,6 +175,11 @@ static void selectMissionTarget(void)
|
|||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (!e->active)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (e->flags & EF_MISSION_TARGET && e->alive == ALIVE_ALIVE)
|
||||
{
|
||||
if (battle.missionTarget == NULL)
|
||||
|
|
|
@ -36,7 +36,7 @@ void drawRadar(void)
|
|||
|
||||
for (f = battle.entityHead.next ; f != NULL ; f = f->next)
|
||||
{
|
||||
if (getDistance(f->x, f->y, player->x, player->y) / RADAR_RANGE < 70)
|
||||
if (f->active && getDistance(f->x, f->y, player->x, player->y) / RADAR_RANGE < 70)
|
||||
{
|
||||
r.x = SCREEN_WIDTH - 85;
|
||||
r.y = SCREEN_HEIGHT - 85;
|
||||
|
|
|
@ -22,12 +22,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static void think(void);
|
||||
static int teamMatesClose(void);
|
||||
void activateNextWaypoint(int id);
|
||||
|
||||
static int waypointId;
|
||||
|
||||
void resetWaypoints(void)
|
||||
{
|
||||
waypointId = 1;
|
||||
}
|
||||
|
||||
Entity *spawnWaypoint(void)
|
||||
{
|
||||
Entity *waypoint = spawnEntity();
|
||||
|
||||
sprintf(waypoint->name, "Waypoint #%d", waypointId++);
|
||||
waypoint->type = ET_WAYPOINT;
|
||||
waypoint->active = 0;
|
||||
waypoint->health = waypoint->maxHealth = FPS;
|
||||
waypoint->texture = getTexture("gfx/entities/waypoint.png");
|
||||
waypoint->flags = EF_MISSION_TARGET;
|
||||
|
@ -43,12 +53,18 @@ static void think(void)
|
|||
self->angle++;
|
||||
if (self->angle >= 360)
|
||||
{
|
||||
self -= 360;
|
||||
self->angle -= 360;
|
||||
}
|
||||
|
||||
if (getDistance(player->x, player->y, self->x, self->y) <= 32 && teamMatesClose())
|
||||
{
|
||||
self->health = 0;
|
||||
|
||||
updateObjective("Waypoint", TT_WAYPOINT);
|
||||
|
||||
checkTrigger(self->name, TRIGGER_WAYPOINT);
|
||||
|
||||
activateNextWaypoint(self->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +74,7 @@ static int teamMatesClose(void)
|
|||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (e->type == ET_FIGHTER && e->side == player->side)
|
||||
if (e->active && e->type == ET_FIGHTER && e->side == player->side)
|
||||
{
|
||||
if (getDistance(player->x, player->y, e->x, e->y) > 350)
|
||||
{
|
||||
|
@ -71,3 +87,22 @@ static int teamMatesClose(void)
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void activateNextWaypoint(int id)
|
||||
{
|
||||
Entity *e;
|
||||
Entity *nextWaypoint = NULL;
|
||||
|
||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||
{
|
||||
if (e->type == ET_WAYPOINT && e->id > id && (nextWaypoint == NULL || e->id < nextWaypoint->id))
|
||||
{
|
||||
nextWaypoint = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextWaypoint != NULL)
|
||||
{
|
||||
nextWaypoint->active = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ extern SDL_Texture *getTexture(char *filename);
|
|||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||
extern Entity *spawnEntity(void);
|
||||
extern void updateObjective(char *name, int type);
|
||||
extern void checkTrigger(char *name, int type);
|
||||
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -56,7 +56,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define EF_DISABLE (2 << 1)
|
||||
#define EF_IMMORTAL (2 << 2)
|
||||
#define EF_MISSION_TARGET (2 << 3)
|
||||
#define EF_INVISIBLE (2 << 4)
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -147,13 +146,15 @@ enum
|
|||
enum
|
||||
{
|
||||
TT_DESTROY,
|
||||
TT_DISABLE
|
||||
TT_DISABLE,
|
||||
TT_WAYPOINT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TRIGGER_TIME,
|
||||
TRIGGER_KILLS
|
||||
TRIGGER_KILLS,
|
||||
TRIGGER_WAYPOINT
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -83,6 +83,7 @@ void loadMission(char *filename)
|
|||
battle.status = MS_IN_PROGRESS;
|
||||
}
|
||||
|
||||
activateNextWaypoint();
|
||||
|
||||
initPlayer();
|
||||
|
||||
|
@ -272,7 +273,11 @@ static void loadEntities(cJSON *node)
|
|||
break;
|
||||
}
|
||||
|
||||
STRNCPY(e->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
if (cJSON_GetObjectItem(node, "name"))
|
||||
{
|
||||
STRNCPY(e->name, cJSON_GetObjectItem(node, "name")->valuestring, MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
e->x = cJSON_GetObjectItem(node, "x")->valueint;
|
||||
e->y = cJSON_GetObjectItem(node, "y")->valueint;
|
||||
|
||||
|
@ -291,10 +296,8 @@ static void loadEntityGroups(cJSON *node)
|
|||
Entity *e;
|
||||
char *name;
|
||||
int i, type, x, y, scatter, number;
|
||||
long flags;
|
||||
|
||||
scatter = 1;
|
||||
flags = 0;
|
||||
|
||||
if (node)
|
||||
{
|
||||
|
@ -303,14 +306,18 @@ static void loadEntityGroups(cJSON *node)
|
|||
while (node)
|
||||
{
|
||||
type = lookup(cJSON_GetObjectItem(node, "type")->valuestring);
|
||||
name = cJSON_GetObjectItem(node, "name")->valuestring;
|
||||
number = cJSON_GetObjectItem(node, "number")->valueint;
|
||||
x = cJSON_GetObjectItem(node, "x")->valueint;
|
||||
y = cJSON_GetObjectItem(node, "y")->valueint;
|
||||
|
||||
if (cJSON_GetObjectItem(node, "flags"))
|
||||
if (cJSON_GetObjectItem(node, "name"))
|
||||
{
|
||||
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring);
|
||||
name = cJSON_GetObjectItem(node, "name")->valuestring;
|
||||
}
|
||||
|
||||
if (cJSON_GetObjectItem(node, "scatter"))
|
||||
{
|
||||
scatter = cJSON_GetObjectItem(node, "scatter")->valueint;
|
||||
}
|
||||
|
||||
for (i = 0 ; i < number ; i++)
|
||||
|
@ -322,11 +329,14 @@ static void loadEntityGroups(cJSON *node)
|
|||
break;
|
||||
}
|
||||
|
||||
STRNCPY(e->name, name, MAX_NAME_LENGTH);
|
||||
if (name)
|
||||
{
|
||||
STRNCPY(e->name, name, MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
e->id = battle.entId++;
|
||||
e->x = x;
|
||||
e->y = y;
|
||||
e->flags = flags;
|
||||
|
||||
e->x += (rand() % scatter) - (rand() % scatter);
|
||||
e->y += (rand() % scatter) - (rand() % scatter);
|
||||
|
|
|
@ -36,6 +36,7 @@ extern void stopMusic(void);
|
|||
extern void initPlayer(void);
|
||||
extern long flagsToLong(char *flags);
|
||||
extern Entity *spawnWaypoint(void);
|
||||
extern void activateNextWaypoint(void);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *player;
|
||||
|
|
|
@ -71,6 +71,7 @@ struct Weapon {
|
|||
struct Entity {
|
||||
int type;
|
||||
char name[MAX_NAME_LENGTH];
|
||||
int active;
|
||||
int id;
|
||||
int side;
|
||||
float x;
|
||||
|
|
|
@ -39,6 +39,7 @@ void initLookups(void)
|
|||
|
||||
addLookup("TT_DESTROY", TT_DESTROY);
|
||||
addLookup("TT_DISABLE", TT_DISABLE);
|
||||
addLookup("TT_WAYPOINT", TT_WAYPOINT);
|
||||
|
||||
addLookup("WT_BUTTON", WT_BUTTON);
|
||||
addLookup("WT_SELECT", WT_SELECT);
|
||||
|
|
Loading…
Reference in New Issue