Advertisement
Guest User

Untitled

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