DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Oct 18, 2014 3:58 pm Post subject: Comparing double values |
|
|
Hey guys,
I'm trying to find which enemy is the closest, to create a bot that will travel to mobs that are near and will try to kill them.
So my script goes like this
Code: | (...)
newmem:
// this scripts works only as long as player has map opens, if he closes it, object will be destroyed, so this will update player cords,
push eax
mov eax,[ecx+18]
cmp eax,0 // 0 for playes, 1 for enemies
jne calculate
mov [flag],1
mov eax,[ecx+58]
cmp eax,(double)1.0
je calculate
mov [flag],2
mov eax,[ecx+24]
cmp eax,0
je calculate
mov eax,[eax+8]
cmp eax,0
je calculate
mov eax,[eax]
cmp eax,0
je calculate
cmp eax,'auto'
jne calculate
mov [autoFlag],1
lea eax,[ecx+38]
mov [playerAddress],eax
mov eax,[ecx+38]
mov [playerX],eax
mov eax,[ecx+3c]
mov [playerX+4],eax
mov eax,[ecx+40]
mov [playerY],eax
mov eax,[ecx+44]
mov [playerY+4],eax
jmp clean
(...) |
ecx+38 holds player x
ecx+40 holds player y
Since I'm not very familiar with assembler, how could I get absolute value, and how could I compare double type registrars
Basically right now, the only thing comes to my mind.
Code: | calculate:
movq xmm0, [playerX]
movq xmm1, [ecx+38]
// not sure how to compare cords in double, compare xmm0 with xmm1
jb @F
subsd xmm0,xmm1
// compare again but this time compare xmm0 with value of (double)50
ja notvalid
movq xmm1,[ecx+38]
movq [enemyX],xmm1
jmp original
@@:
subsd xmm1,xmm0
// compare again but this time compare xmm1 with value of (double)50
ja notvalid
movq xmm1,[ecx+38]
movq [enemyX],xmm1
jmp original |
_________________
|
|