mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-27 21:34:15 -05:00
Add logic for drop compatibility check skipping (parsing)
This commit is contained in:
@@ -14,5 +14,10 @@ public interface IConfigItem
|
||||
/// Wrapping paper type applied if <see cref="WrapAllItems"/> is set.
|
||||
/// </summary>
|
||||
ItemWrappingPaper WrappingPaper { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the Drop Compatibility check should be skipped.
|
||||
/// </summary>
|
||||
bool SkipDropCheck { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ private static Item FinalizeItem(int requestIndex, IConfigItem config, ItemDesti
|
||||
{
|
||||
if (type == ItemDestination.PlayerDropped)
|
||||
{
|
||||
if (!ItemInfo.IsSaneItemForDrop(item))
|
||||
if (!ItemInfo.IsSaneItemForDrop(item) && !config.SkipDropCheck)
|
||||
throw new Exception($"Unsupported item: (index {requestIndex}).");
|
||||
if (config.WrapAllItems && item.ShouldWrapItem())
|
||||
item.SetWrapping(ItemWrapping.WrappingPaper, config.WrappingPaper, true);
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace NHSE.Injection
|
||||
{
|
||||
public class AutoInjector
|
||||
{
|
||||
private readonly IDataInjector Injector;
|
||||
public readonly IDataInjector Injector;
|
||||
private readonly Action<InjectionResult> AfterRead;
|
||||
private readonly Action<InjectionResult> AfterWrite;
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ public class PocketInjector : IDataInjector
|
||||
|
||||
public uint WriteOffset { private get; set; }
|
||||
public bool ValidateEnabled { get; set; } = true;
|
||||
public bool SpoofInventoryWrite { get; set; } = false;
|
||||
private static readonly Item DroppableOnlyItem = new(0x9C9); // Gold nugget
|
||||
|
||||
public PocketInjector(IReadOnlyList<Item> items, IRAMReadWriter bot)
|
||||
{
|
||||
@@ -50,7 +52,9 @@ public InjectionResult Write()
|
||||
|
||||
var orig = (byte[])data.Clone();
|
||||
|
||||
PlayerItemSet.WritePlayerInventory(data, Items);
|
||||
var items = !SpoofInventoryWrite ? Items : Enumerable.Repeat(DroppableOnlyItem, Items.Count).ToArray();
|
||||
|
||||
PlayerItemSet.WritePlayerInventory(data, items);
|
||||
|
||||
if (data.SequenceEqual(orig))
|
||||
return InjectionResult.Same;
|
||||
|
||||
@@ -37,6 +37,7 @@ private class ConfigWrapFake : IConfigItem
|
||||
{
|
||||
public bool WrapAllItems { get; } = true;
|
||||
public ItemWrappingPaper WrappingPaper { get; } = ItemWrappingPaper.Black;
|
||||
public bool SkipDropCheck { get; } = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,17 @@ private void B_WriteCurrent_Click(object sender, EventArgs e)
|
||||
|
||||
try
|
||||
{
|
||||
var result = Injector.Write(true);
|
||||
InjectionResult result;
|
||||
if (Injector.Injector is PocketInjector p)
|
||||
{
|
||||
p.SpoofInventoryWrite = ModifierKeys == Keys.Control;
|
||||
result = Injector.Write(true);
|
||||
p.SpoofInventoryWrite = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Injector.Write(true);
|
||||
}
|
||||
if (result == InjectionResult.Success)
|
||||
return;
|
||||
WinFormsUtil.Alert(result.ToString());
|
||||
|
||||
Reference in New Issue
Block a user