Skip to content

Commit

Permalink
Allow mob aliases, parse rune command
Browse files Browse the repository at this point in the history
  • Loading branch information
eq2reapp committed Nov 19, 2022
1 parent a294aa0 commit 306839b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 43 deletions.
58 changes: 43 additions & 15 deletions WhatRune.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class WhatRune : IActPluginV1

public static string CONSIDER_TOKEN = "You consider";
public static Regex REGEX_CONSIDER = new Regex(@"^(\\#[ABCDEF0-9]{6})?" + CONSIDER_TOKEN);
public static string RUNE_TOKEN = "'rune ";
public static Regex REGEX_RUNE = new Regex(@"^Unknown command: " + RUNE_TOKEN);

private WhatRuneSettings _settings = null;
private TabPage _pluginScreenSpace = null;
Expand Down Expand Up @@ -230,9 +232,11 @@ private async Task FetchRuneDefs()
string[] defParts = line.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (defParts.Length > 0)
{
string mobName = defParts[0].Trim();
// The part of the string on the left of "=" can be a comma separated list of aliases,
// or in multi-name encounters the complete set of mob names
string[] mobNames = defParts[0].Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

string rune = "No rune";
string rune = "No specific rune";
if (defParts.Length >= 2)
{
// Let's make this part future-proof. We'll separate info bits using a token: ";"
Expand All @@ -247,9 +251,13 @@ private async Task FetchRuneDefs()
}

// If we get duplicate mobs, only add the first one
if (!Runes.ContainsKey(mobName))
foreach (string mobName in mobNames)
{
Runes.TryAdd(mobName, rune);
string key = mobName.ToLower();
if (!Runes.ContainsKey(key))
{
Runes.TryAdd(key, rune);
}
}
}
}
Expand Down Expand Up @@ -320,32 +328,52 @@ private void oFormActMain_OnLogLineRead(bool isImport, LogLineEventArgs logInfo)
{
// Scan for consider messages, eg:
// \#FFFF40You consider High Shikari Olyxa... It looks tough -and it's a LOT tougher than it looks. Better have a lot of backup for this one!
// or, /rune MobName
// Unknown command: 'rune Mayong'
try
{
string mobName = null;

string logLine = logInfo.logLine;
int startPos = logLine.IndexOf("]");
if (startPos >= 0)
{
logLine = logLine.Substring(startPos + 2);

if (REGEX_CONSIDER.IsMatch(logLine))
{
startPos = logLine.IndexOf(CONSIDER_TOKEN) + CONSIDER_TOKEN.Length + 1;
int endPos = logLine.IndexOf("...", startPos);
if (endPos >= 0)
{
string mobName = logLine.Substring(startPos, (endPos - startPos));
Log("Considering " + mobName);
string runeInfo = "Unknown rune";
if (Runes.ContainsKey(mobName))
{
runeInfo = Runes[mobName];
}
Log(" " + runeInfo);
ActGlobals.oFormActMain.TTS(runeInfo);
WriteMacroFile(runeInfo);
ShowLog();
mobName = logLine.Substring(startPos, (endPos - startPos));
}
}
else if (REGEX_RUNE.IsMatch(logLine))
{
startPos = logLine.IndexOf(RUNE_TOKEN) + RUNE_TOKEN.Length;
int endPos = logLine.LastIndexOf("'");
if (endPos >= 0)
{
mobName = logLine.Substring(startPos, (endPos - startPos));
}
}
}

if (!string.IsNullOrEmpty(mobName))
{
Log("Considering " + mobName);
string runeInfo = "Unknown rune";

string key = mobName.ToLower();
if (Runes.ContainsKey(key))
{
runeInfo = Runes[key];
}
Log(" " + runeInfo);
ActGlobals.oFormActMain.TTS(runeInfo);
WriteMacroFile(runeInfo);
ShowLog();
}
}
catch { } // Black hole...
Expand Down
Binary file modified bin/Release/ActWhatRune.dll
Binary file not shown.
54 changes: 26 additions & 28 deletions runes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,41 @@ The Reanimated Horror=
Lithania Dyrmelia=

# Forlorn Gist: Akashic Incursion
Flora Maldehyde=Stifle rune
Beulus the Claw=Stun rune
Odelia Wretch=Fear rune
Sister Belladonna=
Auntie Grimm=
Flora Maldehyde,Flora=Stifle rune
Beulus the Claw,Beulus=Stun rune
Odelia Wretch,Odelia=Fear rune
Sister Belladonna,Sister,Auntie Grimm,Auntie=
Cloaked Necromancer=
Mother Ballentree=
Grandmother Deliria=
Mother Ballentree,Mother=
Grandmother Deliria,Grandmother=

# Castle Vacrul: Thirst for Power
Lady of the Lute=Stifle rune
Legion Captain Bloodrite=
Gidget=
The Bloodtender=
Lysander Mistmoore=
Vorigan Mistmoore=
Lady of the Lute,Lady=Stifle rune
Legion Captain Bloodrite,Bloodrite,Captain=
Gidget,The Bloodtender,Bloodtender=
Lysander Mistmoore,Lysander=
Vorigan Mistmoore,Vorigan=

# Castle Vacrul: Haunting Presence
The Butcher of Vacrul=
Zarrakon=
Lenya Thex=
Poppet the Thrasher=
Lord Mayong Mistmoore=Stifle rune
The Butcher of Vacrul,Butcher=
Zarrakon,Zarakon=
Lenya Thex,Lenya=
Poppet the Thrasher,Poppet=
Lord Mayong Mistmoore,Mayong=Stifle rune

# Fabled Veeshan's Peak
Kluzen the Protector=Bloodbound Stun rune
Nexona=
Kluzen the Protector,Kluzen=Stun rune
Nexona=Stun rune
Elder Ekron=
Druusk=Bloodbound Fear rune
Taskmaster Nichok=
Milyex Vioren=
Qunard Ashenclaw=Bloodbound Stun rune
Druushk,Drushk,Druusk=Fear rune
Taskmaster Nichok,Nichok,Taskmaster,Task master=
Milyex Vioren,Milyex=
Qunard Ashenclaw,Qunard=Stun rune
Xygoz=
Hoshkar=
Traverno the Skygazer=
Silverwing=Bloodbound Fear rune
Phara Dar=
Travenro the Skygazer,Travenro,Traverno=
Silverwing=Fear rune
Phara Dar,Phara=

# Fabled Trakanon's Lair
Trakanon=Stifle rune
Trakanon,Trak=Stifle rune

0 comments on commit 306839b

Please sign in to comment.