Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //05-sept-2025
- using Turbo.Plugins.Default;
- using System;
- using System.Text.RegularExpressions;
- using System.Linq;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- using System.Threading;
- namespace Turbo.Plugins.Ez
- {
- public class TalkToOrekPlugin : BasePlugin, IAfterCollectHandler
- {
- 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);
- [DllImport("user32.dll")]
- public static extern bool SetCursorPos(int x, int y);
- [DllImport("user32.dll")]
- private static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, IntPtr dwExtraInfo);
- public static void MoveMouseEventLClick(int x, int y)
- {
- SetCursorPos(x, y);
- Thread.Sleep(1); mouse_event(6U, 0, 0, 0U, IntPtr.Zero);
- Thread.Sleep(1); SetCursorPos(x, y); mouse_event(6U, 0, 0, 0U, IntPtr.Zero); // quick rp and retry
- }
- 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 ChatEntry;
- protected IUiElement ChatEditLine;
- protected IUiElement OrekCLoseGR;
- private IUiElement[] UiEPortraitIcons { get; set; } = new IUiElement[4];
- private long msLapseAction { get; set; } = 0;
- public double distanceOrekMax { get; set; }
- public bool OnlyWorkInParty { get; set; }
- private string _msgParty { get; set; } = string.Empty;
- public string msgParty
- {
- get { return _msgParty; }
- set
- {
- if (_msgParty != value)
- {
- _msgParty = Regex.Replace(value, "[+^%~()]", "{$0}"); // _msgParty = Regex.Replace(value, "[+^%~()\\{\\}]", "{$0}");
- }
- }
- }
- public TalkToOrekPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = int.MaxValue;
- distanceOrekMax = 8.0f;
- OnlyWorkInParty = true;
- msgParty = "+";
- ChatEntry = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content", null, null);
- ChatEditLine = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline", null, null);
- OrekCLoseGR = Hud.Render.RegisterUiElement("Root.NormalLayer.interact_dialog_mainPage.interact_dialog_Background.stack.interact_button_2", null, null);
- for (var i = 0; i < 4; i++)
- {
- UiEPortraitIcons[i] = Hud.Render.RegisterUiElement("Root.NormalLayer.portraits.stack.party_stack.portrait_" + i + ".icon", null, null);
- }
- D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
- }
- private int TotalPortraits()
- {
- var portraits = 0;
- for(var i = 0; i < 4; i++)
- {
- if (UiEPortraitIcons[i].Visible)
- portraits++ ;
- }
- return portraits;
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame || !Hud.Game.IsInTown || Hud.Game.IsPaused || !Hud.Window.IsForeground) return;
- if (Hud.Game.Actors.Any(a => a.SnoActor.Sno == ActorSnoEnum._x1_openworld_tiered_rifts_portal))
- {
- var orek = Hud.Game.Actors.FirstOrDefault(a => a.SnoActor.Sno == ActorSnoEnum._x1_lr_nephalem);
- if (orek != null && orek.CentralXyDistanceToMe < distanceOrekMax && orek.IsOnScreen)
- {
- if (Hud.Game.Me.InGreaterRift)
- {
- if (Hud.Game.RiftPercentage < 100)
- {
- if (Hud.Game.NumberOfPlayersInGame == 1 && (UiEPortraitIcons[1].Visible || !OnlyWorkInParty))
- {
- if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction && Hud.Game.Me.AnimationState == AcdAnimationState.Idle)
- {
- if (OrekCLoseGR.Visible)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + 1500;
- mouseLClickUiE(OrekCLoseGR);
- }
- else
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + 250;
- MoveMouseEventLClick((int) orek.ScreenCoordinate.X + Hud.Window.Offset.X, (int) orek.ScreenCoordinate.Y + Hud.Window.Offset.Y);
- }
- }
- }
- }
- }
- else if (Hud.Game.CurrentRealTimeMilliseconds < msLapseAction)
- {
- if (ChatEntry.Visible)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds;
- if (TotalPortraits() > Hud.Game.NumberOfPlayersInGame)
- {
- SendKeys.SendWait((ChatEditLine.Visible?"{ESC}":"") + "{ENTER}/p " + msgParty + "{ENTER}");
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment