From 0a2e5ae1df91fd53e91a489fc737151bd2dfcb85 Mon Sep 17 00:00:00 2001 From: Cong Date: Tue, 30 Jan 2024 22:41:46 +1100 Subject: [PATCH] Autosave score #71 Adjust cyberdogs enemy density --- .../techdemo/cyberdogs.cdogscpn/missions.json | 18 +++++++++--------- src/autosave.c | 7 +++++++ src/autosave.h | 1 + src/briefing_screens.c | 16 ++++++++-------- src/cdogs/player.c | 1 - 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/missions/custom/techdemo/cyberdogs.cdogscpn/missions.json b/missions/custom/techdemo/cyberdogs.cdogscpn/missions.json index 3067fa195..3aee03124 100644 --- a/missions/custom/techdemo/cyberdogs.cdogscpn/missions.json +++ b/missions/custom/techdemo/cyberdogs.cdogscpn/missions.json @@ -302,7 +302,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 40, + "EnemyDensity": 30, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -499,7 +499,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 50, + "EnemyDensity": 37, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -697,7 +697,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 55, + "EnemyDensity": 42, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -910,7 +910,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 13, + "EnemyDensity": 0, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -1116,7 +1116,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 13, + "EnemyDensity": 0, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -1326,7 +1326,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 65, + "EnemyDensity": 50, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -1541,7 +1541,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 13, + "EnemyDensity": 0, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -1738,7 +1738,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 70, + "EnemyDensity": 57, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", @@ -1941,7 +1941,7 @@ "Pickup": "life", "Count": 2 }], - "EnemyDensity": 80, + "EnemyDensity": 64, "Weapons": ["Fists", "Chainsaw", "2xChainsaw", diff --git a/src/autosave.c b/src/autosave.c index 2b18fe404..60046ddfb 100644 --- a/src/autosave.c +++ b/src/autosave.c @@ -150,6 +150,7 @@ static void LoadPlayersNode(CArray *players, json_t *node) LoadInt(&ps.Lives, child, "Lives"); LoadInt(&ps.HP, child, "HP"); + LoadInt(&ps.Score, child, "Score"); CArrayPushBack(players, &ps); } @@ -171,6 +172,7 @@ static void AddPlayersNode(CArray *players, json_t *root) AddIntArray(playerNode, "Ammo", &ps->ammo); AddIntPair(playerNode, "Lives", ps->Lives); AddIntPair(playerNode, "HP", ps->HP); + AddIntPair(playerNode, "Score", ps->Score); json_insert_child(playersNode, playerNode); CA_FOREACH_END() @@ -375,6 +377,7 @@ void AutosaveAdd( CArrayCopy(&ps.ammo, &pd->ammo); ps.Lives = pd->Lives; ps.HP = pd->HP; + ps.Score = pd->Totals.Score; CArrayPushBack(&ms.Players, &ps); CA_FOREACH_END() AutosaveAddCampaign(a, &ms); @@ -475,5 +478,9 @@ void PlayerSavesApply(const CArray *playerSaves, const bool weaponPersist) { p->HP = ps->HP; } + if (ps->Score > 0) + { + p->Totals.Score = ps->Score; + } } } diff --git a/src/autosave.h b/src/autosave.h index fe8ea28d6..7209843b1 100644 --- a/src/autosave.h +++ b/src/autosave.h @@ -42,6 +42,7 @@ typedef struct CArray ammo; // of int int Lives; int HP; + int Score; } PlayerSave; typedef struct { diff --git a/src/briefing_screens.c b/src/briefing_screens.c index 30e843c2e..c770c888e 100644 --- a/src/briefing_screens.c +++ b/src/briefing_screens.c @@ -472,14 +472,6 @@ static void MissionSummaryOnEnter(GameLoopData *data) { MissionSummaryData *mData = data->Data; - if (mData->completed && CanLevelSelect(mData->c->Entry.Mode)) - { - AutosaveAdd( - &gAutosave, &mData->c->Entry, mData->m->index, - mData->m->NextMission, &gPlayerDatas); - AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); - } - // Calculate bonus scores // Bonuses only apply if at least one player has lived const int accessBonus = GetAccessBonus(mData->m); @@ -501,6 +493,14 @@ static void MissionSummaryOnEnter(GameLoopData *data) p->Totals.TimeTicks += mData->m->time; CA_FOREACH_END() } + + if (mData->completed && CanLevelSelect(mData->c->Entry.Mode)) + { + AutosaveAdd( + &gAutosave, &mData->c->Entry, mData->m->index, + mData->m->NextMission, &gPlayerDatas); + AutosaveSave(&gAutosave, GetConfigFilePath(AUTOSAVE_FILE)); + } // Skip menu if (mData->m->missionData->SkipDebrief) diff --git a/src/cdogs/player.c b/src/cdogs/player.c index ebc00067b..ce8610713 100644 --- a/src/cdogs/player.c +++ b/src/cdogs/player.c @@ -247,7 +247,6 @@ NPlayerData PlayerDataDefault(const int idx) pd.Lives = CampaignGetLives(&gCampaign); if (gCampaign.Setting.BuyAndSell) { - pd.Stats.Score = STARTING_CASH; pd.Totals.Score = STARTING_CASH; }