1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
8 #include "IGameplayRecorder.h"
10 class CGameplayAnalyst
: public IGameplayListener
14 virtual ~CGameplayAnalyst();
17 virtual void OnGameplayEvent(IEntity
* pEntity
, const GameplayEvent
& event
);
20 void ProcessPlayerEvent(EntityId id
, const GameplayEvent
& event
);
23 void GetMemoryStatistics(ICrySizer
* s
) {}
25 typedef struct WeaponAnalysis
27 WeaponAnalysis() : usage(0), timeUsed(0.0f
), zoomUsage(0), timeZoomed(0.0f
), firemodes(0), melee(0), shots(0), hits(0), reloads(0), kills(0), deaths(0), damage(0) {}
29 int usage
; // number of times this weapon was selected
30 CTimeValue timeUsed
; // total time this weapon was used
32 int zoomUsage
; // number of zoom ins
33 CTimeValue timeZoomed
; // total times zoomed with this weapon
35 int firemodes
; // total number of firemode changes
37 int melee
; // total number of melee attacks with this weapon
38 int shots
; // total number of shots fired with this weapon
39 int hits
; // total number of hits with this weapon
40 int reloads
;// total number of reloads with this weapon
41 int kills
; // kills with this weapon
42 int deaths
; // deaths while carrying this weapon
43 int damage
; // total damage dealt with this weapon
46 typedef struct PurchaseDetail
48 PurchaseDetail() : totalAmount(0), totalSpent(0) {}
50 int totalAmount
; // total amount of times purchased
51 int totalSpent
; // total amount of currency spent
54 typedef struct CurrencyAnalysis
56 CurrencyAnalysis() : totalEarned(0), totalSpent(0), nMin(0), nMax(0) {}
58 int totalEarned
; // total number of currency earned
59 int totalSpent
; // total number of currency spent
60 int nMin
; // lowest ever currency value
61 int nMax
; // max ever currency value
63 std::map
<string
, PurchaseDetail
> spentDetail
; // total currency spent on each item
66 typedef struct SuitAnalysis
71 for (int i
= 0; i
< 4; i
++)
80 CTimeValue usageStart
;
81 CTimeValue timeUsed
[4]; // total time using each suit mode
82 int usage
[4]; // number of times this suit mode was selected
84 int kills
[4]; // number of kills using each suit mode
85 int deaths
[4]; // number of deaths using each suit mode
89 typedef std::map
<string
, WeaponAnalysis
> Weapons
;
91 typedef struct PlayerAnalysis
115 memset(rankTime
, 0, sizeof(rankTime
));
118 string name
; // player name
123 CTimeValue rankStart
;
125 int maxRank
; // max rank achieved
126 CTimeValue rankTime
[10];// total time spent in each rank
128 int zoomUsage
; // total number of times zoomed
129 int itemUsage
; // total number of item selections
130 int firemodes
; // total number of firemode changes
132 int melee
; // total number of melee attacks
133 int shots
; // total number of shots
134 int hits
; // total number of hits
135 int reloads
; // total number of reloads
136 int damage
; // total damage dealt
137 int kills
; // total number of kills
138 int deaths
; // total number of deaths
141 CTimeValue deathStart
;
142 CTimeValue timeDead
; // time dead / waiting to respawn
143 CTimeValue timeAlive
; // time alive
144 CTimeValue timeStart
; // total time played
146 Weapons weapons
; // weapon analysis
148 CurrencyAnalysis currency
; // currency analysis
151 typedef std::map
<EntityId
, PlayerAnalysis
> Players
;
158 void Release() { delete this; };
163 void DumpWeapon(EntityId playerId
, string
& lines
);
164 void DumpRank(string
& lines
);
165 void DumpSuit(string
& lines
);
166 void DumpCurrency(string
& lines
);
169 void NewPlayer(IEntity
* pEntity
);
170 bool IsPlayer(EntityId entityId
) const;
172 PlayerAnalysis
& GetPlayer(EntityId playerId
);
174 WeaponAnalysis
& GetWeapon(EntityId playerId
, EntityId weaponId
);
175 WeaponAnalysis
& GetWeapon(EntityId playerId
, const char* weapon
);
176 WeaponAnalysis
& GetCurrentWeapon(EntityId playerId
);
178 GameAnalysis m_gameanalysis
;