Now with spaws detection
This commit is contained in:
parent
d2e9988bdd
commit
56b09f509a
1 changed files with 32 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
@ -43,6 +44,8 @@ namespace MosswartMassacre
|
||||||
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
CoreManager.Current.ChatBoxMessage += new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
||||||
CoreManager.Current.CommandLineText += OnChatCommand;
|
CoreManager.Current.CommandLineText += OnChatCommand;
|
||||||
CoreManager.Current.CharacterFilter.LoginComplete += CharacterFilter_LoginComplete;
|
CoreManager.Current.CharacterFilter.LoginComplete += CharacterFilter_LoginComplete;
|
||||||
|
CoreManager.Current.WorldFilter.CreateObject += OnSpawn;
|
||||||
|
CoreManager.Current.WorldFilter.ReleaseObject += OnDespawn;
|
||||||
|
|
||||||
// Initialize the timer
|
// Initialize the timer
|
||||||
updateTimer = new Timer(1000); // Update every second
|
updateTimer = new Timer(1000); // Update every second
|
||||||
|
|
@ -78,6 +81,8 @@ namespace MosswartMassacre
|
||||||
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
|
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(OnChatText);
|
||||||
CoreManager.Current.CommandLineText -= OnChatCommand;
|
CoreManager.Current.CommandLineText -= OnChatCommand;
|
||||||
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
CoreManager.Current.ChatBoxMessage -= new EventHandler<ChatTextInterceptEventArgs>(AllChatText);
|
||||||
|
CoreManager.Current.WorldFilter.CreateObject -= OnSpawn;
|
||||||
|
CoreManager.Current.WorldFilter.ReleaseObject -= OnDespawn;
|
||||||
|
|
||||||
// Stop and dispose of the timer
|
// Stop and dispose of the timer
|
||||||
if (updateTimer != null)
|
if (updateTimer != null)
|
||||||
|
|
@ -123,6 +128,33 @@ namespace MosswartMassacre
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void OnSpawn(object sender, CreateObjectEventArgs e)
|
||||||
|
{
|
||||||
|
// e.New is the wrapped WorldObject that just appeared
|
||||||
|
var mob = e.New;
|
||||||
|
if (mob.ObjectClass != ObjectClass.Monster) return;
|
||||||
|
|
||||||
|
var coords = mob.Coordinates();
|
||||||
|
float ns = (float)coords.NorthSouth;
|
||||||
|
float ew = (float)coords.EastWest;
|
||||||
|
|
||||||
|
WriteToChat($"[Spawn] {mob.Name} @ (NS={ns:F1}, EW={ew:F1})");
|
||||||
|
// TODO: record (ew, ns) for your heatmap
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDespawn(object sender, ReleaseObjectEventArgs e)
|
||||||
|
{
|
||||||
|
// e.Released is the wrapped WorldObject that just disappeared
|
||||||
|
var mob = e.Released;
|
||||||
|
if (mob.ObjectClass != ObjectClass.Monster) return;
|
||||||
|
|
||||||
|
var coords = mob.Coordinates();
|
||||||
|
float ns = (float)coords.NorthSouth;
|
||||||
|
float ew = (float)coords.EastWest;
|
||||||
|
|
||||||
|
WriteToChat($"[Despawn] {mob.Name} @ (NS={ns:F1}, EW={ew:F1})");
|
||||||
|
}
|
||||||
|
|
||||||
private static string NormalizeChatLine(string raw)
|
private static string NormalizeChatLine(string raw)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(raw))
|
if (string.IsNullOrEmpty(raw))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue