Fixed inventory, spawn and settings

This commit is contained in:
erik 2025-05-15 21:34:20 +02:00
parent 0c539bc023
commit f4ec57a44d
5 changed files with 51 additions and 37 deletions

View file

@ -41,6 +41,18 @@
<Reference Include="Decal.FileService">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Decal 3.0\Decal.FileService.dll</HintPath>
</Reference>
<Reference Include="Decal.Interop.Core, Version=2.9.8.3, Culture=neutral, PublicKeyToken=481f17d392f1fb65, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Decal 3.0\.NET 4.0 PIA\Decal.Interop.Core.DLL</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Decal.Interop.Filters, Version=2.9.8.3, Culture=neutral, PublicKeyToken=481f17d392f1fb65, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Decal 3.0\.NET 4.0 PIA\Decal.Interop.Filters.DLL</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Decal.Interop.Inject, Version=2.9.8.3, Culture=neutral, PublicKeyToken=481f17d392f1fb65, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<EmbedInteropTypes>False</EmbedInteropTypes>
@ -53,6 +65,7 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.Remoting" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -181,7 +194,7 @@
<Lcid>0</Lcid>
<WrapperTool>primary</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
<EmbedInteropTypes>False</EmbedInteropTypes>
</COMReference>
<COMReference Include="DecalNet">
<Guid>{572B87C4-93BD-46B3-A291-CD58181D25DC}</Guid>

View file

@ -19,21 +19,25 @@ namespace MosswartMassacre
{
get
{
// 1) grab your character name
// 1) Character name
var characterName = CoreManager.Current.CharacterFilter.Name;
// 2) grab the folder where your plugin dll is running
// 2) Plugin folder
var pluginFolder = Path.GetDirectoryName(
System.Reflection.Assembly
.GetExecutingAssembly()
.Location
);
// 3) combine into a full path with .json
return Path.Combine(
pluginFolder,
$"{characterName}.json"
);
// 3) Character-specific folder path
var characterFolder = Path.Combine(pluginFolder, characterName);
// 4) Ensure directory exists (can do it here, thread-safe for most single-user plugin cases)
if (!Directory.Exists(characterFolder))
Directory.CreateDirectory(characterFolder);
// 5) Return full path to the .json file inside the character folder
return Path.Combine(characterFolder, $"{characterName}.json");
}
}

View file

@ -1,11 +1,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Timers;
using Decal.Adapter;
using Decal.Adapter.Wrappers;
@ -30,7 +32,6 @@ namespace MosswartMassacre
public static bool TelemetryEnabled { get; set; } = false;
public bool WebSocketEnabled { get; set; } = false;
public bool InventoryLogEnabled { get; set; } = false;
private MossyInventory _inventoryLogger;
private static Queue<string> rareMessageQueue = new Queue<string>();
@ -44,7 +45,6 @@ namespace MosswartMassacre
MyHost = Host;
WriteToChat("Mosswart Massacre has started!");
// Subscribe to chat message event
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
@ -53,6 +53,7 @@ namespace MosswartMassacre
CoreManager.Current.WorldFilter.CreateObject += OnSpawn;
CoreManager.Current.WorldFilter.ReleaseObject += OnDespawn;
// Initialize the timer
updateTimer = new Timer(1000); // Update every second
updateTimer.Elapsed += UpdateStats;
@ -95,6 +96,7 @@ namespace MosswartMassacre
CoreManager.Current.WorldFilter.CreateObject -= OnSpawn;
CoreManager.Current.WorldFilter.ReleaseObject -= OnDespawn;
// Stop and dispose of the timer
if (updateTimer != null)
{
@ -140,8 +142,9 @@ namespace MosswartMassacre
WebSocket.Start();
}
private async void OnSpawn(object sender, CreateObjectEventArgs e)
{
var mob = e.New;
@ -235,29 +238,7 @@ namespace MosswartMassacre
DelayedCommandManager.AddDelayedCommand($"/a {rareText}", 3000);
}
// if (e.Text.EndsWith("!testrare\""))
// {
// string simulatedText = $"{CoreManager.Current.CharacterFilter.Name} has discovered the Ancient Pickle!";
//
// if (IsRareDiscoveryMessage(simulatedText, out string simulatedRareText))
// {
// rareCount++;
// MainView.UpdateRareCount(rareCount);
//
// if (RareMetaEnabled)
// {
// Decal_DispatchOnChatCommand("/vt setmetastate loot_rare");
// }
//
// DelayedCommandManager.AddDelayedCommand($"/a {simulatedRareText}", 3000);
// }
// else
// {
// WriteToChat("[Test] Simulated rare message didn't match the regex.");
// }
//
// return;
// }
if (e.Color == 18 && e.Text.EndsWith("!report\""))
{
TimeSpan elapsed = DateTime.Now - statsStartTime;
@ -540,6 +521,7 @@ namespace MosswartMassacre
WriteToChat("/mm http - Local http-command server enable|disable");
WriteToChat("/mm remotecommand - Listen to allegiance !do/!dot enable|disable");
WriteToChat("/mm getmetastate - Gets the current metastate");
break;
case "report":

View file

@ -26,10 +26,21 @@ namespace MosswartMassacre
public static void Initialize()
{
// determine settings file path
// determine plugin folder and character-specific folder
string characterName = CoreManager.Current.CharacterFilter.Name;
string pluginFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
_filePath = Path.Combine(pluginFolder, $"{characterName}.yaml");
// Path for character-specific folder
string characterFolder = Path.Combine(pluginFolder, characterName);
// Create the character folder if it doesn't exist
if (!Directory.Exists(characterFolder))
{
Directory.CreateDirectory(characterFolder);
}
// YAML file is now in the character-specific folder
_filePath = Path.Combine(characterFolder, $"{characterName}.yaml");
// build serializer/deserializer once
var builder = new DeserializerBuilder()

View file

@ -14,6 +14,10 @@
<assemblyIdentity name="Decal.Interop.Inject" publicKeyToken="481f17d392f1fb65" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.9.8.3" newVersion="2.9.8.3" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Decal.FileService" publicKeyToken="bd1c8ce002ce221e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.9.8.3" newVersion="2.9.8.3" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>