Thread Rating:
  • 4 Vote(s) - 2.25 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mp charging
#1
2.0 
ok i am here
i tried to make a state where tou charge mp without a beer and it has a limit too

here

is the code
    ASM-Code:
;part of state8xxx proc
charging:
        CMP EAX,6000
        jl return
        CMP EAX,7000
        jge return
        sub eax,6000
        mov ebp,dword ptr ds:[esi+eax*4+194h]
        mov ecx,dword ptr ds:[ebp+308]
        add ecx,eax
        cmp ecx,500
        jge short no_charge
 
no_charge:
        sub ecx,500
        add ecx,500


please tell me whats wrong
Reply
Thanks given by:
#2
Post the entire proc, because your code is really messed up, so I doubt you got the rest of it right.

CMP EAX,6000
jl return
CMP EAX,7000
jge return
sub eax,6000
mov ebp,dword ptr ds:[esi+eax*4+194h]


I assume the EAX contains the state number, so you make sure it is between 6000 and 7000 then subtract 6000, at this point EAX contains how much mp you want to recover. Then you try loading the character pointer, and treat EAX as the character number, which is obviously isn't.

You shouldn't be using ebp - ebp and esp are special, you shouldn't be touching them unless you know what you are doing.

mov ecx,dword ptr ds:[ebp+308h]

You forgot the h after 308.

add ecx,eax
mov dword ptr ds:[ebp+308h],ecx (shouldn't be ebp)

You add eax to ecx, which means now ecx contains how much mp he should have. The problem is, you never set the characters mp to what you want.


cmp ecx,500
jge short no_charge
no_charge:
sub ecx,500
add ecx,500


You're taking 500 off, then add 500. That's pretty much like doing nothing, I don't get the point of that.

If you don't want the mp to go over 500, then replace those 2 lines with

mov dword ptr ds:[ebp+308h],500

You should post the rest of your code.
[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:
#3
    ASM-Code:
State8xxx proc
        CMP EAX,1F40h
        jl state4xxx
        CMP EAX,2328h
        jge state4xxx
        jmp Transform1
 
state4xxx:
;I didn't bother really understanding the code, just copied it
;there is only 1 line you should edit, I commented it :p
 
        CMP EAX,0FA0h
        jl timestop
        CMP EAX,1388h
        jge timestop
        MOV ECX,DWORD PTR DS:[EBX+7D4h]
        LEA EDX,DWORD PTR DS:[EAX-0FA0h]
        XOR EAX,EAX
        CMP DWORD PTR DS:[ECX+4D82380h],EAX
        JLE a
d:        MOV ESI,DWORD PTR DS:[ECX]
        CMP DWORD PTR DS:[ESI+6F4h],EDX
        JE b
        MOV ESI,DWORD PTR DS:[EBX+7D4h]
        ADD EAX,1
        ADD ECX,4
        CMP EAX,DWORD PTR DS:[ESI+4D82380h]
        JL d
        JMP a
b:        MOV ECX,DWORD PTR DS:[EBX+7D4h]
        MOV ECX,DWORD PTR DS:[ECX+EAX*4h]
        MOV EAX,DWORD PTR DS:[EBX+EDI*4+194h]
        MOV DWORD PTR DS:[EAX+368h],ECX
 
a:        MOV EDX,DWORD PTR DS:[EBX+EDI*4+194h]
        MOV DWORD PTR DS:[EDX+70h],0 ; this line sets your frame number to 0, remove it if you want
        MOV EAX,DWORD PTR DS:[EBX+EDI*4+194h]
 
timestop:
	    CMP EAX,10000
        jl charging
        CMP EAX,20000
        jge charging
        sub eax,10000
        push ecx
        lea ecx, dword ptr ds:[memAlloc+edi*4+edi]
        mov dword ptr ds:[ecx+1],eax
        mov byte ptr ds:[ecx],1
        pop ecx
 
 
charging:
        CMP EAX,6000
        jl return
        CMP EAX,7000
        jge return
        sub eax,6000
        mov ebp,dword ptr ds:[esi+eax*4+194h]
        mov ecx,dword ptr ds:[ebp+308]
        add ecx,eax
        cmp ecx,500
        jge short no_charge
 
no_charge:
        sub ecx,500
        add ecx,500
 
return: jmp Transform2
 
 
State8xxx endp


i used the state8xxx proc

im gonna change it a bit i guess and see
Reply
Thanks given by:
#4
Code:
charging:
        CMP EAX,6000
        jl return
        CMP EAX,7000
        jge return
        sub eax,6000
        MOV EDX,DWORD PTR DS:[EBX+EDI*4+194h]
        add dword ptr ds:[edx+308h],eax
        cmp dword ptr ds:[edx+308h],500
        jle return
    mov dword ptr ds:[edx+308h],500

return: jmp Transform2
That should work.
[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:




Users browsing this thread: 1 Guest(s)