![]() |
|
Can someone check this for me? - Printable Version +- Little Fighter Empire - Forums (https://lf-empire.de/forum) +-- Forum: Little Fighter 2 Zone (https://lf-empire.de/forum/forumdisplay.php?fid=7) +--- Forum: [2.0] Exe Editing (https://lf-empire.de/forum/forumdisplay.php?fid=43) +---- Forum: Solved Problems (https://lf-empire.de/forum/forumdisplay.php?fid=45) +---- Thread: Can someone check this for me? (/showthread.php?tid=3883) |
Can someone check this for me? - Thomas - 11-06-2009 I want to bring the enemy into a frame(#XXX) when his red hp is lower than #YYY % (I had changed to code after Lord Silva gave me some suggestion) This is my code Code: frame_event:
sub eax,2000000 ; take off the '2' in front
mov ebx,1000
mov edx,0
idiv ebx
xor ebx,ebx
mov ebx,eax
xor eax,eax
mov eax,edx
xor edx,edx ; separate number #2XXXYYY into #XXX, #YYY. #XXX is stored in ebx, #YYY is stored in eax, EDX is cleared.
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov edx,dword ptr ds:[ecx+368h]
cmp dword ptr ds:[edx+6F8h],0 ; check the target is type 0 or not
jnz r2
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov edx,dword ptr ds:[ecx+368h]
push eax ; push the eax into temporary memory
xor eax,eax
mov eax,dword ptr ds:[edx+304h] ; MaxHP is stored in eax
xor ecx,ecx
xor edx,edx
mov ecx,100
mov edx,0
idiv ecx ; Divied the MaxHP into 100(change into % state)
xor edx,edx
xor ecx,ecx
mov eax,ecx ; Move MaxHP into ecx
xor eax,eax
mov eax,dword ptr ds:[edx+2fch] ; Get the red HP(eax) into eax
mov edx,0
idiv ecx ; Divied the red HP by MaxHP(get the percentage)
xor edx,edx
xor ecx,ecx
pop ecx ; Get the percentage into ecx
cmp ecx,eax
jl r2 ; check if red hp is lower than #YYYYY
xor eax,eax
mov eax,ebx
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov dword ptr ds:[ecx+70h],eax ; if red hp is lower, move character to frame at indicated number #XXX.
jmp r2Please help me ![]() ( RE: Can someone check this for me? - Boop - 11-06-2009 Where did you stick that code? Doesn't really make much sense out of context. The code seems fine, but you see to be doing a lot of pointless xor-ing. xor ecx,ecx - ecx becomes 0 xor edx,edx - edx becomes 0 mov ecx,100 - ecx becomes a 100 mov edx,0 - edx becomes 0 I don't understand why you make them 0, and then mov values into them, especially when the value is 0. RE: Can someone check this for me? - Thomas - 11-07-2009 This code is write by myself. ![]() I'm a beginner and I just refer to the code in the first part and write the other part. First part: Code: sub eax,2000000
mov ebx,1000
mov edx,0
idiv ebx
xor ebx,ebx
mov ebx,eax
xor eax,eax
mov eax,edx
xor edx,edx
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov edx,dword ptr ds:[ecx+368h]
cmp dword ptr ds:[edx+6F8h],0
jnz r2Code: sub eax,2000000 eax=110025
mov ebx,1000 ebx=1000
mov edx,0 edx=0
idiv ebx eax/ebx --> integer part=eax decimal part=edx
xor ebx,ebx ebx=0
mov ebx,eax eax=ebx=110
xor eax,eax eax=0
mov eax,edx edx=eax=25
xor edx,edx edx=0
.....But, Is just the 'xor' part make the LF2 close automatically? And thank you for you reply.
RE: Can someone check this for me? - Boop - 11-07-2009 I don't think it is the xor part that makes you lf2 crash, but getting rid of the xor's will make the code much more readable. mov replaces the value, so there is no need to set it to 0. lets say eax = 100 xor eax,eax ; eax is now 0 mov eax,5 ; eax is 5 if you only do: mov eax,5 eax will also be 5. The xor's are not needed. I think the problem is in these 2 lines: mov ecx,dword ptr ds:[esi+edi*4+194h] mov dword ptr ds:[ecx+70h],eax I think that edi doesn't hold the enemy number, but some random value, probably something very high. Then when it tries to use it as a pointer it is pointing to memory which isn't in use and it crashes. edit: Actually, I think it is this part: mov edx,0 idiv ecx ; Divied the MaxHP into 100(change into % state) mov eax,ecx ; Move MaxHP into ecx mov eax,dword ptr ds:[edx+2fch] you set edx to 0, then you use it as part of your pointer, so you are pointing to an invalid memory address .Edit 2: I fixed it Code: frame_event:
sub eax,2000000 ; take off the '2' in front
mov ebx,1000
mov edx,0
idiv ebx
mov ebx,eax
mov eax,edx ; separate number #2XXXYYY into #XXX, #YYY. #XXX is stored in ebx, #YYY is stored in eax, EDX is cleared.
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov edx,dword ptr ds:[ecx+368h]
cmp dword ptr ds:[edx+6F8h],0 ; check the target is type 0 or not
jnz r2
mov ecx,dword ptr ds:[esi+edi*4+194h]
;mov edx,dword ptr ds:[ecx+368h] Line isn't needed because maxhp is part of the primrary object atributes
push eax ; push the eax into temporary memory
push ecx
mov eax,dword ptr ds:[ecx+304h] ; MaxHP is stored in eax
mov ecx,100
xor edx,edx
idiv ecx ; Divied the MaxHP into 100(change into % state)
mov ecx,eax ; Move MaxHP into ecx
pop edx
mov eax,dword ptr ds:[edx+2fch] ; Get the red HP(eax) into eax
xor edx,edx
idiv ecx ; Divied the red HP by MaxHP(get the percentage)
pop ecx ; Get the percentage into ecx
cmp ecx,eax
jl r2 ; check if red hp is lower than #YYYYY
mov eax,ebx
mov ecx,dword ptr ds:[esi+edi*4+194h]
mov dword ptr ds:[ecx+70h],eax ; if red hp is lower, move character to frame at indicated number #XXX.
jmp r2There are no hit sparks for some reason :\ , don't ask me why. Maybe it is the way the effect detour is implemented(might be a feature). I also see a potential bug in your code. If the max hp is lower than 100, the code won't work because you're dividing the maxhp by 100 ( 10/100 = 0, remainder 10), not a big deal really, as long as the attack does more than 100 dmg. |