script logic wrong

10/16/2011 20:17 pixellegolas#1
Hi guys! I hope you can help me correct this script I have done. The problem is that I have memory address for enemy and when it is 0 bot should press TAB to switch to a new enemy. But it does so before HP is 0

Code might look a bit strange but I have tried many different possibilities but same result

Code:
HotKeySet ("{ESC}", "_exit")
HotKeySet ("{F12}", "_pause")
#include "NoMadMemory.AU3"
$ID=_MemoryOpen(0x00001484)
$Address= 0x02EE20DC ;Player HP
$Address5= 0x02EE7AAC ;Player Max HP
$Address2= 0x02ED54AC ;CTU energy
$Address3= 0x02EE7AE4 ;Enemy HP
$Address6= 0x02EE7AF4 ;Enemy Max HP
$Address4= 0x02ED9A94 ;CTU HP

$HP=_MemoryRead($Address,$ID)
$enemyHP=_MemoryRead($Address3,$ID)
$enemyMAX=_MemoryRead($Address6,$ID)

WinActivate("Bounty Hounds Online 1.094.41")

While 1
_Fight() ;Start fighting enemy

If $enemyHP = 0 Then
_Switch() ;If enemy is dead switch to next target
EndIf

 WEnd


Func _exit()
    Exit
EndFunc


Func _pause()
    while 1
    Sleep(9999999)
WEnd
EndFunc


Func _Fight()

	If $HP > 500 And $enemyHP = $enemyMAX Then
		Sleep(50)
		_Attack() ;Start attacking because enemy has full health and you enough
	ElseIf $HP > 500 And $enemyHP < $enemyMAX Then
		Sleep(50)
		_Attack() ;Keep attacking
	ElseIf $HP < 500 Then ;If HP to low, do nothing
		_noFight()
			EndIf
	EndFunc

Func _Attack() ;Attack sequence
Sleep(30)
Send("2")
Sleep(10)
Send("2")
Sleep(10)
Send("2")
Sleep(10)
Send("4")
Sleep(10)
Send("3")
Sleep(10)
EndFunc

Func _Switch() ;Wait a little and then switch to next target, if current target is dead
	Sleep(200)
If $enemyHP = 0 Then
Send("{TAB}")
Sleep(50)
Send("z")
Sleep(10)
Send("z")
Sleep(10)
Send("z")
Sleep(10)
Send("z")
Sleep(50)

ElseIf $HP < 500 Then
	_Fight()

EndIf
EndFunc

Func _noFight()
	while 1
	WEnd
	EndFunc
10/17/2011 17:09 Ludder231#2
If $enemyHP = 0 Then
_Switch() ;If enemy is dead switch to next target
EndIf

Test: If $enemyHP < 0 Then ....
10/17/2011 23:07 Imaginär#3
Are you sure you got the right address?
Have you looked at the value of the address while fighting with an enemy?
(to be sure 0 = enemy dead; maybe it's another value ...)
10/17/2011 23:18 pixellegolas#4
yeah I am sure...I think ;) The funny thing with this game is that you find the GREEN address immediatly so it's the pointer address. No matter if I restart etc its still the same.

When clicking on an enemy I get hp and hp max. Then I switch to a different enemy and get new hp and hp max.

These of course are the same first. When hitting enemy I get the hp because it's lower and the hp max.

This address is the same all the time and I am scripting this address to be the 0 to switch. I will look again for address to make sure it is correct. Is the logic...logical otherwise?
10/18/2011 17:09 .AppleTree.#5
Quote:
Originally Posted by Ludder231 View Post
If $enemyHP = 0 Then
_Switch() ;If enemy is dead switch to next target
EndIf

Test: If $enemyHP <= 0 Then ....
I think <= is better ;)
10/18/2011 23:55 pixellegolas#6
don't have time to test but even if it is 0 or less than zero it should not switch before. It sometimes switches almost at 100% of the enemy hp :) I put in some sleep to make sure that it actually registers everything in time

And it also checks twice for hp = 0

First if it is 0 it start the switch, then the function again checks if hp is zero and then executes tab. So I actually ask it 2 times and still it does it beforehand....weird