Author Topic: Allow for growth beyond triple, alternative growth rates  (Read 12587 times)

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
I'd like to give one specific armor or weapon per characters a triple and maybe quadruple
I assume this is likely unproable, but it was worth asking anyway.

So, does anyone know if that's possible?

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #1 on: 2012-09-17 18:42:51 »
I found this once. Like always, don't take my word for it, but it shouldn't be a hard thing. The only issue is the text indicating the growth won't read correctly. I'll have to look it up tomorrow though.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #2 on: 2012-09-17 19:40:37 »
I found this once. Like always, don't take my word for it, but it shouldn't be a hard thing. The only issue is the text indicating the growth won't read correctly. I'll have to look it up tomorrow though.

It should be possible to change "Double" or "Triple" into other words to go with the new rates, no?

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #3 on: 2012-09-18 17:28:41 »
How high are you wanting to make this? It's an easy modification, but there are lots of little things that will need to be modified. None of it is complicated, but there will be at least a dozen things that have to be tweaked to add more words.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #4 on: 2012-09-18 17:41:20 »
I think one, maximum two more is all that I need
i.e. x4 and x5
anything above is ludricous
Instead of Quadruple, I'll just call it Quadra and Quint

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #5 on: 2012-09-18 17:49:06 »
There's no reason not to say "Quadruple" and "Quintuple". That will make it more clear and separate it from "Quadra Magic".

