[AutoIt] Lesser Magic

08/14/2009 12:14 Penakle#1
This script macros mana missile and heal self. Start with your staff equipped and sheathed.

~ Toggles pause and DEL exits the script.

EDIT- Updated to include launch at the users' discretion.

Code:
Dim $a, $b, $c, $d, $e, $f
Global $Paused
HotKeySet("`", "TogglePause")
HotKeySet("{DEL}", "Terminate")
$d = InputBox( "Question", "Hotbar number for Mana Missile?", "1" )
$e = InputBox( "Question", "Hotbar number for Heal Self?", "3" )
$f = InputBox( "Question", "Hotbar number for Rest?", "0" )
$b = InputBox( "Question", "How Many Mana Missiles?", "18" )
$c = InputBox( "Question", "How Long to Rest?", "155000" )
$g = InputBox( "Question", "Are you using Launch? 1 for yes, 2 for no.", "1" )
If $g = 1 Then
	$h = InputBox( "Question", "Hotbar number for Launch?", "4" )
MsgBox( 0, "Alert", "Click OK then Alt + Tab into Darkfall to start the script." )
WinWaitActive( "Darkfall Online" )

While 1
	$a = 0
	Sleep ( 2000 )
	Send( "R" )
	Sleep ( 500 )
	Call( "Launch" )
	Call( "HealSelf" )
		
	Do
		Call( "ManaMissile" )
		$a = $a + 1
	Until $a = $b
	Sleep( 500 )
	Call( "Launch" )
	Call( "HealSelf" )
	Sleep( 2500 )
	Call( "Rest" )
WEnd

ElseIf $g = 2 Then
	MsgBox( 0, "Alert", "Click OK then Alt + Tab into Darkfall to start the script." )
	WinWaitActive( "Darkfall Online" )

While 1
	$a = 0
	Sleep ( 2000 )
	Send( "R" )
	Sleep ( 500 )
	Call( "HealSelf" )
		
	Do
		Call( "ManaMissile" )
		$a = $a + 1
	Until $a = $b
	Sleep( 500 )
	Call( "HealSelf" )
	Sleep( 2500 )
	Call( "Rest" )
WEnd

Else
	MsgBox( 0, "Alert", "You must choose yes or no for the launch question." )
	Exit
EndIf

Func HealSelf( )
	Sleep( 500 )
	Send( $e )
	Sleep( 500 )
	MouseClick( "Left" )
	Sleep( 2400 )
EndFunc

Func ManaMissile( )
	Sleep( 500 )
	Send( $d )
	Sleep( 500 )
	MouseClick( "Left" )
	Sleep( 1100 )
	EndFunc

Func Rest( )
	Sleep( 2000 )
	Send( "R" )
	Sleep( 500 )
	Send( $f )
	Sleep( 500 )
	MouseClick( "Left" )
	Sleep( $c )
	Send( "{SPACE}" )
	Sleep( 500 )
EndFunc

Func Launch( )
	Sleep( 1000 )
	Send( $h )
	Sleep( 500 )
	MouseClick( "Left" )
	Sleep( 6000 )
EndFunc


Func TogglePause( )
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc

Func Terminate( )
    Exit 0
