diff --git a/dev/screenshots/v0.8-01.png b/dev/screenshots/v0.8-01.png new file mode 100644 index 0000000..0cf6f4b Binary files /dev/null and b/dev/screenshots/v0.8-01.png differ diff --git a/src/battle/ai.c b/src/battle/ai.c index ff6e7a0..413af13 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -961,6 +961,36 @@ static void wander(void) { self->aiActionTime = 0; } - - nextAction(); +} + +/* + * Used only for the optional missions, in Pandoran-controlled space. We can therefore hardcode the response. + */ +void checkSuspicionLevel(void) +{ + battle.hasSuspicionLevel = 0; + + if (self->side == player->side) + { + battle.hasSuspicionLevel = 1; + + /* raise if player is too far away */ + if (getDistance(self->x, self->y, player->x, player->y) > SCREEN_WIDTH / 2) + { + battle.suspicionLevel++; + } + + /* raise if there are active enemies */ + if (battle.numEnemies) + { + battle.suspicionLevel++; + } + + 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); + } + } } diff --git a/src/battle/ai.h b/src/battle/ai.h index 202f8ed..8d17606 100644 --- a/src/battle/ai.h +++ b/src/battle/ai.h @@ -39,6 +39,7 @@ 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 Battle battle; extern Colors colors; diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 9fa27e1..6c8627a 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -180,6 +180,11 @@ static void checkCollisions(Bullet *b) { battle.stats[STAT_ROCKETS_HIT]++; } + + if (battle.hasSuspicionLevel) + { + battle.suspicionLevel = MAX(0, battle.suspicionLevel - (MAX_SUSPICION_LEVEL * 0.01)); + } } if (e->flags & EF_IMMORTAL) diff --git a/src/battle/fighters.c b/src/battle/fighters.c index c5c8cb5..6835ff4 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -254,6 +254,11 @@ void doFighter(void) self->action = doAI; } } + + if (self->aiFlags & AIF_SUSPICIOUS) + { + checkSuspicionLevel(); + } } if (self->alive == ALIVE_ESCAPED) @@ -555,6 +560,11 @@ static void die(void) { battle.stats[STAT_ENEMIES_KILLED_PLAYER]++; + if (battle.hasSuspicionLevel) + { + battle.suspicionLevel = MAX(0, battle.suspicionLevel - (MAX_SUSPICION_LEVEL * 0.1)); + } + if (battle.isEpic) { battle.stats[STAT_EPIC_KILL_STREAK]++; diff --git a/src/battle/fighters.h b/src/battle/fighters.h index 31e328d..6e31834 100644 --- a/src/battle/fighters.h +++ b/src/battle/fighters.h @@ -51,6 +51,7 @@ extern char **toTypeArray(char *types, int *numTypes); extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); extern void awardTrophy(char *id); extern void addRandomItem(int x, int y); +extern void checkSuspicionLevel(void); extern Battle battle; extern Colors colors; diff --git a/src/battle/hud.c b/src/battle/hud.c index c355283..28dd899 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -31,6 +31,7 @@ static void drawPlayerSelect(void); static void drawAbilityBars(void); static void drawBoostECMBar(int current, int max, int x, int y, int r, int g, int b); static void drawHealthShieldBar(int current, int max, int x, int y, int r, int g, int b, int flashLow); +static void drawSuspicionLevel(void); static HudMessage hudMessageHead; static HudMessage *hudMessageTail; @@ -157,6 +158,11 @@ void drawHud(void) drawRadar(); drawRadarRangeWarning(); + + if (battle.hasSuspicionLevel) + { + drawSuspicionLevel(); + } } drawHudMessages(); @@ -577,6 +583,43 @@ static void drawPlayerSelect(void) blit(arrowRight, (SCREEN_WIDTH / 2) + 200, 520, 1); } +static void drawSuspicionLevel(void) +{ + SDL_Rect r; + + drawText((SCREEN_WIDTH / 2) - 150, SCREEN_HEIGHT - 60, 18, TA_RIGHT, colors.white, _("Suspicion")); + + r.x = (SCREEN_WIDTH / 2) - 140; + r.y = SCREEN_HEIGHT - 58; + r.w = 400; + r.h = 20; + + SDL_SetRenderDrawColor(app.renderer, 192, 192, 192, 255); + SDL_RenderDrawRect(app.renderer, &r); + + r.x += 2; + r.y += 2; + r.w -= 4; + r.h -= 4; + + r.w = (r.w / MAX_SUSPICION_LEVEL) * battle.suspicionLevel; + + if (battle.suspicionLevel < (MAX_SUSPICION_LEVEL * 0.5)) + { + SDL_SetRenderDrawColor(app.renderer, 255, 128, 0, 255); + } + else if (battle.suspicionLevel < (MAX_SUSPICION_LEVEL * 0.75)) + { + SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255); + } + else + { + SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255); + } + + SDL_RenderFillRect(app.renderer, &r); +} + void resetHud(void) { HudMessage *hudMessage; diff --git a/src/defs.h b/src/defs.h index 72f041a..336e761 100644 --- a/src/defs.h +++ b/src/defs.h @@ -129,6 +129,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define AIF_TARGET_FOCUS (2 << 16) #define AIF_DROPS_MINES (2 << 17) #define AIF_ASSASSIN (2 << 18) +#define AIF_SUSPICIOUS (2 << 19) /* player abilities */ #define BOOST_RECHARGE_TIME (FPS * 7) @@ -143,6 +144,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SS_SOL 1 #define SS_PANDORAN 2 +#define MAX_SUSPICION_LEVEL 5000.0 + enum { CONTROL_FIRE, diff --git a/src/structs.h b/src/structs.h index 70cbcf1..78c5361 100644 --- a/src/structs.h +++ b/src/structs.h @@ -350,6 +350,8 @@ typedef struct { int numObjectivesComplete, numObjectivesTotal, numConditions; int scriptedEnd; int hasThreats; + int hasSuspicionLevel; + int suspicionLevel; Entity *missionTarget; Entity *jumpgate; Entity *messageSpeaker; diff --git a/src/system/lookup.c b/src/system/lookup.c index 5c94fad..1487038 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -90,6 +90,7 @@ void initLookups(void) addLookup("AIF_TARGET_FOCUS", AIF_TARGET_FOCUS); addLookup("AIF_DROPS_MINES", AIF_DROPS_MINES); addLookup("AIF_ASSASSIN", AIF_ASSASSIN); + addLookup("AIF_SUSPICIOUS", AIF_SUSPICIOUS); addLookup("DT_ANY", DT_ANY); addLookup("DT_NO_SPIN", DT_NO_SPIN);