Skip to content

Commit

Permalink
Autosave score #71
Browse files Browse the repository at this point in the history
Adjust cyberdogs enemy density
  • Loading branch information
cxong committed Jan 30, 2024
1 parent cc98dc9 commit 0a2e5ae
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
18 changes: 9 additions & 9 deletions missions/custom/techdemo/cyberdogs.cdogscpn/missions.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 40,
"EnemyDensity": 30,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -499,7 +499,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 50,
"EnemyDensity": 37,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -697,7 +697,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 55,
"EnemyDensity": 42,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -910,7 +910,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 13,
"EnemyDensity": 0,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -1116,7 +1116,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 13,
"EnemyDensity": 0,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -1326,7 +1326,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 65,
"EnemyDensity": 50,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -1541,7 +1541,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 13,
"EnemyDensity": 0,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -1738,7 +1738,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 70,
"EnemyDensity": 57,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down Expand Up @@ -1941,7 +1941,7 @@
"Pickup": "life",
"Count": 2
}],
"EnemyDensity": 80,
"EnemyDensity": 64,
"Weapons": ["Fists",
"Chainsaw",
"2xChainsaw",
Expand Down
7 changes: 7 additions & 0 deletions src/autosave.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
}
1 change: 1 addition & 0 deletions src/autosave.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ typedef struct
CArray ammo; // of int
int Lives;
int HP;
int Score;
} PlayerSave;
typedef struct
{
Expand Down
16 changes: 8 additions & 8 deletions src/briefing_screens.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/cdogs/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0a2e5ae

Please sign in to comment.