Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //05-sept-2025
- // Complements the TalkToOrek plugin
- // Use ValidMsgToCome to specify which word or phrase will trigger the "Resume Game" button to be pressed.
- // Use ValidMsgToStart to specify which word or phrase will trigger the "Start Game" button to be pressed. Only if EnableAutoStart is set to true (the default is false).
- using Turbo.Plugins.Default;
- using System;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Runtime.InteropServices;
- namespace Turbo.Plugins.Ez
- {
- public class autoResumeGame : BasePlugin, IChatLineChangedHandler
- {
- public bool deBUG { get; set; } = false;
- public static IntPtr D3Hwnd = IntPtr.Zero;
- [DllImport("USER32.DLL")]
- private static extern IntPtr FindWindow(string ClassName, string WindowText);
- [DllImport("USER32.DLL")]
- private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
- private static IntPtr MakeLParam(int x, int y)
- {
- return (IntPtr)(y << 16 | (x & 65535));
- }
- public void mouseLClickUiE(IUiElement uie)
- {
- IntPtr lParam = MakeLParam((int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f), (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f));
- SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
- SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
- }
- protected IUiElement uiPlayGameButton;
- protected IUiElement uiChangeQuestButton;
- public string[] ValidMsgToCome { get; set; }
- public string[] ValidMsgToStart { get; set; }
- public bool EnableAutoStart { get; set; }
- public autoResumeGame()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- ValidMsgToCome = new string[] {"+", "++", "b", "back", "come", "join"};
- ValidMsgToStart = new string[] {"start", "go"};
- EnableAutoStart = false;
- uiPlayGameButton = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.PlayGameButton", null, null);
- uiChangeQuestButton = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.ChangeQuestButton", null, null);
- D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
- }
- public void OnChatLineChanged(string currentLine, string previousLine)
- {
- if (!Hud.Game.IsInGame && !string.IsNullOrEmpty(currentLine))
- {
- var match = Regex.Match(currentLine, @"^\[([^\|]+)\]\|HOnlUserHdl:(.+)\|h\[(<.+>\s)?(.+)\]\|h:\s(.+)$"); // match.Groups[x].Value // x => 1 = Party (word) , 2 = Userid , 3 = <Clan>, 4 = Name, 5 = Msg
- if (match.Success)
- {
- if (uiPlayGameButton.Visible && (uiPlayGameButton.AnimState == 58 || uiPlayGameButton.AnimState == 57) && uiChangeQuestButton.Visible) // (58/57Over/56Click) enabled, 55 disabled
- {
- string textPlayer = match.Groups[5].Value.Trim().Replace("\\|","|");
- if (uiChangeQuestButton.AnimState == 13) // not Leader or not All in Menu // (16/15Over/14Click) enabled, 13 disabled
- {
- if (ValidMsgToCome.Contains(textPlayer, StringComparer.OrdinalIgnoreCase))
- {
- mouseLClickUiE(uiPlayGameButton);
- }
- }
- else if (uiChangeQuestButton.AnimState == 16 || uiChangeQuestButton.AnimState == 15) // All in Menu and Leader
- {
- if (EnableAutoStart && ValidMsgToStart.Contains(textPlayer, StringComparer.OrdinalIgnoreCase))
- {
- mouseLClickUiE(uiPlayGameButton);
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment