Author Topic: Can stats with battle addresses exceed 255 if modified by a battle address?  (Read 3135 times)

james_c

  • *
  • Posts: 9
    • View Profile
Hello,

For a mod I'm working on I'm attempting to do a difficulty rebalance I'm interested in making abilities which modify a characters stats in battle under specific conditions (For instance, Tifa parries attacks randomly and after a parry she gains speed) and I'm wondering if modifications made to stats through AI scripts work beyond the ordinary 255 cap.

I.e, let's say I want to give a character an innate trait where whenever they are hit, their attack increase. Attack is normally capped at 255 outside of battle; but there doesn't seem to be a reason why I couldn't just continue to increment it beyond that point via AI Script. I want to know if this will actually do anything? Str and out of battle Attack seem to be bytes, but the AI variables which hold these values do not seem to be.

Will these stats simply be set to 255 if they are over it for the purpose of damage calculations?

Thanks!

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
The cap will be in multiple places and what you're asking will likely be a lot of hassle to implement. The main obstacle is that the main "cap" is the one byte var which only has a range up to 255. Thats a limitation in computing. You cant extend it without making the engine use 2 bytes (range up to 65535) which takes a lot of work and recoding. If you want to make a proper balance, divide all character and enemy stats by say 10 and then design game around that instead.

james_c

  • *
  • Posts: 9
    • View Profile
Thanks! I will do exactly that.

picklejar

  • *
  • Posts: 147
    • View Profile
Dividing all character and enemy stats by N is an interesting idea, but it would only effectively increase the cap, and it wouldn't actually fix the "game breaks if I go over the cap" issue (it only delays it), and it would introduce other problems related to the resulting loss of granularity (especially in the lower ranges), and you might have to re-balance various formulas in the game.

james_c, it sounds like you're trying to "temporarily" change a "stat" to accomplish "some change in damage, speed, etc.", without violating the 255 stat caps. In order to accomplish something like this successfully, on a "global" scale (i.e. where you don't have to modify tons of scripts in the game), I'd recommend that you first read Terence Fergusson's FF7 Battle Mechanics FAQ:
https://www.gamefaqs.com/ps/197341-final-fantasy-vii/faqs/22395

This explains things like "Primary Stats" vs. "Derived Stats", "Before Damage Effect" and "After Damage Effect", a hundred other factors, and all the math formulas for calculating damage, etc., in general. It will also explain the (very complicated) system that governs speed and timing.

The other thing I'd recommend looking at is to find out how the game does similar things to what you're wanting to do. For example, what happens when a character drinks a Source potion during battle, which normally raises a stat by 1? Does it permanently affect their stat after the battle has ended? How does Berserk accomplish a temporary hit% decrease? How does Haste accomplish a temporary speed increase?

You might find that you'll need to invent new stats and modify existing formulas to accomplish what you want? Not sure, depending on how creative you get.

Good luck!

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Youd also limit max hp and stats. You can limit them lower.

james_c

  • *
  • Posts: 9
    • View Profile
One issue I see is that that defense becomes a very weak stat which effectively does nothing because the formula for it limits it to being 50 % DR since the max player value is 255 (and unlike for enemies, where one can easily get higher defense modifiers (It seems like for enemies, the defense values listed in scene.bin get multiplied by 2 before they are used with the formulas; whereas for player characters are hard limited at 255 and even changing the value of their 4100 battle address won't let the value go any higher than that.)

I think this needs formula change; I'd like it to be (256 - def) instead of 512 minus def (I'm assuming I can just change 0x200 to a 0x0FF with a hex editor somewhere in the EXE wherever these formulas are) -- that part is easy.

Does anyone know how to remove the multiplier that takes place for enemy defense stats, and just make it 1 instead of 2, that way both stat ranges are standardized & I can make this formula modification to improve the value of the defensive stats.

EDIT:
Apparently what I need was mentioned in this thread:
http://forums.qhimm.com/index.php?topic=15960.0

defensing double takes place at 5D08CE.. this confuses me a bit as from the size of the executable it doesn't seem to have a 5D0 address (Last address is 59Cx), so there must be somekind of offset here between the indexes you guys are looking at and what shows up in HxD/the OS file size?
« Last Edit: 2017-12-17 19:25:15 by james_c »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
5D08CE is a mem address.  To get the file address, deduct 400C00 using calc.  Be aware that 400C00 won't work with very mem address... since the range changes the amount to deduct.  But for the one above, that's correct:

5D08CE - 400C00 = 1CFCCE



but a better way of editing game is using HextLaunch from my Hext tools pack in tools (this edits mem address).  But the next version of The Reunion allows for my standalone optional mod pack which will allow plain text instruction files on load.  You won't need to edit exe ever again.  Just your own plain text files.

See Hext Tools.
« Last Edit: 2017-12-17 23:03:48 by DLPB »