Автоматизационный макрос. Autohotkey

Гайды и учебники.
Post Reply
Smack
Bereaver of Loot
Posts: 1032
Joined: Mon Dec 08, 2008 9:30 pm

Автоматизационный макрос. Autohotkey

Post by Smack »

Автоматизационный макрос для Autohotkey.

Мы с Миксом его тестили. В принципе - штука полезная. Выкладываю по запросу.

Что в нем есть:

Автолут (кривой, лучше взять автолут с первого нашего макроса и дополнить этот).
Переключение оружия и смена соответствующей панельки для него в одну кнопку
Регенит стамину на правую кнопку мыши (или еду вешает или мана2стамина спелл)
Бафает на кнопку + на доп.клаве все бафы.
Позволяет разворачиваться в прыжке на 180 градусов на полсекунды для выстрела и обратно для продолжения бега.

Дополните его пожалуйста автолутом предыдущим и выложите рабочий вариант в конце. На вопросы по этому макросу отвечать тут не буду - даже не старайтесь. Вопросы в венте или мне или Миксу.. Но лучше разбирайтесь сами.


- It switches weapons with 1-button clicks.
- Autolooter/ninja looter included. Ctrl+f to mark where items are to be dragged to. Alt+f to start dragging items under the cursor, and press "tab" (my key for ui-mode switch) to stop looting.
- It regains stam with 1 button (right mouse button). If your food timer is up it eats, otherwise casts mana-2-stamina.
- It buffs with 1 button (numeric keypad "+"), remembers timers on buff spells, and buffs the most important spells first that the timer is up for.
- If you have bow or wand equipped AND you run forward AND left mousebutton is down AND you jump, it turns you 180-degrees in a split second and leaves you 700milliseconds to release the loaded spell/arrows on who ever is chasing you, before it turns you back again in a splitsecond

Code:

;
; 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.)
;
; Bar 1 setup:
; 1 - 1h
; 2 - shield
; 3 - 2h
; 4 - bow
; 5 - staff
; 6 - food
; 7 - stamina potion
; 8 - health potion
; 9 - mount
;
; Bar 2 setup:
; 1 - Whirlwind 2h
; 2 - Powerattack 2h
; 3 - Knockback 2h
; 4 - Powerattack 1h
; 5 - Knockback 1h
;
; Bar 3 setup:
; 1 - Mana Missile
; 2 - Heal Self
; 3 - Stam 2 health
; 4 - Mana 2 stam
; ...the rest is up to yourself
;
; Bar 0 - Buffs:
; 1 - Unburden
; 2 - Arrow Shield
; 3 - Agility
; 4 - Brawn
;

#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\ding.wav

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

nx = 0
ny = 0
lmb = 0

bar = 1

weapon = 0
shield = 0

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

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

cast_buff2 := 5500
dura_buff2 := 360000
time_buff2 := A_TickCount - dura_buff2

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

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

cast_healself := 5500
dura_healself := 30000
time_healself := A_TickCount - dura_healself

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

cast_stam2health := 3500
dura_stam2health := 4000
time_stam2health := A_TickCount - dura_stam2health

dura_food := 180000
time_food := A_TickCount - dura_food

dura_whirlwind := 20000
time_whirlwind := A_TickCount - dura_whirlwind

return

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

Tab::MButton

Break::Suspend, Toggle

Home::Reload

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

LMB(t)
{
global lmb

if(lmb = 0) {
lmb = 1
Loop
{
Send {LButton}
Sleep, %t%
}
}
else
{
lmb:= 0
}
}

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}
}

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)
{
LGM()
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 !{3}
Sleep, 250
Send {2}
Sleep, 250
Send {LButton}
Sleep, %cast_healself%
time_healself := A_TickCount
}
else if (t2 > dura_stam2health)
{
Staff()
Send !{3}
Sleep, 250
Send {3}
Sleep, 250
Send {LButton}
Sleep, %cast_stam2health%
time_stam2health := A_TickCount
}
}

