Healing script

Ask gaming related questions (AHK v1.1 and older)
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Healing script

28 Feb 2018, 05:51

Spark wrote:Maybe the pixel color not same, to be honest I don't know how to make the shades of pixel color variations
Take a look at PixelSearch.

Example:

Code: Select all

PixelGetColor, Krenn1, 1177, 542, RGB
if (Krenn1 = 0xC26F93)
    MsgBox Color Found! Do something
Could be changed to this to get 5 variations of color for the pixel you want to check:

Code: Select all

PixelSearch,,, 1177, 542, 1178, 543, 0xC26F93, 5, RGB
if (ErrorLevel = 0)
    MsgBox Color Found! Do something
Variation
A number between 0 and 255 (inclusive) to indicate the allowed number of shades of variation in either direction for the intensity of the red, green, and blue components of the color (can be an expression). This parameter is helpful if the color sought is not always exactly the same shade. If you specify 255 shades of variation, all colors will match. The default is 0 shades.
HTH
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Healing script

28 Feb 2018, 07:28

OHHHHHHHHHHH but why did I say that pixelsearch can interpret variations and then midway forget what I was doing lmao. Btw you're doing great.
I am your average ahk newbie. Just.. a tat more cute. ;)
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

28 Feb 2018, 08:08

I managed to get this code to work as I wanted, however its not very elegant and its very hard to read and it will get cluttered if I add 15 more, still reading up on more but as of now I'm uncertain how to make it better.

Pixelsearch is abit slower I imagine? either way, I don't need to look for variations anymore, luckily :D

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
Coordmode, mouse, client

HP0 = 0xF58CBA
HP25 = F58CBA
HP50 = F58CBA
HP75v1 = 0xF58CBA ;Krenn-Dreyet
HP75v2 = 0xF58CBA ;Kostus-Ilia-Danicus
HP100 = 0xF58CBA

F7::
gosub, HP_Coordinate

if (Krenn4 != HP75v1) {
Send, ^+!{F1 Down}
Sleep, 50
Send, ^+!{F1 Up}
Sleep, 50
KeyWait, F7, D
Sleep, 50
Send, !1
}
if (Kostus4 != HP75v2) {
Send, ^+!{F3 Down}
Sleep, 50
Send, ^+!{F3 Up}
Sleep, 50
KeyWait, F7, D
Sleep, 50
Send, !1
}
if (Ilia4 != HP75v2) {
Send, ^+!{F5 Down}
Sleep, 50
Send, ^+!{F5 Up}
Sleep, 50
KeyWait, F7, D
Sleep, 50
Send, !1
}
if (Dreyel4 != HP75v1) {
Send, ^+!{F2 Down}
Sleep, 50
Send, ^+!{F2 Up}
Sleep, 50
KeyWait, F7, D
Sleep, 50
Send, !1
}
if (Danicus4 != HP75v2) {
Send, ^+!{F4 Down}
Sleep, 50
Send, ^+!{F4 Up}
Sleep, 50
KeyWait, F7, D
Sleep, 50
Send, !1
}
return

HP_Coordinate:
;PixelGetColor, Krenn1, 1177, 542, RGB	; 0%
;PixelGetColor, Krenn2, 1208, 542, RGB 	;25%
;PixelGetColor, Krenn3, 1242, 542, RGB	;50%
PixelGetColor, Krenn4, 1275, 542, RGB	;75%
;PixelGetColor, Krenn5, 1311, 542, RGB	;100%

;PixelGetColor, Kostus1, 1034, 542, RGB	;0%
;PixelGetColor, Kostus2, 1065, 542, RGB	;25%
;PixelGetColor, Kostus3, 1099, 542, RGB	;50%
PixelGetColor, Kostus4, 1133, 542, RGB	;75%
;PixelGetColor, Kostus5, 1169, 542, RGB	;100%

