Add logic for drop compatibility check skipping (parsing)

This commit is contained in:
Kurt
2021-03-03 17:44:16 -08:00
parent 75c176c028
commit 2242861c80
6 changed files with 24 additions and 4 deletions

View File

@@ -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; }
}
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -37,6 +37,7 @@ private class ConfigWrapFake : IConfigItem
{
public bool WrapAllItems { get; } = true;
public ItemWrappingPaper WrappingPaper { get; } = ItemWrappingPaper.Black;
public bool SkipDropCheck { get; } = false;
}
}
}

View File

@@ -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());