Author Topic: Battle/Global Variables  (Read 8319 times)

Sega Chief

  • *
  • Posts: 4087
  • These guys is sick
    • View Profile
Battle/Global Variables
« on: 2014-08-08 01:28:51 »
Hi all,

At the moment I'm trying to come up with a in-game enemy AI system that would allow for 2-3 different settings, adjusting the EXP given by enemies (and in some cases their stats depending on the chosen setting). Basically it would be fast, normal, and slow; it'd let people choose between playing a 'fast' game or getting stuck into a lasting challenge. It could also be changed mid-game without any consequences.

I've got a pre-battle AI template set up, but what it needs is a trigger that can be set through the field. I've been looking at the character AI that handles 'Love Points' through Global Variables as a point of reference but I'm a little unsure about the way functions with these are carried out and how the numbers used determine the variable address. 7H could easily skirt this by swapping in different scene.bins, but I want to keep the non-7H version of the mod as functional as possible and keep file clutter down for the planned 7H one.

That, and I reckon having global variables to make use of in AI might lead to some interesting new possibilities when making enemies beside stat alterations. Let's say you're fighting Reno and Poison is effective so you use it against him. A variable flips when it returns true that the actor is poisoned; this then unlocks AI in subsequent fights (using that global variable) where he makes use of an ability that prevents or gets rid of Poison because of what happened in the last encounter. Recurring enemies with 'evolving' AI like that could be a good laugh, and be used to present different kinds of challenges. There's a lot of other possibilities as well.

I'd appreciate pointers on these global variables; I'm already finding this to be a bit of a nightmare for my usual trial & error approach  :(

Vgr

  • Global moderator
  • *
  • Posts: 2163
  • If it quacks like a duck, it must be a duck
    • View Profile
Re: Battle/Global Variables
« Reply #1 on: 2014-08-08 03:45:14 »
Those love points you're referring to aren't used in the game. They're so-called affection points, but actual love points are unaffected by battle, thus why you were confused.

sithlord48

  • *
  • Posts: 1634
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Battle/Global Variables
« Reply #2 on: 2014-08-08 12:37:53 »
to expand apon what vgr said.

there are two kinds of love points  regular and battle  both are written to your save . and both can be edited in black chcoobo to make finding them easier in ram when running. each is a single byte.

the regular ones are used to pick your date for the gold saucer . they seam to be only added to on field maps as a result of dialog choices.

the battle points are susposed to added to the regular love points for actions taken in battle. The starting value is 100 for everyone. I have many saves with non 100 values it seams to go up by 4 each time . in order to use them as extra space you must first remove what is changing them or you additions may have unexpected results.

Sega Chief

  • *
  • Posts: 4087
  • These guys is sick
    • View Profile
Re: Battle/Global Variables
« Reply #3 on: 2014-08-08 13:50:12 »
Those love points you're referring to aren't used in the game. They're so-called affection points, but actual love points are unaffected by battle, thus why you were confused.

That'll explain why my testing wasn't going anywhere.

the battle points are susposed to added to the regular love points for actions taken in battle. The starting value is 100 for everyone. I have many saves with non 100 values it seams to go up by 4 each time . in order to use them as extra space you must first remove what is changing them or you additions may have unexpected results.

Remove the modifiers; gotcha. I've been reading up on the Qhimm wiki though and I'm starting to think that global variables are actually a separate thing to field-handled variables; is that true? Is there any way to have a battle script look up the value of a variable from the Field module?

sithlord48

  • *
  • Posts: 1634
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Battle/Global Variables
« Reply #4 on: 2014-08-08 14:20:53 »
i know the field has its own set of accessable varibles (they may be what your thinking of global) somethings are not see there like char data but that might be able to be used via some functions of scripting.  im not well enuff versed on the battle system to say much about its vars. you can access both battle and love points in the field vars (via makou reactor)  so it possible that battle just gets fed some data when a battle starts and maybe can't return data (perhaps why battle love is never added to regular love).

Sega Chief

  • *
  • Posts: 4087
  • These guys is sick
    • View Profile
Re: Battle/Global Variables
« Reply #5 on: 2014-08-08 16:01:35 »
you can access both battle and love points in the field vars (via makou reactor)

That sounds promising. Do you happen to know the field variable addresses used by each character for battle love points? Once I strip out the character AI and, assuming this causes no problems, I could start using them for different things.

sithlord48

  • *
  • Posts: 1634
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Battle/Global Variables
« Reply #6 on: 2014-08-08 16:12:06 »
That sounds promising. Do you happen to know the field variable addresses used by each character for battle love points? Once I strip out the character AI and, assuming this causes no problems, I could start using them for different things.

the address are viewable in the varible manager they are named in the list.

looks like in bank 1 bytes 80, 81, 82 and 83 . converting them to memory offsets naturally will be differnt addresses

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battle/Global Variables
« Reply #7 on: 2014-08-08 16:18:03 »
Battles can change any value in the 1/2 Memory block in the savemap. That's the only way the results of a battle can communicate with other modules. As mentioned, the battle love values are not calculated when determining the few things affection points are used to determine. They go up by 2 every time Cloud heals them (their HP has to go up), down by 2 if Cloud hurts them, up by 4 if Cloud covers them, and down by 4 (maybe 9, it's hard to tell) if they die during the battle. Because they're never considered, Cloud's, Aerith's, Tifa's, Barret's, and Yuffie's scripts are pointless.
This whole battle love points seems ridiculous anyway because a lot of it is out of the player's control.

If you want to control exp it would be easy to hijack any/all of these values. Make Cloud's post-battle script multiply/divide the exp by an amount and tell Tifa's, Barret's, and Cid's scripts to copy Cloud's, but it should only run once. That'd be tricky.

sithlord48

  • *
  • Posts: 1634
  • Dark Lord of the Savegame
    • View Profile
    • Blackchocobo
Re: Battle/Global Variables
« Reply #8 on: 2014-08-08 16:23:06 »
if your looking to save things to the charcters themselfs there is 4 unused bytes in the char data too

char data is saved as seen here in memory it should be the same.

z_4 being the unused / unknown (but never seen with a non 0 value)  bytes.

Sega Chief

  • *
  • Posts: 4087
  • These guys is sick
    • View Profile
Re: Battle/Global Variables
« Reply #9 on: 2014-08-08 16:49:15 »
the address are viewable in the varible manager they are named in the list.

looks like in bank 1 bytes 80, 81, 82 and 83 . converting them to memory offsets naturally will be differnt addresses

Gotcha. I'll give them a whirl tonight.

Battles can change any value in the 1/2 Memory block in the savemap. That's the only way the results of a battle can communicate with other modules. As mentioned, the battle love values are not calculated when determining the few things affection points are used to determine. They go up by 2 every time Cloud heals them (their HP has to go up), down by 2 if Cloud hurts them, up by 4 if Cloud covers them, and down by 4 (maybe 9, it's hard to tell) if they die during the battle. Because they're never considered, Cloud's, Aerith's, Tifa's, Barret's, and Yuffie's scripts are pointless.
This whole battle love points seems ridiculous anyway because a lot of it is out of the player's control.

If you want to control exp it would be easy to hijack any/all of these values. Make Cloud's post-battle script multiply/divide the exp by an amount and tell Tifa's, Barret's, and Cid's scripts to copy Cloud's, but it should only run once. That'd be tricky.

Thanks for the heads-up, NFITC1. I hadn't considered doing this through the character AI instead of the enemy, that would definitely cut down on time and space. If the pointless scripts are functioning properly (and it seems from Sithlord's experiments that they are) then hopefully all the components are already there and ready to be moved around. I'll see if I can set something up that gets it all working properly.

if your looking to save things to the charcters themselfs there is 4 unused bytes in the char data too

char data is saved as seen here in memory it should be the same.

z_4 being the unused / unknown (but never seen with a non 0 value)  bytes.


I'll keep this in mind; 0x0034, right? Actually, that's an interesting database; can all those addresses be used (and their values altered) in battle AI?

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Battle/Global Variables
« Reply #10 on: 2014-08-08 18:01:07 »
...can all those addresses be used (and their values altered) in battle AI?
0x34 can't be accessed during battle. Battles don't read or modify the memory in the save map at all until the battle is over. When a battle begins the values from the savemap are read into a different memory location and accessed from there. 0x34 is never read from the savemap and never written back to it.

Sega Chief

  • *
  • Posts: 4087
  • These guys is sick
    • View Profile
Re: Battle/Global Variables
« Reply #11 on: 2014-08-08 18:55:26 »
I see, so 0x34 is a no-go. I'll stick with these four variables for now and try to get it working.

Roden

  • *
  • Posts: 125
    • View Profile
Re: Battle/Global Variables
« Reply #12 on: 2014-10-31 00:27:34 »
if your looking to save things to the charcters themselfs there is 4 unused bytes in the char data too

char data is saved as seen here in memory it should be the same.

z_4 being the unused / unknown (but never seen with a non 0 value)  bytes.
Can you even write to those character info records from the field script (never mind battle)?