;PixelGetColor, Ilia1, 892, 542, RGB
;PixelGetColor, Ilia2, 923, 542, RGB
;PixelGetColor, Ilia3, 957, 542, RGB
PixelGetColor, Ilia4, 990, 542, RGB
;PixelGetColor, Ilia5, 1026, 542, RGB

;PixelGetColor, Dreyel1, 748, 542, RGB
;PixelGetColor, Dreyel2, 779, 542, RGB
;PixelGetColor, Dreyel3, 813, 542, RGB
PixelGetColor, Dreyel4, 846, 542, RGB
;PixelGetColor, Dreyel5, 883, 542, RGB

;PixelGetColor, Danicus1, 606, 542, RGB
;PixelGetColor, Danicus2, 637, 542, RGB
;PixelGetColor, Danicus3, 671, 542, RGB
PixelGetColor, Danicus4, 704, 542, RGB
;PixelGetColor, Danicus5, 740, 542 , RGB
return
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Healing script

28 Feb 2018, 08:13

ahk takes up kilobytes at max. You shouldn't be concerned about resource usage unless you have a really big script. :D
I am your average ahk newbie. Just.. a tat more cute. ;)
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

28 Feb 2018, 08:40

Is there a way to write the complete script abit more compact? It'll be quite ugly finished!

Perhaps consolidate it some? I made a script using arrays but I don't know how to add in the key presses :/

Thanks for all your help Nwb too :) forgot to thank you before!
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Healing script

28 Feb 2018, 08:56

Xtra wrote:
Spoiler
WHoaaaaaa.... thanks ALOT
gsboxing wrote:

assume
0xF58CBA = remaining HP
0x3D232F = HP loss

maybe i can change like this :

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
CoordMode, pixel, Client
CoordMode, mouse, Client

;https://autohotkey.com/docs/Functions.htm#Global
global Krennkey
global Kostuskey
global Iliakey
global Dreyelkey
global Danicuskey
global resurrection_spell
global instant_heal
global slower_heal
global quick_heal
HP_col = 0xF58CBA
;========= SETTING =========
;change as needed

Krennkey = F1
Kostuskey = F2
Iliakey = F3
Dreyelkey = F4
Danicuskey = F5
resurrection_spell = 0
instant_heal = 1
slower_heal = 2
quick_heal = 3
;======================

e::
; PixelSearch Reference
; https://autohotkey.com/docs/commands/PixelSearch.htm
PixelSearch,,, 1177, 542, 1178, 543, HP_col, 5, RGB	; Krenn HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 1034, 542, 1035, 543, HP_col, 5, RGB	; Kostus HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 892, 542, 893, 543, HP_col, 5, RGB	; Ilia HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 748, 542, 749, 543, HP_col, 5, RGB	; Dreyel HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 606, 542, 607, 543, HP_col, 5, RGB	; Danicus HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)


PixelSearch,,, 1208, 542, 1209, 543, HP_col, 5, RGB	; Krenn HP 25%
if ErrorLevel
	    Heal(Krennkey,instant_heal)
PixelSearch,,, 1065, 542, 1066, 543, HP_col, 5, RGB	; Kostus HP 25%
if ErrorLevel
	    Heal(Kostuskey,instant_heal)
PixelSearch,,, 923, 542, 924, 543, HP_col, 5, RGB	; Ilia HP 25%
if ErrorLevel
	    Heal(Iliakey,instant_heal)
PixelSearch,,, 779, 542, 780, 543, HP_col, 5, RGB	; Dreyel HP 25%
if ErrorLevel
	    Heal(Dreyelkey,instant_heal)
PixelSearch,,, 637, 542, 638, 543, HP_col, 5, RGB	; Danicus HP 25%
if ErrorLevel
	    Heal(Danicuskey,instant_heal)


PixelSearch,,, 1242, 542, 1243, 543, HP_col, 5, RGB	; Krenn HP 50%
if ErrorLevel
	    Heal(Krennkey,slower_heal)
PixelSearch,,, 1099, 542, 1100, 543, HP_col, 5, RGB	; Kostus HP 50%
if ErrorLevel
	    Heal(Kostuskey,slower_heal)
