Added inventory over websockets, death reporting, taper reporting.
This commit is contained in:
parent
ebf6fd0bf7
commit
28bdf7f312
7 changed files with 273 additions and 8 deletions
|
|
@ -13,6 +13,7 @@ using System.Timers;
|
|||
using Decal.Adapter;
|
||||
using Decal.Adapter.Wrappers;
|
||||
using MosswartMassacre.Views;
|
||||
using Mag.Shared.Constants;
|
||||
|
||||
namespace MosswartMassacre
|
||||
{
|
||||
|
|
@ -22,6 +23,8 @@ namespace MosswartMassacre
|
|||
internal static PluginHost MyHost;
|
||||
internal static int totalKills = 0;
|
||||
internal static int rareCount = 0;
|
||||
internal static int sessionDeaths = 0; // Deaths this session
|
||||
internal static int totalDeaths = 0; // Total deaths from character
|
||||
internal static DateTime lastKillTime = DateTime.Now;
|
||||
internal static double killsPer5Min = 0;
|
||||
internal static double killsPerHour = 0;
|
||||
|
|
@ -94,6 +97,7 @@ namespace MosswartMassacre
|
|||
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
||||
CoreManager.Current.CommandLineText += OnChatCommand;
|
||||
CoreManager.Current.CharacterFilter.LoginComplete += CharacterFilter_LoginComplete;
|
||||
CoreManager.Current.CharacterFilter.Death += OnCharacterDeath;
|
||||
CoreManager.Current.WorldFilter.CreateObject += OnSpawn;
|
||||
CoreManager.Current.WorldFilter.ReleaseObject += OnDespawn;
|
||||
// Initialize VVS view after character login
|
||||
|
|
@ -142,6 +146,7 @@ namespace MosswartMassacre
|
|||
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
|
||||
CoreManager.Current.CommandLineText -= OnChatCommand;
|
||||
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
||||
CoreManager.Current.CharacterFilter.Death -= OnCharacterDeath;
|
||||
CoreManager.Current.WorldFilter.CreateObject -= OnSpawn;
|
||||
CoreManager.Current.WorldFilter.ReleaseObject -= OnDespawn;
|
||||
|
||||
|
|
@ -219,6 +224,10 @@ namespace MosswartMassacre
|
|||
WriteToChat($"[ERROR] Harmony initialization failed: {ex.Message}");
|
||||
}
|
||||
|
||||
// Initialize death tracking
|
||||
totalDeaths = CoreManager.Current.CharacterFilter.GetCharProperty((int)IntValueKey.NumDeaths);
|
||||
sessionDeaths = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -287,6 +296,13 @@ namespace MosswartMassacre
|
|||
|
||||
return collapsed;
|
||||
}
|
||||
|
||||
private void OnCharacterDeath(object sender, Decal.Adapter.Wrappers.DeathEventArgs e)
|
||||
{
|
||||
sessionDeaths++;
|
||||
totalDeaths = CoreManager.Current.CharacterFilter.GetCharProperty((int)IntValueKey.NumDeaths);
|
||||
}
|
||||
|
||||
private void HandleServerCommand(CommandEnvelope env)
|
||||
{
|
||||
// Skicka commands
|
||||
|
|
@ -395,6 +411,7 @@ namespace MosswartMassacre
|
|||
// Recalculate kill rates
|
||||
CalculateKillsPerInterval();
|
||||
ViewManager.UpdateKillStats(totalKills, killsPer5Min, killsPerHour);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -487,11 +504,12 @@ namespace MosswartMassacre
|
|||
{
|
||||
totalKills = 0;
|
||||
rareCount = 0;
|
||||
sessionDeaths = 0; // Reset session deaths only
|
||||
statsStartTime = DateTime.Now;
|
||||
killsPer5Min = 0;
|
||||
killsPerHour = 0;
|
||||
|
||||
WriteToChat("Stats have been reset.");
|
||||
WriteToChat($"Stats have been reset. Session deaths: {sessionDeaths}, Total deaths: {totalDeaths}");
|
||||
ViewManager.UpdateKillStats(totalKills, killsPer5Min, killsPerHour);
|
||||
ViewManager.UpdateRareCount(rareCount);
|
||||
}
|
||||
|
|
@ -608,11 +626,14 @@ namespace MosswartMassacre
|
|||
WriteToChat("/mm decalstatus - Check Harmony patch status (UtilityBelt version)");
|
||||
WriteToChat("/mm decaldebug - Enable/disable plugin message debug output + WebSocket streaming");
|
||||
WriteToChat("/mm harmonyraw - Show raw intercepted messages (debug output)");
|
||||
WriteToChat("/mm testprismatic - Test Prismatic Taper detection and icon lookup");
|
||||
WriteToChat("/mm deathstats - Show current death tracking statistics");
|
||||
WriteToChat("/mm testdeath - Manual death tracking test and diagnostics");
|
||||
WriteToChat("/mm gui - Manually initialize/reinitialize GUI");
|
||||
break;
|
||||
case "report":
|
||||
TimeSpan elapsed = DateTime.Now - statsStartTime;
|
||||
string reportMessage = $"Total Kills: {totalKills}, Kills per Hour: {killsPerHour:F2}, Elapsed Time: {elapsed:dd\\.hh\\:mm\\:ss}, Rares Found: {rareCount}";
|
||||
string reportMessage = $"Total Kills: {totalKills}, Kills per Hour: {killsPerHour:F2}, Elapsed Time: {elapsed:dd\\.hh\\:mm\\:ss}, Rares Found: {rareCount}, Session Deaths: {sessionDeaths}, Total Deaths: {totalDeaths}";
|
||||
WriteToChat(reportMessage);
|
||||
break;
|
||||
case "getmetastate":
|
||||
|
|
@ -815,6 +836,139 @@ namespace MosswartMassacre
|
|||
}
|
||||
break;
|
||||
|
||||
case "testprismatic":
|
||||
try
|
||||
{
|
||||
WriteToChat("=== FULL INVENTORY DUMP ===");
|
||||
var worldFilter = CoreManager.Current.WorldFilter;
|
||||
var playerInv = CoreManager.Current.CharacterFilter.Id;
|
||||
|
||||
WriteToChat("Listing ALL items in your main inventory:");
|
||||
int itemNum = 1;
|
||||
|
||||
foreach (WorldObject item in worldFilter.GetByContainer(playerInv))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Name))
|
||||
{
|
||||
int stackCount = item.Values(LongValueKey.StackCount, 0);
|
||||
WriteToChat($"{itemNum:D2}: '{item.Name}' (count: {stackCount}, icon: 0x{item.Icon:X}, class: {item.ObjectClass})");
|
||||
itemNum++;
|
||||
|
||||
// Highlight anything that might be a taper
|
||||
string nameLower = item.Name.ToLower();
|
||||
if (nameLower.Contains("taper") || nameLower.Contains("prismatic") ||
|
||||
nameLower.Contains("prism") || nameLower.Contains("component"))
|
||||
{
|
||||
WriteToChat($" *** POSSIBLE MATCH: '{item.Name}' ***");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WriteToChat($"=== Total items listed: {itemNum - 1} ===");
|
||||
|
||||
// Now test our utility functions on the found Prismatic Taper
|
||||
WriteToChat("=== Testing Utility Functions on Prismatic Taper ===");
|
||||
var foundItem = Utils.FindItemByName("Prismatic Taper");
|
||||
if (foundItem != null)
|
||||
{
|
||||
WriteToChat($"SUCCESS! Found: '{foundItem.Name}'");
|
||||
WriteToChat($"Utils.GetItemStackSize: {Utils.GetItemStackSize("Prismatic Taper")}");
|
||||
WriteToChat($"Utils.GetItemIcon: 0x{Utils.GetItemIcon("Prismatic Taper"):X}");
|
||||
WriteToChat($"Utils.GetItemDisplayIcon: 0x{Utils.GetItemDisplayIcon("Prismatic Taper"):X}");
|
||||
WriteToChat("=== TELEMETRY WILL NOW WORK! ===");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("ERROR: Still can't find Prismatic Taper with utility functions!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToChat($"Search error: {ex.Message}");
|
||||
}
|
||||
break;
|
||||
|
||||
case "deathstats":
|
||||
try
|
||||
{
|
||||
WriteToChat("=== Death Tracking Statistics ===");
|
||||
WriteToChat($"Session Deaths: {sessionDeaths}");
|
||||
WriteToChat($"Total Deaths: {totalDeaths}");
|
||||
|
||||
// Get current character death count to verify sync
|
||||
int currentCharDeaths = CoreManager.Current.CharacterFilter.GetCharProperty((int)IntValueKey.NumDeaths);
|
||||
WriteToChat($"Character Property NumDeaths: {currentCharDeaths}");
|
||||
|
||||
if (currentCharDeaths != totalDeaths)
|
||||
{
|
||||
WriteToChat($"[WARNING] Death count sync issue detected!");
|
||||
WriteToChat($"Updating totalDeaths from {totalDeaths} to {currentCharDeaths}");
|
||||
totalDeaths = currentCharDeaths;
|
||||
}
|
||||
|
||||
WriteToChat("Death tracking is active and will increment on character death.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToChat($"Death stats error: {ex.Message}");
|
||||
}
|
||||
break;
|
||||
|
||||
case "testdeath":
|
||||
try
|
||||
{
|
||||
WriteToChat("=== Manual Death Test ===");
|
||||
WriteToChat($"Current sessionDeaths variable: {sessionDeaths}");
|
||||
WriteToChat($"Current totalDeaths variable: {totalDeaths}");
|
||||
|
||||
// Read directly from character property
|
||||
int currentCharDeaths = CoreManager.Current.CharacterFilter.GetCharProperty((int)IntValueKey.NumDeaths);
|
||||
WriteToChat($"Character Property NumDeaths (43): {currentCharDeaths}");
|
||||
|
||||
// Manually increment session deaths for testing
|
||||
sessionDeaths++;
|
||||
WriteToChat($"Manually incremented sessionDeaths to: {sessionDeaths}");
|
||||
WriteToChat("Note: This doesn't simulate a real death, just tests the tracking variables.");
|
||||
|
||||
// Check if death event is properly subscribed
|
||||
WriteToChat($"Death event subscription check:");
|
||||
var deathEvent = typeof(Decal.Adapter.Wrappers.CharacterFilter).GetEvent("Death");
|
||||
WriteToChat($"Death event exists: {deathEvent != null}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToChat($"Test death error: {ex.Message}");
|
||||
}
|
||||
break;
|
||||
|
||||
case "finditem":
|
||||
if (args.Length > 1)
|
||||
{
|
||||
string itemName = string.Join(" ", args, 1, args.Length - 1).Trim('"');
|
||||
WriteToChat($"=== Searching for: '{itemName}' ===");
|
||||
|
||||
var foundItem = Utils.FindItemByName(itemName);
|
||||
if (foundItem != null)
|
||||
{
|
||||
WriteToChat($"FOUND: '{foundItem.Name}'");
|
||||
WriteToChat($"Count: {foundItem.Values(LongValueKey.StackCount, 0)}");
|
||||
WriteToChat($"Icon: 0x{foundItem.Icon:X}");
|
||||
WriteToChat($"Display Icon: 0x{(foundItem.Icon + 0x6000000):X}");
|
||||
WriteToChat($"Object Class: {foundItem.ObjectClass}");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat($"NOT FOUND: '{itemName}'");
|
||||
WriteToChat("Make sure the name is exactly as it appears in-game.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteToChat("Usage: /mm finditem \"Item Name\"");
|
||||
WriteToChat("Example: /mm finditem \"Prismatic Taper\"");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
WriteToChat($"Unknown /mm command: {subCommand}. Try /mm help");
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue