Page 1 of 1

Weapon/hotbar switch macro stops working

Posted: January 14th, 2010, 2:44 pm
by jay311
This autohotkey macro switches my weapons and hotbar with one button, and a couple other cool things. I believe I found it on these forums but cannot locate the thread. Couple of problems I am having that hopefully can be fixed.

Whenever I switch to my skinning knife it will not let me switch back to the weapon I had equipped. I have to switch to a different weapon then back to that one. It also randomly stops letting me switch to certain weapons. Doesn't happen often but I have to restart darkfall to fix. Any help would be appreciated.

This is not my code and I would give credit to whoever wrote it but I don't know where I got it.

;
; Requires you to replace Shift with Left-Alt for selecting bars.
; We also need to be able to select all slots on bar 1
; (Gui_Hotbar_Col_1_Row_0 = LEFT_CTRL+0, Gui_Hotbar_Col_1_Row_1 = LEFT_CTRL+1, etc.)
;

#SingleInstance,Force
#MaxThreadsPerHotkey 2
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
WinActivate, Darkfall Online
Sleep, 200
#IfWinActive Darkfall Online
SoundPlay, %A_WinDir%\Media\start.wav

; VARS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;

nx = 0
ny = 0
lmb = 0

bar = 1

weapon = 0
shield = 0

; TIMERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;

cast_buff1 := 3500
dura_buff1 := 120000
time_buff1 := A_TickCount - dura_buff1

cast_buff2 := 4500
dura_buff2 := 120000
time_buff2 := A_TickCount - dura_buff2

cast_buff3 := 5500
dura_buff3 := 120000
time_buff3 := A_TickCount - dura_buff3

cast_buff4 := 5500
dura_buff4 := 90000
time_buff4 := A_TickCount - dura_buff4

cast_healself := 2500
dura_healself := 15000
time_healself := A_TickCount - dura_healself

cast_mana2stam := 3500
dura_mana2stam := 4000
time_mana2stam := A_TickCount - dura_mana2stam

cast_stam2health := 6500
dura_stam2health := 6000
time_stam2health := A_TickCount - dura_stam2health

dura_food := 120000
time_food := A_TickCount - dura_food

dura_whirlwind := 15000
time_whirlwind := A_TickCount - dura_whirlwind

return

; REMAPPING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;

Break::Suspend, Toggle

Home::Reload

; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;

OneHand()
{
global weapon, shield, bar

bar = 2
if not weapon = 1
{
Send ^{1}
weapon = 1
}
if shield = 0
{
Sleep, 1200
Send ^{2}
shield = 1
}
Sleep, 500
Send !{%bar%}
}

TwoHand(n = 1)
{
global weapon, shield, bar

bar = 2
if not weapon = 2
{
shield = 0
Send ^{3}
Sleep, 500
weapon = 2
}
if(n = 1)
{
Send !{%bar%}
Sleep, 500
Send {1}
}
}

Bow()
{
global weapon, shield, bar

bar = 1
if not weapon = 3
{
shield = 0
Send ^{4}
weapon = 3
}
Sleep, 500
}

LGM()
{
global bar

bar = 3
Staff()
Send !{%bar%}
Sleep, 350
Send {1}
}

UTILITY()
{
global bar

bar = 4
Staff()
Send !{%bar%}
Sleep, 350
Send {2}
}

BUFFYOU()
{
global bar

bar = 5
Staff()
Send !{%bar%}
Sleep, 350
Send {1}
}

UNBURDEN()
{
global bar

bar = 3
Staff()
Send !{%bar%}
Sleep, 350
Send {0}
Sleep, 250
Send {LButton}
Sleep, 1250
Send {1}
}

Stamina()
{
global weapon, bar, dura_food, time_food, cast_mana2stam, dura_mana2stam, time_mana2stam

w := weapon
b := bar

t1 := A_TickCount - time_food
t2 := A_TickCount - time_mana2stam

if (t1 > dura_food)
{
Send ^{6}
Sleep, 450
time_food := A_TickCount
}
else if (t2 > dura_mana2stam)
{
UTILITY()
Sleep, 250
Send {4}
Sleep, 250
Send {LButton}
Sleep, %cast_mana2stam%
time_mana2stam := A_TickCount
}
}


StaminaPotion()
{
Send ^{7}
Sleep, 350
}

HealthPotion()
{
Send ^{8}
Sleep, 350
}