EndFunc
06/20/2010 15:24 WyrdNEXUS#2
I built my own hotkey management wrapper (I'll post it once its ready and tested), and I needed those same hotkeys. They're so commonly used, I figured I might as well make a GUI for it. So here you are.

It will save the hotkeys as follows:
$keyMM - Mana Missle
$keyHS - Heal Self
$keyRS - Rest
$keyLN - Launch

a global is required, don't forget it.

near the bottom of the main Function, there is an "Exit 0"
you may want to change that to your own Terminate() function.

All you have to do is paste it in, call the main function, and the use the variables listed above.

Code:
;don't forget the globals and includes
Global $keyMM = 2, $keyHS = 3, $keyRS = 4, $keyLN = 5
#include <GUIConstantsEx.au3>

call("UserConfig")



Func UserConfig()
	$mainGUI = GUICreate("Darkfall MacroMan v1.0", 165, 210)
	
	GUICtrlCreateGroup("Hotbar Keys", 10, 10, 145, 140 )
		GUICtrlCreateLabel("Default", 110, 25)
		GUICtrlSetFont(-1, 7)
		GUICtrlSetColor(-1, 0x555555)
		GUICtrlCreateLabel("Mana Missile", 20, 30)
	$guiMM = GUICtrlCreateInput("", 90, 30, 20, 20)
		GUICtrlSetTip(-1, "The key you would press to equip Mana Missile.")
		GUICtrlCreateLabel($keyMM, 115, 38)
		GUICtrlSetFont(-1, 7)
		GUICtrlSetColor(-1, 0x555555)
		
		GUICtrlCreateLabel("Heal Self", 20, 60)
	$guiHS = GUICtrlCreateInput("", 90, 60, 20, 20)
		GUICtrlSetTip(-1, "The key you would press to equip Heal Self.")
		GUICtrlCreateLabel($keyHS, 115, 68)
		GUICtrlSetFont(-1, 7)
		GUICtrlSetColor(-1, 0x555555)
		
		GUICtrlCreateLabel("Rest", 20, 90)
	$guiRS = GUICtrlCreateInput("", 90, 90, 20, 20)
		GUICtrlSetTip(-1, "The key you would press to equip Rest.")
		GUICtrlCreateLabel($keyRS, 115, 98)
		GUICtrlSetFont(-1, 7)
		GUICtrlSetColor(-1, 0x555555)
		
		GUICtrlCreateLabel("Launch", 20, 120)
	$guiLN = GUICtrlCreateInput("", 90, 120, 20, 20)
		GUICtrlSetTip(-1, "The key you would press to equip Launch - leave empty if not it use.")
		GUICtrlCreateLabel($keyLN, 115, 128)
		GUICtrlSetFont(-1, 7)
		GUICtrlSetColor(-1, 0x555555)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	
	GUICtrlCreateGroup("", 10, 150, 145, 50)
		$guiRUN = GUICtrlCreateButton("Run Macro", 20, 165)
		$guiEXIT = GUICtrlCreateButton("Abort", 110, 165)
	GUICtrlCreateGroup("", -99, -99, 1, 1)
	
	GUISetState() ; show gui

	; Collect Response
    While 1
        $msg = GUIGetMsg()
		Switch $msg
			Case $guiMM
				$keyMM = filter(GUICtrlRead($guiMM), 2)
			Case $guiHS
				$keyHS = filter(GUICtrlRead($guiHS), 3)
			Case $guiRS
				$keyRS = filter(GUICtrlRead($guiRS), 4)
			Case $guiLN
				$keyLN = filter(GUICtrlRead($guiLN), 5)
			Case $GUI_EVENT_CLOSE, $guiEXIT
				; Abort or program closed
				Exit 0
			Case $guiRUN
				If alertKeySet() Then
					; Run Macro, and keys are good. Exit loop so it doesn't terminate program.
					ExitLoop
				EndIf
        EndSwitch
    WEnd
	Sleep(200)
	GUIDelete($mainGUI) ; Manually delete the GUI
EndFunc

Func alertKeySet()
	$msgTXT = "Keybinding for the main spells have been set." & @CR & @CR & _ 
					$keyMM & " -     Mana Missile"	& @CR & _ 
					$keyHS & " -     Heal Self" 	& @CR & _ 
					$keyRS & " -     Rest" 			& @CR & _ 
					$keyLN & " -     Launch" 		& @CR & @CR & _ 
					"Run Macro?"
	While 1
		$iMsgBoxAnswer = MsgBox(1, "Spell Hotkeys Set", $msgTXT)
		
		Select
			Case $iMsgBoxAnswer = 1 ;OK
				return True
			Case $iMsgBoxAnswer = 2 ;Cancel
				return False
		EndSelect
	WEnd	
EndFunc

Func filter($str, $default)
	; forces input to single Alpha-Numeric character
	; returns result (1st char) or default on failure

	$str = StringStripWS($str, 8)

	if StringLen($str)>0 then
		$str = StringLower(StringLeft($str, 1))
	EndIf

	if StringLen($str)=1 AND StringIsAlNum($str) then
		return $str
	Else
		return $default
	EndIf
EndFunc
08/16/2010 01:19 Relix1650#3
? not much but you seem pretty good so if you'd like to work with me PM me
01/06/2012 06:53 dsnutz#4
you need to add a hotkey to your hotbar tab so you keep 20 of the same kind staff in your inventory and hit your staff hotbar key in the macro that way when one breaks you can keep switching to new ones when the macro starts over again.