-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from JimWails/add-extra-stat-data
Add extra stat data
- Loading branch information
Showing
6 changed files
with
166 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Source/AkiSupport/Singleplayer/Patches/MainMenu/AmmoUsedCounterPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using EFT; | ||
using HarmonyLib; | ||
using System.Reflection; | ||
|
||
namespace StayInTarkov.AkiSupport.Singleplayer.Patches.MainMenu | ||
{ | ||
/// <summary> | ||
/// Created by: SPT-Aki team | ||
/// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/3.8.0/project/Aki.SinglePlayer/Patches/MainMenu/AmmoUsedCounterPatch.cs | ||
/// Modified by: KWJimWails. Modified to use SIT ModulePatch | ||
/// </summary> | ||
public class AmmoUsedCounterPatch : ModulePatch | ||
{ | ||
private static Player player; | ||
|
||
protected override MethodBase GetTargetMethod() | ||
{ | ||
return AccessTools.Method(typeof(Player), nameof(Player.OnMakingShot)); | ||
} | ||
|
||
[PatchPostfix] | ||
private static void PatchPostfix(Player __instance) | ||
{ | ||
if (__instance.IsYourPlayer) | ||
{ | ||
__instance.Profile.EftStats.SessionCounters.AddLong(1L, ASessionCounterManager.AmmoUsed); | ||
} | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Source/AkiSupport/Singleplayer/Patches/MainMenu/ArmorDamageCounterPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Comfort.Common; | ||
using EFT; | ||
using EFT.InventoryLogic; | ||
using HarmonyLib; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace StayInTarkov.AkiSupport.Singleplayer.Patches.MainMenu | ||
{ | ||
/// <summary> | ||
/// Created by: SPT-Aki team | ||
/// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/3.8.0/project/Aki.SinglePlayer/Patches/MainMenu/ArmorDamageCounterPatch.cs | ||
/// Modified by: KWJimWails. Modified to use SIT ModulePatch | ||
/// </summary> | ||
public class ArmorDamageCounterPatch : ModulePatch | ||
{ | ||
protected override MethodBase GetTargetMethod() | ||
{ | ||
return AccessTools.Method(typeof(Player), nameof(Player.ApplyDamageInfo)); | ||
} | ||
|
||
[PatchPostfix] | ||
private static void PatchPostfix(DamageInfo damageInfo) | ||
{ | ||
if (damageInfo.SourceId == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (damageInfo.Player == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (damageInfo.Player.iPlayer == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (!damageInfo.Player.iPlayer.IsYourPlayer) | ||
{ | ||
return; | ||
} | ||
|
||
if (damageInfo.Weapon is Weapon) | ||
{ | ||
if (!Singleton<ItemFactory>.Instance.ItemTemplates.TryGetValue(damageInfo.SourceId, out var template)) | ||
{ | ||
return; | ||
} | ||
|
||
if (template is AmmoTemplate bulletTemplate) | ||
{ | ||
float absorbedDamage = (float)Math.Round(bulletTemplate.Damage - damageInfo.Damage); | ||
damageInfo.Player.iPlayer.Profile.EftStats.SessionCounters.AddFloat(absorbedDamage, ASessionCounterManager.CauseArmorDamage); | ||
} | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
Source/AkiSupport/Singleplayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using Comfort.Common; | ||
using EFT; | ||
using HarmonyLib; | ||
using StayInTarkov; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace StayInTarkov.AkiSupport.Singleplayer.Patches.ScavMode | ||
{ | ||
/// <summary> | ||
/// Created by: SPT-Aki team | ||
/// Link: https://dev.sp-tarkov.com/SPT-AKI/Modules/src/branch/3.8.0/project/Aki.SinglePlayer/Patches/ScavMode/ScavRepAdjustmentPatch.cs | ||
/// Modified by: KWJimWails. Modified to use SIT ModulePatch and Class Fix | ||
/// </summary> | ||
public class ScavRepAdjustmentPatch : ModulePatch | ||
{ | ||
protected override MethodBase GetTargetMethod() | ||
{ | ||
return AccessTools.Method(typeof(AStatisticsManagerForPlayer), nameof(AStatisticsManagerForPlayer.OnEnemyKill)); | ||
} | ||
|
||
[PatchPrefix] | ||
private static void PatchPrefix(string playerProfileId, out Tuple<Player, bool> __state) | ||
{ | ||
var player = Singleton<GameWorld>.Instance.MainPlayer; | ||
__state = new Tuple<Player, bool>(null, false); | ||
|
||
if (player.Profile.Side != EPlayerSide.Savage) | ||
{ | ||
return; | ||
} | ||
|
||
if (Singleton<GameWorld>.Instance.GetEverExistedPlayerByID(playerProfileId) is Player killedPlayer) | ||
{ | ||
__state = new Tuple<Player, bool>(killedPlayer, killedPlayer.AIData.IsAI); | ||
killedPlayer.AIData.IsAI = false; | ||
player.Loyalty.method_1(killedPlayer); | ||
} | ||
} | ||
[PatchPostfix] | ||
private static void PatchPostfix(Tuple<Player, bool> __state) | ||
{ | ||
if(__state.Item1 != null) | ||
{ | ||
__state.Item1.AIData.IsAI = __state.Item2; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters