Skip to content

Commit

Permalink
Merge branch 'durability'
Browse files Browse the repository at this point in the history
  • Loading branch information
sailro committed Apr 21, 2024
2 parents 4dd7664 + 28b3a43 commit 8382fd0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 16 additions & 8 deletions Features/Durability.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using EFT.Trainer.Extensions;
using System.Linq;
using EFT.InventoryLogic;
using EFT.Trainer.Extensions;
using JetBrains.Annotations;

#nullable enable
Expand All @@ -9,7 +11,7 @@ namespace EFT.Trainer.Features;
internal class Durability : ToggleFeature
{
public override string Name => "durability";
public override string Description => "Maintains maximum durability of the player's weapon.";
public override string Description => "Maximum durability of items.";

public override bool Enabled { get; set; } = false;

Expand All @@ -19,13 +21,19 @@ protected override void UpdateWhenEnabled()
if (!player.IsValid())
return;

if (player.HandsController is not Player.FirearmController controller)
return;
var allPlayerItems = player.Profile
.Inventory
.GetPlayerItems()
.ToArray();

if (controller.Item?.Repairable is not {} repairable)
return;
foreach (var item in allPlayerItems)
{
var repairable = item?.GetItemComponent<RepairableComponent>();
if (repairable == null)
continue;

repairable.MaxDurability = repairable.TemplateDurability;
repairable.Durability = repairable.MaxDurability;
repairable.MaxDurability = repairable.TemplateDurability;
repairable.Durability = repairable.MaxDurability;
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This is an attempt -for educational purposes only- to alter a Unity game at runt
| `AutomaticGun` | `autogun` | Force all guns (even bolt action guns) to use automatic firing mode with customizable fire rate. |
| `Commands` | `commands` | Popup window to enable/disable all features (use right-alt or setup your own key in [trainer.ini](#sample-trainerini-configuration-file)). |
| `CrossHair` | `crosshair` | Crosshair with customizable size, color, thickness and auto-hide feature when aiming. |
| `Durability` | `durability` | Maintains maximum durability of the player's weapon. |
| `Durability` | `durability` | Maximum durability of items. |
| `Examine` | `examine` | All items already examined. |
| `ExfiltrationPoints` | `exfil` | Exfiltration points with customizable colors given eligibility, status filter, distance. |
| `FovChanger` | `fovchanger` | Change Field Of View (FOV). |
Expand Down

0 comments on commit 8382fd0

Please sign in to comment.