Compare commits
8 Commits
a3517b0c8c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
344ff7bb42 | ||
|
|
c2686f3a38 | ||
|
|
91364aab2b | ||
|
|
252a848806 | ||
|
|
594896e75f | ||
|
|
bf1f049f53 | ||
|
|
c991178de7 | ||
|
|
50996400bc |
34
ASS.csproj
34
ASS.csproj
@@ -9,9 +9,10 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>dvize.ASS</RootNamespace>
|
<RootNamespace>dvize.ASS</RootNamespace>
|
||||||
<AssemblyName>dvize.ASS</AssemblyName>
|
<AssemblyName>dvize.ASS</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -23,31 +24,21 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>portable</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>
|
||||||
|
</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>BepInEx\core\0Harmony.dll</HintPath>
|
<HintPath>BepInEx\core\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</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>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
@@ -75,6 +66,12 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\ItemTemplate.Types.dll</HintPath>
|
<HintPath>F:\SPT-AKI-DEV\EscapeFromTarkov_Data\Managed\ItemTemplate.Types.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="spt-common">
|
||||||
|
<HintPath>F:\SPT-AKI-DEV\BepInEx\plugins\spt\spt-common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="spt-reflection">
|
||||||
|
<HintPath>F:\SPT-AKI-DEV\BepInEx\plugins\spt\spt-reflection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
@@ -108,11 +105,14 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>copy "$(TargetPath)" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll"
|
<PostBuildEvent>copy "$(TargetPath)" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll"
|
||||||
|
|
||||||
if $(ConfigurationName) == Debug (
|
if "$(ConfigurationName)" == "Debug" (
|
||||||
copy "$(TargetDir)$(TargetName).pdb" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
copy "$(TargetDir)$(TargetName).pdb" "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
||||||
) else (
|
) else (
|
||||||
del "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
del "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).pdb"
|
||||||
)
|
)
|
||||||
</PostBuildEvent>
|
|
||||||
|
if "$(ConfigurationName)" == "Release" (
|
||||||
|
powershell -ExecutionPolicy Bypass -NoProfile -NonInteractive -File "$(ProjectDir)PackageMods.ps1" -ConfigurationName "$(ConfigurationName)" -TargetPath "F:\SPT-AKI-DEV\BepInEx\plugins\$(TargetName).dll" -TargetName "$(TargetName)" -TargetDir "F:\SPT-AKI-DEV\BepInEx\plugins"
|
||||||
|
)</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
299
Component.cs
299
Component.cs
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using BepInEx.Logging;
|
using BepInEx.Logging;
|
||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using EFT;
|
using EFT;
|
||||||
@@ -11,221 +10,131 @@ namespace armorMod
|
|||||||
{
|
{
|
||||||
internal class AssComponent : MonoBehaviour
|
internal class AssComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static GameWorld gameWorld = new GameWorld();
|
internal static ManualLogSource Logger;
|
||||||
private static Player player = new Player();
|
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;
|
internal static List<EquipmentSlot> equipmentSlotDictionary = new List<EquipmentSlot>
|
||||||
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>>
|
|
||||||
{
|
{
|
||||||
{ EquipmentSlot.ArmorVest, new List<Item>() },
|
{ EquipmentSlot.ArmorVest},
|
||||||
{ EquipmentSlot.TacticalVest, new List<Item>() },
|
{ EquipmentSlot.TacticalVest},
|
||||||
{ EquipmentSlot.Eyewear, new List<Item>() },
|
{ EquipmentSlot.Eyewear},
|
||||||
{ EquipmentSlot.FaceCover, new List<Item>() },
|
{ EquipmentSlot.FaceCover},
|
||||||
{ EquipmentSlot.Headwear, new List<Item>() },
|
{ 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.FirstPrimaryWeapon },
|
||||||
{ EquipmentSlot.SecondPrimaryWeapon, new List<Item>() },
|
{ EquipmentSlot.SecondPrimaryWeapon },
|
||||||
{ EquipmentSlot.Holster, new List<Item>() },
|
{ EquipmentSlot.Holster },
|
||||||
};
|
};
|
||||||
protected static ManualLogSource Logger
|
|
||||||
{
|
private void Awake()
|
||||||
get; private set;
|
|
||||||
}
|
|
||||||
private AssComponent()
|
|
||||||
{
|
{
|
||||||
if (Logger == null)
|
if (Logger == null)
|
||||||
{
|
|
||||||
Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AssComponent));
|
Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(AssComponent));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
player = Singleton<GameWorld>.Instance.MainPlayer;
|
player = gameWorld.MainPlayer;
|
||||||
player.BeingHitAction += Player_BeingHitAction;
|
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.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.MaxDurability);
|
||||||
|
component.MaxDurability = Mathf.Max(component.MaxDurability - 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()
|
internal static void Enable()
|
||||||
{
|
{
|
||||||
if (Singleton<IBotGame>.Instantiated)
|
if (Singleton<IBotGame>.Instantiated)
|
||||||
{
|
{
|
||||||
gameWorld = Singleton<GameWorld>.Instance;
|
gameWorld = Singleton<GameWorld>.Instance;
|
||||||
gameWorld.GetOrAddComponent<AssComponent>();
|
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;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Aki.Reflection.Patching;
|
using SPT.Reflection.Patching;
|
||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using EFT;
|
using EFT;
|
||||||
|
|
||||||
namespace armorMod
|
namespace armorMod
|
||||||
{
|
{
|
||||||
[BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.5.0")]
|
[BepInPlugin("com.dvize.ASS", "dvize.ASS", "1.7.0")]
|
||||||
[BepInDependency("com.spt-aki.core", "3.7.0")]
|
|
||||||
public class AssPlugin : BaseUnityPlugin
|
public class AssPlugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
internal static ConfigEntry<Boolean> ArmorServiceMode
|
internal static ConfigEntry<Boolean> ArmorServiceMode
|
||||||
@@ -95,7 +94,7 @@ namespace armorMod
|
|||||||
protected override MethodBase GetTargetMethod() => typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
protected override MethodBase GetTargetMethod() => typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void PatchPrefix()
|
internal static void PatchPrefix()
|
||||||
{
|
{
|
||||||
AssComponent.Enable();
|
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
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.4.0.0")]
|
[assembly: AssemblyVersion("1.7.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
[assembly: AssemblyFileVersion("1.7.0.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user