Rest()
{
bar = 1
Sleep, 500
Send ^{0}
Sleep, 500
Send {LButton}
}

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 !{0}
Sleep, 250
Send {1}
Sleep, 250
Send {LButton}
Sleep, %cast_buff1%
time_buff1 := A_TickCount
}
else if (t2 > dura_buff2)
{
Staff()
Send !{0}
Sleep, 250
Send {2}
Sleep, 250
Send {LButton}
Sleep, %cast_buff2%
time_buff2 := A_TickCount
}
else if (t3 > dura_buff3)
{
Staff()
Send !{0}
Sleep, 250
Send {3}
Sleep, 250
Send {LButton}
Sleep, %cast_buff3%
time_buff3 := A_TickCount
}
else if (t4 > dura_buff4)
{
Staff()
Send !{0}
Sleep, 250
Send {4}
Sleep, 250
Send {LButton}
Sleep, %cast_buff4%
time_buff4 := A_TickCount
}
}

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

NinjaMark()
{
global nx, ny
MouseGetPos, x, y
nx := x
ny := y
SoundPlay, %A_WinDir%\Media\ding.wav
}

NinjaLoot()
{
global nx, ny
Sleep, 500
Loop {
BlockInput On
MouseGetPos, x, y
MouseClickDrag, L, %x%, %y%, %nx%, %ny%, 0
MouseMove, %x%, %y%, 0
BlockInput Off
Loop 7 {
If GetKeyState("Tab","P")
{
return
}
Sleep, 1
}
}
}

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\ding.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::LMB(11000)

F1::OneHand()
+F1::OneHand()
F2::TwoHand()
+F2::TwoHand()
F3::Bow()
+F3::Bow()
F4::LGM()
+F4::LGM()
F10::StaminaPotion()
+F10::StaminaPotion()
F11::HealthPotion()
+F11::HealthPotion()
F12::HealSpells()
+F12::HealSpells()

RButton::Stamina()
+RButton::Stamina()

^F::NinjaMark()
!F::NinjaLoot()

NumpadDot::Rest()
+NumpadDot::Rest()
NumpadAdd::Buff()
+NumpadAdd::Buff()

End::Mount()
+space::Jump180()
User avatar
Reaper
Posts: 5654
Joined: Mon Jul 11, 2005 10:43 am
Location: Beckingen
Contact:

Post by Reaper »

Ну, первый набросок, как обещал, функция кайтинга спокойно выдирается:

[HTML]Jump180()
{
Send {Space Down}
Sleep, 50
Send {Space Up}

if( GetKeyState("w", "P") && GetKeyState("LButton", "P") )
{
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
}
}

+space::Jump180()[/HTML]

Нужен некоторый навык, чтобы научиться (этому легко научиться) отпускать шифт в прыжке, иначе бот не сможет отследить следущее нажатие шифт+спейс.

Проверку условия что зажато "w" (движение в перёд) и нажата левая кнопка мыши (оружие готово к стрельбе) оставил.
Smack
Bereaver of Loot
Posts: 1032
Joined: Mon Dec 08, 2008 9:30 pm

Post by Smack »

Рипер. В связи с последним патчем необходимость в кайте отпала.

Можешь выкинуть эту функцию из скрипта и добавить старый автолут взамен автолута этого патча. Было бы очень удобно.
User avatar
Reaper
Posts: 5654
Joined: Mon Jul 11, 2005 10:43 am
Location: Beckingen
Contact:

Post by Reaper »

2Smack:

каммент на строку +space::Jump180()

это:

RButton::Stamina()
+RButton::Stamina()

меняем на

BS::Stamina()
+BS::Stamina()

добавляем в скрипт это:

$!Lbutton:: ;quick loot -------------------------

MouseGetPos, x1, y1
MouseClickDrag, left, x1, y1, xdest, ydest, 0 ;0 is mouse speed, 0 is instant
MouseMove, x1, y1, 0 ;0 is mouse speed, 0 is instant

return

$!Rbutton:: ;loot destination ------------------------->

MouseGetPos, xdest, ydest
IniWrite, %xdest%, %IniFile%, Loot, xdest
IniWrite, %ydest%, %IniFile%, Loot, ydest

return
Feal Thas
Mercenary Sailor
Posts: 53
Joined: Fri May 29, 2009 4:22 pm
Location: Ukraine, Odessa
Contact:

Post by Feal Thas »

А кто знает как в AutoHotKey кликать в буквы?
Я имею ввиду, например, как послать R или S. Что-то у меня с этим проблема.
С циферками все ок, а буковки не хотят отсылаться :(
Post Reply

Return to “F.A.Q.”

Who is online

Users browsing this forum: No registered users and 1 guest