AcademyStats.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: AcademyStats.h ////////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Electronic Arts Los Angeles
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2003 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: AcademyStats.h
  36. //
  37. // Created: Kris Morness, July 2003
  38. //
  39. // Desc: Keeps track of various statistics in order to provide advice to
  40. // the player about how to improve playing.
  41. //
  42. //-----------------------------------------------------------------------------
  43. #pragma once
  44. #ifndef __ACADEMY_STATS_H
  45. #define __ACADEMY_STATS_H
  46. #include "Lib/BaseType.h"
  47. #include "Common/Debug.h"
  48. #include "Common/Snapshot.h"
  49. #include "Common/UnicodeString.h"
  50. class Object;
  51. class Player;
  52. class SpecialPowerTemplate;
  53. class UpgradeTemplate;
  54. class CommandSet;
  55. class ThingTemplate;
  56. #define MAX_ADVICE_TIPS 1
  57. struct AcademyAdviceInfo
  58. {
  59. UnicodeString advice[ MAX_ADVICE_TIPS ];
  60. UnsignedInt numTips;
  61. };
  62. enum AcademyClassificationType
  63. {
  64. //Don't forget to update the strings too!
  65. ACT_NONE,
  66. ACT_UPGRADE_RADAR,
  67. ACT_SUPERPOWER,
  68. };
  69. extern const char *TheAcademyClassificationTypeNames[]; //Change above, change this!
  70. // ----------------------------------------------------------------------------------------------
  71. class AcademyStats : public Snapshot
  72. {
  73. public:
  74. AcademyStats();
  75. void init( const Player *player );
  76. void update();
  77. Bool isFirstUpdate() const { return m_firstUpdate; }
  78. void setFirstUpdate( Bool set ) { m_firstUpdate = set; }
  79. void recordProduction( const Object *obj, const Object *constructer );
  80. void recordUpgrade( const UpgradeTemplate *upgrade, Bool granted );
  81. void recordSpecialPowerUsed( const SpecialPowerTemplate *spTemplate );
  82. void recordIncome();
  83. void recordBuildingCapture() { m_structuresCaptured++; }
  84. void recordGeneralsPointsSpent( Int points ) { m_generalsPointsSpent += points; }
  85. void recordBuildingGarrisoned() { m_structuresGarrisoned++; }
  86. void recordDragSelection() { m_dragSelectUnits++; }
  87. void recordStrategyCenter() { m_hadAStrategyCenter = TRUE; }
  88. void recordBattlePlanSelected() { m_choseAStrategyForCenter = TRUE; }
  89. void recordUnitEnteredTunnelNetwork() { m_unitsEnteredTunnelNetwork++; }
  90. void recordControlGroupsUsed() { m_controlGroupsUsed++; }
  91. void recordClearedGarrisonedBuilding() { m_clearedGarrisonedBuildings++; }
  92. void recordVehicleDisguised() { m_vehiclesDisguised++; }
  93. void recordFirestormCreated() { m_firestormsCreated++; }
  94. void recordGuardAbilityUsed() { m_guardAbilityUsedCount++; }
  95. void recordSalvageCollected() { m_salvageCollected++;}
  96. void recordDoubleClickAttackMoveOrderGiven() { m_doubleClickAttackMoveOrdersGiven++; }
  97. void recordMineCleared() { m_minesCleared++; }
  98. //Returns the natural command center template (you may capture others in a game...)
  99. const ThingTemplate* getCommandCenterTemplate() const { return m_commandCenterTemplate; }
  100. //Use these functions for the Neutral player only!
  101. void recordVehicleSniped() { m_vehiclesSniped++; }
  102. UnsignedInt getVehiclesSniped() const { return m_vehiclesSniped; }
  103. void recordMine() { m_mines++; }
  104. UnsignedInt getMines() const { return m_mines; }
  105. const Player *getPlayer() { return m_player; }
  106. Bool hadASupplyCenter() const { return m_supplyCentersBuilt > 0; }
  107. Bool calculateAcademyAdvice( AcademyAdviceInfo *info );
  108. protected:
  109. // snapshot methods
  110. virtual void crc( Xfer *xfer );
  111. virtual void xfer( Xfer *xfer );
  112. virtual void loadPostProcess( void );
  113. private:
  114. void evaluateTier1Advice( AcademyAdviceInfo *info, Int numAvailableTips = -1 );
  115. void evaluateTier2Advice( AcademyAdviceInfo *info, Int numAvailableTips = -1 );
  116. void evaluateTier3Advice( AcademyAdviceInfo *info, Int numAvailableTips = -1 );
  117. const Player *m_player;
  118. UnsignedInt m_nextUpdateFrame;
  119. Bool m_firstUpdate;
  120. const CommandSet *m_dozerCommandSet;
  121. Bool m_unknownSide;
  122. const ThingTemplate *m_commandCenterTemplate;
  123. //+-----------------------+
  124. //| Tier 1 (Basic advice) |
  125. //+-----------------------+
  126. //1) Did player build at least one of each structure type available?
  127. //CUT!!!
  128. //2) Did player run out of money before building a supply center?
  129. Bool m_spentCashBeforeBuildingSupplyCenter;
  130. UnsignedInt m_supplyCentersBuilt;
  131. const ThingTemplate *m_supplyCenterTemplate;
  132. UnsignedInt m_supplyCenterCost;
  133. //3) Did player build radar (if applicable)?
  134. Bool m_researchedRadar;
  135. //4) Did player build any dozers/workers?
  136. UnsignedInt m_peonsBuilt;
  137. //5) Did player ever capture a structure?
  138. UnsignedInt m_structuresCaptured;
  139. //6) Did player spend any generals points?
  140. UnsignedInt m_generalsPointsSpent;
  141. //7) Did player ever use a generals power or superweapon?
  142. UnsignedInt m_specialPowersUsed;
  143. //8) Did player garrison any structures?
  144. UnsignedInt m_structuresGarrisoned;
  145. //9) How idle was the player in building military units?
  146. UnsignedInt m_idleBuildingUnitsMaxFrames;
  147. UnsignedInt m_lastUnitBuiltFrame;
  148. //10) Did player drag select units?
  149. UnsignedInt m_dragSelectUnits;
  150. //11) Did player upgrade anything?
  151. UnsignedInt m_upgradesPurchased;
  152. //12) Was player out of power for more than 10 minutes?
  153. UnsignedInt m_powerOutMaxFrames;
  154. UnsignedInt m_oldestPowerOutFrame;
  155. Bool m_hadPowerLastCheck;
  156. //13) Extra gathers built?
  157. UnsignedInt m_gatherersBuilt;
  158. //14) Heros built?
  159. UnsignedInt m_heroesBuilt;
  160. //+------------------------------+
  161. //| Tier 2 (Intermediate advice) |
  162. //+------------------------------+
  163. //15) Selected a strategy center battle plan?
  164. Bool m_hadAStrategyCenter;
  165. Bool m_choseAStrategyForCenter;
  166. //16) Placed units inside tunnel network?
  167. UnsignedInt m_unitsEnteredTunnelNetwork;
  168. Bool m_hadATunnelNetwork;
  169. //17) Player used control groups?
  170. UnsignedInt m_controlGroupsUsed;
  171. //18) Built secondary income unit (hacker, dropzone, blackmarket)?
  172. UnsignedInt m_secondaryIncomeUnitsBuilt;
  173. //19) Cleared out garrisoned buildings?
  174. UnsignedInt m_clearedGarrisonedBuildings;
  175. //20) Did the Player pick up salvage (as GLA)?
  176. UnsignedInt m_salvageCollected;
  177. //21) Did the player ever use the "Guard" ability?
  178. UnsignedInt m_guardAbilityUsedCount;
  179. //22) Did the player build more than one Supply Center (that is, did he expand out)?
  180. //Uses m_supplyCentersBuilt!
  181. //23) Did the player ever garrison a vehicle?
  182. //CUT!!!
  183. //24) Did the player ever use the hotkey to grab all of one unit type (change to use any hotkeys)?
  184. //CUT!!!
  185. //+--------------------------+
  186. //| Tier 3 (Advanced advice) |
  187. //+--------------------------+
  188. //25) Did the player use the new alternate interface in the options?
  189. //Uses TheGlobalData->m_useAlternateMouse
  190. //26) Player did not use the new "double click location attack move/guard"
  191. UnsignedInt m_doubleClickAttackMoveOrdersGiven;
  192. //27) Built barracks within 5 minutes?
  193. Bool m_builtBarracksWithinFiveMinutes;
  194. //28) Built war factory within 10 minutes?
  195. Bool m_builtWarFactoryWithinTenMinutes;
  196. //29) Built tech structure within 15 minutes?
  197. Bool m_builtTechStructureWithinFifteenMinutes;
  198. //30) No income for 2 minutes?
  199. UnsignedInt m_lastIncomeFrame;
  200. UnsignedInt m_maxFramesBetweenIncome;
  201. //31) Did the Player ever use Dozers/Workers to clear out traps/mines/booby traps?
  202. UnsignedInt m_mines; //Neutral player stat
  203. UnsignedInt m_minesCleared;
  204. //32) Captured any sniped vehicles?
  205. UnsignedInt m_vehiclesRecovered;
  206. UnsignedInt m_vehiclesSniped;
  207. //33) Did the player ever build a "disguisable" unit and never used the disguise ability?
  208. UnsignedInt m_disguisableVehiclesBuilt;
  209. UnsignedInt m_vehiclesDisguised;
  210. //34) Did the player never build a "stealth" upgrade?
  211. //CUT!!!
  212. //35) Did the player ever create a "Firestorm" with his MiGs or Inferno Cannons?
  213. UnsignedInt m_firestormsCreated;
  214. };
  215. #endif // __ACADEMY_STATS_H