Added pickups count to Flow.Statistics class

This commit is contained in:
Lwmte 2025-03-09 19:07:28 +01:00
parent 39a23fb755
commit cb73477b90
8 changed files with 59 additions and 2 deletions

View file

@ -47,6 +47,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Added various Translate() methods to Vec2 and Vec3 script objects.
* Added alpha transparency functionality for statics and moveables to be used with SetColor() method.
* Added extra arguments for sprite object slots and starting rotation value for EmitParticle function.
* Added pickups count to Flow.Statistics class.
* Added ability to save Flow.Level fields such as fog or horizon to a savegame.
## [Version 1.7.1](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.4) - 2025-04-01

View file

@ -146,6 +146,10 @@
<td class="summary">Kills.</td>
</tr>
<tr>
<td class="name" ><a href="#pickups">pickups</a></td>
<td class="summary">Pickups.</td>
</tr>
<tr>
<td class="name" ><a href="#secrets">secrets</a></td>
<td class="summary">Secrets.</td>
</tr>
@ -287,6 +291,27 @@
</dd>
<dt>
<a name = "pickups"></a>
<strong>pickups</strong>
</dt>
<dd>
Pickups.
<ul>
<li><span class="parameter">pickups</span>
<span class="types"><span class="type">int</span></span>
amount of picked up items.
</li>
</ul>
</dd>
<dt>
<a name = "secrets"></a>

View file

@ -22,6 +22,7 @@
#include "Game/pickup/pickup_misc_items.h"
#include "Game/pickup/pickup_weapon.h"
#include "Game/room.h"
#include "Game/savegame.h"
#include "Game/Setup.h"
#include "Math/Math.h"
#include "Objects/Generic/Object/burning_torch.h"
@ -158,6 +159,11 @@ void PickedUpObject(GAME_OBJECT_ID objectID, std::optional<int> count)
{
// Item isn't any of the above; do nothing.
}
else
{
SaveGame::Statistics.Level.Pickups++;
SaveGame::Statistics.Game.Pickups++;
}
}
void PickedUpObject(ItemInfo& item)

View file

@ -274,6 +274,7 @@ const std::vector<byte> SaveGame::Build()
sgLevelStatisticsBuilder.add_medipacks_used(Statistics.Level.HealthUsed);
sgLevelStatisticsBuilder.add_damage_taken(Statistics.Level.DamageTaken);
sgLevelStatisticsBuilder.add_distance(Statistics.Level.Distance);
sgLevelStatisticsBuilder.add_pickups(Statistics.Level.Pickups);
sgLevelStatisticsBuilder.add_secrets(Statistics.Level.Secrets);
sgLevelStatisticsBuilder.add_timer(SaveGame::Statistics.Level.TimeTaken);
auto levelStatisticsOffset = sgLevelStatisticsBuilder.Finish();
@ -285,6 +286,7 @@ const std::vector<byte> SaveGame::Build()
sgGameStatisticsBuilder.add_medipacks_used(Statistics.Game.HealthUsed);
sgGameStatisticsBuilder.add_damage_taken(Statistics.Game.DamageTaken);
sgGameStatisticsBuilder.add_distance(Statistics.Game.Distance);
sgGameStatisticsBuilder.add_pickups(Statistics.Game.Pickups);
sgGameStatisticsBuilder.add_secrets(Statistics.Game.Secrets);
sgGameStatisticsBuilder.add_timer(SaveGame::Statistics.Game.TimeTaken);
auto gameStatisticsOffset = sgGameStatisticsBuilder.Finish();
@ -1771,6 +1773,7 @@ static void ParseStatistics(const Save::SaveGame* s, bool isHub)
SaveGame::Statistics.Level.HealthUsed = s->level()->medipacks_used();
SaveGame::Statistics.Level.DamageTaken = s->level()->damage_taken();
SaveGame::Statistics.Level.Kills = s->level()->kills();
SaveGame::Statistics.Level.Pickups = s->level()->pickups();
SaveGame::Statistics.Level.Secrets = s->level()->secrets();
SaveGame::Statistics.Level.TimeTaken = s->level()->timer();
@ -1784,6 +1787,7 @@ static void ParseStatistics(const Save::SaveGame* s, bool isHub)
SaveGame::Statistics.Game.HealthUsed = s->game()->medipacks_used();
SaveGame::Statistics.Game.DamageTaken = s->game()->damage_taken();
SaveGame::Statistics.Game.Kills = s->game()->kills();
SaveGame::Statistics.Game.Pickups = s->game()->pickups();
SaveGame::Statistics.Game.Secrets = s->game()->secrets();
SaveGame::Statistics.Game.TimeTaken = s->game()->timer();
}

View file

