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: Please 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 Code: sub eax,2000000 eax=110025 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: There 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. |