|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
tbonge How do I cheat? Reputation: 0
Joined: 25 Apr 2018 Posts: 4
|
Posted: Sun Apr 29, 2018 7:54 am Post subject: Can someone check my assembly code? |
|
|
Can someone please check my code for any obvious mistakes or better ways of doing this. I have no idea what I'm doing and just put this together by googling opcodes. The floating point stuff really through me off.
Code: |
// Double damage to mobs and half damage to player
// Parameters set by game are:
// xmm1 is attack damage (as a nagative number)
// xmm0 is new HP (original HP plus attack damage)
// Negative HP will make the mob invincible in the game
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000,"game.exe"+3F8F6F)
label(code)
label(return)
label(exit)
label(isPlayer)
label(resist)
label(finalBlow)
label(zero)
newmem:
pushfq
cmp rdx,3 // rdx is 3 if player (2 if mob)
je isPlayer
subss xmm0,xmm1 // Add back the attack damage (damage is negative)
mulss xmm1,[resist] // Multiply attack damage by 2
addss xmm0,xmm1 // Subtract attack damage
comiss xmm0,[zero] // Check that HP is not negative
jbe finalBlow
exit:
popfq
code:
movss [rcx+000000CC],xmm0 // Original game code, sets after attack HP
jmp return
isPlayer: // Damage to player
subss xmm0,xmm1 // Add back the attack damage (damage is negative)
divss xmm1,[resist] // Divide attack damage by 2
addss xmm0,xmm1 // Subtract attack damage
jmp exit
finalBlow:
movss xmm0,[zero] //Kill mob if after attack HP was negative
jmp exit
resist:
dd (float)2
zero:
dd (float)0
address:
jmp newmem
nop
nop
nop
return:
[DISABLE]
address:
db bytes
// movss [rcx+000000CC],xmm0
dealloc(newmem) | [/code]
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sun Apr 29, 2018 8:08 am Post subject: |
|
|
It looks good to me, the only thing would be to remove the repeated code.
Code: |
// Double damage to mobs and half damage to player
// Parameters set by game are:
// xmm1 is attack damage (as a nagative number)
// xmm0 is new HP (original HP plus attack damage)
// Negative HP will make the mob invincible in the game
[ENABLE]
assert(address,bytes)
alloc(newmem,$1000,"game.exe"+3F8F6F)
label(code)
label(return)
label(exit)
label(isPlayer)
label(resist)
label(finalBlow)
label(zero)
newmem:
pushfq
cmp rdx,3 // rdx is 3 if player (2 if mob)
subss xmm0,xmm1 // Add back the attack damage (damage is negative)
mulss xmm1,[resist] // Multiply attack damage by 2
addss xmm0,xmm1 // Subtract attack damage
je exit
comiss xmm0,[zero] // Check that HP is not negative
jbe finalBlow
exit:
popfq
code:
movss [rcx+000000CC],xmm0 // Original game code, sets after attack HP
jmp return
finalBlow:
movss xmm0,[zero] //Kill mob if after attack HP was negative
jmp exit
resist:
dd (float)2
zero:
dd (float)0
address:
jmp newmem
nop
nop
nop
return:
[DISABLE]
address:
db bytes
// movss [rcx+000000CC],xmm0
dealloc(newmem) |
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|