Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can someone check this for me?
#4
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 :D.


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 r2

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.
[Image: doty7Xn.gif]

10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.


Reply
Thanks given by: Thomas


Messages In This Thread
Can someone check this for me? - by Thomas - 11-06-2009, 01:38 AM
RE: Can someone check this for me? - by Boop - 11-06-2009, 06:29 AM
RE: Can someone check this for me? - by Thomas - 11-07-2009, 12:11 AM
RE: Can someone check this for me? - by Boop - 11-07-2009, 07:32 AM



Users browsing this thread: 1 Guest(s)