Guest User

boss_summon_callout.ahk

a guest
Dec 13th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. #SingleInstance force
  3.  
  4. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  5. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  6. DetectHiddenWindows, On
  7.  
  8.  
  9. game_title := "Secret World Legends"    ; Name of game window key presses to be sent to
  10. summon_count := 0   ; Track of current number of summons
  11.  
  12. ; Note: # has a special meaning in the context of using Send/ControlSend so if you wish to use HTML hex colour codes use {#} to represent a #
  13. summon_cols := ["{#}00FF00", "{#}FF0000", "{#}0000FF", "{#}00FF00", "{#}FF0000", "{#}0000FF", "{#}00FF00", "{#}FF0000", "{#}0000FF", "{#}FF00FF"]
  14.  
  15.  
  16. ; Ctrl + F1
  17. ; Reset and reload any script changes
  18. ^F1::
  19.     Reload
  20.     Sleep 1000
  21.  
  22.     ; If successful (i.e. no errors in script) the reload will close this instance during the Sleep
  23.     ; This means remaining code shouldn't execute.
  24.  
  25.     ; However, if we reached here, means something went wrong so let user know.
  26.  
  27.     MsgBox, 4,, The script could not be reloaded. Would you like to exit?
  28.     IfMsgBox, Yes, ExitApp
  29. Return
  30.  
  31.  
  32. ; Ctrl + F2 but only if game has focus
  33. #If WinActive(game_title)
  34. ^F2::
  35.     script_name := "MBAH"
  36.     call_out(script_name)
  37. Return
  38. #If
  39.  
  40.  
  41. ; Ctrl + F3 but only if game has focus
  42. #If WinActive(game_title)
  43. ^F3::
  44.     script_name := "MBBP"
  45.     call_out(script_name)
  46. Return
  47. #If
  48.  
  49.  
  50. send_message(message) {
  51.     global game_name
  52.  
  53.     ; Sends the following to the window with a name matching game_name
  54.     ; Enter key to give chat cursor focus, the message to be sent, Enter key to have the message sent.
  55.     ControlSend,, {Enter}%message%{Enter}, %game_name%
  56.     Sleep 200
  57. }
  58.  
  59. call_out(script_name) {
  60.     global summon_count
  61.     global summon_cols
  62.    
  63.     ; Determine colour based on number of summons tracked and the number of colours to choose from
  64.     ; i.e. make sure 0 < index < number of summon colours
  65.     index := Mod(summon_count, summon_cols.Length()) + 1
  66.     colour := summon_cols[index]
  67.  
  68.     ; Adjust displayed representation of summon count to be what is expected
  69.     count := summon_count + 1
  70.  
  71.     ; Form the message that's to be typed in chat
  72.     chat_msg := "/" . script_name . " " . colour . " " . count
  73.  
  74.     ; Type message in chat
  75.     send_message(chat_msg)
  76.  
  77.     ; Update summon count
  78.     summon_count += 1
  79. }
  80.  
Advertisement
Add Comment
Please, Sign In to add comment