@ -50,6 +50,11 @@ namespace TEN::Scripting
*/
"kills", &Statistics::Kills,
/*** Pickups.
@tfield int pickups amount of picked up items.
*/
"pickups", &Statistics::Pickups,
/*** Secrets.
@tfield int secrets amount of found secrets.
*/

View file

@ -15,6 +15,7 @@ namespace TEN::Scripting
unsigned int HealthUsed = 0;
unsigned int DamageTaken = 0;
unsigned int Kills = 0;
unsigned int Pickups = 0;
unsigned int Secrets = 0;
static void Register(sol::table&);

View file

@ -7858,6 +7858,7 @@ struct SaveGameStatisticsT : public flatbuffers::NativeTable {
int32_t damage_taken = 0;
int32_t distance = 0;
int32_t kills = 0;
int32_t pickups = 0;
int32_t secrets = 0;
int32_t timer = 0;
};
@ -7873,8 +7874,9 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VT_DAMAGE_TAKEN = 10,
VT_DISTANCE = 12,
VT_KILLS = 14,
VT_SECRETS = 16,
VT_TIMER = 18
VT_PICKUPS = 16,
VT_SECRETS = 18,
VT_TIMER = 20
};
int32_t ammo_hits() const {
return GetField<int32_t>(VT_AMMO_HITS, 0);
@ -7894,6 +7896,9 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
int32_t kills() const {
return GetField<int32_t>(VT_KILLS, 0);
}
int32_t pickups() const {
return GetField<int32_t>(VT_PICKUPS, 0);
}
int32_t secrets() const {
return GetField<int32_t>(VT_SECRETS, 0);
}
@ -7908,6 +7913,7 @@ struct SaveGameStatistics FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
VerifyField<int32_t>(verifier, VT_DAMAGE_TAKEN) &&
VerifyField<int32_t>(verifier, VT_DISTANCE) &&
VerifyField<int32_t>(verifier, VT_KILLS) &&
VerifyField<int32_t>(verifier, VT_PICKUPS) &&
VerifyField<int32_t>(verifier, VT_SECRETS) &&
VerifyField<int32_t>(verifier, VT_TIMER) &&
verifier.EndTable();
@ -7939,6 +7945,9 @@ struct SaveGameStatisticsBuilder {
void add_kills(int32_t kills) {
fbb_.AddElement<int32_t>(SaveGameStatistics::VT_KILLS, kills, 0);
}
void add_pickups(int32_t pickups) {
fbb_.AddElement<int32_t>(SaveGameStatistics::VT_PICKUPS, pickups, 0);
}
void add_secrets(int32_t secrets) {
fbb_.AddElement<int32_t>(SaveGameStatistics::VT_SECRETS, secrets, 0);
}
@ -7964,11 +7973,13 @@ inline flatbuffers::Offset<SaveGameStatistics> CreateSaveGameStatistics(
int32_t damage_taken = 0,
int32_t distance = 0,
int32_t kills = 0,
int32_t pickups = 0,
int32_t secrets = 0,
int32_t timer = 0) {
SaveGameStatisticsBuilder builder_(_fbb);
builder_.add_timer(timer);
builder_.add_secrets(secrets);
builder_.add_pickups(pickups);
builder_.add_kills(kills);
builder_.add_distance(distance);
builder_.add_damage_taken(damage_taken);
@ -11269,6 +11280,7 @@ inline void SaveGameStatistics::UnPackTo(SaveGameStatisticsT *_o, const flatbuff
{ auto _e = damage_taken(); _o->damage_taken = _e; }
{ auto _e = distance(); _o->distance = _e; }
{ auto _e = kills(); _o->kills = _e; }
{ auto _e = pickups(); _o->pickups = _e; }
{ auto _e = secrets(); _o->secrets = _e; }
{ auto _e = timer(); _o->timer = _e; }
}
@ -11287,6 +11299,7 @@ inline flatbuffers::Offset<SaveGameStatistics> CreateSaveGameStatistics(flatbuff
auto _damage_taken = _o->damage_taken;
auto _distance = _o->distance;
auto _kills = _o->kills;
auto _pickups = _o->pickups;
auto _secrets = _o->secrets;
auto _timer = _o->timer;
return TEN::Save::CreateSaveGameStatistics(
@ -11297,6 +11310,7 @@ inline flatbuffers::Offset<SaveGameStatistics> CreateSaveGameStatistics(flatbuff
_damage_taken,
_distance,
_kills,
_pickups,
_secrets,
_timer);
}

View file

@ -584,6 +584,7 @@ table SaveGameStatistics {
damage_taken: int32;
distance: int32;
kills: int32;
pickups: int32;
secrets: int32;
timer: int32;
}