Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
About mana regen
the mana regen formula in lf2 is: (500-health)*0.01 + 1
if it is a special char then (500-health/2)*0.01 + 1
mana is added every 3 TU's
clones(rudolf and maybe something else?) cannot have more than 150mp
you do not regen mp while you are *flashing*(invincible)
for characters with more than 500hp - 500 is used as the health instead of the real value

you can find the code at: 0041FA7Bh

the code was rewriten so that instead of using 500-health it will use max_health - health
the code was also cleaned up and lots of useless stuff was removed

mana_regen proc
				cmp     dword ptr [ecx+2F4h], -1 ;check if clone
                je      short not_clone
                cmp     dword ptr [ecx+308h], 96h ;check if mp is larger than 150
                jge     short return
                cmp     dword ptr [ecx+308h], 1F4h ;check if mp is larger than 500
                jge     short return
                cmp     dword ptr ds:[450BD4h], 0 ;unknown? TU counter maybe
                jnz     short return
                cmp     dword ptr [ecx+8], 0 ;check if invincible (flashing)
                jl      short return
                mov     eax, [ecx+2FCh] ;load hp into eax                            
                mov     edx, [ecx+368h]
                mov     edx, [edx+6F4h] ;load id into edx
                cmp     edx, 33h ;compare id
                jz      short high_regen
                cmp     edx, 34h ;compare id
                jnz     short not_high_regen
                sar     eax, 1 ;divide eax(health) by 2 a.k.a shift right
				mov		edx, dword ptr ds:[ecx+304h] ;load max health into edx
                sub     edx, eax ;subtract health from max health
                mov     eax, 51EB851Fh ;a bunch of optimizations to basically multiply by 0.01
                imul    edx ;multiply result by 51EB851F
                sar     edx, 5 ;divide hi-bits by 32
                lea     edx, [edx+1] ;figure out how much mana to add
                add     [ecx+308h], edx ; add mana
return: ;if you are detouring lf2, this will return. address is for 2.0a
				push	0041FAF8h
				retn ;little trick to avoid using jmp to return
mana_regen endp

it is a cleaned up version of the original code except it replaces edx,500 with mov edx, dword ptr ds:[ecx+304h]

if you want to add it to the dll then:
invoke JmpPatch, 0041FA7Bh, addr mp_regen

this should make boss fights much more challenging
Thanks given by: Bamboori , SahilJ , AmadisLFE , bashscrazy

Users browsing this thread: 1 Guest(s)