HealSpells()
{
global weapon, bar, cast_healself, dura_healself, time_healself, cast_stam2health, dura_stam2health, time_stam2health

w := weapon
b := bar

t1 := A_TickCount - time_healself
t2 := A_TickCount - time_stam2health

if (t1 > dura_healself)
{
Staff()
Send !{4}
Sleep, 250
Send {1}
Sleep, 250
Send {LButton}
Sleep, %cast_healself%
time_healself := A_TickCount
}
else if (t2 > dura_stam2health)
{
Staff()
Send !{4}
Sleep, 250
Send {3}
Sleep, 250
Send {LButton}
Sleep, %cast_stam2health%
time_stam2health := A_TickCount
}
}

Buff()
{
global weapon, bar, cast_buff1, dura_buff1, time_buff1, cast_buff2, dura_buff2, time_buff2, cast_buff3, dura_buff3, time_buff3, cast_buff4, dura_buff4, time_buff4

w := weapon
b := bar

t1 := A_TickCount - time_buff1
t2 := A_TickCount - time_buff2
t3 := A_TickCount - time_buff3
t4 := A_TickCount - time_buff4

if (t1 > dura_buff1)
{
Staff()
Send !{5}
Sleep, 250
Send {1}
Sleep, 250
Send {LButton}
Sleep, %cast_buff1%
time_buff1 := A_TickCount
}
else if (t2 > dura_buff2)
{
Staff()
Send !{5}
Sleep, 250
Send {2}
Sleep, 250
Send {LButton}
Sleep, %cast_buff2%
time_buff2 := A_TickCount
}
else if (t3 > dura_buff3)
{
Staff()
Send !{5}
Sleep, 250
Send {3}
Sleep, 250
Send {LButton}
Sleep, %cast_buff3%
time_buff3 := A_TickCount
}
else if (t4 > dura_buff4)
{
Staff()
Send !{5}
Sleep, 250
Send {4}
Sleep, 250
Send {LButton}
Sleep, %cast_buff4%
time_buff4 := A_TickCount
}
}

Mount()
{
Sleep, 250
Send ^{9}
}

Jump180()
{
global weapon, bar, time_whirlwind

Send {Space Down}
Sleep, 50
Send {Space Up}
if GetKeyState("w","P") && GetKeyState("LButton","P") && weapon > 2
{
Sleep, 50
DllCall("mouse_event",uint,1,int,-1250,int,0,uint,0,int,0)
Sleep, 750
DllCall("mouse_event",uint,1,int,1250,int,0,uint,0, int,0)
Sleep, 50
SoundPlay, %A_WinDir%\Media\start.wav
}
}

; FUNCS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;

Staff()
{
global weapon, shield
if not weapon = 4
{
Send ^{5}
Sleep, 250
}
shield = 0
weapon = 4
}

Back(w = -1, b = -1)
{
global bar

if w = 1
{
OneHand()
}
else if w = 2
{
TwoHand(0)
}
else if w = 3
{
Bow()
}
else if w = 4
{
Staff()
}

if b > -1
{
bar := b
}

Sleep, 250
Send !{%bar%}
Sleep, 250
Send {1}
}

Whirlwind()
{
global weapon, bar, dura_whirlwind, time_whirlwind

w := weapon
b := bar
t := A_TickCount - time_whirlwind

if (t > dura_whirlwind)
{
Sleep, 300
BlockInput On
TwoHand()
Sleep, 50
Send {LButton}
BlockInput Off
Sleep, 1200
time_whirlwind := A_TickCount
}

}

Print(t)
{
Gui, Destroy
Gui, +AlwaysOnTop -SysMenu +Owner
Gui, Add, Text,, %t%
Gui, Show, NoActivate, Console
}

; ASSIGN KEYS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;

F1::OneHand()
+F1::OneHand()

F2::TwoHand()
+F2::TwoHand()

F3::Bow()
+F3::Bow()

F4::LGM()
+F4::LGM()

F5::UTILITY()
+F5::UTILITY()

F6::BUFFYOU()
+F6::BUFFYOU()

F8::Mount()
+F8::Mount()

F9::StaminaPotion()
+F9::StaminaPotion()

F10::HealthPotion()
+F10::HealthPotion()

F11::Stamina()
+F11::Stamina()

F12::HealSpells()
+F12::HealSpells()

^Y::Buff()

+B::Jump180()
^B::UNBURDEN()

Posted: January 16th, 2010, 8:37 am
by Tault_admin
Can members say yay or nay to this so we may give tu bucks and/or premium. If you nay the submission remember to include as to why.

Posted: January 16th, 2010, 10:56 am
by hokuto78
This isnt a submission this is a question on how to fix his macro.

Posted: January 19th, 2010, 7:37 pm
by Tault_admin
O whoops lol it was a late night.