PixelSearch,,, 957, 542, 958, 543, HP_col, 5, RGB	; Ilia HP 50%
if ErrorLevel
	    Heal(Iliakey,slower_heal)
PixelSearch,,, 813, 542, 814, 543, HP_col, 5, RGB	;Dreyel HP 50%
if ErrorLevel
	    Heal(Dreyelkey,slower_heal)
PixelSearch,,, 671, 542, 672, 543, HP_col, 5, RGB	;Danicus HP 50%
if ErrorLevel
	    Heal(Danicuskey,slower_heal)


PixelSearch,,, 1275, 542, 1276, 543, HP_col, 5, RGB	; Krenn HP 75%
if ErrorLevel
	    Heal(Krennkey,quick_heal)
PixelSearch,,, 1133, 542, 1134, 543, HP_col, 5, RGB	; Kostus HP 75%
if ErrorLevel
	    Heal(Kostuskey,quick_heal)
PixelSearch,,, 990, 542, 991, 543, HP_col, 5, RGB	; Ilia HP 75%
if ErrorLevel
	    Heal(Iliakey,quick_heal)
PixelSearch,,, 846, 542, 847, 543, HP_col, 5, RGB	; Dreyel HP 75%
if ErrorLevel
	    Heal(Dreyelkey,quick_heal)
PixelSearch,,, 704, 542, 705, 543, HP_col, 5, RGB	; Danicus HP 75%
if ErrorLevel
	    Heal(Danicuskey,quick_heal)
return

; Function Reference
; https://autohotkey.com/docs/Functions.htm
Heal(charbut,HealBut)	; Char Button = F1/F2/F3/F4/F5  HealBut=Heal button 0/1/2/3/4 etc
{
Send, {%charbut% Down}	; send Char Keybutton Down , in your case F1/F2/F3/F4
Sleep, 75				; Delay 75 ms
Send, {%charbut% Up}		; send Char Keybutton Up
Sleep, 100	
KeyWait, e, D			; wait for "e" button to be pressed again
Sleep, 100				; delay 100ms to avoid "e" press button too long
Send, %healbut%		; send Heal button, in your case 0/1/2/3/4
} 
Question :
why you should press Ctrl+Shift+Alt+F1 ??

correct me if i'm wrong :
Your heal like this, assume Krenn (F1 below 50%) and heal button is 2
Press F1, to focus on krenn Icon..and then press button [2] to heal Krenn
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

28 Feb 2018, 10:35

Ctrl+Shift+Alt+F1-F5 is bound to my macro targeting ingame since I'm playing 5 characters at the time, I only want the key sent to my healer, it's how I set it up, while normal F1-F5 target respective target member normally.

Alt+1,Alt+2,Alt+3,Alt+4 is also bound to ingame healing macro.

The script works except for the hotkeys at this moment, thank you very much! One last touch, I'll read up on it later tonight if noone chimes in!

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
CoordMode, pixel, Client
CoordMode, mouse, Client

;https://autohotkey.com/docs/Functions.htm#Global
global Krennkey
global Kostuskey
global Iliakey
global Dreyelkey
global Danicuskey
global resurrection_spell
global instant_heal
global slower_heal
global quick_heal
HP_col = 0xF58CBA
;========= SETTING =========
;change as needed

Krennkey = ^+!F1
Kostuskey = ^+!F2
Iliakey = ^+!F3
Dreyelkey = ^+!F4
Danicuskey = ^+!F5
resurrection_spell = !0
instant_heal = !1
slower_heal = !2
quick_heal = !1
;======================

e::
; PixelSearch Reference
; https://autohotkey.com/docs/commands/PixelSearch.htm
PixelSearch,,, 1177, 542, 1178, 543, HP_col, 5, RGB	; Krenn HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 1034, 542, 1035, 543, HP_col, 5, RGB	; Kostus HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 892, 542, 893, 543, HP_col, 5, RGB	; Ilia HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 748, 542, 749, 543, HP_col, 5, RGB	; Dreyel HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)
PixelSearch,,, 606, 542, 607, 543, HP_col, 5, RGB	; Danicus HP 0%
if ErrorLevel
		Heal(Krennkey,resurrection_spell)


PixelSearch,,, 1208, 542, 1209, 543, HP_col, 5, RGB	; Krenn HP 25%
if ErrorLevel
	    Heal(Krennkey,instant_heal)
PixelSearch,,, 1065, 542, 1066, 543, HP_col, 5, RGB	; Kostus HP 25%
if ErrorLevel
	    Heal(Kostuskey,instant_heal)
PixelSearch,,, 923, 542, 924, 543, HP_col, 5, RGB	; Ilia HP 25%
if ErrorLevel
	    Heal(Iliakey,instant_heal)
PixelSearch,,, 779, 542, 780, 543, HP_col, 5, RGB	; Dreyel HP 25%
if ErrorLevel
	    Heal(Dreyelkey,instant_heal)
PixelSearch,,, 637, 542, 638, 543, HP_col, 5, RGB	; Danicus HP 25%
if ErrorLevel
	    Heal(Danicuskey,instant_heal)


PixelSearch,,, 1242, 542, 1243, 543, HP_col, 5, RGB	; Krenn HP 50%
if ErrorLevel
	    Heal(Krennkey,slower_heal)
PixelSearch,,, 1099, 542, 1100, 543, HP_col, 5, RGB	; Kostus HP 50%
if ErrorLevel
	    Heal(Kostuskey,slower_heal)
PixelSearch,,, 957, 542, 958, 543, HP_col, 5, RGB	; Ilia HP 50%
if ErrorLevel
	    Heal(Iliakey,slower_heal)
PixelSearch,,, 813, 542, 814, 543, HP_col, 5, RGB	;Dreyel HP 50%
if ErrorLevel
	    Heal(Dreyelkey,slower_heal)
PixelSearch,,, 671, 542, 672, 543, HP_col, 5, RGB	;Danicus HP 50%
if ErrorLevel
	    Heal(Danicuskey,slower_heal)


PixelSearch,,, 1275, 542, 1276, 543, HP_col, 5, RGB	; Krenn HP 75%
if ErrorLevel
	    Heal(Krennkey,quick_heal)
PixelSearch,,, 1133, 542, 1134, 543, HP_col, 5, RGB	; Kostus HP 75%
if ErrorLevel
	    Heal(Kostuskey,quick_heal)
PixelSearch,,, 990, 542, 991, 543, HP_col, 5, RGB	; Ilia HP 75%
if ErrorLevel
	    Heal(Iliakey,quick_heal)
PixelSearch,,, 846, 542, 847, 543, HP_col, 5, RGB	; Dreyel HP 75%
if ErrorLevel
	    Heal(Dreyelkey,quick_heal)
PixelSearch,,, 704, 542, 705, 543, HP_col, 5, RGB	; Danicus HP 75%
if ErrorLevel
	    Heal(Danicuskey,quick_heal)
return

; Function Reference
; https://autohotkey.com/docs/Functions.htm
Heal(charbut,HealBut)	; Char Button = F1/F2/F3/F4/F5  HealBut=Heal button 0/1/2/3/4 etc
{
Send, {%charbut% Down}	; send Char Keybutton Down , in your case F1/F2/F3/F4
Sleep, 75				; Delay 75 ms
Send, {%charbut% Up}		; send Char Keybutton Up
Sleep, 100	
KeyWait, e, D			; wait for "e" button to be pressed again
Sleep, 100				; delay 100ms to avoid "e" press button too long
Send, %healbut%		; send Heal button, in your case 0/1/2/3/4
} 

You're utterly amazing, thanks for helping me out :)
Wow! Thanks!!

Best regards,
gs
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Healing script

28 Feb 2018, 16:05

Just messing around, based on your script.
Spoiler
Not tested.
Maybe someone will learn something from it.

HTH
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

28 Feb 2018, 18:48

Thank you kindly for your contribution Xtra, but unfortunately it's not working correctly >- Player.Krennkey.charbut := "^+!F1" <- doesn't get sent, actually none of them are. However, the !0,!1,!2!3 works perfectly now!

But geez, heh! This code is way too advanced for me, I'm just a newbie - but I'll def. keep it and perhaps one day I can use it :] thanks! :bravo:

Wish I could write code like that, I keep multiple tabs open and reading up but shit, nothing sticks. I'm starting to wonder if I'm dumber than I thought :crazy:

Best regards,
-D
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Healing script

28 Feb 2018, 19:19

In your Heal Function:

Heal(charbut,HealBut) ; Char Button = F1/F2/F3/F4/F5 HealBut=Heal button 0/1/2/3/4 etc
{
Send, {%charbut% Down} ; send Char Keybutton Down , in your case F1/F2/F3/F4
Sleep, 75 ; Delay 75 ms
Send, {%charbut% Up} ; send Char Keybutton Up
Sleep, 100
KeyWait, e, D ; wait for "e" button to be pressed again
Sleep, 100 ; delay 100ms to avoid "e" press button too long
Send, %healbut% ; send Heal button, in your case 0/1/2/3/4
}

Take a look at the 1st send line do you see the problem?
Spoiler
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Healing script

28 Feb 2018, 21:20

Xtra wrote:;NOTE: change as needed (Looks like you have instant_heal and quick_heal with the same keypresses)
My bad, typos :oops:
Xtra wrote:Just messing around, based on your script.
Spoiler
Not tested.
Maybe someone will learn something from it.


HTH
It's my pleasure, thank you very much :thumbup:
i never use for-loop before, can you give me a simple example and some explanations for learning purpose?
thanks in advance

maybe something like this :

Code: Select all

Heal(charbut,HealBut)	; Char Button = F1/F2/F3/F4/F5  HealBut=Heal button 0/1/2/3/4 etc
{
Send, {LCtrl Down}{LShift Down}{LAlt Down}{%charbut%}{LAlt Up}{LShift Up}{LCtrl Up}	
KeyWait, e, D			; wait for "e" button to be pressed again
Sleep, 100				; delay 100ms to avoid "e" press button too long
Send, %healbut%		; send Heal button, in your case 0/1/2/3/4
} 
please add SetKeyDelay, 100, 75 below CoordMode, mouse, Client

Change the key to F1 or F2 or F2 etc at the top of the script
ie:
^+!F1
to
F1
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

01 Mar 2018, 05:35

Thanks Xtra, I was able to see the problem once you gave me the hint, overlooked that part completely.
Spark, thanks for setting it up like so, works wonderful!

Would anyone help me run down the function of this part? I'm unable to understand what its true purpose is, and how its used?

Code: Select all

CheckObjects()
{   ; testing only
    for spellname, Healbut in Spells
    {
        for name in Player
        {
            MsgBox % "name= " . name . "`n"
                    . "charbut= " . Player[name].charbut . "`n"
                    . "spellname= " . spellname . "`n"
                    . "healbut= " . healbut . "`n"
                    . "X1= " . Player[name][spellname].1 . "`n"
                    . "Y1= " . Player[name][spellname].2 . "`n"
                    . "X2= " . Player[name][spellname].3 . "`n"
                    . "X2= " . Player[name][spellname].4
        }
    }  
}

Seeing this script working in action is truely epic, I can finally play without having my hand aching after 15minutes, it's great! I'm truely thankful.
Also while playing I came up with an idea for a second function and I'm not entirely sure if it's even possible, I'm still reading up on the tutorials but having to read it several times to even get the slightest clue of how it works is starting to get to me. Unfortunetely I start to think I won't ever really understand it deeply enough :/

The idea is to search 5 locations and if they are all true -> send a hotkey.

Code: Select all


PlayerCheck = 0

