Experimental new gameplay features.
This commit is contained in:
parent
5be325fe9f
commit
6b768b4554
|
@ -33,5 +33,10 @@
|
|||
"CONTROL_NEXT_FIGHTER" : 5,
|
||||
"CONTROL_SCREENSHOT" : 0
|
||||
}
|
||||
},
|
||||
"gameplay" : {
|
||||
"friendlyFire" : 0,
|
||||
"autoSwitchPlayerTarget" : 0,
|
||||
"missileReTarget" : 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
static void huntTarget(Bullet *b);
|
||||
static void checkCollisions(Bullet *b);
|
||||
static void resizeDrawList(void);
|
||||
static void selectNewTarget(Bullet *b);
|
||||
|
||||
static Bullet bulletDef[BT_MAX];
|
||||
static Bullet **bulletsToDraw;
|
||||
|
@ -165,7 +166,7 @@ static void checkCollisions(Bullet *b)
|
|||
|
||||
if (b->owner != e && e->health > 0 && collision(b->x - b->w / 2, b->y - b->h / 2, b->w, b->h, e->x - e->w / 2, e->y - e->h / 2, e->w, e->h))
|
||||
{
|
||||
if (b->owner->side == e->side)
|
||||
if (b->owner->side == e->side && !app.gameplay.friendlyFire)
|
||||
{
|
||||
b->damage = 0;
|
||||
}
|
||||
|
@ -325,7 +326,35 @@ static void huntTarget(Bullet *b)
|
|||
}
|
||||
else
|
||||
{
|
||||
b->target = NULL;
|
||||
selectNewTarget(b);
|
||||
}
|
||||
}
|
||||
|
||||
static void selectNewTarget(Bullet *b)
|
||||
{
|
||||
int i;
|
||||
Entity *e, **candidates;
|
||||
|
||||
b->target = NULL;
|
||||
|
||||
candidates = getAllEntsWithin(b->x - (SCREEN_WIDTH / 2), b->y - (SCREEN_HEIGHT / 2), SCREEN_WIDTH, SCREEN_HEIGHT, NULL);
|
||||
|
||||
if (app.gameplay.missileReTarget)
|
||||
{
|
||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||
{
|
||||
if (e->type == ET_FIGHTER && e->side != b->owner->side && e->health > 0)
|
||||
{
|
||||
b->target = e;
|
||||
|
||||
if (b->target == player)
|
||||
{
|
||||
playSound(SND_INCOMING);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,7 +458,7 @@ void fireMissile(Entity *owner)
|
|||
|
||||
playBattleSound(b->sound, owner->x, owner->y);
|
||||
|
||||
if (owner->target == player)
|
||||
if (b->target == player)
|
||||
{
|
||||
playSound(SND_INCOMING);
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ extern void awardTrophy(char *id);
|
|||
extern int isOnBattleScreen(int x, int y, int w, int h);
|
||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
|
|
|
@ -35,6 +35,7 @@ static void handleMouse(void);
|
|||
static void preFireMissile(void);
|
||||
static void applyRestrictions(void);
|
||||
static int isPriorityMissionTarget(Entity *e, int dist, int closest);
|
||||
static int targetOutOfRange(void);
|
||||
|
||||
static int selectedPlayerIndex;
|
||||
static int availableGuns[BT_MAX];
|
||||
|
@ -107,7 +108,7 @@ void doPlayer(void)
|
|||
|
||||
handleMouse();
|
||||
|
||||
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0)
|
||||
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || targetOutOfRange())
|
||||
{
|
||||
selectTarget();
|
||||
}
|
||||
|
@ -159,6 +160,11 @@ void doPlayer(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int targetOutOfRange(void)
|
||||
{
|
||||
return (app.gameplay.autoSwitchPlayerTarget && getDistance(player->x, player->y, player->target->x, player->target->y) > SCREEN_WIDTH * 2);
|
||||
}
|
||||
|
||||
static void applyRestrictions(void)
|
||||
{
|
||||
if (game.currentMission->challengeData.noMissiles)
|
||||
|
|
|
@ -383,6 +383,12 @@ struct Trophy {
|
|||
Trophy *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int friendlyFire;
|
||||
int autoSwitchPlayerTarget;
|
||||
int missileReTarget;
|
||||
} Gameplay;
|
||||
|
||||
typedef struct {
|
||||
StarSystem starSystemHead;
|
||||
Mission challengeMissionHead;
|
||||
|
@ -453,6 +459,7 @@ typedef struct {
|
|||
int fullscreen;
|
||||
int musicVolume;
|
||||
int soundVolume;
|
||||
Gameplay gameplay;
|
||||
Mouse mouse;
|
||||
int keyboard[MAX_KEYBOARD_KEYS];
|
||||
SDL_Texture *backBuffer;
|
||||
|
|
|
@ -216,12 +216,15 @@ static void loadConfig(void)
|
|||
{
|
||||
loadConfigFile(configFilename);
|
||||
}
|
||||
|
||||
/* so that the player doesn't get confused if this is a new game */
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
static void loadConfigFile(char *filename)
|
||||
{
|
||||
int i;
|
||||
cJSON *root, *controlsJSON, *node;
|
||||
cJSON *root, *controlsJSON, *node, *gameplayJSON;
|
||||
char *text;
|
||||
|
||||
text = readFile(filename);
|
||||
|
@ -257,19 +260,24 @@ static void loadConfigFile(char *filename)
|
|||
node = node->next;
|
||||
}
|
||||
}
|
||||
|
||||
gameplayJSON = cJSON_GetObjectItem(root, "gameplay");
|
||||
if (gameplayJSON)
|
||||
{
|
||||
app.gameplay.friendlyFire = cJSON_GetObjectItem(gameplayJSON, "friendlyFire")->valueint;
|
||||
app.gameplay.autoSwitchPlayerTarget = cJSON_GetObjectItem(gameplayJSON, "autoSwitchPlayerTarget")->valueint;
|
||||
app.gameplay.missileReTarget = cJSON_GetObjectItem(gameplayJSON, "missileReTarget")->valueint;
|
||||
}
|
||||
|
||||
cJSON_Delete(root);
|
||||
free(text);
|
||||
|
||||
/* so that the player doesn't get confused if this is a new game */
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
void saveConfig(void)
|
||||
{
|
||||
int i;
|
||||
char *out, *configFilename;
|
||||
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON;
|
||||
cJSON *root, *controlsJSON, *keysJSON, *mouseJSON, *gameplayJSON;
|
||||
|
||||
configFilename = getSaveFilePath(CONFIG_FILENAME);
|
||||
|
||||
|
@ -297,8 +305,13 @@ void saveConfig(void)
|
|||
controlsJSON = cJSON_CreateObject();
|
||||
cJSON_AddItemToObject(controlsJSON, "keys", keysJSON);
|
||||
cJSON_AddItemToObject(controlsJSON, "mouse", mouseJSON);
|
||||
|
||||
cJSON_AddItemToObject(root, "controls", controlsJSON);
|
||||
|
||||
gameplayJSON = cJSON_CreateObject();
|
||||
cJSON_AddNumberToObject(gameplayJSON, "friendlyFire", app.gameplay.friendlyFire);
|
||||
cJSON_AddNumberToObject(gameplayJSON, "autoSwitchPlayerTarget", app.gameplay.autoSwitchPlayerTarget);
|
||||
cJSON_AddNumberToObject(gameplayJSON, "missileReTarget", app.gameplay.missileReTarget);
|
||||
cJSON_AddItemToObject(root, "gameplay", gameplayJSON);
|
||||
|
||||
out = cJSON_Print(root);
|
||||
|
||||
|
|
Loading…
Reference in New Issue