Putting together a second generation unit? (Math Commands)

Hello all! The project I’m currently working on has second generation units, that have their stats and growths altered depending on who the mother was paired with. The problem however, is trying to get the stats correct. The formula should go like so:

[(father’s current stats - father’s class base stats) + (mother’s current stats - mother’s class base stats) + child’s absolute base stats] / 3 = Child’s full base stats

What I’ve figured so far, is that you can use a command to take one of the parent units stats, but I’m not sure how you would go about reducing the number, adding it to the other parents stat, dividing it, and finally applying to the unit! If anyone has some insight, it would be much appreciated!

2 Likes

Im interested in hearing the answer but one thing i noticed with your equation, since mothers are set, that part of the equation should be a set number making the father the only veritable. You put “current stats” so that part might be tough

You could use the various save slot related commands (SADD to add, SSUB to subtract, SMUL to multiply, SDIV to divide, etc.) to do this arithmetic. Get/Set Unit Status patch should allow you to apply those to stats.

iirc theres a patch that lets another unit inherit another persons inventory/stats. Cant say what it was

The problem there, is that the Set Unit Status commands don’t seem to have an option to use a number that’s been saved like that. From what I can see, it’s only a number that you enter manually.

Enable LOW commands and you should see one that takes from a slot.

How do you enable LOW commands?

Do you know if there’s any way to change the number saved in a slot by hand? For example, part of the equation is removing the classes base stats, so I’d need some way to do that.

Untitled-1
I threw together an example of what I though would work, trying to get the Max Hp changed. Was there any errors here? The max hp ended up not being changed, so something obviously went wrong.


Simpler calculation, but you can see here that the commands do work. Are you sure all of those units have been loaded?

It’s a little hard to follow the logic (consider using the “comments” field in the event command to make it more legible, especially for other people), but are you sure every operation does what you think they should do? Trying to simplify what you’re doing:

SlotA = 16 - Gaius's Max HP
Slot8 = 16 - Sumia's Max HP
Slot7 = 32 - Gaius's Max HP - Sumia's Max HP
Slot5 = 39 - Gaius's Max HP - Sumia's Max HP
Slot3 = 3 / (39 - Gaius's Max HP - Sumia's Max HP)
Result = 16 + (3 / (39 - Gaius's Max HP - Sumia's Max HP))

Isn’t Slot3 supposed to be the other way around? You can’t get anything higher than 3, you’re probably getting decimals (as in, not an integer number, so the result gets truncated), and you could even end up dividing by 0. So the results you’d be getting are between 13 and 19.

Seems that you also got the current/base stats inverted.

I thank you for the comment, however, the calculation doesn’t seem to fully work, as it’s a number off for me.

To explain more of what I was trying to do in my example:

[(Gaius’s Max HP 22 - Thief class base HP 16) + (Sumia’s Max HP 18 - Pegasus Knight class base HP 16) + Cynthia’s absolute HP 7] / 3 + Pegasus Knight class base HP 16 = Max HP of 19

The result of what you posted should be 21, not 19.
I understood what you wanted to do, and I explained what was different from what you did. Keep in mind that numbers get truncated in division, meaning they always get rounded down, which might explain what you think are inconsistencies.
Make sure you fixed the operations to what I explained. If there’s still a problem, you should post a patch so we can look into it, otherwise there’s not much else to say.

Took a bit to wake up, and realize what was wrong with the last attempt

This new order of commands may be a bit crude, with how long it is, but it works as intended!

2 Likes