EzPlugins

autoResumeGame

Aug 27th, 2025 (edited)
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.50 KB | None | 0 0
  1. //05-sept-2025
  2. // Complements the TalkToOrek plugin
  3. // Use ValidMsgToCome to specify which word or phrase will trigger the "Resume Game" button to be pressed.
  4. // 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).
  5.  
  6. using Turbo.Plugins.Default;
  7. using System;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Text.RegularExpressions;
  11. using System.Runtime.InteropServices;
  12.  
  13. namespace Turbo.Plugins.Ez
  14. {
  15.     public class autoResumeGame : BasePlugin, IChatLineChangedHandler
  16.     {
  17.         public bool deBUG { get; set; } = false;
  18.  
  19.         public static IntPtr D3Hwnd = IntPtr.Zero;
  20.  
  21.         [DllImport("USER32.DLL")]
  22.         private static extern IntPtr FindWindow(string ClassName, string WindowText);
  23.  
  24.         [DllImport("USER32.DLL")]
  25.         private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  26.  
  27.         private static IntPtr MakeLParam(int x, int y)
  28.         {
  29.             return (IntPtr)(y << 16 | (x & 65535));
  30.         }
  31.  
  32.         public void mouseLClickUiE(IUiElement uie)
  33.         {
  34.             IntPtr lParam = MakeLParam((int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f), (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f));
  35.             SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
  36.             SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
  37.         }
  38.  
  39.         protected IUiElement uiPlayGameButton;
  40.         protected IUiElement uiChangeQuestButton;
  41.  
  42.         public string[] ValidMsgToCome { get; set; }
  43.         public string[] ValidMsgToStart { get; set; }
  44.         public bool EnableAutoStart { get; set; }
  45.  
  46.         public autoResumeGame()
  47.         {
  48.             Enabled = true;
  49.         }
  50.  
  51.         public override void Load(IController hud)
  52.         {
  53.             base.Load(hud);
  54.  
  55.             ValidMsgToCome  = new string[] {"+", "++", "b", "back", "come", "join"};
  56.             ValidMsgToStart = new string[] {"start", "go"};
  57.             EnableAutoStart = false;
  58.  
  59.             uiPlayGameButton = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.PlayGameButton", null, null);
  60.             uiChangeQuestButton = Hud.Render.RegisterUiElement("Root.NormalLayer.BattleNetCampaign_main.LayoutRoot.Menu.ChangeQuestButton", null, null);
  61.  
  62.             D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
  63.         }
  64.  
  65.         public void OnChatLineChanged(string currentLine, string previousLine)
  66.         {
  67.             if (!Hud.Game.IsInGame && !string.IsNullOrEmpty(currentLine))
  68.             {
  69.                 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
  70.                 if (match.Success)
  71.                 {
  72.                     if (uiPlayGameButton.Visible && (uiPlayGameButton.AnimState == 58 || uiPlayGameButton.AnimState == 57) && uiChangeQuestButton.Visible)  // (58/57Over/56Click) enabled, 55 disabled
  73.                     {
  74.                         string textPlayer = match.Groups[5].Value.Trim().Replace("\\|","|");
  75.                         if (uiChangeQuestButton.AnimState == 13)    // not Leader or not All in Menu // (16/15Over/14Click) enabled, 13 disabled
  76.                         {
  77.                             if (ValidMsgToCome.Contains(textPlayer, StringComparer.OrdinalIgnoreCase))
  78.                             {
  79.                                 mouseLClickUiE(uiPlayGameButton);
  80.                             }
  81.                         }
  82.                         else if (uiChangeQuestButton.AnimState == 16 || uiChangeQuestButton.AnimState == 15)    // All in Menu and Leader
  83.                         {
  84.                             if (EnableAutoStart && ValidMsgToStart.Contains(textPlayer, StringComparer.OrdinalIgnoreCase))
  85.                             {
  86.                                 mouseLClickUiE(uiPlayGameButton);
  87.                             }
  88.                         }                      
  89.                     }
  90.                 }
  91.             }
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment