Added inventory over websockets, death reporting, taper reporting.

This commit is contained in:
erik 2025-06-08 22:45:22 +02:00
parent ebf6fd0bf7
commit 28bdf7f312
7 changed files with 273 additions and 8 deletions

View file

@ -2,6 +2,7 @@
using Decal.Adapter;
using Decal.Adapter.Wrappers;
using System.Numerics;
using Mag.Shared.Constants;
namespace MosswartMassacre
{
@ -72,5 +73,83 @@ namespace MosswartMassacre
public static double DegToRad(double deg) => deg * Math.PI / 180.0;
public static double RadToDeg(double rad) => rad * 180.0 / Math.PI;
/* ----------------------------------------------------------
* 4) Generic item property access
* -------------------------------------------------------- */
/// <summary>
/// Find a WorldObject item by name in inventory
/// </summary>
/// <param name="itemName">Name of the item to find</param>
/// <returns>WorldObject or null if not found</returns>
public static WorldObject FindItemByName(string itemName)
{
try
{
var worldFilter = CoreManager.Current.WorldFilter;
var playerInv = CoreManager.Current.CharacterFilter.Id;
// Search inventory
foreach (WorldObject item in worldFilter.GetByContainer(playerInv))
{
if (string.Equals(item.Name, itemName, StringComparison.OrdinalIgnoreCase))
return item;
}
return null;
}
catch
{
return null;
}
}
/// <summary>
/// Get the stack size/quantity of a specific item by name
/// </summary>
/// <param name="itemName">Name of the item to find</param>
/// <returns>Stack size or 0 if not found</returns>
public static int GetItemStackSize(string itemName)
{
try
{
var item = FindItemByName(itemName);
return item?.Values(LongValueKey.StackCount) ?? 0;
}
catch
{
return 0;
}
}
/// <summary>
/// Get the icon ID of a specific item by name
/// </summary>
/// <param name="itemName">Name of the item to find</param>
/// <returns>Icon ID or 0 if not found</returns>
public static int GetItemIcon(string itemName)
{
try
{
var item = FindItemByName(itemName);
return item?.Icon ?? 0;
}
catch
{
return 0;
}
}
/// <summary>
/// Get the display icon ID (with 0x6000000 offset) for an item by name
/// </summary>
/// <param name="itemName">Name of the item to find</param>
/// <returns>Display icon ID or 0x6002D14 (default icon) if not found</returns>
public static int GetItemDisplayIcon(string itemName)
{
int rawIcon = GetItemIcon(itemName);
return rawIcon != 0 ? rawIcon + 0x6000000 : 0x6002D14;
}
}
}