Advertisement
Nipper4369

Untitled

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