Advertisement
Guest User

Untitled

a guest
Nov 13th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; This script is a cleaned up and enhanced version of the one found here:
  2. ; https://www.pathofexile.com/forum/view-thread/594346
  3.  
  4. #IfWinActive, Path of Exile
  5. #NoEnv                      ; Recommended for performance and compatibility with future AutoHotkey releases.
  6. #Persistent                 ; Stay open in background
  7. SendMode Input              ; Recommended for new scripts due to its superior speed and reliability.
  8. StringCaseSense, On         ; Match strings with case.
  9.  
  10. ; Options
  11. ; Pixels mouse must move to auto-dismiss tooltip
  12. MouseMoveThreshold := 40
  13.  
  14. ; Menu tooltip
  15. Menu, tray, Tip, Path of Exile Itemlevel and DPS Display (fork by Aeons)
  16.  
  17. ; Font size for the tooltip, leave empty for default
  18. FontSize := 10
  19. ; Create font for later use
  20. FixedFont := CreateFont()
  21.  
  22. ; Creates a font for later use
  23. ; Fixed fonts are: Courier New, Consolas, Lucida Console
  24. CreateFont()
  25. {
  26.   global FontSize
  27.   Options :=
  28.   If (!(FontSize = ""))
  29.   {
  30.     Options = s%FontSize%
  31.   }
  32.   Gui Font, %Options%, Lucida Console
  33.   Gui Add, Text, HwndHidden,
  34.   SendMessage, 0x31,,,, ahk_id %Hidden%
  35.   return ErrorLevel
  36. }
  37.  
  38. ; Sets the font for a created ahk tooltip
  39. SetFont(Font)
  40. {
  41.   SendMessage, 0x30, Font, 1,, ahk_class tooltips_class32 ahk_exe autohotkey.exe
  42. }
  43.  
  44. ; Parse elemental damage
  45. ParseDamage(String, DmgType, ByRef DmgLo, ByRef DmgHi)
  46. {
  47.   IfInString, String, %DmgType% Damage
  48.   {
  49.     IfNotInString, String, increased
  50.     {
  51.       StringSplit, Arr, String, %A_Space%
  52.       StringSplit, Arr, Arr2, -
  53.       DmgLo := Arr1
  54.       DmgHi := Arr2
  55.     }
  56.   }
  57. }
  58.  
  59. ; Parse clipboard content for item level and dps
  60. ParseClipBoardChanges()
  61. {
  62.   NameIsDone  := False
  63.   ItemName    :=
  64.   ItemLevel   := -1
  65.   IsWeapon    := False
  66.   PhysLo      := 0
  67.   PhysHi      := 0
  68.   Quality     := 0
  69.   AttackSpeed := 0
  70.   PhysMult    := 0
  71.   ChaoLo      := 0
  72.   ChaoHi      := 0
  73.   ColdLo      := 0
  74.   ColdHi      := 0
  75.   FireLo      := 0
  76.   FireHi      := 0
  77.   LighLo      := 0
  78.   LighHi      := 0
  79.  
  80.   Loop, Parse, Clipboard, `n, `r
  81.   {
  82.   ; Clipboard must have "Rarity:" in the first line
  83.     If A_Index = 1
  84.     {
  85.       IfNotInString, A_LoopField, Rarity:
  86.      {
  87.         Exit
  88.       }
  89.       Else
  90.       {
  91.         Continue
  92.       }
  93.     }
  94.  
  95.   ; Get name
  96.     If Not NameIsDone
  97.     {
  98.       If A_LoopField = --------
  99.       {
  100.         NameIsDone := True
  101.       }
  102.       Else
  103.       {
  104.         ItemName := ItemName . A_LoopField . "`n" ; Add a line of name
  105.       }
  106.       Continue
  107.     }
  108.  
  109.   ; Get item level
  110.     IfInString, A_LoopField, Itemlevel:
  111.    {
  112.       StringSplit, ItemLevelArray, A_LoopField, %A_Space%
  113.       ItemLevel := ItemLevelArray2
  114.       Continue
  115.     }
  116.  
  117.   ; Get quality
  118.     IfInString, A_LoopField, Quality:
  119.    {
  120.       StringSplit, Arr, A_LoopField, %A_Space%, +`%
  121.       Quality := Arr2
  122.       Continue
  123.     }
  124.  
  125.   ; Get total physical damage
  126.     IfInString, A_LoopField, Physical Damage:
  127.    {
  128.       IsWeapon = True
  129.       StringSplit, Arr, A_LoopField, %A_Space%
  130.       StringSplit, Arr, Arr3, -
  131.       PhysLo := Arr1
  132.       PhysHi := Arr2
  133.       Continue
  134.     }
  135.  
  136.   ; These only make sense for weapons
  137.     If IsWeapon
  138.     {
  139.       ; Get attack speed
  140.       IfInString, A_LoopField, Attacks per Second:
  141.      {
  142.         StringSplit, Arr, A_LoopField, %A_Space%
  143.         AttackSpeed := Arr4
  144.         Continue
  145.       }
  146.  
  147.       ; Get percentage physical damage increase
  148.       IfInString, A_LoopField, increased Physical Damage
  149.       {
  150.         StringSplit, Arr, A_LoopField, %A_Space%, `%
  151.         PhysMult := Arr1
  152.         Continue
  153.       }
  154.  
  155.       ; Parse elemental damage
  156.       ParseDamage(A_LoopField, "Chaos", ChaoLo, ChaoHi)
  157.       ParseDamage(A_LoopField, "Cold", ColdLo, ColdHi)
  158.       ParseDamage(A_LoopField, "Fire", FireLo, FireHi)
  159.       ParseDamage(A_LoopField, "Lightning", LighLo, LighHi)
  160.     }
  161.   }
  162.  
  163.   If ItemLevel = -1 ; Something without an itemlevel
  164.   {
  165.     Exit
  166.   }
  167.  
  168. ; Get position of mouse cursor
  169.   global X
  170.   global Y
  171.   MouseGetPos, X, Y
  172.  
  173.   ; All items should show name and item level
  174.   ; Pad to 3 places
  175.   ItemLevel := "   " + ItemLevel
  176.   StringRight, ItemLevel, ItemLevel, 3
  177.  
  178.   ItemInfo = %ItemName%     ilvl:  %ItemLevel%
  179.   ItemDps  =
  180.  
  181. ; DPS calculations
  182.   If IsWeapon {
  183.     SetFormat, FloatFast, 5.1
  184.  
  185.     PhysDps   := AttackSpeed * ((PhysLo + PhysHi) / 2)
  186.     EleDps    := AttackSpeed * ((ChaoLo + ChaoHi + ColdLo + ColdHi + FireLo + FireHi + LighLo + LighHi) / 2)
  187.     TotalDps  := PhysDps + EleDps
  188.  
  189.     ItemDps = `n Phys DPS: %PhysDps%`n Elem DPS: %EleDps%`n`nTotal DPS: %TotalDps%
  190.  
  191.     ; Only show Q20 values if item is not Q20
  192.     If Quality < 20
  193.     {
  194.       TotalPhysMult := (PhysMult + Quality + 100) / 100
  195.       BasePhysDps   := PhysDps / TotalPhysMult
  196.       Q20Dps        := BasePhysDps * ((PhysMult + 120) / 100) + EleDps
  197.  
  198.       ItemDps = %ItemDps%`n  Q20 DPS: %Q20Dps%
  199.  
  200.     }
  201.   }
  202.   Else
  203.   {
  204.     ItemDps =
  205.   }
  206.  
  207.   ; Build tooltip text
  208.   TT = %ItemInfo%`n%ItemDps%
  209.  
  210.   ; Show tooltip, with fixed width font
  211.   ToolTip, %TT%, X + 35, Y + 35
  212.   global FixedFont
  213.   SetFont(FixedFont)
  214.   ; Set up count variable and start timer for tooltip timeout
  215.   global ToolTipTimeout := 0
  216.   SetTimer, ToolTipTimer, 100
  217. }
  218.  
  219. ; Tick every 100 ms
  220. ; Remove tooltip if mouse is moved or 5 seconds pass
  221. ToolTipTimer:
  222. ToolTipTimeout += 1
  223. MouseGetPos, CurrX, CurrY
  224. MouseMoved := (CurrX - X)**2 + (CurrY - Y)**2 > MouseMoveThreshold**2
  225. If (MouseMoved or ToolTipTimeout >= 100)
  226. {
  227.   SetTimer, ToolTipTimer, Off
  228.   ToolTip
  229. }
  230. return
  231.  
  232. OnClipBoardChange:
  233. ParseClipBoardChanges()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement