* If you tele to godsland while being underleved, you are 1hitko, 3hitko at best. You are still gonna die just like that. And nothing will help you. Not even God. Same with suicidal melee enemies - they 1hitko until like lvl12.
Took 20 min to write, 80min to debug out, and one day of playing to optimize
;; Installation instructions:
;; 0. Be a pro. There will be no further explaining that
;; 1. Screenshoot your ign and save as myIgn.png (jpeg is lossy, so don't save as jpg)
;; 2. Measure your health Bar Length in pixels
;; 3. Read the fu*** script to know what and how
;;Warning. Read TODO to know what is NOT implemented
;; TODO:
;; 1. Implement other graphics for other hp potions (like those in spider cave for example). Only basic HP pot icon works now.
;; 2. Implement whole mp regen stuff (following the example of hp) (but 1 mp check every 5 hp checks)
;; 3. Implement automatic trigger adjustments with level (instead of manual alt + e )
#SingleInstance force
Process, Priority, , High
;; Preferences
hpHealTrigger := 55 ;; amount as percent. For example hpHealTrigger := 35 means to use health potion when hp is below 35%
hpExitTrigger := 30 ;; amount as percent. For example hpExitTrigger := 25 means to exit when hp reaches below 25%
hpHealScaleTriggerWithLevelBy := 0.8 ;; how to scale above triggers with each level gained
hpExitScaleTriggerWithLevelBy := -0.22 ;; btw press alt+e to notify the script you got a lvl
;; User variables
MyBrowser := "Mozilla Firefox" ;; name of your web browser as displayed in Title Bar after opening any web page
healthBarLength := 175 ;; Amount in pixels of length of hp Bar (depends mostly on your zoom level, also on browser, you can take a sc and measure it with ms paint)
dummy_img_myIgn = "take a screenshoot of your ign in game as seen in example and replace it. See img_myIgn for the details on what to replace"
dummy_exitButton = "Insert" ;; go edit exitToNexus function if it's different for you
;; List of known Images
img_healthPot := A_WorkingDir . "\images\healthPot.png"
img_myIgn := A_WorkingDir . "\images\myIgn.png"
img_hpBarPixel := A_WorkingDir . "\images\hpBarPixel.png"
;; Declarations of variables
myIgnXPos := 0
myIgnYPox := 0
healthBarStartXPos := 0
healthBarStartYPos := 0
healthBarStatusAsPercent := 0
alwaysLoop := true
logFile = %A_ScriptDir%\hpStatusLog.txt
updateTime := 0
healTriggerScalerCounter := 0
exitTriggerScalerCounter := 0
defaulthpHealTrigger := hpHealTrigger
defaulthpExitTrigger := hpExitTrigger
;; Functions
getMyIgnPosition() {
global myIgnXPos
global myIgnYPos
global img_myIgn
global windowSizeX
global windowSizeY
startPlaceExists := 0
While (startPlaceExists = 0)
{
ImageSearch, myszX, myszY, 1, 1, windowSizeX, windowSizeY, *15 %img_myIgn%
if (ErrorLevel = 0) {
myIgnXPos := myszX
myIgnYPos := myszY
startPlaceExists := 1
;;MsgBox, , "ZNalazlo mnie" , "Znalazlo mnie" ;; DEBUG line
}
Sleep, 100
}
}
getBasicHealthBarPosition() {
global healthBarStartXPos
global healthBarStartYPos
global img_hpBarPixel
global myIgnXPos
global myIgnYPos
Sleep, 250 ;; let the window load really really properly :P Could use WinWaitActive, but come on, I won't make the code THAT pretty
ImageSearch, myszX, myszY, myIgnXPos - 25, myIgnYPos + 5, myIgnXPos + 15 , myIgnYPos + 244, *15 %img_hpBarPixel%
if (ErrorLevel = 0) {
healthBarStartXPos := myszX
healthBarStartYPos := myszY
MouseMove, myszX, myszY ;; DEBUG line
;;MsgBox, "jest basic health bar" ;; DEBUG line
startPlaceExists := 1
}
}
healOrExitIfNecessary() {
global healthBarStatusAsPercent
global hpExitTrigger
global hpHealTrigger
getHealthBarStatusAsPercent()
;;MsgBox, "health bar as percent is:" %healthBarStatusAsPercent%
if (( healthBarStatusAsPercent < hpExitTrigger ) && ( healthBarStatusAsPercent > 1 )) {
Sleep, 50
getHealthBarStatusAsPercent()
if (( healthBarStatusAsPercent < hpExitTrigger ) && ( healthBarStatusAsPercent > 1 )) {
exitToNexus()
}
} else if (( healthBarStatusAsPercent < hpHealTrigger ) && (healthBarStatusAsPercent > 1)) {
heal()
}
}
getHealthBarStatusAsPercent() {
global healthBarStartXPos
global healthBarStartYPos
global healthBarLength
global healthBarStatusAsPercent
global img_hpBarPixel
global logFile
global updateTime
;; local toLoop
;; local minOffset
;; local maxOffset
;; local middleShot
;;MsgBox, "We getting hp status now" ;; DEBUG line
toLoop := true
minOffset := 1
maxOffset := healthBarLength
middleShot := (minOffset + maxOffset) // 2 ;; + (healthBarLength // 4) ;; it favourizes the fact that we are USUALLY healed (and if not we heal after 1 loop so we are healed)
;; can't create different middleshot - 50-76% is missed then. I dun wanna recode all that
;; ---------------------------- A simple Binary Search here ----------------------------------
while ( toLoop = true ) {
ImageSearch, myszX, myszY, healthBarStartXPos + middleShot, healthBarStartYPos - 3, healthBarStartXPos + middleShot + 9, healthBarStartYPos + 11, *19 %img_hpBarPixel%
if (ErrorLevel = 0) {
if ((minOffset = maxOffset) || ((minOffset + 1) = maxOffset)) {
toLoop := false
}
minOffset := (minOffset + maxOffset) // 2
} else if (ErrorLevel = 1) {
if ((minOffset = maxOffset) || ((minOffset + 1) = maxOffset)) {
toLoop := false
}
maxOffset := (minOffset + maxOffset) // 2
}
middleShot := (minOffset + maxOffset) // 2
}
;;MsgBox, "we found max offset! it is:" %maxOffset% ;; DEBUG line
healthBarStatusAsPercent := Floor(( middleShot / healthBarLength ) * 100) + 1
GuiControl,, MyProgress, %healthBarStatusAsPercent%
GuiControl,, MyText, Hp Status: %healthBarStatusAsPercent%
if (updateTime = 9) { ;; we will write every 10th of the checking
updateTime := 0
FormatTime, timeString,, mm:ss ;;Gettin all that as table to dump at the END. gettin the time only 1 every 10 cases?
FileAppend, %healthBarStatusAsPercent% %timeString%`r`n, %logFile%
} else {
updateTime += 1
;;FileAppend, %healthBarStatusAsPercent%`r`n, %logFile% ;; really no point in writting SO MUCH into the file
}
}
generateNextOffset(ByRef offset) {
global healthBarLength
}
exitToNexus() {
global alwaysLoop
global logFile
global healthBarStatusAsPercent
Sleep, 50
Send, {Insert}
Sleep, 100
Send, {Insert}
Sleep, 150
Send, {Insert}
;;alwaysLoop := false
FileAppend, we exiting to Nexus coz of hp is %healthBarStatusAsPercent%`r`n, %logFile%
MsgBox, "Super low hp Detected. Went to Nexus - will resume script in 10 seconds"
Sleep, 10000
}
heal() {
global myIgnXPos
global myIgnYPos
global img_healthPot
global healthBarStatusAsPercent
global logFile
;;local nearestHpPotXPos
;;local nearestHpPotYPos
;;local localMouseXPos
;;local localMouseYPos
;;MsgBox, "we will heal"
FileAppend, we are initiating heal because hp is %healthBarStatusAsPercent% , %logFile%
MouseGetPos, localMouseXPos, localMouseYPos
ImageSearch, myszX, myszY, myIgnXPos - 85, myIgnYPos, myIgnXPos + 224, myIgnYPos + 520, *20 %img_healthPot%
if (ErrorLevel = 0) {
;;MsgBox, "we found healing potion" ;; DEBUG line
nearestHpPotXPos := myszX + 5
nearestHpPotYPos := myszY + 5
Sleep, 30
Send, {Shift Down} ;; in case it doesn't work for you, you can use Send, (LShift Down} and then {LShift Up}
Sleep, 90
MouseMove, nearestHpPotXPos, nearestHpPotYPos
MouseClick, Left, nearestHpPotXPos, nearestHpPotYPos
Sleep, 50
Send, {Shift Up}
Sleep, 90
MouseMove, localMouseXPos, localMouseYPos
FileAppend, . We healed correctly`r`n, %logFile%
} else {
GuiControl,, MyText, Hp Status: %healthBarStatusAsPercent% Too low. No HP POTION available
FileAppend, no hp potion cant heal at all`r`n, %logFile%
}
}
initiate() {
global alwaysLoop
global windowSizeX
global windowSizeY
global MyBrowser
global logFile
;;MsgBox, "we initiatiin" ;; DEBUG Line
SetTitleMatchMode, RegEx ;RegEx = sets title matching mode to regular expressions ( 1 = exact 2 = anywhere inside )
WinActivate, .* %MyBrowser% ;window's name ends with the browser name ( %MyBrowser% )
WinGetPos, , , windowSizeX, windowSizeY , A
getMyIgnPosition()
getBasicHealthBarPosition()
FileAppend, we are initiating the script now`r`n, %logFile%
;;MsgBox, "we will start endless loop now!" ;; DEBUG line
while (alwaysLoop = true) {
healOrExitIfNecessary()
;;regenManaIfNecessary() ;; not implemented atm
Sleep, 10
}
return
}
FileDelete, %logFile%
Gui,+AlwaysOnTop
Gui, Add, Progress, vMyProgress x5 y5 w180 h20, 100
Gui, Add, Text, vMyText x5 y30 w180 h30 , Text
Gui, Show, x484 y282 h55 w190, AlwaysOnTop Window
initiate()
q::
Sleep, 50
Send, {Insert}
Sleep, 100
Send, {Insert}
Sleep, 150
Send, {Insert}
Sleep, 10000
return
!e::
healTriggerScalerCounter += 1
exitTriggerScalerCounter += 1
hpHealTrigger := Floor(defaulthpHealTrigger + (hpHealScaleTriggerWithLevelBy * healTriggerScalerCounter))
hpExitTrigger := Floor(defaulthpExitTrigger + (hpExitScaleTriggerWithLevelBy * exitTriggerScalerCounter))
;;MsgBox "notified of new lvl" ;; DEBUG msg
return
btw. here are the images:
http://www.mediafire.com/?4sg95jfqnapdh77
Enjoy ^^