PixelSearch,,, 1275, 542, 1276, 543, HP_col, 5, RGB	; Krenn HP 75%
if ErrorLevel
	    PlayerCheck = 1

PixelSearch,,, 990, 542, 991, 543, HP_col, 5, RGB	; Ilia HP 75%
if ErrorLevel
	    PlayerCheck = 2

PixelSearch,,, 1133, 542, 1134, 543, HP_col, 5, RGB	; Kostus HP 75%
if ErrorLevel
	    PlayerCheck = 3

PixelSearch,,, 846, 542, 847, 543, HP_col, 5, RGB	; Dreyel HP 75%
if ErrorLevel
	    PlayerCheck = 4

PixelSearch,,, 704, 542, 705, 543, HP_col, 5, RGB	; Danicus HP 75%
if ErrorLevel
	    PlayerCheck = 5
		
		
If (PlayerCheck = 5)
   AoE(Area_of_Effect)
   PlayerCheck = 0 ; reset variable
   
	;#############################
	;	Function
	;#############################
	
AoE(aoebut)
{
Sleep, 150			; small delay before casting
Send, %aoebut%		; send aoe button
Sleep, 1500			; global wait
} 
Would something like the above work? Don't be harsh I'm still learning, atleast trying to. If it works, would it be possible to add 4 more buttons to the AoE function?
So Heal function would be for single target and AoE function would be for Area of Effect? so it only cast aoe when everyone is at 75,50,25?

Thanks for everyone's contribution!
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Healing script

01 Mar 2018, 06:33

yes you can..
Hint : Nested IF's
something like this :

Code: Select all

if (a = "true") {
	if { b = "true"} {
		if ( c = "true") {
			if (d = "True") {
			; Do Something ! ! !
			}
		}
	}
}
ErrorLevel docs https://autohotkey.com/docs/misc/ErrorLevel.htm
good luck
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Healing script

01 Mar 2018, 12:08

gsboxing wrote:Would anyone help me run down the function of this part? I'm unable to understand what its true purpose is, and how its used?
CheckObjects()
Its not needed for your script just for testing in the script i posted.
The 1 hotkey would call the function and you would see a msgbox with all the values defined.
Spark wrote:i never use for-loop before, can you give me a simple example and some explanations for learning purpose?
For-loop [v1.0.90+]
Repeats a series of commands once for each key-value pair in an object.

For Key [, Value] in Expression
The names Key and Value can be anything you want to call it.
ie:
for myPlayerNames, myKeyboardKeys in Object

myPlayerNames is the key
myKeyboardKeys is the value
Expression is an object in this case

Look in the Docs for more examples to show how to use it.
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

01 Mar 2018, 13:14

Ok, I gave it a shot

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
CoordMode, pixel, Client
CoordMode, mouse, Client

	;#############################
	;	Global
	;#############################

global Char5
global Char4
global Char3
global Char2
global Char1
global Panic_Heal
global Instant_Heal
global Holy_Light
global Flash_Of_Light
global AoE
HP_col = 0xF58CBA

	;#############################
	;	Setting - Change as needed
	;#############################

Char5 = F1
Char4 = F2
Char3 = F3
Char2 = F4
Char1 = F5
Panic_Heal = !0
Instant_Heal = !1
Holy_Light = !2
Flash_Of_Light = !3
AoE = !4
;======================

	;#############################
	;	Hotkey
	;#############################

F7::



	;#############################
	;	AoE 50%HP
	;#############################

