Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Linq;
- using System.Windows.Forms;
- using SharpDX.DirectInput;
- using System.Runtime.InteropServices;
- namespace Turbo.Plugins.Ez
- {
- public class AlwaysUseYourParagon : BasePlugin, IAfterCollectHandler, INewAreaHandler, IInGameTopPainter
- {
- 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);
- public static void SendPressKey(Keys key)
- {
- SendMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero);
- SendMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
- }
- public static void SendHoldKey(Keys key)
- {
- SendMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero);
- }
- public static void SendReleaseKey(Keys key)
- {
- SendMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
- }
- public void mouseLClickUiE(IUiElement uie) // D3Hwnd
- {
- var x = (int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f);
- var y = (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f);
- IntPtr lParam = (IntPtr)(y << 16 | (x & 65535));
- SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
- SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
- }
- protected IUiElement PARAGONUI;
- protected IUiElement PARAGON_TAB_ONE;
- protected IUiElement PARAGON_BUTTON_MAIN;
- protected IUiElement PARAGON_BUTTON_VIT;
- protected IUiElement PARAGON_BUTTON_SPEED;
- protected IUiElement PARAGON_BUTTON_ACCEPT;
- protected IUiElement PARAGON_BUTTON_CANCEL;
- protected IUiElement PARAGON_BUTTON_OPEN;
- protected IUiElement GreaterRifts_VictoryScreen;
- protected IUiElement Rift_Join_Party;
- private System.Drawing.RectangleF rectangleMain { get; set; }
- private System.Drawing.RectangleF rectangleVit { get; set; }
- public IFont FontGreen { get; set; }
- public IBrush BrushAll { get; set; }
- private bool DetectParagonButton { get; set; } = false;
- private bool doParagon { get; set; } = false;
- private long msLapseAction { get; set; } = 0;
- private uint LastAreaSno { get; set; } = 0;
- public long msLapseMin { get; set; } = 20;
- public long msLapseUiEVisible { get; set; } = 200;
- public bool MaxSpeed { get; set; }
- public int ParagonMin { get; set; }
- public bool AlsoInNewGame { get; set; }
- public bool SupportVit { get; set; }
- public Keys KeyParagonWindow { get; set; } = Keys.P; // ParagonWindow
- public AlwaysUseYourParagon()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = int.MaxValue;
- ParagonMin = 800; // Minimum Paragon required for this plugin to start working.
- SupportVit = true; // Increases Vit instead of the Main Stat if you have toxin or icebLink equipped.
- MaxSpeed = true; // Increase movement speed first
- AlsoInNewGame = true; // Work also when you enter a new game.
- PARAGONUI = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect", null, null, 0f, 0f);
- PARAGON_TAB_ONE = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.tab_1", null, null, 0f, 0f);
- PARAGON_BUTTON_MAIN = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.Bonuses.bonus0.IncreaseStat", null, null, 0f, 0f);
- PARAGON_BUTTON_VIT = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.Bonuses.bonus1.IncreaseStat", null, null, 0f, 0f);
- PARAGON_BUTTON_SPEED = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.Bonuses.bonus2.IncreaseStat", null, null, 0f, 0f);
- PARAGON_BUTTON_ACCEPT = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.AcceptParagonPointsButton", null, null, 0f, 0f);
- PARAGON_BUTTON_CANCEL = Hud.Render.RegisterUiElement("Root.NormalLayer.Paragon_main.LayoutRoot.ParagonPointSelect.CancelParagonPointsButton", null, null, 0f, 0f);
- PARAGON_BUTTON_OPEN = Hud.Render.RegisterUiElement("Root.NormalLayer.game_notify_dialog_backgroundScreen.dlg_new_paragon.button", null, null);
- GreaterRifts_VictoryScreen = Hud.Render.RegisterUiElement("Root.NormalLayer.GreaterRifts_VictoryScreen.LayoutRoot", null, null);
- Rift_Join_Party = Hud.Render.RegisterUiElement("Root.NormalLayer.rift_join_party_main.LayoutRoot", null, null);
- BrushAll = Hud.Render.CreateBrush(255, 100, 255, 100, 2);
- FontGreen = Hud.Render.CreateFont("tahoma", 10f, 250, 0, 250, 0, false, false, 250, 0, 0, 0, true);
- D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
- }
- public void OnNewArea(bool newGame, ISnoArea area) // bug ??
- {
- if (LastAreaSno != area.Sno) LastAreaSno = area.Sno; else if (!newGame) return; // Fix ??
- if (area.IsTown)
- {
- if (Hud.Game.Me.ParagonPointsAvailable[0] > 0 && Hud.Game.Me.CurrentLevelParagon >= ParagonMin)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseMin;
- if (newGame)
- {
- if (AlsoInNewGame)
- {
- doParagon = true;
- if (Hud.Game.CurrentAct != 1)
- {
- var pl = Hud.AllPlugins.FirstOrDefault(p => p.GetType().Name == "AlwaysActOne"); // So that it doesn't interfere too much with AlwaysActOne
- if (pl != null && pl.Enabled == true)
- {
- msLapseAction += 10000;
- }
- }
- }
- }
- else
- {
- doParagon = true;
- }
- }
- DetectParagonButton = !PARAGON_BUTTON_OPEN.Visible;
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.AfterClip || !Hud.Game.IsInGame || doParagon) return;
- if (PARAGON_TAB_ONE.Visible && PARAGON_TAB_ONE.AnimState == 13 && PARAGON_BUTTON_MAIN.Visible)
- {
- var layout = FontGreen.GetTextLayout("All");
- rectangleMain = new System.Drawing.RectangleF(PARAGON_BUTTON_MAIN.Rectangle.X + PARAGON_BUTTON_MAIN.Rectangle.Width * 2, PARAGON_BUTTON_MAIN.Rectangle.Y, PARAGON_BUTTON_MAIN.Rectangle.Width, PARAGON_BUTTON_MAIN.Rectangle.Height);
- BrushAll.DrawRectangle(rectangleMain.X, rectangleMain.Y, rectangleMain.Width, rectangleMain.Height);
- FontGreen.DrawText(layout, rectangleMain.X + (rectangleMain.Width - layout.Metrics.Width)/2.0f, rectangleMain.Y + (rectangleMain.Height - layout.Metrics.Height)/2.0f);
- rectangleVit = new System.Drawing.RectangleF(PARAGON_BUTTON_VIT.Rectangle.X + PARAGON_BUTTON_VIT.Rectangle.Width * 2, PARAGON_BUTTON_VIT.Rectangle.Y, PARAGON_BUTTON_VIT.Rectangle.Width, PARAGON_BUTTON_VIT.Rectangle.Height);
- BrushAll.DrawRectangle(rectangleVit.X, rectangleVit.Y, rectangleVit.Width, rectangleVit.Height);
- FontGreen.DrawText(layout, rectangleVit.X + (rectangleVit.Width - layout.Metrics.Width)/2.0f, rectangleVit.Y + (rectangleVit.Height - layout.Metrics.Height)/2.0f);
- if (Hud.Input.IsKeyDown(Keys.LButton))
- {
- var UiEStat = rectangleMain.Contains(Hud.Window.CursorX, Hud.Window.CursorY)? PARAGON_BUTTON_MAIN : rectangleVit.Contains(Hud.Window.CursorX, Hud.Window.CursorY)? PARAGON_BUTTON_VIT : null;
- if (UiEStat != null)
- {
- int i = Hud.Game.Me.ParagonPointsAvailable[0]/100 + 2;
- SendHoldKey(Keys.ControlKey);
- while (i-- > 0)
- {
- mouseLClickUiE(UiEStat);
- }
- SendReleaseKey(Keys.ControlKey);
- }
- }
- }
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame || Hud.Game.IsPaused) return;
- if (doParagon)
- {
- if (Hud.Inventory.InventoryMainUiElement.Visible || GreaterRifts_VictoryScreen.Visible || Rift_Join_Party.Visible)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseUiEVisible;
- }
- else if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction)
- {
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseMin;
- if (PARAGON_TAB_ONE.Visible) // PARAGONUI.Visible && PARAGON_TAB_ONE.Visible
- {
- DetectParagonButton = true;
- if (PARAGON_TAB_ONE.AnimState != 13)
- {
- mouseLClickUiE(PARAGON_TAB_ONE);
- }
- else
- {
- if (MaxSpeed && PARAGON_BUTTON_SPEED.Visible)
- {
- SendHoldKey(Keys.ControlKey);
- mouseLClickUiE(PARAGON_BUTTON_SPEED);
- SendReleaseKey(Keys.ControlKey);
- }
- else
- {
- if (PARAGON_BUTTON_MAIN.Visible) // doesn't matter if I check PARAGON_BUTTON_MAIN or PARAGON_BUTTON_VIT
- {
- IUiElement UiEStat = (SupportVit && (Hud.Game.Me.Powers.BuffIsActive(428354) || Hud.Game.Me.Powers.BuffIsActive(403556))) ? PARAGON_BUTTON_VIT : PARAGON_BUTTON_MAIN;
- int i = Hud.Game.Me.ParagonPointsAvailable[0]/100 + 2;
- SendHoldKey(Keys.ControlKey);
- while (i-- > 0)
- {
- mouseLClickUiE(UiEStat);
- }
- SendReleaseKey(Keys.ControlKey);
- }
- else
- {
- if (PARAGON_BUTTON_ACCEPT.Visible && PARAGON_BUTTON_ACCEPT.AnimState != 38)
- {
- mouseLClickUiE(PARAGON_BUTTON_ACCEPT);
- }
- else if (PARAGON_BUTTON_CANCEL.Visible)
- {
- mouseLClickUiE(PARAGON_BUTTON_CANCEL);
- }
- }
- }
- }
- }
- else if (Hud.Game.MapMode == MapMode.Minimap)
- {
- if (Hud.Game.Me.ParagonPointsAvailable[0] > 0)
- {
- SendPressKey(KeyParagonWindow); // Hud.Interaction.DoAction(ActionKey.ParagonWindow);
- }
- else
- {
- doParagon = false;
- }
- }
- }
- }
- else if (Hud.Game.IsInTown)
- {
- if (DetectParagonButton && PARAGON_BUTTON_OPEN.Visible)
- {
- if (Hud.Game.Me.CurrentLevelParagon >= ParagonMin)
- {
- doParagon = true;
- msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseMin;
- }
- DetectParagonButton = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment