Author Topic: Battle info and algorithm.  (Read 7130 times)

Akari

  • *
  • Posts: 766
    • View Profile
Battle info and algorithm.
« on: 2008-08-12 18:05:42 »
I'm again step by step go into battle algorithm. now I start with initialization and go into depth of battle function. Here I will post some interest things I found.

1) There are only 8 additional actions per player character can be added (counter, final attack, first attack). Only first 8 will be added, next will be ignored. Counter with command materia that has 2 commands will add two additional actions.

2) There are fields in weapon and armor description that can add status attack or protect character from this status. this never used in game though.

3) There is posibility to create Strength Plus, Spirit Plus and Magic Plus materias.
« Last Edit: 2008-08-12 18:07:44 by Akari »

Akari

  • *
  • Posts: 766
    • View Profile
Re: Battle info and algorithm.
« Reply #1 on: 2008-08-14 14:54:50 »
Day by day I'm go futher and futher. Here is small map of how battle function works:

I. Initialization
1) Party Character Initialization
a) Stats Initialization
b) Materia initialization
?)
II. Battle Cycle
III. Final

I'm still in very first phase of battle initialization. At step I.1b. I finish paired materia initialization and now go through copiing data from temp to main party character battle structure where all stats, info about attacks, magic, summon, commands are gathered. Nothing very unusual here. A lot of hacks and small mistakes, but they are fixed in some other functions. Only interesting thing that there are 16 places for commands, but the maximum I see in game was 12. Is there way to get more command, I want to see it?

Akari

  • *
  • Posts: 766
    • View Profile
Re: Battle info and algorithm.
« Reply #2 on: 2008-08-26 16:22:37 »
Party characters initialization finished. This is differs from enemy initialization because there are a lot of parcing and bonus modificators from a lot of equipment.

Next functions read scene file and initialize enemy.

By the way most of interesting thing in party initialization can be found in TFergusson faqs. Only thing I nether see anywhere is bug that Attack Indirect Restore and Indirect Restore Attack magic orders are switched.
« Last Edit: 2008-08-26 16:27:24 by Akari »

Vanit

  • *
  • Posts: 73
    • View Profile
    • http://vanitstudios.burn.at
Re: Battle info and algorithm.
« Reply #3 on: 2008-08-27 02:28:23 »
I think you might be going about this the wrong way. I'm pretty sure inbattle that characters have the same set of reference stats as monsters. All the bonuses from weapons/armor/accessory modifiy the stats on equip and then the new value is stored as the "effective stat", ie "effective strength" (has to be kept seperate or there would be no way to monitor if you've hit the max base stat of 100 etc), and this is the stat that is used for battle calculations.

Similarly, the materia check would be run from the menu every time you've finished with one character's materia setup (by either changing to another character, or returning to the main menu). Check the Magic and Status sections in the menu, the latest magic list and command list have already been generated for each character.

The only thing there is to initialize that hasn't been done prior to battle would be to setup non-permanent status effects (I think there's 28 of them? Sadness, Fury and Death are permanent, there may be another I've forgotten) and to reference back to the character's equipment to check for effects recieved at the start of battle, immunites, etc. There are no other calculations for characters because they're permanent objects that aren't created everytime a battle starts. Monsters, on the other hand, are *usually* unique to every battle (there are a few exceptions like Ultimate Weapon), so they must be initialized from the monster templates into a max of 6 tempory objects (6 is the most monsters you ever see at one time I think?).

That, atleast, is the most logical way to do it. You're doing a lot of unnecessary calculations if you're checking modifiers at the start of every battle, rather than simply everytime there's a change.
« Last Edit: 2008-08-27 02:31:20 by Vanit »

Akari

  • *
  • Posts: 766
    • View Profile
Re: Battle info and algorithm.
« Reply #4 on: 2008-08-27 02:48:28 »
I think you might be going about this the wrong way. I'm pretty sure inbattle that characters have the same set of reference stats as monsters. All the bonuses from weapons/armor/accessory modifiy the stats on equip and then the new value is stored as the "effective stat", ie "effective strength" (has to be kept seperate or there would be no way to monitor if you've hit the max base stat of 100 etc), and this is the stat that is used for battle calculations.

Similarly, the materia check would be run from the menu every time you've finished with one character's materia setup (by either changing to another character, or returning to the main menu). Check the Magic and Status sections in the menu, the latest magic list and command list have already been generated for each character.

The only thing there is to initialize that hasn't been done prior to battle would be to setup non-permanent status effects (I think there's 28 of them? Sadness, Fury and Death are permanent, there may be another I've forgotten) and to reference back to the character's equipment to check for effects recieved at the start of battle, immunites, etc. There are no other calculations for characters because they're permanent objects that aren't created everytime a battle starts. Monsters, on the other hand, are *usually* unique to every battle (there are a few exceptions like Ultimate Weapon), so they must be initialized from the monster templates into a max of 6 tempory objects (6 is the most monsters you ever see at one time I think?).

That, atleast, is the most logical way to do it. You're doing a lot of unnecessary calculations if you're checking modifiers at the start of every battle, rather than simply everytime there's a change.

What can I say... this IS done every battle, want you this or not. Magic list and Command generated every time you enter battle. As well as stats with bonuses calculated every time (of course there is untouched stats in savemap structure) and stored into party player structure. Only thing set in menu (and stored in the same structure as all commands or final stats) is limit id (though this is the easiest thing to set during battle init).

The main reason why do this at beging of the battle - cause after each battle commands and magic, as well as stats may change due to materia or character level up.

Final fantasy VII is very bad organized from code perspective. A lot of thing done few times even during battle initialization. A lot of hardcoded values are very bad thing (for example if materia has id XX done something, so if we add new materia before this - everything will go wrong).
« Last Edit: 2008-08-27 02:50:59 by Akari »

Vanit

  • *
  • Posts: 73
    • View Profile
    • http://vanitstudios.burn.at
Re: Battle info and algorithm.
« Reply #5 on: 2008-08-27 02:52:44 »
I stand corrected, I forgot we were dealing with FF7 logic. :(

LeeHiOoO

  • *
  • Posts: 128
    • View Profile
Re: Battle info and algorithm.
« Reply #6 on: 2008-09-24 12:57:43 »

3) There is possibility to create Strength Plus, Spirit Plus and Magic Plus materias.


As Magic Plus already exists...I think u mean Strength Plus , Spirit Plus and Vitality Plus Materias...

Akari

  • *
  • Posts: 766
    • View Profile
Re: Battle info and algorithm.
« Reply #7 on: 2008-09-24 17:48:38 »

3) There is possibility to create Strength Plus, Spirit Plus and Magic Plus materias.


As Magic Plus already exists...I think u mean Strength Plus , Spirit Plus and Vitality Plus Materias...


Yup. All stats boost can be created.

L. Spiro

  • *
  • Posts: 797
    • View Profile
    • http://www.memoryhacking.com/index.php
Re: Battle info and algorithm.
« Reply #8 on: 2008-10-04 16:08:15 »
You are working through this with a debugger right?


L. Spiro

Akari

  • *
  • Posts: 766
    • View Profile
Re: Battle info and algorithm.
« Reply #9 on: 2008-10-05 06:33:35 »
You are working through this with a debugger right?


L. Spiro

With debugger and disassembler.