Advertisement
Treedestroyed

KFOnlineStatsWrite

Jun 7th, 2021
2,634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // KFOnlineStatsWrite
  3. //=============================================================================
  4. // The KF2 game stats writer
  5. //=============================================================================
  6. // Killing Floor 2
  7. // Copyright (C) 2015 Tripwire Interactive LLC
  8. //  - Joshua Rowan 3/4/2014
  9. //=============================================================================
  10.  
  11. class KFOnlineStatsWrite extends OnlineStatsWrite
  12.     native
  13.     config(game);
  14.  
  15. `include(KFOnlineStats.uci)
  16. `include(KFGame\KFMatchStats.uci);
  17.  
  18. const   WeldingPointsRequired = 510;
  19. const   HealingPointsRequired = 20;
  20. const   MaxPerkLevel = `MAX_PERK_LEVEL;
  21. const   MaxPrestigeLevel = `MAX_PRESTIGE_LEVEL;
  22.  
  23. /** Cached PC */
  24. var KFPlayerController MyKFPC;
  25.  
  26. /** Cached general stats */
  27. var private int     Kills;
  28. var private int     StalkerKills;
  29. var private int     CrawlerKills;
  30. var private int     FleshPoundKills;
  31. var private int     WeldingPoints;
  32. var private int     HealingPoints;
  33.  
  34. /** Cached perk XP and build stats */
  35. var private int     CommandoXP, CommandoLVL, CommandoPSG;
  36. var private int     CommandoBuild;
  37. var private int     BerserkerXP, BerserkerLVL, BerserkerPSG;
  38. var private int     BerserkerBuild;
  39. var private int     SupportXP, SupportLVL, SupportPSG;
  40. var private int     SupportBuild;
  41. var private int     MedicXP, MedicLVL, MedicPSG;
  42. var private int     MedicBuild;
  43. var private int     FirebugXP, FirebugLVL, FirebugPSG;
  44. var private int     FirebugBuild;
  45. var private int     DemoXP, DemoLVL, DemoPSG;
  46. var private int     DemoBuild;
  47. var private int     SharpshooterXP, SharpshooterLVL, SharpshooterPSG;
  48. var private int     SharpshooterBuild;
  49.  
  50. var private int     PersonalBest_KnifeKills;
  51. var private int     PersonalBest_PistolKills;
  52. var private int     PersonalBest_HeadShots;
  53. var private int     PersonalBest_Healing;
  54. var private int     PersonalBest_Kills;
  55. var private int     PersonalBest_Assists;
  56. var private int     PersonalBest_LargeZedKil;
  57. var private int     PersonalBest_Dosh;
  58.  
  59. /** Achievement IDs **/
  60. // ids must be sequential (no gaps)
  61. const KFACHID_ParisNormal               =   0;
  62. const KFACHID_ParisHard                 =   1;
  63. const KFACHID_ParisSuicidal             =   2;
  64. const KFACHID_ParisHellOnEarth          =   3;
  65. const KFACHID_OutpostNormal             =   4;
  66. const KFACHID_OutpostHard               =   5;
  67. const KFACHID_OutpostSuicidal           =   6;
  68. const KFACHID_OutpostHellOnEarth        =   7;
  69. const KFACHID_BioticsNormal             =   8;
  70. const KFACHID_BioticsHard               =   9;
  71. const KFACHID_BioticsSuicidal           =   10;
  72. const KFACHID_BioticsHellOnEarth        =   11;
  73. const KFACHID_ManorNormal               =   12;
  74. const KFACHID_ManorHard                 =   13;
  75. const KFACHID_ManorSuicidal             =   14;
  76. const KFACHID_ManorHellOnEarth          =   15;
  77.  
  78. const KFACHID_ParisCollectibles         =   16;
  79. const KFACHID_OutpostCollectibles       =   17;
  80. const KFACHID_BioticsCollectibles       =   18;
  81. const KFACHID_ManorCollectibles         =   19;
  82.  
  83. const KFACHID_EvacNormal                =   20;
  84. const KFACHID_EvacHard                  =   21;
  85. const KFACHID_EvacSuicidal              =   22;
  86. const KFACHID_EvacHellOnEarth           =   23;
  87. const KFACHID_CatacombsNormal           =   24;
  88. const KFACHID_CatacombsHard             =   25;
  89. const KFACHID_CatacombsSuicidal         =   26;
  90. const KFACHID_CatacombsHellOnEarth      =   27;
  91.  
  92. const KFACHID_EvacsCollectibles         =   28;
  93. const KFACHID_CatacombsCollectibles     =   29;
  94.  
  95. /* __TW_ANALYTICS_ */
  96. var int PerRoundWeldXP;
  97. var int PerRoundHealXP;
  98.  
  99. //Cache of achievements information
  100. var array<AchievementDetails> Achievements;
  101.  
  102. //var private const InterpCurveFloat    LevelXPCurve;
  103. var const int XPTable[`MAX_PERK_LEVEL];
  104.  
  105. /** Dev cheats */
  106. var config  bool    bAllowPerkCheats;
  107. var private const   bool    bDisabled;
  108.  
  109. /** Debugging */
  110. var         bool    bLogStatsWrite;
  111.  
  112. cpptext
  113. {
  114.     UBOOL IsValidProgressStatId(INT StatId);
  115. }
  116.  
  117. native function IncrementIntStat(int StatId,optional int IncBy = 1);
  118. native function IncrementFloatStat( int StatId, optional float IncBy = 1.0 );
  119. native function SetIntStat( int StatId, int Value );
  120. native function SetFloatStat( int StatId, float Value );
  121. native final function bool HasCheated();
  122.  
  123. native final function NotifyCheats(optional bool bSaveToConfig);
  124.  
  125. native final private function int LogSubsystemIntStat( int StatId );
  126.  
  127. /*********************************************************************************************
  128. * @name Saving & Loading
  129. ********************************************************************************************* */
  130. simulated function LogStats()
  131. {
  132.     `log( "###############################################################" );
  133.     `log( "CACHED VALUES:" );
  134.     `log( "CommandoXP, CommandoLVL " @ "    =" @ CommandoXP @ CommandoLVL );
  135.     `log( "BerserkerXP, BerserkerLVL " @ "  =" @ BerserkerXP @ BerserkerLVL );
  136.     `log( "SupportXP, SupportLVL " @ "      =" @ SupportXP @ SupportLVL );
  137.     `log( "MedicXP, MedicLVL " @ "          =" @ MedicXP @ MedicLVL );
  138.     `log( "---------------------------------------------------------------" );
  139.     `log( "STEAM VALUES:" );
  140.     `log( "CommandoXP, CommandoLVL " @ "    =" @ GetXPFromProgress( LogSubsystemIntStat( `STATID_Cmdo_Progress ) ) @ GetLVLFromProgress( LogSubsystemIntStat( `STATID_Cmdo_Progress ) ) );
  141.     `log( "BerserkerXP, BerserkerLVL " @ "  =" @ GetXPFromProgress( LogSubsystemIntStat( `STATID_Bsrk_Progress ) ) @ GetLVLFromProgress( LogSubsystemIntStat( `STATID_Bsrk_Progress ) ) );
  142.     `log( "SupportXP, SupportLVL " @ "      =" @ GetXPFromProgress( LogSubsystemIntStat( `STATID_Sup_Progress ) ) @ GetLVLFromProgress( LogSubsystemIntStat( `STATID_Sup_Progress ) ) );
  143.     `log( "MedicXP, MedicLVL " @ "          =" @ GetXPFromProgress( LogSubsystemIntStat( `STATID_Medic_Progress ) ) @ GetLVLFromProgress( LogSubsystemIntStat( `STATID_Medic_Progress ) ) );
  144.     `log( " " );
  145.     `log( "CommandoProgress " @ "           =" @ LogSubsystemIntStat( `STATID_Cmdo_Progress ) );
  146.     `log( "BerserkerProgress " @ "          =" @ LogSubsystemIntStat( `STATID_Bsrk_Progress ) );
  147.     `log( "SupportProgress " @ "            =" @ LogSubsystemIntStat( `STATID_Sup_Progress ) );
  148.     `log( "MedicProgress " @ "              =" @ LogSubsystemIntStat( `STATID_Medic_Progress ) );
  149.     `log( "###############################################################" );
  150. }
  151.  
  152. //Steam stats -> the gameplay variables
  153. event CacheStatsValue(int StatID, float Value)
  154. {
  155.     switch( StatID )
  156.     {
  157.         // Perk XPs and builds
  158.         case `STATID_Cmdo_Progress:
  159.             CommandoXP = GetXPFromProgress( Value );
  160.             CommandoLVL = GetLVLFromProgress( Value );
  161.             CommandoPSG = GetPSGFromProgress( Value );
  162.             `log(GetFuncName() @ "CommandoXP:" @ CommandoXP @CommandoLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  163.             break;
  164.         case `STATID_Cmdo_Build:
  165.             CommandoBuild = Value;
  166.             `log(GetFuncName() @ "CommandoBuild:" @ CommandoBuild, bLogStatsWrite);
  167.             break;
  168.         case `STATID_Bsrk_Progress:
  169.             BerserkerXP = GetXPFromProgress( Value );
  170.             BerserkerLVL = GetLVLFromProgress( Value );
  171.             BerserkerPSG = GetPSGFromProgress( Value );
  172.             `log(GetFuncName() @ "BerserkerXP:" @ BerserkerXP @ BerserkerLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  173.             break;
  174.         case `STATID_Bsrk_Build:
  175.             BerserkerBuild = Value;
  176.             `log(GetFuncName() @ "BerserkerBuild:" @ BerserkerBuild, bLogStatsWrite);
  177.             break;
  178.         case `STATID_Sup_Progress:
  179.             SupportXP = GetXPFromProgress( Value );
  180.             SupportLVL = GetLVLFromProgress( Value );
  181.             SupportPSG = GetPSGFromProgress( Value );
  182.             `log(GetFuncName() @ "SupportXP:" @ SupportXP @ SupportLVL @ "VALUE:" @ Round( value ),   bLogStatsWrite);
  183.             break;
  184.         case `STATID_Sup_Build:
  185.             SupportBuild = Value;
  186.             `log(GetFuncName() @ "SupportBuild:" @ SupportBuild, bLogStatsWrite);
  187.             break;
  188.         case `STATID_Medic_Progress:
  189.             MedicXP = GetXPFromProgress( Value );
  190.             MedicLVL = GetLVLFromProgress( Value );
  191.             MedicPSG = GetPSGFromProgress( Value );
  192.             `log(GetFuncName() @ "MedicXP:" @ MedicXP @ MedicLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  193.             break;
  194.         case `STATID_Medic_Build:
  195.             MedicBuild = Value;
  196.             `log(GetFuncName() @ "MedicBuild:" @ MedicBuild, bLogStatsWrite);
  197.             break;
  198.         case `STATID_Fire_Progress:
  199.             FirebugXP = GetXPFromProgress( Value );
  200.             FirebugLVL = GetLVLFromProgress( Value );
  201.             FirebugPSG = GetPSGFromProgress( Value );
  202.             `log(GetFuncName() @ "FirebugXP:" @ FirebugXP @ FirebugLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  203.             break;
  204.         case `STATID_Fire_Build:
  205.             FirebugBuild = Value;
  206.             `log(GetFuncName() @ "FirebugBuild:" @ FirebugBuild, bLogStatsWrite);
  207.             break;
  208.         case `STATID_Demo_Progress:
  209.             DemoXP = GetXPFromProgress( Value );
  210.             DemoLVL = GetLVLFromProgress( Value );
  211.             DemoPSG = GetPSGFromProgress( Value );
  212.             `log(GetFuncName() @ "DemoXP:" @ DemoXP @ DemoLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  213.             break;
  214.         case `STATID_Demo_Build:
  215.             DemoBuild = Value;
  216.             `log(GetFuncName() @ "DemoBuild:" @ DemoBuild, bLogStatsWrite);
  217.             break;
  218.         case STATID_Shrp_Progress:
  219.             SharpshooterXP = GetXPFromProgress( Value );
  220.             SharpshooterLVL = GetLVLFromProgress( Value );
  221.             SharpshooterPSG = GetPSGFromProgress( Value );
  222.             CheckPerkLvlAchievement( class'KFPerk_Sharpshooter', SharpshooterLVL );
  223.             `log(GetFuncName() @ "SharpshooterXP:" @ SharpshooterXP @ SharpshooterLVL @ "VALUE:" @ Round( value ), bLogStatsWrite);
  224.             break;
  225.         case STATID_Shrp_Build:
  226.             SharpshooterBuild = Value;
  227.             `log(GetFuncName() @ "SharpshooterBuild:" @ SharpshooterBuild, bLogStatsWrite);
  228.             break;
  229.         // end of perk progress stats
  230.         case `STATID_Kills:
  231.             Kills = Value;
  232.             `log(GetFuncName() @ "Kills:" @ Kills, bLogStatsWrite);
  233.             break;
  234.         case `STATID_StalkerKills:
  235.             StalkerKills = Value;
  236.             `log(GetFuncName() @ "Stalker Kills:" @ StalkerKills, bLogStatsWrite);
  237.             break;
  238.         case `STATID_Sup_WeldPoints:
  239.             WeldingPoints = Value;
  240.             `log(GetFuncName() @ "Welding points:" @ WeldingPoints, bLogStatsWrite);
  241.             break;
  242.         case `STATID_Medic_HealPoints:
  243.             HealingPoints = Value;
  244.             `log(GetFuncName() @ "Healing points:" @ HealingPoints, bLogStatsWrite);
  245.             break;
  246.         case `STATID_CrawlerKills:
  247.             CrawlerKills = Value;
  248.             `log(GetFuncName() @ "Crawler kills:" @ CrawlerKills, bLogStatsWrite);
  249.             break;
  250.         case `STATID_FleshpoundKills:
  251.             FleshpoundKills = Value;
  252.             `log(GetFuncName() @ "Fleshpound kills:" @ FleshpoundKills, bLogStatsWrite);
  253.             break;
  254.         case `STATID_PersonalBest_KnifeKills:
  255.             PersonalBest_KnifeKills = Value;
  256.             `log(GetFuncName() @ "PersonalBest_KnifeKills:" @ PersonalBest_KnifeKills, bLogStatsWrite);
  257.             break;
  258.         case `STATID_PersonalBest_PistolKills:
  259.             PersonalBest_PistolKills = Value;
  260.             `log(GetFuncName() @ "PersonalBest_PistolKills:" @ PersonalBest_PistolKills, bLogStatsWrite);
  261.             break;
  262.         case `STATID_PersonalBest_HeadShots:
  263.             PersonalBest_HeadShots = Value;
  264.             `log(GetFuncName() @ "PersonalBest_HeadShots:" @ PersonalBest_HeadShots, bLogStatsWrite);
  265.             break;
  266.         case `STATID_PersonalBest_Healing:
  267.             PersonalBest_Healing = Value;
  268.             `log(GetFuncName() @ "PersonalBest_Healing:" @ PersonalBest_Healing, bLogStatsWrite);
  269.             break;
  270.         case `STATID_PersonalBest_Kills:
  271.             PersonalBest_Kills = Value;
  272.             `log(GetFuncName() @ "PersonalBest_Kills:" @ PersonalBest_Kills, bLogStatsWrite);
  273.             break;
  274.         case `STATID_PersonalBest_Assists:
  275.             PersonalBest_Assists = Value;
  276.             `log(GetFuncName() @ "PersonalBest_Assists:" @ PersonalBest_Assists, bLogStatsWrite);
  277.             break;
  278.         case `STATID_PersonalBest_LargeZedKill:
  279.             PersonalBest_LargeZedKil = Value;
  280.             `log(GetFuncName() @ "PersonalBest_LargeZedKil:" @ PersonalBest_LargeZedKil, bLogStatsWrite);
  281.             break;
  282.         case `STATID_PersonalBest_Dosh:
  283.             PersonalBest_Dosh = Value;
  284.             `log(GetFuncName() @ "PersonalBest_Dosh:" @ PersonalBest_Dosh, bLogStatsWrite);
  285.             break;
  286.     }
  287. }
  288.  
  289. /** returns cached stats value */
  290. private event GetPerkBuildFromStats( class<KFPerk> PerkClass, out int Build )
  291. {
  292.     switch( PerkClass )
  293.     {
  294.         case class'KFPerk_Commando':
  295.             Build = CommandoBuild;
  296.             break;
  297.         case class'KFPerk_Berserker':
  298.             Build = BerserkerBuild;
  299.             break;
  300.         case class'KFPerk_Support':
  301.             Build = SupportBuild;
  302.             break;
  303.         case class'KFPerk_FieldMedic':
  304.             Build = MedicBuild;
  305.             break;
  306.         case class'KFPerk_Firebug':
  307.             Build = FirebugBuild;
  308.             break;
  309.         case class'KFPerk_Demolitionist':
  310.             Build = DemoBuild;
  311.             break;
  312.         case class'KFPerk_Sharpshooter':
  313.             Build = SharpshooterBuild;
  314.             break;
  315.     }
  316. }
  317.  
  318. /** returns cached stats value */
  319. private event SaveBuildToStats(class<KFPerk> InPerk, int Build)
  320. {
  321.     local int StatID;
  322.     StatId = InPerk.static.GetPerkBuildStatID();
  323.  
  324.     // save and update cached var
  325.     SetIntStat(StatId, Build);
  326.     CacheStatsValue(StatId, Build);
  327.  
  328.     `log(GetFuncName() @ "Saving build for perk:" @ InPerk @ "Build:" @ Build, bLogStatsWrite);
  329. }
  330.  
  331. /*********************************************************************************************
  332. * @name Perk Progression
  333. ********************************************************************************************* */
  334.  
  335. // External get functions
  336. native final function int GetPerkLevel( class<KFPerk> Perk );
  337. native final function int GetPerkBuild( class<KFPerk> Perk );
  338. native final static function int GetXPNeededAt( int Level );
  339.  
  340. // Use these instead of IncrementIntStat, etc...
  341. native final private function IncrementXPStat( class<KFPerk> PerkClass, optional int IncBy = 1 );
  342. native final private function int GetXPFromProgress( int PerkProgress );
  343. native final private function int GetLVLFromProgress( int PerkProgress );
  344. native final private function int GetPSGFromProgress( int PerkProgress );
  345.  
  346. /** Called when some game event awards XP */
  347. private event AddXP( class<KFPerk> PerkClass, int dXP )
  348. {
  349.     if( PerkClass == None )
  350.     {
  351.         return;
  352.     }
  353.  
  354.     IncrementXPStat( PerkClass, dXP );
  355.  
  356.     if( MyKFPC != none )
  357.     {
  358.         MyKFPC.NotifyXPGain(PerkClass, dXP);
  359.     }
  360.     `log("AddXP Perk:"$PerkClass@"dXP:"$dXP, bLogStatsWrite);
  361. }
  362.  
  363. /** Called by IncrementXPStat when new level is achieved */
  364. private event NotifyLevelUp(class<KFPerk> PerkClass, int NewLVL)
  365. {
  366.     if( MyKFPC != None )
  367.     {
  368.         MyKFPC.NotifyLevelUp( PerkClass, NewLVL );
  369.         `log(GetFuncName() @ "PerkClass:" @ PerkClass @ "New LVL:" @ NewLVL, bLogStatsWrite);
  370.     }
  371. }
  372.  
  373. /** returns cached value for xp */
  374. private event int GetPerkXP( int StatID )
  375. {
  376.     switch( StatID )
  377.     {
  378.         case `STATID_Cmdo_Progress:         return CommandoXP;
  379.         case `STATID_Bsrk_Progress:         return BerserkerXP;
  380.         case `STATID_Sup_Progress:          return SupportXP;
  381.         case `STATID_Medic_Progress:        return MedicXP;
  382.         case `STATID_Fire_Progress:         return FirebugXP;
  383.         case `STATID_Demo_Progress:         return DemoXP;
  384.         case STATID_Shrp_Progress:          return SharpshooterXP;
  385.     }
  386.  
  387.     return 0;
  388. }
  389.  
  390. /** returns cached value for lvl */
  391. private event int GetPerkLVLInternal( int StatID )
  392. {
  393.     switch( StatID )
  394.     {
  395.         case `STATID_Cmdo_Progress:         return CommandoLVL;
  396.         case `STATID_Bsrk_Progress:         return BerserkerLVL;
  397.         case `STATID_Sup_Progress:          return SupportLVL;
  398.         case `STATID_Medic_Progress:        return MedicLVL;
  399.         case `STATID_Fire_Progress:         return FirebugLVL;
  400.         case `STATID_Demo_Progress:         return DemoLVL;
  401.         case STATID_Shrp_Progress:          return SharpshooterLVL;
  402.     }
  403.  
  404.     return 0;
  405. }
  406.  
  407. /** returns cached value for lvl */
  408. private event int GetPerkPSG( int StatID )
  409. {
  410.     switch( StatID )
  411.     {
  412.         case `STATID_Cmdo_Progress:         return CommandoPSG;
  413.         case `STATID_Bsrk_Progress:         return BerserkerPSG;
  414.         case `STATID_Sup_Progress:          return SupportPSG;
  415.         case `STATID_Medic_Progress:        return MedicPSG;
  416.         case `STATID_Fire_Progress:         return FirebugPSG;
  417.         case `STATID_Demo_Progress:         return DemoPSG;
  418.         case STATID_Shrp_Progress:          return SharpshooterPSG;
  419.     }
  420.  
  421.     return 0;
  422. }
  423.  
  424. private event int GetPerkLVLByClass(class<KFPerk> PerkClass)
  425. {
  426.     local int StatID;
  427.  
  428.     StatID = PerkClass.static.GetProgressStatID();
  429.     return GetPerkLVLInternal(StatID);
  430. }
  431.  
  432. /*********************************************************************************************
  433. * @name Personal Bests (AAR)
  434. ********************************************************************************************* */
  435.  
  436. function int GetPersonalBest( EPersonalBests PersonalBestID )
  437. {
  438.     switch( PersonalBestID )
  439.     {
  440.         case EPB_KnifeKills:            return PersonalBest_KnifeKills;
  441.         case EPB_PistolKills:           return PersonalBest_PistolKills;
  442.         case EPB_HeadShots:             return PersonalBest_HeadShots;
  443.         case EPB_Healing:               return PersonalBest_Healing;
  444.         case EPB_Kills:                 return PersonalBest_Kills;
  445.         case EPB_Assists:               return PersonalBest_Assists;
  446.         case EPB_LargeZedKill:          return PersonalBest_LargeZedKil;
  447.         case EPB_Dosh:                  return PersonalBest_Dosh;
  448.     }
  449.    
  450.     return 0;
  451. }
  452.  
  453. function SavePersonalBest( EPersonalBests PersonalBestID, int Value )
  454. {
  455.     switch( PersonalBestID )
  456.     {
  457.         case EPB_KnifeKills:            SetIntStat(`STATID_PersonalBest_KnifeKills, Value);     break;
  458.         case EPB_PistolKills:           SetIntStat(`STATID_PersonalBest_PistolKills, Value);    break;
  459.         case EPB_HeadShots:             SetIntStat(`STATID_PersonalBest_HeadShots, Value);      break;
  460.         case EPB_Healing:               SetIntStat(`STATID_PersonalBest_Healing, Value);        break;
  461.         case EPB_Kills:                 SetIntStat(`STATID_PersonalBest_Kills, Value);          break;
  462.         case EPB_Assists:               SetIntStat(`STATID_PersonalBest_Assists, Value);        break;
  463.         case EPB_LargeZedKill:          SetIntStat(`STATID_PersonalBest_LargeZedKill, Value);   break;
  464.         case EPB_Dosh:                  SetIntStat(`STATID_PersonalBest_Dosh, Value);           break;
  465.     }  
  466. }
  467.  
  468. /*********************************************************************************************
  469. * @name Gameplay
  470. ********************************************************************************************* */
  471. /**
  472.  * @brief Add a kill and give some EXP tp the player
  473.  * @param MonsterClass The killed monster's class
  474.  * @param Difficulty The current game difficulty
  475.  * @param DT The damagetype used to kill the zed
  476.  * @return [description]
  477.  */
  478. private event AddToKills( class<KFPawn_Monster> MonsterClass, byte Difficulty, class<DamageType> DT )
  479. {
  480.     IncrementIntStat( `STATID_Kills, 1 );
  481.     Kills++;
  482.  
  483.     if( IsStalkerKill( MonsterClass, DT ) )
  484.     {
  485.         AddStalkerKill( Difficulty );
  486.     }
  487.     else if( IsCrawlerKill( MonsterClass, DT ) )
  488.     {
  489.         AddCrawlerKill( Difficulty );
  490.     }
  491.     else if( IsFleshPoundKill( MonsterClass, DT ) )
  492.     {
  493.         AddFleshpoundKill( Difficulty );
  494.     }
  495.    
  496.     `RecordAARZedKill(MyKFPC, MonsterClass, DT);
  497. }
  498.  
  499. /**
  500.  * @brief Adds EXP for a qualified stalker kill
  501.  * @details The commando perk only receives extra EXP when a stalker is killed
  502.  *          with a commando weapon. The currently slected skill does not matter
  503.  * @param Difficulty current game difficulty
  504.  */
  505. private function AddStalkerKill( byte Difficulty )
  506. {
  507.     StalkerKills++;
  508.     IncrementIntStat( `STATID_StalkerKills, 1 );
  509.     AddXP( class'KFPerk_Commando', class'KFPerk_Commando'.static.GetStalkerKillXP( Difficulty ) );
  510.     `log(GetFuncName() @ "Adding stalker kill, IncrementIntStat STATID_StalkerKills by:" @ class'KFPerk_Commando'.static.GetStalkerKillXP(Difficulty), bLogStatsWrite);
  511.  
  512.     //AAR
  513.     `RecordSecondaryXPGain( MyKFPC, class'KFPerk_Commando', class'KFPerk_Commando'.static.GetStalkerKillXP( Difficulty ) );
  514. }
  515.  
  516. /**
  517.  * @brief Adds EXP for a qualified crawler kill
  518.  * @details The Firebug perk only receives extra EXP when a crawler is killed
  519.  *          with a Firebug weapon. The currently selected skill does not matter
  520.  * @param Difficulty current game difficulty
  521.  */
  522. private function AddCrawlerKill( byte Difficulty )
  523. {
  524.     CrawlerKills++;
  525.     IncrementIntStat( `STATID_CrawlerKills, 1 );
  526.     AddXP( class'KFPerk_Firebug', class'KFPerk_Firebug'.static.GetCrawlerKillXP( Difficulty ) );
  527.     `log(GetFuncName() @ "Adding crawler kill, IncrementIntStat STATID_CrawlerKills by:" @ class'KFPerk_Firebug'.static.GetCrawlerKillXP(Difficulty), bLogStatsWrite);
  528.  
  529.     //AAR
  530.     `RecordSecondaryXPGain( MyKFPC, class'KFPerk_Firebug', class'KFPerk_Firebug'.static.GetCrawlerKillXP( Difficulty ) );
  531. }
  532.  
  533. /**
  534.  * @brief Adds EXP for a qualified Fleshpound kill
  535.  * @details The Firebug perk only receives extra EXP when a crawler is killed
  536.  *          with a Firebug weapon. The currently selected skill does not matter
  537.  * @param Difficulty current game difficulty
  538.  */
  539. private function AddFleshpoundKill( byte Difficulty )
  540. {
  541.     FleshpoundKills++;
  542.     IncrementIntStat( `STATID_FleshpoundKills, 1 );
  543.     AddXP( class'KFPerk_Demolitionist', class'KFPerk_Demolitionist'.static.GetFleshpoundKillXP( Difficulty ) );
  544.     `log(GetFuncName() @ "Adding crawler kill, IncrementIntStat STATID_CrawlerKills by:" @ class'KFPerk_Firebug'.static.GetCrawlerKillXP(Difficulty), bLogStatsWrite);
  545.  
  546.     //AAR
  547.     `RecordSecondaryXPGain( MyKFPC, class'KFPerk_Demolitionist', class'KFPerk_Demolitionist'.static.GetFleshpoundKillXP( Difficulty ) );
  548. }
  549.  
  550. /**
  551.  * @brief Checks if a stalker kill qualifies for Firebug EXP
  552.  *
  553.  * @param DT Used damage type
  554.  * @param MonsterClass the killed zed's class
  555.  * @return true if the zed was a crawler and the damage type is on perk
  556.  */
  557. private final function bool IsCrawlerKill( class<KFPawn_Monster> MonsterClass, class<DamageType> DT )
  558. {
  559.     return  MonsterClass.static.IsCrawlerClass() &&
  560.             class'KFPerk'.static.IsDamageTypeOnThisPerk( class<KFDamageType>(DT), class'KFPerk_Firebug'.static.GetPerkClass() );
  561. }
  562.  
  563. /**
  564.  * @brief Checks if a stalker kill qualifies for Commando EXP
  565.  *
  566.  * @param DT Used damage type
  567.  * @param MonsterClass the killed zed's class
  568.  * @return true if the zed was a stalker and the damage type is on perk
  569.  */
  570. private final function bool IsStalkerKill( class<KFPawn_Monster> MonsterClass, class<DamageType> DT )
  571. {
  572.     return  MonsterClass.static.IsStalkerClass() &&
  573.             class'KFPerk'.static.IsDamageTypeOnThisPerk( class<KFDamageType>(DT), class'KFPerk_Commando'.static.GetPerkClass() );
  574. }
  575.  
  576. /**
  577.  * @brief Checks if a fleshpund kill qualifies for demo EXP
  578.  *
  579.  * @param DT Used damage type
  580.  * @param MonsterClass the killed zed's class
  581.  * @return true if the zed was a stalker and the damage type is on perk
  582.  */
  583. private final function bool IsFleshPoundKill( class<KFPawn_Monster> MonsterClass, class<DamageType> DT )
  584. {
  585.     return  MonsterClass.static.IsFleshpoundClass() &&
  586.             class'KFPerk'.static.IsDamageTypeOnThisPerk( class<KFDamageType>(DT), class'KFPerk_Demolitionist'.static.GetPerkClass() );
  587. }
  588.  
  589. // Berserker gains XP when killing a zed close to another player
  590. private event AddSmallRadiusKill( byte Difficulty )
  591. {
  592.     AddXP( class'KFPerk_Berserker', class'KFPerk_Berserker'.static.GetSmallRadiusKillXP(Difficulty) );
  593.  
  594.     //AAR
  595.     `RecordSecondaryXPGain( MyKFPC, class'KFPerk_Berserker', class'KFPerk_Berserker'.static.GetSmallRadiusKillXP(Difficulty) );
  596. }
  597.  
  598. /*
  599.  * Calculates the perk XP reward for a certain number of points
  600.  * Split from AddWeldingPoints so analytics can log XP earned.
  601.  */
  602. private function int ComputeWeldingXP( int Points )
  603. {
  604.     local int XPEarned;
  605.     local KFGameReplicationInfo KFGRI; 
  606.  
  607.     XPEarned = FFloor( float(Points) / float(WeldingPointsRequired) );
  608.     if( XPEarned >= 1 )
  609.     {
  610.         KFGRI = KFGameReplicationInfo(MyKFPC.WorldInfo.GRI);
  611.         class'KFPerk_Support'.static.MultiplySecondaryXPPoints( XPEarned, KFGRI.GameDifficulty );
  612.     }
  613.  
  614.     return XPEarned;
  615. }
  616.  
  617. /** Welding does not earn XP directly, WeldingPointsRequired have to be earned first */
  618. private event int AddWeldingPoints( int PointsWelded )
  619. {
  620.     local int XPEarned;
  621.  
  622.     WeldingPoints += PointsWelded;
  623.  
  624.     `log(GetFuncName() @ "WeldingPoints are now:" @ WeldingPoints, bLogStatsWrite);
  625.  
  626.     XPEarned = ComputeWeldingXP( WeldingPoints ); //FFloor( float(WeldingPoints) / float(WeldingPointsRequired) );
  627.     if( XPEarned >= 1 )
  628.     {
  629.         AddXP(class'KFPerk_Support', XPEarned);
  630.  
  631.         //AAR
  632.         `RecordSecondaryXPGain( MyKFPC, class'KFPerk_Support', XPEarned );
  633.  
  634.         // keep a running tally for analytics at the end of the match
  635.         PerRoundWeldXP += XPEarned;
  636.  
  637.         // reset/rollover points needed for next xp gain
  638.         WeldingPoints = WeldingPoints % WeldingPointsRequired;
  639.  
  640.         `log(GetFuncName() @ "Welding XP earned :" @ XPEarned, bLogStatsWrite);
  641.     }
  642.  
  643.     // We need the welding points to be persistent
  644.     SetIntStat( `STATID_Sup_WeldPoints,  WeldingPoints );
  645.  
  646.     return XPEarned;
  647. }
  648.  
  649. /*
  650.  * Calculates the perk XP reward for a certain number of points
  651.  * Split from AddHealingPoints so analytics can log XP earned.
  652.  */
  653. private function int ComputeHealingXP( int Points )
  654. {
  655.     local int XPEarned;
  656.     local KFGameReplicationInfo KFGRI; 
  657.  
  658.     XPEarned = FFloor( float(Points) / float(HealingPointsRequired) );
  659.     if( XPEarned >= 1 )
  660.     {
  661.         KFGRI = KFGameReplicationInfo(MyKFPC.WorldInfo.GRI);
  662.         class'KFPerk_FieldMedic'.static.MultiplySecondaryXPPoints( XPEarned, KFGRI.GameDifficulty );
  663.     }
  664.  
  665.     return XPEarned;
  666. }
  667.  
  668. /** Healing does not earn XP directly, HealingPointsRequired have to be earned first */
  669. private event int AddHealingPoints( int PointsHealed )
  670. {
  671.     local int XPEarned;
  672.  
  673.     HealingPoints += PointsHealed;
  674.  
  675.     `log(GetFuncName() @ "HealingPoints are now:" @ HealingPointsRequired, bLogStatsWrite);
  676.  
  677.     XPEarned = ComputeHealingXP( HealingPoints );
  678.     if( XPEarned >= 1 )
  679.     {
  680.         AddXP(class'KFPerk_FieldMedic', XPEarned);
  681.  
  682.         //AAR
  683.         `RecordSecondaryXPGain( MyKFPC, class'KFPerk_FieldMedic', XPEarned );
  684.  
  685.         // keep a running tally for analytics at the end of the match
  686.         PerRoundHealXP += XPEarned;
  687.  
  688.         // reset/rollover points needed for next xp gain
  689.         HealingPoints = HealingPoints % HealingPointsRequired;
  690.  
  691.         `log(GetFuncName() @ "Healing XP earned :" @ XPEarned, bLogStatsWrite);
  692.     }
  693.  
  694.     // We need the welding points to be persistent
  695.     SetIntStat( `STATID_Medic_HealPoints,  HealingPoints );
  696.  
  697.     return XPEarned;
  698. }
  699.  
  700. /*********************************************************************************************
  701. * @name Achievements
  702. ********************************************************************************************* */
  703.  
  704. function GetAchievements()
  705. {
  706.     if( MyKFPC.IsLocalPlayerController() )
  707.     {
  708.         Achievements.Remove( 0, Achievements.length );
  709.         MyKFPC.OnlineSub.PlayerInterface.GetAchievements( 0, Achievements );
  710.     }
  711. }
  712.  
  713. function bool IsAchievementUnlocked( int AchievementIndex )
  714. {
  715.     return ( AchievementIndex < Achievements.length ) && Achievements[AchievementIndex].bWasAchievedOnline;
  716. }
  717.  
  718. function OnUnlockAchievement( int AchievementIndex )
  719. {
  720.     //Reload the achievement list to get the change
  721.     GetAchievements();
  722. }
  723.  
  724. /**
  725.  * @brief Call into native to determine if we achieved anything
  726.   *
  727.  * @param MapName The name of the map played
  728.  * @param Difficulty The game's difficulty
  729.  * @param GameLength short/medium/long
  730.  * @param bCoop mutiplayer or not
  731.   */
  732. native final function OnGameWon( string MapName, byte Difficulty, byte GameLength, byte bCoop );
  733.  
  734. /**
  735.  * @brief Check for map specific achievements on game end
  736.  *
  737.  * @param MapName The name of the map played
  738.  * @param Difficulty The game's difficulty
  739.  * @param GameLength short/medium/long
  740.  * @param bCoop mutiplayer or not
  741.  */
  742. native final function CheckMapEndAchievements( string MapName, byte Difficulty, byte bCoop );
  743.  
  744. defaultproperties
  745. {
  746.     bLogStatsWrite=false
  747.  
  748.     PerRoundWeldXP = 0
  749.     PerRoundHealXP = 0
  750.  
  751.     // These are the stats we are collecting
  752.     Properties.Add((PropertyId=`STATID_None,Data=(Type=SDT_Int32,Value1=0))
  753.     Properties.Add((PropertyId=`STATID_Cmdo_Progress,Data=(Type=SDT_Int32,Value1=0))
  754.     Properties.Add((PropertyId=`STATID_Cmdo_Build,Data=(Type=SDT_Int32,Value1=0))
  755.     Properties.Add((PropertyId=`STATID_Bsrk_Progress,Data=(Type=SDT_Int32,Value1=0))
  756.     Properties.Add((PropertyId=`STATID_Bsrk_Build,Data=(Type=SDT_Int32,Value1=0))
  757.     Properties.Add((PropertyId=`STATID_Sup_Progress,Data=(Type=SDT_Int32,Value1=0))
  758.     Properties.Add((PropertyId=`STATID_Sup_Build,Data=(Type=SDT_Int32,Value1=0))
  759.     Properties.Add((PropertyId=`STATID_Fire_Progress,Data=(Type=SDT_Int32,Value1=0))
  760.     Properties.Add((PropertyId=`STATID_Fire_Build,Data=(Type=SDT_Int32,Value1=0))
  761.     Properties.Add((PropertyId=`STATID_Medic_Progress,Data=(Type=SDT_Int32,Value1=0))
  762.     Properties.Add((PropertyId=`STATID_Medic_Build,Data=(Type=SDT_Int32,Value1=0))
  763.     Properties.Add((PropertyId=`STATID_Shrp_Progress,Data=(Type=SDT_Int32,Value1=0))
  764.     Properties.Add((PropertyId=`STATID_Shrp_Build,Data=(Type=SDT_Int32,Value1=0))
  765.     Properties.Add((PropertyId=`STATID_Demo_Progress,Data=(Type=SDT_Int32,Value1=0))
  766.     Properties.Add((PropertyId=`STATID_Demo_Build,Data=(Type=SDT_Int32,Value1=0))
  767.     Properties.Add((PropertyId=`STATID_Ninja_Progress,Data=(Type=SDT_Int32,Value1=0))
  768.     Properties.Add((PropertyId=`STATID_Ninja_Build,Data=(Type=SDT_Int32,Value1=0))
  769.     Properties.Add((PropertyId=`STATID_Guns_Progress,Data=(Type=SDT_Int32,Value1=0))
  770.     Properties.Add((PropertyId=`STATID_Guns_Build,Data=(Type=SDT_Int32,Value1=0))
  771.     Properties.Add((PropertyId=`STATID_SWAT_Progress,Data=(Type=SDT_Int32,Value1=0))
  772.     Properties.Add((PropertyId=`STATID_SWAT_Build,Data=(Type=SDT_Int32,Value1=0))
  773.     Properties.Add((PropertyId=`STATID_Kills,Data=(Type=SDT_Int32,Value1=0))
  774.     Properties.Add((PropertyId=`STATID_StalkerKills,Data=(Type=SDT_Int32,Value1=0))
  775.     Properties.Add((PropertyId=`STATID_Sup_WeldPoints,Data=(Type=SDT_Int32,Value1=0))
  776.     Properties.Add((PropertyId=`STATID_Medic_HealPoints,Data=(Type=SDT_Int32,Value1=0))
  777.     Properties.Add((PropertyId=`STATID_CrawlerKills,Data=(Type=SDT_Int32,Value1=0))
  778.     Properties.Add((PropertyId=`STATID_FleshpoundKills,Data=(Type=SDT_Int32,Value1=0))
  779.     Properties.Add((PropertyId=`STATID_PersonalBest_KnifeKills,Data=(Type=SDT_Int32,Value1=0))
  780.     Properties.Add((PropertyId=`STATID_PersonalBest_PistolKills,Data=(Type=SDT_Int32,Value1=0))
  781.     Properties.Add((PropertyId=`STATID_PersonalBest_HeadShots,Data=(Type=SDT_Int32,Value1=0))
  782.     Properties.Add((PropertyId=`STATID_PersonalBest_Healing,Data=(Type=SDT_Int32,Value1=0))
  783.     Properties.Add((PropertyId=`STATID_PersonalBest_Kills,Data=(Type=SDT_Int32,Value1=0))
  784.     Properties.Add((PropertyId=`STATID_PersonalBest_Assists,Data=(Type=SDT_Int32,Value1=0))
  785.     Properties.Add((PropertyId=`STATID_PersonalBest_LargeZedKill,Data=(Type=SDT_Int32,Value1=0))
  786.     Properties.Add((PropertyId=`STATID_PersonalBest_Dosh,Data=(Type=SDT_Int32,Value1=0))
  787.  
  788.     // These are the views we are writing to
  789.     ViewIds(0)=`VIEWID_KFGameStats
  790.  
  791.     XPTable(0)=2640
  792.     XPTable(1)=2917
  793.     XPTable(2)=3224
  794.     XPTable(3)=3562
  795.     XPTable(4)=3936
  796.     XPTable(5)=4349
  797.     XPTable(6)=4806
  798.     XPTable(7)=5311
  799.     XPTable(8)=5868
  800.     XPTable(9)=6484
  801.     XPTable(10)=7165
  802.     XPTable(11)=7918
  803.     XPTable(12)=8749
  804.     XPTable(13)=9667
  805.     XPTable(14)=10683
  806.     XPTable(15)=11804
  807.     XPTable(16)=13044
  808.     XPTable(17)=14413
  809.     XPTable(18)=15927
  810.     XPTable(19)=17599
  811.     XPTable(20)=19447
  812.     XPTable(21)=21489
  813.     XPTable(22)=23745
  814.     XPTable(23)=26238
  815.     XPTable(24)=28993
  816. }
  817.  
  818.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement