playerdata.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. ** Command & Conquer Renegade(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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/playerdata.h $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 3/29/02 3:42p $*
  29. * *
  30. * $Revision:: 25 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef PLAYERDATA_H
  36. #define PLAYERDATA_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef GAMEOBJREF_H
  41. #include "gameobjref.h"
  42. #endif
  43. #ifndef _DATASAFE_H
  44. #include "..\commando\datasafe.h"
  45. #endif //_DATASAFE_H
  46. #ifndef SIMPLEVEC_H
  47. #include "simplevec.h"
  48. #endif
  49. class ChunkSaveClass;
  50. class ChunkLoadClass;
  51. class DamageableGameObj;
  52. class SmartGameObj;
  53. class BitStreamClass;
  54. /*
  55. ** PlayerDataClass
  56. **
  57. ** This class maintains the score and statistics for human player.
  58. ** It is intended that the Commando code will derive a custom version,
  59. ** and install it into each Human Player controlled SoldierGameObj.
  60. ** When the SoldierGameObj dies, a new one should be created and the
  61. ** same PlayerDataClass should be plugged into the new SoldierGameObj
  62. **
  63. ** It is the creators responsibility to save and restore these classes,
  64. ** and to re-install into the GameObjs after load.
  65. */
  66. class PlayerDataClass
  67. {
  68. public:
  69. PlayerDataClass( void );
  70. ~PlayerDataClass( void );
  71. virtual void Reset_Player(void);
  72. bool Save(ChunkSaveClass & csave);
  73. bool Load(ChunkLoadClass & cload);
  74. void Set_GameObj( SmartGameObj * soldier ) { GameObj = (ScriptableGameObj*)soldier; }
  75. SmartGameObj * Get_GameObj( void ) { return (SmartGameObj*)(GameObj.Get_Ptr()); }
  76. // Score access
  77. float Get_Score( void ) const { return (float)Score; }
  78. virtual void Set_Score( float score ) { Score = score; }
  79. virtual void Increment_Score( float add );
  80. // Money access
  81. float Get_Money( void ) const { return (float)Money; }
  82. virtual void Set_Money( float money ) { Money = money; }
  83. virtual void Increment_Money( float add );
  84. virtual bool Purchase_Item( int cost );
  85. // Damage Notification
  86. virtual void Apply_Damage_Points( float points, DamageableGameObj * victim );
  87. virtual void Apply_Death_Points( float points, DamageableGameObj * victim );
  88. // Network support
  89. void Import_Occasional( BitStreamClass & packet );
  90. void Export_Occasional( BitStreamClass & packet );
  91. // Stats
  92. void Stats_Reset( void );
  93. void Stats_Add_Game_Time( float time ) { StatTimeInGame += time; StatTimeInSession+=time; }
  94. void Stats_Add_Enemy_Killed( void ) { StatEnemiesKilled++; }
  95. void Stats_Add_Ally_Killed( void ) { StatAlliesKilled++; }
  96. void Stats_Add_Shot_Fired( void ) { StatShotsFired++; }
  97. void Stats_Add_Head_Shot( void ) { StatHeadShots++; }
  98. void Stats_Add_Torso_Shot( void ) { StatTorsoShots++; }
  99. void Stats_Add_Arm_Shot( void ) { StatArmShots++; }
  100. void Stats_Add_Leg_Shot( void ) { StatLegShots++; }
  101. void Stats_Add_Crotch_Shot( void ) { StatCrotchShots++; }
  102. void Stats_Set_Final_Health( float health ) { StatFinalHealth = health; }
  103. void Stats_Add_Powerup( void ) { StatPowerups++; }
  104. void Stats_Add_Vehicle_Destroyed( void ) { StatVehiclesDestroyed++; }
  105. void Stats_Add_Vehicle_Time( float time ) { StatTimeInVehicles += time; }
  106. void Stats_Add_Kill_From_Vehicle( void ) { StatKillsFromVehicles++; }
  107. void Stats_Add_Squish( void ) { StatSquishes++; }
  108. void Stats_Add_Credit_Grant( float grant ) { StatCreditsGranted += grant; }
  109. void Stats_Add_Building_Destroyed( void ) { StatBuildingsDestroyed++; }
  110. void Stats_Add_Head_Hit( void ) { StatHeadHits++; }
  111. void Stats_Add_Torso_Hit( void ) { StatTorsoHits++; }
  112. void Stats_Add_Arm_Hit( void ) { StatArmHits++; }
  113. void Stats_Add_Leg_Hit( void ) { StatLegHits++; }
  114. void Stats_Add_Crotch_Hit( void ) { StatCrotchHits++; }
  115. void Stats_Add_Weapon_Fired( int weapon_id );
  116. float Get_Game_Time(void) const {return StatTimeInGame;}
  117. float Get_Session_Time(void) const {return StatTimeInSession;} // Note: This is per-session, it is not saved or loaded!
  118. int Get_Enemies_Killed(void) const {return StatEnemiesKilled;}
  119. int Get_Allies_Killed(void) const {return StatAlliesKilled;}
  120. int Get_Shots_Fired(void) const {return StatShotsFired;}
  121. int Get_Head_Shots(void) const {return StatHeadShots;}
  122. int Get_Torso_Shots(void) const {return StatTorsoShots;}
  123. int Get_Arm_Shots(void) const {return StatArmShots;}
  124. int Get_Leg_Shots(void) const {return StatLegShots;}
  125. int Get_Crotch_Shots(void) const {return StatCrotchShots;}
  126. float Get_Final_Health(void) const {return StatFinalHealth;}
  127. int Get_Powerups_Collected(void) const {return StatPowerups;}
  128. int Get_Vehiclies_Destroyed(void) const {return StatVehiclesDestroyed;}
  129. float Get_Vehicle_Time(void) const {return StatTimeInVehicles;}
  130. int Get_Kills_From_Vehicle(void) const {return StatKillsFromVehicles;}
  131. int Get_Squishes(void) const {return StatSquishes;}
  132. float Get_Credit_Grant(void) const {return StatCreditsGranted;}
  133. int Get_Building_Destroyed(void) const {return StatBuildingsDestroyed;}
  134. int Get_Head_Hit(void) const {return StatHeadHits;}
  135. int Get_Torso_Hit(void) const {return StatTorsoHits;}
  136. int Get_Arm_Hit(void) const {return StatArmHits;}
  137. int Get_Leg_Hit(void) const {return StatLegHits;}
  138. int Get_Crotch_Hit(void) const {return StatCrotchHits;}
  139. int Get_Weapon_Fired_Count( void ) const;
  140. bool Get_Weapon_Fired( int index, unsigned long& weaponID, unsigned long& firedCount) const;
  141. float Get_Punish_Timer( void ) {return PunishTimer;}
  142. void Inc_Punish_Timer( float amount ) {PunishTimer += amount;}
  143. private:
  144. safe_float Score;
  145. safe_float Money;
  146. GameObjReference GameObj;
  147. float PunishTimer;
  148. protected:
  149. float StatTimeInGame;
  150. float StatTimeInSession;
  151. int StatEnemiesKilled;
  152. int StatAlliesKilled;
  153. int StatShotsFired;
  154. int StatHeadShots;
  155. int StatTorsoShots;
  156. int StatArmShots;
  157. int StatLegShots;
  158. int StatCrotchShots;
  159. float StatFinalHealth;
  160. int StatPowerups;
  161. int StatVehiclesDestroyed;
  162. float StatTimeInVehicles;
  163. int StatKillsFromVehicles;
  164. int StatSquishes;
  165. float StatCreditsGranted;
  166. int StatBuildingsDestroyed;
  167. int StatHeadHits;
  168. int StatTorsoHits;
  169. int StatArmHits;
  170. int StatLegHits;
  171. int StatCrotchHits;
  172. int StatLastWeaponIndex;
  173. SimpleDynVecClass<int> StatWeaponIDFired;
  174. SimpleDynVecClass<int> StatWeaponFireCount;
  175. };
  176. #endif // PLAYERDATA_H
  177. //safe_int Score;
  178. //virtual bool Purchase_Item( int cost );
  179. //virtual void On_Kill( int victim_id ) {}
  180. //virtual void On_Kill( int victim_id, int victim_team ) {}