Compare commits
10 Commits
a3517b0c8c
...
9c1f40c6c8
Author | SHA1 | Date | |
---|---|---|---|
9c1f40c6c8 | |||
c849601598 | |||
![]() |
344ff7bb42 | ||
![]() |
c2686f3a38 | ||
![]() |
91364aab2b | ||
![]() |
252a848806 | ||
![]() |
594896e75f | ||
![]() |
bf1f049f53 | ||
![]() |
c991178de7 | ||
![]() |
50996400bc |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -362,3 +362,4 @@ MigrationBackup/
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
/.config/dotnet-tools.json
|
||||
.idea/.idea.ASS/.idea
|
||||
|
63
ASS.csproj
63
ASS.csproj
@@ -9,9 +9,10 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>dvize.ASS</RootNamespace>
|
||||
<AssemblyName>dvize.ASS</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -23,57 +24,53 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>portable</DebugType>
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>BepInEx\core\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Build">
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Build.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Common, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Aki.Reflection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\BepInEx\core\0Harmony.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BepInEx, Version=5.4.21.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\BepInEx\core\BepInEx.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\BepInEx\core\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Comfort.Unity, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\Comfort.Unity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ConfigurationManager">
|
||||
<HintPath>F:\SPT-AKI-DEV\BepInEx\plugins\ConfigurationManager.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\BepInEx\plugins\ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ItemComponent.Types, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ItemTemplate.Types, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\ItemTemplate.Types.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\ItemTemplate.Types.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="spt-common">
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\BepInEx\plugins\spt\spt-common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="spt-reflection">
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\BepInEx\plugins\spt\spt-reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -85,17 +82,17 @@
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.IMGUIModule">
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.TextRenderingModule">
|
||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||
<HintPath>C:\Games\Escape from Tarkov\Escape from Tarkov\EscapeFromTarkov_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -105,14 +102,4 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy "$(TargetPath)" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll"
|
||||
|
||||
if $(ConfigurationName) == Debug (
|
||||
copy "$(TargetDir)$(TargetName).pdb" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
||||
) else (
|
||||
del "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
||||
)
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
300
Component.cs
300
Component.cs
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BepInEx.Logging;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
@@ -11,221 +10,132 @@ namespace armorMod
|
||||
{
|
||||
internal class AssComponent : MonoBehaviour
|
||||
{
|
||||
private static GameWorld gameWorld = new GameWorld();
|
||||
private static Player player = new Player();
|
||||
internal static ManualLogSource Logger;
|
||||
internal static GameWorld gameWorld;
|
||||
internal static Player player;
|
||||
internal static float timeSinceLastHit = 0f;
|
||||
internal static float timeSinceLastRepair = 0f; // New variable to control repair frequency
|
||||
internal static Slot slotContents;
|
||||
internal static InventoryControllerClass inventoryController;
|
||||
|
||||
private static float newRepairRate;
|
||||
private static float newMaxDurabilityDrainRate;
|
||||
private static float newWeaponRepairRate;
|
||||
private static float newWeaponMaxDurabilityDrainRate;
|
||||
private static RepairableComponent armor;
|
||||
private static FaceShieldComponent faceShield;
|
||||
private static RepairableComponent weapon;
|
||||
private static float maxRepairableDurabilityBasedOnCap;
|
||||
private static float maxWeaponRepairableDurabilityBasedOnCap;
|
||||
private static float timeSinceLastHit = 0f;
|
||||
|
||||
private static Dictionary<EquipmentSlot, List<Item>> equipmentSlotDictionary = new Dictionary<EquipmentSlot, List<Item>>
|
||||
internal static List<EquipmentSlot> equipmentSlotDictionary = new List<EquipmentSlot>
|
||||
{
|
||||
{ EquipmentSlot.ArmorVest, new List<Item>() },
|
||||
{ EquipmentSlot.TacticalVest, new List<Item>() },
|
||||
{ EquipmentSlot.Eyewear, new List<Item>() },
|
||||
{ EquipmentSlot.FaceCover, new List<Item>() },
|
||||
{ EquipmentSlot.Headwear, new List<Item>() },
|
||||
{ EquipmentSlot.ArmorVest},
|
||||
{ EquipmentSlot.TacticalVest},
|
||||
{ EquipmentSlot.Eyewear},
|
||||
{ EquipmentSlot.FaceCover},
|
||||
{ EquipmentSlot.Headwear},
|
||||
};
|
||||
|
||||
private static Dictionary<EquipmentSlot, List<Item>> weaponSlotDictionary = new Dictionary<EquipmentSlot, List<Item>>
|
||||
internal static List<EquipmentSlot> weaponSlotDictionary = new List<EquipmentSlot>
|
||||
{
|
||||
{ EquipmentSlot.FirstPrimaryWeapon, new List<Item>() },
|
||||
{ EquipmentSlot.SecondPrimaryWeapon, new List<Item>() },
|
||||
{ EquipmentSlot.Holster, new List<Item>() },
|
||||
{ EquipmentSlot.FirstPrimaryWeapon },
|
||||
{ EquipmentSlot.SecondPrimaryWeapon },
|
||||
{ EquipmentSlot.Holster },
|
||||
};
|
||||
protected static ManualLogSource Logger
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
private AssComponent()
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Logger == null)
|
||||
{
|
||||
Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AssComponent));
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
player = Singleton<GameWorld>.Instance.MainPlayer;
|
||||
player.BeingHitAction += Player_BeingHitAction;
|
||||
player = gameWorld.MainPlayer;
|
||||
inventoryController = (InventoryControllerClass)AccessTools.Field(typeof(Player), "_inventoryController").GetValue(player);
|
||||
player.BeingHitAction += ResetTimeSinceLastHit;
|
||||
Logger.LogDebug("AssComponent enabled successfully.");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timeSinceLastHit += Time.deltaTime;
|
||||
timeSinceLastRepair += Time.deltaTime;
|
||||
|
||||
if (timeSinceLastRepair >= 1.0f)
|
||||
{
|
||||
if (timeSinceLastHit >= AssPlugin.TimeDelayRepairInSec.Value && AssPlugin.ArmorServiceMode.Value)
|
||||
{
|
||||
RepairItems(equipmentSlotDictionary, true);
|
||||
}
|
||||
|
||||
if (timeSinceLastHit >= AssPlugin.weaponTimeDelayRepairInSec.Value && AssPlugin.WeaponServiceMode.Value)
|
||||
{
|
||||
RepairItems(weaponSlotDictionary, false);
|
||||
}
|
||||
|
||||
timeSinceLastRepair = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RepairItems(List<EquipmentSlot> slots, bool isArmor)
|
||||
{
|
||||
float repairRate = isArmor ? AssPlugin.ArmorRepairRateOverTime.Value : AssPlugin.weaponRepairRateOverTime.Value;
|
||||
float maxDurabilityDrainRate = isArmor ? AssPlugin.MaxDurabilityDegradationRateOverTime.Value : AssPlugin.weaponMaxDurabilityDegradationRateOverTime.Value;
|
||||
|
||||
foreach (var slot in slots)
|
||||
{
|
||||
var slotContents = GetEquipSlot(slot);
|
||||
if (slotContents?.ContainedItem == null) continue;
|
||||
|
||||
foreach (Item item in slotContents.ContainedItem.GetAllItems())
|
||||
{
|
||||
if (isArmor)
|
||||
{
|
||||
// Specifically for face shields, if the item has a FaceShieldComponent.
|
||||
if (item.TryGetItemComponent<FaceShieldComponent>(out var faceShield) && AssPlugin.fixFaceShieldBullets.Value)
|
||||
{
|
||||
// Check if face shield has been hit and reset hits if so.
|
||||
if (faceShield.Hits > 0)
|
||||
{
|
||||
faceShield.Hits = 0;
|
||||
faceShield.HitsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.TryGetItemComponent<RepairableComponent>(out var component))
|
||||
{
|
||||
float maxCap = isArmor ? AssPlugin.MaxDurabilityCap.Value : AssPlugin.weaponMaxDurabilityCap.Value;
|
||||
float maxRepairableDurability = (maxCap / 100) * component.TemplateDurability;
|
||||
// Logger.LogInfo(component.Item.Id + " " + component.TemplateDurability + " " + component.MaxDurability);
|
||||
|
||||
if (component.Durability < maxRepairableDurability)
|
||||
{
|
||||
#if DEBUG
|
||||
Logger.LogWarning($"Repairing {item.Name.Localized()} in {slot} with {component.Durability} / {component.MaxDurability} durability");
|
||||
#endif
|
||||
component.Durability = Mathf.Min(component.Durability + repairRate, component.TemplateDurability);
|
||||
component.MaxDurability = Mathf.Max(component.TemplateDurability - maxDurabilityDrainRate, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetTimeSinceLastHit(DamageInfo dmgInfo, EBodyPart bodyPart, float hitEffectId)
|
||||
{
|
||||
timeSinceLastHit = 0f;
|
||||
}
|
||||
|
||||
private static Slot GetEquipSlot(EquipmentSlot slot)
|
||||
{
|
||||
if (inventoryController != null)
|
||||
{
|
||||
slotContents = inventoryController.Inventory.Equipment.GetSlot(slot);
|
||||
return slotContents.ContainedItem == null ? null : slotContents;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
internal static void Enable()
|
||||
{
|
||||
if (Singleton<IBotGame>.Instantiated)
|
||||
{
|
||||
gameWorld = Singleton<GameWorld>.Instance;
|
||||
gameWorld.GetOrAddComponent<AssComponent>();
|
||||
|
||||
Logger.LogDebug("AssComponent enabled");
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
|
||||
timeSinceLastHit += Time.deltaTime;
|
||||
|
||||
if ((timeSinceLastHit >= AssPlugin.TimeDelayRepairInSec.Value) && AssPlugin.ArmorServiceMode.Value)
|
||||
{
|
||||
RepairArmor();
|
||||
}
|
||||
|
||||
if ((timeSinceLastHit >= AssPlugin.weaponTimeDelayRepairInSec.Value) && AssPlugin.WeaponServiceMode.Value)
|
||||
{
|
||||
RepairWeapon();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void RepairArmor()
|
||||
{
|
||||
newRepairRate = AssPlugin.ArmorRepairRateOverTime.Value * Time.deltaTime;
|
||||
newMaxDurabilityDrainRate = AssPlugin.MaxDurabilityDegradationRateOverTime.Value * Time.deltaTime;
|
||||
|
||||
foreach (EquipmentSlot slot in equipmentSlotDictionary.Keys.ToArray())
|
||||
{
|
||||
Slot tempSlot = getEquipSlot(slot);
|
||||
|
||||
if (tempSlot == null || tempSlot.ContainedItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var item in tempSlot.ContainedItem.GetAllItems())
|
||||
{
|
||||
//get the armorcomponent of each item in items and check to see if all item componenets (even helmet side ears) are max durability
|
||||
|
||||
//Logger.LogDebug("Examining the item: " + item.Name.Localized() + " in slot: " + slot.ToString() + " for repairable component");
|
||||
|
||||
item.TryGetItemComponent<RepairableComponent>(out armor);
|
||||
|
||||
|
||||
if (armor == null)
|
||||
{
|
||||
//Logger.LogDebug("Item: " + item.Name.Localized() + " in slot: " + slot.ToString() + " does not have a repairable component");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (slot == EquipmentSlot.Headwear)
|
||||
{
|
||||
|
||||
item.TryGetItemComponent<FaceShieldComponent>(out faceShield);
|
||||
|
||||
if (faceShield != null)
|
||||
{
|
||||
if (faceShield.Hits > 0 && AssPlugin.fixFaceShieldBullets.Value)
|
||||
{
|
||||
faceShield.Hits = 0;
|
||||
faceShield.HitsChanged.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
maxRepairableDurabilityBasedOnCap = ((AssPlugin.MaxDurabilityCap.Value / 100) * armor.MaxDurability);
|
||||
|
||||
//check if it needs repair for the current item in loop of all items for the slot
|
||||
if (armor.Durability < maxRepairableDurabilityBasedOnCap)
|
||||
{
|
||||
//increase armor durability by newRepairRate until maximum then set as maximum durability
|
||||
if (armor.Durability + newRepairRate >= armor.MaxDurability)
|
||||
{
|
||||
armor.Durability = armor.MaxDurability;
|
||||
}
|
||||
else
|
||||
{
|
||||
armor.Durability += newRepairRate;
|
||||
armor.MaxDurability -= newMaxDurabilityDrainRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RepairWeapon()
|
||||
{
|
||||
|
||||
newWeaponRepairRate = AssPlugin.weaponRepairRateOverTime.Value * Time.deltaTime;
|
||||
newWeaponMaxDurabilityDrainRate = AssPlugin.weaponMaxDurabilityDegradationRateOverTime.Value * Time.deltaTime;
|
||||
|
||||
foreach (EquipmentSlot slot in weaponSlotDictionary.Keys.ToArray())
|
||||
{
|
||||
Slot tempSlot = getEquipSlot(slot);
|
||||
|
||||
if (tempSlot == null || tempSlot.ContainedItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var item in tempSlot.ContainedItem.GetAllItems())
|
||||
{
|
||||
item.TryGetItemComponent<RepairableComponent>(out weapon);
|
||||
|
||||
if (weapon == null)
|
||||
{
|
||||
//Logger.LogDebug("Item: " + item.Name.Localized() + " in slot: " + slot.ToString() + " does not have a repairable component");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Logger.LogDebug("Item: " + item.Name.Localized() + " in slot: " + slot.ToString() + " has a repairable component");
|
||||
maxWeaponRepairableDurabilityBasedOnCap = ((AssPlugin.weaponMaxDurabilityCap.Value / 100) * weapon.MaxDurability);
|
||||
|
||||
//check if it needs repair for the current item in loop of all items for the slot
|
||||
if (weapon.Durability < maxWeaponRepairableDurabilityBasedOnCap)
|
||||
{
|
||||
//increase weapon durability by newWeaponRepairRate until maximum then set as maximum durability
|
||||
if (weapon.Durability + newWeaponRepairRate >= weapon.MaxDurability)
|
||||
{
|
||||
weapon.Durability = weapon.MaxDurability;
|
||||
}
|
||||
else
|
||||
{
|
||||
weapon.Durability += newWeaponRepairRate;
|
||||
weapon.MaxDurability -= newWeaponMaxDurabilityDrainRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void Player_BeingHitAction(DamageInfo dmgInfo, EBodyPart bodyPart, float hitEffectId) => timeSinceLastHit = 0f;
|
||||
|
||||
|
||||
|
||||
private static Slot slotContents;
|
||||
private static InventoryControllerClass inventoryController;
|
||||
private Slot getEquipSlot(EquipmentSlot slot)
|
||||
{
|
||||
// Use AccessTools to get the protected field _inventoryController
|
||||
inventoryController = (InventoryControllerClass)AccessTools.Field(typeof(Player), "_inventoryController").GetValue(player);
|
||||
|
||||
if (inventoryController != null)
|
||||
{
|
||||
slotContents = inventoryController.Inventory.Equipment.GetSlot(slot);
|
||||
|
||||
if (slotContents.ContainedItem == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return slotContents;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
117
PackageMods.ps1
Normal file
117
PackageMods.ps1
Normal file
@@ -0,0 +1,117 @@
|
||||
param (
|
||||
[string]$ConfigurationName,
|
||||
[string]$TargetPath,
|
||||
[string]$TargetName,
|
||||
[string]$TargetDir
|
||||
)
|
||||
|
||||
# Define the base directory
|
||||
$baseDir = "F:\SPT-AKI-DEV\BepInEx\plugins"
|
||||
|
||||
# Function to log messages to the console
|
||||
function Log {
|
||||
param (
|
||||
[string]$message
|
||||
)
|
||||
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
||||
Write-Host "$timestamp - $message"
|
||||
}
|
||||
|
||||
Log "Script started"
|
||||
Log "ConfigurationName: $ConfigurationName"
|
||||
Log "TargetPath: $TargetPath"
|
||||
Log "TargetName: $TargetName"
|
||||
Log "TargetDir: $TargetDir"
|
||||
|
||||
# Get the assembly version
|
||||
$assembly = [System.Reflection.Assembly]::LoadFile($TargetPath)
|
||||
$version = $assembly.GetName().Version.ToString()
|
||||
Log "Assembly version: $version"
|
||||
|
||||
# Determine the directory of the deployed DLL
|
||||
$deployDir = Split-Path -Parent $TargetPath
|
||||
Log "DeployDir: $deployDir"
|
||||
|
||||
# Check if the deploy directory is the base directory or one level further
|
||||
if ($deployDir -ne $baseDir) {
|
||||
$relativePath = $deployDir.Substring($baseDir.Length + 1) # Get the relative path beyond the base directory
|
||||
Log "RelativePath: $relativePath"
|
||||
if (($relativePath -split '\\').Count -eq 1) { # Check if it's exactly one directory level further
|
||||
$directoryName = (Get-Item $deployDir).Name
|
||||
$zipPath = "F:\SPT-AKI-DEV\BepInEx\plugins\$directoryName-v$version.zip"
|
||||
Log "DirectoryName: $directoryName"
|
||||
Log "ZipPath: $zipPath"
|
||||
|
||||
# Remove existing zip file if it exists
|
||||
if (Test-Path $zipPath) {
|
||||
Log "ZipPath exists, removing"
|
||||
Remove-Item $zipPath -Force
|
||||
}
|
||||
|
||||
# Create the temp directory structure
|
||||
$tempZipDir = "F:\SPT-AKI-DEV\tempZip"
|
||||
if (Test-Path $tempZipDir) {
|
||||
Log "TempZipDir exists, removing"
|
||||
Remove-Item $tempZipDir -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Path $tempZipDir
|
||||
Log "TempZipDir created: $tempZipDir"
|
||||
|
||||
$newZipStructure = Join-Path $tempZipDir "Bepinex\plugins\$directoryName"
|
||||
New-Item -ItemType Directory -Path $newZipStructure -Force
|
||||
Log "New zip structure directory created: $newZipStructure"
|
||||
|
||||
# Copy files to the new zip structure
|
||||
Copy-Item -Path "$TargetDir\*" -Destination $newZipStructure -Recurse -Force
|
||||
Log "Files copied to new zip structure"
|
||||
|
||||
# Create the final zip file
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($tempZipDir, $zipPath)
|
||||
Log "Final zip file created: $zipPath"
|
||||
|
||||
# Clean up temp directory
|
||||
Remove-Item $tempZipDir -Recurse -Force
|
||||
Log "TempZipDir removed"
|
||||
} else {
|
||||
Log "RelativePath is not one directory level further"
|
||||
}
|
||||
} else {
|
||||
$zipPath = "F:\SPT-AKI-DEV\BepInEx\plugins\$TargetName-v$version.zip"
|
||||
Log "ZipPath: $zipPath"
|
||||
|
||||
# Remove existing zip file if it exists
|
||||
if (Test-Path $zipPath) {
|
||||
Log "ZipPath exists, removing"
|
||||
Remove-Item $zipPath -Force
|
||||
}
|
||||
|
||||
# Create the temp directory structure
|
||||
$tempZipDir = "F:\SPT-AKI-DEV\tempZip"
|
||||
if (Test-Path $tempZipDir) {
|
||||
Log "TempZipDir exists, removing"
|
||||
Remove-Item $tempZipDir -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Path $tempZipDir
|
||||
Log "TempZipDir created: $tempZipDir"
|
||||
|
||||
# Create the required folder structure within the temp directory
|
||||
$bepinexPluginsDir = Join-Path $tempZipDir "Bepinex\plugins"
|
||||
New-Item -ItemType Directory -Path $bepinexPluginsDir -Force
|
||||
Log "Bepinex\plugins directory created: $bepinexPluginsDir"
|
||||
|
||||
# Copy the single DLL to the new structure
|
||||
Copy-Item -Path $TargetPath -Destination $bepinexPluginsDir -Force
|
||||
Log "DLL copied to Bepinex\plugins directory"
|
||||
|
||||
# Create the final zip file
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||
[System.IO.Compression.ZipFile]::CreateFromDirectory($tempZipDir, $zipPath)
|
||||
Log "Final zip file created: $zipPath"
|
||||
|
||||
# Clean up temp directory
|
||||
Remove-Item $tempZipDir -Recurse -Force
|
||||
Log "TempZipDir removed"
|
||||
}
|
||||
|
||||
Log "Script finished"
|
@@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Aki.Reflection.Patching;
|
||||
using SPT.Reflection.Patching;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using EFT;
|
||||
|
||||
namespace armorMod
|
||||
{
|
||||
[BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.5.0")]
|
||||
[BepInDependency("com.spt-aki.core", "3.7.0")]
|
||||
[BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.7.0")]
|
||||
public class AssPlugin : BaseUnityPlugin
|
||||
{
|
||||
internal static ConfigEntry<Boolean> ArmorServiceMode
|
||||
@@ -95,7 +94,7 @@ namespace armorMod
|
||||
protected override MethodBase GetTargetMethod() => typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
||||
|
||||
[PatchPrefix]
|
||||
private static void PatchPrefix()
|
||||
internal static void PatchPrefix()
|
||||
{
|
||||
AssComponent.Enable();
|
||||
}
|
||||
|
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.4.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
||||
[assembly: AssemblyVersion("1.7.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.7.0.0")]
|
||||
|
Reference in New Issue
Block a user