Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing MP restore speed for ID
#1
====================================================================================================​====
ID of mp's restore speed

0041FB6D > 8B91 68030000 mov edx,dword ptr ds:[ecx+368]
0041FB73 . 8B92 F4060000 mov edx,dword ptr ds:[edx+6F4]
0041FB79 . 83FA 33 cmp edx,33←←←←←←←←←←←←←←id 51 Firzen
0041FB7C . 74 05 je short lf2.0041FB83
0041FB7E . 83FA 34 cmp edx,34←←←←←←←←←←←←←←id 52 Julian
0041FB81 . 75 05 jnz short lf2.0041FB88
0041FB83 > 99 cdq
0041FB84 . 2BC2 sub eax,edx
0041FB86 . D1F8 sar eax,1 ←←←←←←←←←←←←←←add some character's restore speed
0041FB88 > BA F4010000 mov edx,1F4
0041FB8D . 2BD0 sub edx,eax
0041FB8F . B8 1F85EB51 mov eax,51EB851F
0041FB94 . F7EA imul edx
0041FB96 . C1FA 05 sar edx,5
0041FB99 . 8BC2 mov eax,edx
0041FB9B . C1E8 1F shr eax,1F
0041FB9E . 8D5402 01 lea edx,dword ptr ds:[edx+eax+1]←←←←←←←←←←[edx+eax+X],X=basic restore speed of every character


====================================================================================================​====

I am aware of this from ADDRESS OF LF 2.0 HEX thread

The addresses are a bit different in 2.0a like the first line is actually 0041FABD

I modified this line 0041FB9E . 8D5402 01 lea edx,dword ptr ds:[edx+eax+1]←←←←←←←←←←[edx+eax+X],X=basic restore speed of every character
The problem was I can't do negatives so 1 is the normal rate and 0 just doesnt regen at all at full health but it does regen when you lose like 100 hp or something.

So I went to this line: 0041FB88 > BA F4010000 mov edx,1F4
1F4 is 500, I changed the decimal value to 1000 and mp regened faster. I put it at 393, 399, 400, there was no regeneration. At 401 there was some regen. At 100, mp drained really fast. So now I know I can make mp decrease by default and using the last line I can probably increase the number from 1 to a higher number and then some characters can have mp drainage while others restore by default. Only problem is I don't know how to change the restore speed to a specific ID.

That way by default everyone's MP drops. But I can also make everyone have increased speed. Using both the draining method and the restore method can also result in slower mp restore speeds than the default base 1 speed.

I hope you understand my question/problem? Thanks!
Reply
Thanks given by: Bamboori
#2
(07-22-2014, 05:35 PM)bashscrazy Wrote:  0041FB9E . 8D5402 01 lea edx,dword ptr ds:[edx+eax+1]←←←←←←←←←←[edx+eax+X],X=basic restore speed of every character
What the hell? Why would that X be the restore speed of every character? That's merely the address where the speed is stored, and shouldn't be anything other than that (someone correct me if I am wrong please). Did you try changing that one into something else? And if yes, then did it work?

Edit: And how can sar possibly "add"..
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#3
@A-MAN: http://stackoverflow.com/a/1658310 -Corrected. It's just the compiler being efficient.

@bashscrazy: You are going about it all wrong. Mana regeneration is explained here: http://www.lf-empire.de/forum/showthread.php?tid=5835

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

The 1F4 you are changing is the 500 in that equation. You won't really be able to solve this without writing your own code, at which point you may as well rewrite the mana regen algorithm to make more sense.

Edit @A-MAN: you are right. The sar here is divide by 2.
[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: bashscrazy , A-Man , Bamboori
#4
Oh, oops!
Thanks for the insight.
Reply
Thanks given by:
#5
WOHO!.. interesting. Just to make sure I got it right: LEA's job is to get the address of some data. Since ptr DS:[] fetches data from a pointer/address, LEA reverses that by asking for the address of that data; thus the actual sums of edx, eax and 1 are stored in edx(?)
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#6
(07-22-2014, 07:55 PM)A-MAN Wrote:  thus the actual sums of edx, eax and 1 are stored in edx(?)

Yes.

To be honest, I doubt that a modern compiler, or at least one made by intel, would do this optimisation now days.
[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: A-Man
#7
One thing if not asked:

Quote:mana is added every 3 TU's

How to change this to something else, like 6 TU?
Reply
Thanks given by:
#8
It's these two lines:


Code:
0041FA9C   .  833D D40B4500 CMP DWORD PTR DS:[450BD4],0
0041FAA3   .  75 53         JNE SHORT 0041FAF8


So every time 450BD4 is 0 mana regens. 450BD4 goes 0,1,2,0,1,2 etc.

This is the line that writes to it.

Code:
0041D7DF   .  8915 D00B4500 MOV DWORD PTR DS:[450BD0],EDX


Why does EDX go 0,1,2? Too much effort to figure out :P. There is a MOV ECX 3 there. But if you change it, everything breaks. So yeah.... Good luck :P


Edit: Just noticed, thats the wrong line. The correct one is near it, it has 450BD4 in the address, not 450BD0
[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:
#9
EDX might be a counter that adds MP every time it reaches a 0. It adds (I would've guessed decreases) 1 for every TU, and then reset to 2 when it reaches 0. I am not sure, but that's how I would've done it.
[Image: signature.png]
A-Engine: A new beat em up game engine inspired by LF2. Coming soon

A-Engine Dev Blog - Update #8: Timeout

Reply
Thanks given by:
#10
What? The question is why does it stop at 3. EDX is a different thing in different places. The memory location 450BD4 is the "counter" that gets 1 added to it every TU. The question is how does this code work:

Code:
0041D7A6   .  893D FC0B4500 MOV DWORD PTR DS:[450BFC],EDI
0041D7AC   >  A1 D00B4500   MOV EAX,DWORD PTR DS:[450BD0]
0041D7B1   .  83C0 01       ADD EAX,1
0041D7B4   .  8BCF          MOV ECX,EDI
0041D7B6   .  2B0D D80B4500 SUB ECX,DWORD PTR DS:[450BD8]
0041D7BC   .  99            CDQ
0041D7BD   .  890D D80B4500 MOV DWORD PTR DS:[450BD8],ECX
0041D7C3      B9 0C000000   MOV ECX,0C
0041D7C8   .  F7F9          IDIV ECX
0041D7CA   .  A1 D40B4500   MOV EAX,DWORD PTR DS:[450BD4]
0041D7CF   .  83C0 01       ADD EAX,1
0041D7D2      B9 03000000   MOV ECX,3
0041D7D7   .  C74424 64 000 MOV DWORD PTR SS:[ESP+64],0
0041D7DF   .  8915 D00B4500 MOV DWORD PTR DS:[450BD0],EDX
0041D7E5   .  99            CDQ
0041D7E6   .  F7F9          IDIV ECX
0041D7E8   .  393D 60114500 CMP DWORD PTR DS:[451160],EDI
0041D7EE   .  8915 D40B4500 MOV DWORD PTR DS:[450BD4],EDX


Edit: Okay, it's easy enough. It is the MOV ECX,3 thing.

If you change it to 6 it will indeed by 6 TU. You just need to make sure you change ECX back to 3 after doing the IDIV ECX or the exe crashes later.

Here is an exe where mana regenerates every 100 TU : http://www.mediafire.com/download/oyjvv6...100+TU.rar
[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: Ikran Ahiyìk




Users browsing this thread: 3 Guest(s)