You can safely go as high as x252 without running into problems. :D

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #6 on: 2012-09-18 17:52:34 »
this is mostly for special weapons with 1-2 slots maximum. as there are weapons with 8 slots and double ( for example, Yuffie's Taiou no Maou ) I kinda need weapons with few slots and above triple
quadruple and maybe 1-2 weapons in total for quintuple are enough

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #7 on: 2012-09-18 22:00:59 »
There's a lot of information so I'll try to break it up as best I can:

0x920A8C (0x51F48C)
Here's where the text for the menus resides. There's a duplicate table nearly elsewhere, but it's not used.
Don't be fooled by the references to 0x920A80 (0x51F480), that doesn't reference the text "Nothing", "Normal", etc. It's actually back at 0x9209A8 (0x51F3A8) that skips ahead 19 entries to get to those strings.

This happens in eight places in four chunks.
0x706073
0x706090
0x70623E
0x70625C
0x7069EF
0x706A0C
0x706BB5
0x706BCD

The offending (offensive) code is:
Code: [Select]
[mov ecx, AP_Growth_mult ;retrieved from the weapon.armor data]
add ecx, 13h
imul 0Ch
add ecx, offset_9209A8

This is more than slightly absurd. If we change it to this:

Code: [Select]
[mov ecx, AP_Growth_mult ;retrieved from the weapon.armor data]
add ecx, 0 ;we could NOP these three bytes.
imul 0Ah
add ecx, offset_920A8C

Then we'll directly reference that array of words as well as have room for two more. ONLY two more. There are exactly 60 bytes between the start of that and the next set of data. Then we'll have to change the array's dimensions from 5,12 to 6, 10 (again, at 0x920A8C (0x51F48C) ). That's a change of three bytes per section.

The string array will have to be changed too. 0x920A8C (0x51F48C) is this (using the FF7 characters:
Code: [Select]
Nothing'\n'____
Normal'\n'_____
Double'\n'_____
Triple'\n'_____
'\n'___________
You can change it to:
Code: [Select]
Nothing'\n'__
Normal'\n'___
Double'\n'___
Triple'\n'___
Quadruple'\n'
Quintuple'\n'

We'll call that all 60 bytes of change. We're getting rid of the blank one, but the next change will account for that.

There are four other related blocks that need to change:
0x70604F
0x706217
0x7069C8
0x706B88

The code block here is:
Code: [Select]
mov eax, AP_Growth_mult ;from weapon/armor data
mov var_64, eax
cmp var_64, 0 ;lower bound
jl short loc_706XXX ;depending on where this code is
cmp var_64, 3 ;upper bound
jle short loc_706XXX+2 ;depending on where this code is
jmp short loc_706XXX
jmp short loc_706XXX+7
mov AP_Growth_mult, 4

This is a reality check that will set the growth rate text to "" if it gets something less than 0 or greater than 3. That's stupid because the game treats all other numbers as normal growth. So we can change it to this:
Code: [Select]
mov eax, AP_Growth_mult ;from weapon/armor data
mov var_64, eax
cmp var_64, 0 ;lower bound
jl short loc_706XXX ;depending on where this code is
cmp var_64, 5 ;upper bound
jle short loc_706XXX+2 ;depending on where this code is
jmp short loc_706XXX
jmp short loc_706XXX+7
mov AP_Growth_mult, 1 ;"panic" value

And that will give us six text stings to work with only changing two bytes in each of these sections.

Now we have to actually implement these growths, don't we?
Weapon AP multiplier is set starting at 0x5CAE4A (0x1CA24A).
Armor AP multiplier is set starting at 0x5CAFF9 (0x1CA3F9).

These blocks are needlessly long and inefficient:
Code: [Select]
pseudo-code
if (multiplier = 0)
{
}
elseif (multiplier = 2)
{
   Materia_AP += (AP_Gained & FFFFh) * 2;
}
elseif (multiplier = 3)
{
   Materia_AP += (AP_Gained & FFFFh) * 3;
}
else
{
   Materia_AP += (AP_Gained & FFFFh) ;
}

What it SHOULD read is:
Code: [Select]
pseudo-code
if (multiplier > 3) ;upper bound here again too
{
   multiplier = 1
}
if (AP_Gained > 65535)
{
   AP_Gained = 65535
}
Materia_AP += AP_Gained * multiplier
Anyone disagree that this is a MUCH better idea? Didn't think so. If it happens to go above the upper bound, slap it down to "Normal". That's 79 bytes per section that are now forfeit and reduced to 51 bytes each.

Let's add the changes:
3 * 8 + 60 + 2 * 4 + 79 * 2 = 250 total bytes changed! That's really not that much. If that doesn't seem too involved let me know and I'll provide more details. I just wanted to let you know the scope of changes that would be involved.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #8 on: 2012-09-18 22:14:48 »
I'm sorry to say that that went way over my head.
Cloudiar wanted to know about this first of all, ( and I thought I'd use it too ) but you're trying to explain this to someone who just about knows how to use editors and change some hex values
I don't actually know how to read code.
stuff like

Code: [Select]
[mov ecx, AP_Growth_mult ;retrieved from the weapon.armor data]
add ecx, 13h
imul 0Ch
add ecx, offset_9209A8

Code: [Select]
[mov ecx, AP_Growth_mult ;retrieved from the weapon.armor data]
add ecx, 0 ;we could NOP these three bytes.
imul 0Ah
add ecx, offset_920A8C

is really beyond me. I wouldn't even know how and what to do where.
I could maybe figure out changing text on my own, but that'd be really it.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #9 on: 2012-09-19 03:07:28 »
I could tell you exactly what, where, from and to of bytes to change. Just focus on the last few sentences of that post and I can tell you how to do it if you'e interested in a list of the 250 changes that would need to be made.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #10 on: 2012-09-19 03:41:28 »
yeah, that sounds like something even a dog could do. I should be able to do that :D
saving space,
0xYYYYYY ZZ
where as YY is the .exe address and ZZ the value that needs to be written is probably easiest on you

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Allow for growth beyond triple, alternative growth rates
« Reply #11 on: 2012-09-19 10:58:26 »
These blocks are needlessly long and inefficient:
Code: [Select]
pseudo-code
if (multiplier = 0)
{
}
elseif (multiplier = 2)
{
   Materia_AP += (AP_Gained & FFFFh) * 2;
}
elseif (multiplier = 3)
{
   Materia_AP += (AP_Gained & FFFFh) * 3;
}
else
{
   Materia_AP += (AP_Gained & FFFFh) ;
}

What it SHOULD read is:
Code: [Select]
pseudo-code
if (multiplier > 3) ;upper bound here again too
{
   multiplier = 1
}
if (AP_Gained > 65535)
{
   AP_Gained = 65535
}
Materia_AP += AP_Gained * multiplier
Anyone disagree that this is a MUCH better idea?
Me! That would be changing the mechanics (limiting the AP_Gained thing different way) ;)

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #12 on: 2012-09-19 13:42:52 »
Me! That would be changing the mechanics (limiting the AP_Gained thing different way) ;)

Vanilla already limits the AP. BUT, instead of pushing it down to 65535, it ANDs it with FFFFh. This can cause an AP overflow issue. So if a battle has more than 65535, say 66K AP, then it will give the modulus answer. Instead of 66K, you'd only get 464 AP. The battle reward screen doesn't account for this (I don't think) and it won't tell you that's what happened.
If that's what you want then shame on you. :(

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: Allow for growth beyond triple, alternative growth rates
« Reply #13 on: 2012-09-19 14:48:24 »
I know how it works, just saying that you changed the way the overflow is handled. You won't find a single battle in vanilla FF7 with more that 65k AP anyway.

Edit: The value seems to be stripped to 16bit before even calling the function, so the overflow would never be handled at that point - you could simplify it even more... Anywayz, digressed, sorry for disrupting your thread, please carry on with the productive actions.
« Last Edit: 2012-09-19 17:02:48 by dziugo »

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #14 on: 2012-09-19 16:58:17 »
we're modding the game though so battles >65k AP become a possibility

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #15 on: 2012-09-19 18:21:20 »
The value seems to be stripped to 16bit before even calling the function, so the overflow would never be handled at that point...

Well what do you know. 0x4372FF dumps the AP reward into a 16-bit register space. Didn't notice that before. Still, that has the same overflow resolution problem. Making it eax instead of ax would make that part go away. Just changing the 66 to a 90 would fix that.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #16 on: 2012-09-19 19:07:19 »
can you give me the addresses I need to change? :D

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #17 on: 2012-09-19 21:25:00 »
I just PM'd you.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #18 on: 2012-09-19 22:11:27 »
I did the changes as you wrote them down, all of them ( you got quadruple as quakruqle and quintuple as quintuqle but thats just text, easily fixed )
but when i give a weapon higher growth than 3, it just turns into 1

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #19 on: 2012-09-20 01:32:52 »
( you got quadruple as quakruqle and quintuple as quintuqle but thats just text, easily fixed )

What's wrong with that? I thought you'd appreciate a little originality. ;)

but when i give a weapon higher growth than 3, it just turns into 1

Does it say "Normal" or does it say what it should, but not provide (perhaps vice versa)?

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #20 on: 2012-09-20 02:03:23 »
It says what it is supposed to say ( quadruple, quintuple ) but it only gives normal growth
actually, I only tested it with a weapon i guess, I'll test it with armor
( and test if double and triple still works )

edit:
weapons x4 and x5 result both in x1
armor x4 results in x1 and armor x5 results in x0
« Last Edit: 2012-09-20 02:59:50 by KuugenTheFox »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #21 on: 2012-09-20 03:25:44 »
Do the other growths work correctly? Double and Triple?

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #22 on: 2012-09-20 04:10:58 »
Do the other growths work correctly? Double and Triple?

No, they all return single growth, regardless of weapon / armor

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Allow for growth beyond triple, alternative growth rates
« Reply #23 on: 2012-09-20 18:15:29 »
LOL! I made it so any multiplier higher than 5 would work. :P Seriously, try it. Even x255 would work. :D

Make these two changes:
0x1CA257:7E (77)
0x1CA406:7E (77)

Just so you can get in on the laugh, here's what that did:
Code: [Select]
First try:
If ( AP_multiplier <= 5 )
{
   AP_multiplier = 1;
}

This try:
If ( AP_multiplier > 5 )
{
   AP_multiplier = 1;
}

See the difference? It's like using '\' instead of '/' when trying to divide. TOTALLY different meaning. :)

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Allow for growth beyond triple, alternative growth rates
« Reply #24 on: 2012-09-20 18:43:44 »
in general, AP gain is totally messed up
armor with triple growth = totally messed up ( one time it was triple growth, then next battle was single growth, then NONE then MINUS normal growth then normal and it switches back and forth from -1 to +1 from there... it actually took AP away. I think that is what causes the instant mastering too. replacing the materia resets the counter )
weapon or armor with quad growth = works fine but every 2nd or 3rd battle instantly maxes out materia
double is messed up too ( occasionally it returns 150% instead of 200%, other times it returns 250% or even 300 )