{ ;; <--- Is this right?

	PixelSearch,,, 1242, 542, 1243, 543, HP_col, 5, RGB	; Krenn HP 50%
	if ErrorLevel
    	{
		PixelSearch,,, 957, 542, 958, 543, HP_col, 5, RGB	; Ilia HP 50%
		if ErrorLevel
        	{
			PixelSearch,,, 1099, 542, 1100, 543, HP_col, 5, RGB	; Kostus HP 50%
			if ErrorLevel
			{
		PixelSearch,,, 813, 542, 814, 543, HP_col, 5, RGB	;Dreyel HP 50%
		if ErrorLevel
		{
	PixelSearch,,, 671, 542, 672, 543, HP_col, 5, RGB	;Danicus HP 50%
	if ErrorLevel
	{
           AoE(AoE)
    	}
}
return ; <--- Return?


	;#############################
	;	Panic 0-10%HP
	;#############################

;========= Char5 0% - SLOT1 - =========
PixelSearch,,, 1177, 542, 1179, 543, HP_col, 5, RGB	; Krenn HP 0%
if ErrorLevel
		Heal(Char5,Panic_Heal)

;========= Char3 0% - SLOT3 - =========
PixelSearch,,, 892, 542, 893, 543, HP_col, 5, RGB	; Ilia HP 0%
if ErrorLevel
		Heal(Char3,Panic_Heal)

;========= Char4 0% - SLOT2 =========
PixelSearch,,, 1034, 542, 1035, 543, HP_col, 5, RGB	; Kostus HP 0%
if ErrorLevel
		Heal(Char4,Panic_Heal)

;========= Char2 0% - SLOT4 - =========
PixelSearch,,, 748, 542, 749, 543, HP_col, 5, RGB	; Dreyel HP 0%
if ErrorLevel
		Heal(Char2,Panic_Heal)
		
;========= Char1 0% - SLOT5 - =========
PixelSearch,,, 606, 542, 607, 543, HP_col, 5, RGB	; Danicus HP 0%
if ErrorLevel
		Heal(Char1,Panic_Heal)

	;#############################
	;	Instant Heal 25%HP
	;#############################
		
;========= Char5 25% - SLOT1 - =========
PixelSearch,,, 1208, 542, 1209, 543, HP_col, 5, RGB	; Krenn HP 25%
if ErrorLevel
	    Heal(Char5,Instant_Heal)

;========= Char3 25% - SLOT3 - =========
PixelSearch,,, 923, 542, 924, 543, HP_col, 5, RGB	; Ilia HP 25%
if ErrorLevel
	    Heal(Char3,Instant_Heal)

;========= Char4 25% - SLOT2 =========
PixelSearch,,, 1065, 542, 1066, 543, HP_col, 5, RGB	; Kostus HP 25%
if ErrorLevel
	    Heal(Char4,Instant_Heal)

;========= Char2 25% - SLOT4 - =========
PixelSearch,,, 779, 542, 780, 543, HP_col, 5, RGB	; Dreyel HP 25%
if ErrorLevel
	    Heal(Char2,Instant_Heal)

;========= Char1 25% - SLOT5 - =========
PixelSearch,,, 637, 542, 638, 543, HP_col, 5, RGB	; Danicus HP 25%
if ErrorLevel
	    Heal(Char1,Instant_Heal)

	;#############################
	;	Holy Light 50%HP
	;#############################

PixelSearch,,, 1242, 542, 1243, 543, HP_col, 5, RGB	; Krenn HP 50%
if ErrorLevel
	    Heal(Char5,Holy_Light)

PixelSearch,,, 957, 542, 958, 543, HP_col, 5, RGB	; Ilia HP 50%
if ErrorLevel
	    Heal(Char3,Holy_Light)

PixelSearch,,, 1099, 542, 1100, 543, HP_col, 5, RGB	; Kostus HP 50%
if ErrorLevel
	    Heal(Char4,Holy_Light)

PixelSearch,,, 813, 542, 814, 543, HP_col, 5, RGB	;Dreyel HP 50%
if ErrorLevel
	    Heal(Char2,Holy_Light)

PixelSearch,,, 671, 542, 672, 543, HP_col, 5, RGB	;Danicus HP 50%
if ErrorLevel
	    Heal(Char1,Holy_Light)

	;#############################
	;	Flash of Light 75%HP
	;#############################

PixelSearch,,, 1275, 542, 1276, 543, HP_col, 5, RGB	; Krenn HP 75%
if ErrorLevel
	    Heal(Char5,Flash_Of_Light)

PixelSearch,,, 990, 542, 991, 543, HP_col, 5, RGB	; Ilia HP 75%
if ErrorLevel
	    Heal(Char3,Flash_Of_Light)

PixelSearch,,, 1133, 542, 1134, 543, HP_col, 5, RGB	; Kostus HP 75%
if ErrorLevel
	    Heal(Char4,Flash_Of_Light)

PixelSearch,,, 846, 542, 847, 543, HP_col, 5, RGB	; Dreyel HP 75%
if ErrorLevel
	    Heal(Char2,Flash_Of_Light)

PixelSearch,,, 704, 542, 705, 543, HP_col, 5, RGB	; Danicus HP 75%
if ErrorLevel
	    Heal(Char1,Flash_Of_Light)
return

	;#############################
	;	Heal Function
	;#############################
	
Heal(charbut,HealBut)	; Char Button = F1/F2/F3/F4/F5  HealBut=Heal button 0/1/2/3/4 etc
{
Send, {%charbut% Down}	; send Char Keybutton Down , in your case F1/F2/F3/F4
Sleep, 100				; Delay 75 ms
Send, {%charbut% Up}		; send Char Keybutton Up
Sleep, 100	
KeyWait, F7, D			; wait for "e" button to be pressed again
Sleep, 150				; delay 100ms to avoid "F7" press button too long
Send, %healbut%		; send Heal button, in your case 0/1/2/3/4
Sleep, 2500
} 

	;#############################
	;	AoE Function
	;#############################

AoE(aoebut)
{
Sleep, 75
Send, %aoebut%		; send aoe button
Sleep, 1500		; gcd
} 

I haven't actually tested it but does this look right to you? What I think it does is, it checks al 5 and if all 5 are below 50% hp the aoe is sent.

How many pixelsearches can you eventually add before things start to get messy? is another 20 pixel searches allright? what about 40? - I wont actualy do it but just wondering, googling about pixelsearches you find many people requesting help because the script is slow and they're refered to pixelgetcolor.

Xtra, thanks for your script again, I'm howeer unable to learn its process so its hard for me to add things on my own, down the line so I would have to keep that script on the side for noow but I'm very glad you join in, I don't really wanna take someone elses work and be done with it.

i would very much like to learn along the way, of course i wouldnt be here without everyones help but Sparks code is abit more understandable for me at this moment :)

Thanks again!
Spark
Posts: 80
Joined: 04 Jan 2017, 02:22

Re: Healing script

01 Mar 2018, 22:19

Xtra wrote: The names Key and Value can be anything you want to call it.
ie:
for myPlayerNames, myKeyboardKeys in Object

myPlayerNames is the key
myKeyboardKeys is the value
Expression is an object in this case

Look in the Docs for more examples to show how to use it
maybe I should read it over and over again to better understand, thank you

@gsboxing
I probably don't qualify is an AutoHotkey Guru yet but
@Anyone
Correct me if i'm wrong :D

If your script is more complex, maybe you need a better script editor, try this :
SciTE4AutoHotkey OR Notepad++

the number of blocks/bracket must be the same
Spoiler
If you want your script to be more readable, Try GoSub
gsboxing wrote:How many pixelsearches can you eventually add before things start to get messy? is another 20 pixel searches allright? what about 40? - I wont actualy do it but just wondering, googling about pixelsearches you find many people requesting help because the script is slow and they're refered to pixelgetcolor.
better use another method, many ways to achieve goals :D

this forum is just like a gold mine for me, if you have extra effort you can find what you want
and the people here don't mind spending their precious time to help you

Good luck
gsboxing
Posts: 30
Joined: 25 Feb 2018, 05:54

Re: Healing script

02 Mar 2018, 17:03

Thanks spark, i got it running now and working but it seems to bug down the script some, im reading abit Evert night so eventually it will work ok!

Thanks for everyones effort helping me, learnt á great deal, thanks!

Best regards

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: mikeyww and 88 guests