FF2/SaGa stat system?

For several days now, I've been searching for a way to make something similar to the FF2/SaGa stat systems with events, but to no avail...

For those who don't know what I'm talking about, here are several exemples of what I want to do:

- If Actor1 attacks Enemy1 with a melee attack and the attack doesn't miss, Actor1 would have a 12% chance to have their Attack stat increase permanently by 1~3.

- If Actor3 attacks Enemy1 with a spell and the attack doesn't miss, Actor3 would have a 12% chance to have their M.Attack stat increase permanently by 1~3 and if Actor3 used at least 1MP to cast that spell, then they would have a 20% chance to have their MP increase permanently by 3~7.

- If Enemy2 attacks Actor1 with a melee attack and the attack doesn't miss, Actor1 would have a 13% chance to have their Defense stat increase permanently by 1~4 and if Actor1 lost at least 1HP from that attack, then they would have a 23% chance to have their HP increase by 5~12.

- If Enemy1 attacks Actor2 with a melee attack but the attack misses, Actor2 would have a 7% chance to have their Agility stat increase permanently by 1~2.


While I was searching, I found 2 posts where I saw members say that they were able to do this with events, but unfortunately, they didn't say how.... Could someone please help me with this? You would help a LOT of other members too. Finally, If there's something that wasn't clear in my explanation or if you want more exemples, just let me know.

EDIT: I forgot to mention that I'm going to use my actors' level for something else, so I don't want the system to have anything to do with an actor's level. If possible, I would like the system to be related to skills, since some skills will not increase an actor's stats when used.
Providing a link to the posts where members said they were able to do this with events might be helpful. Even if they didn't say what they ended up doing, the discussion that happened could give some ideas.
Providing a link to the posts where members said they were able to do this with events might be helpful. Even if they didn't say what they ended up doing, the discussion that happened could give some ideas.
Oh boy... You'll have to give me some time then. I read a LOT of posts these past few days. Ill update my main post as soon as I find them again.

EDIT: Gaah... I can't find them anymore. Darn it! I would have kept the tabs if I knew that those posts could have helped.
Well, you essentially want something to happen when an enemy/actor uses a skill. Even if at first it's just to increase a variable by 1 and the stat boosts would come later. One way would be to incorporate variable script calls into either the damage formula of the skills themselves or have the skills call a Common Event that increased the variables. At the end of the battle, you would have a troop event that would add the variables to the stats and reset them to 0. Now, there's surely much better ways to go about this in different ways, but this is what I can think of right now.
Well, you essentially want something to happen when an enemy/actor uses a skill. Even if at first it's just to increase a variable by 1 and the stat boosts would come later. One way would be to incorporate variable script calls into either the damage formula of the skills themselves or have the skills call a Common Event that increased the variables. At the end of the battle, you would have a troop event that would add the variables to the stats and reset them to 0. Now, there's surely much better ways to go about this in different ways, but this is what I can think of right now.

Making a damage formula was the 1st thing that came to mind. I even asked for help on the "RMMV Damage Formula - ideas and help" section of this forum, but so far, no one answered. After I posted my question, I went back on google to search for more answers and I remember reading something like what you wrote. Someone answered that it was only possible to call variables in a damage formula and that you can't modify them. I didn't think of using a common event though. I'll give that a try today.

EDIT: Oh, wait! That only solved part of the problem. What about the last exemple?
- If Enemy1 attacks Actor2 with a melee attack but the attack misses, Actor2 would have a 7% chance to have their Agility stat increase permanently by 1~2.
Your solution would only work if a skill hits the enemy, right? How am I supposed to make the last exemple work?

EDIT2: I found this on a spreadsheet just now.
Code:
b.result().missed
Could that help?


EDIT3: Forget what I wrote above. I just noticed that it was a spreadsheet that had to do with Yanfly's plugins. My bad.
Making a damage formula was the 1st thing that came to mind. I even asked for help on the "RMMV Damage Formula - ideas and help" section of this forum, but so far, no one answered. After I posted my question, I went back on google to search for more answers and I remember reading something like what you wrote. Someone answered that it was only possible to call variables in a damage formula and that you can't modify them. I didn't think of using a common event though. I'll give that a try today.

EDIT: Oh, wait! That only solved part of the problem. What about the last exemple?

Your solution would only work if a skill hits the enemy, right? How am I supposed to make the last exemple work?

I'm pretty sure you can change a variable through a damage formula. Can't hurt to try anyway.

As for your other question, if a skill misses, it won't call the damage formula. However, if you have a Common Event called in skill's effects, it will be triggered no matter what. You could combine these two.

So, you could have a script call in the damage formula that changes a variable. If the skill misses, the damage formula won't execute and the variable won't change. This variable would represent the number of successful hits. Then, the common event would increase a different variable, that would represent the amount of total hits attempted (successful or not). At the end of the battle, you would then subtract the amount of successful hits from the total hits and calculate the Agility stat raises from the resulting amount of missed hits.
Oh my gosh... That's soooo confusing. I didn't even know that we could use script calls in a damage formula.
I'll try and see if I can do what you said but I'm a visual learner and on top of that, I really sock at making formulas. If I can't make it work, could you please help me out?

EDIT: You're right. From what I just read, it's possible to change a variable in the formula box with " v[x] = "


Forget everything that I wrote above. I reread your message and doing what you said isn't difficult. The only problem that I'm having is with the variable script call. I looked at a list of MZ script calls and the only 2 script calls that I found was the one to get a value and the other is to set a value. There's no script call to change a value or if there is one, I cant seem to find it.

EDIT: Found it! Now it works.
Oh my gosh... That's soooo confusing. I didn't even know that we could use script calls in a damage formula.
I'll try and see if I can do what you said but I'm a visual learner and on top of that, I really sock at making formulas. If I can't make it work, could you please help me out?

EDIT: You're right. From what I just read, it's possible to change a variable in the formula box with " v[x] = "


Forget everything that I wrote above. I reread your message and doing what you said isn't difficult. The only problem that I'm having is with the variable script call. I looked at a list of MZ script calls and the only 2 script calls that I found was the one to get a value and the other is to set a value. There's no script call to change a value or if there is one, I cant seem to find it.

EDIT: Found it! Now it works.

Glad it works for you now!
Glad it works for you now!
Yes! It works, but for some unknown reason, one of the variables refuse to go back to 0 after the battle even if I set it to 0. XD
Anyways! I can't thank you enough! You're a real life saver!


EDIT: I have a new problem. When I try to modify more than one variable with a formula, at least one of the variables stay at 0 for some reason. Here's the formulas that I'm using:

$gameVariables.setValue(2 && 5, $gameVariables.value(2 && 5) + 1) ; 200
$gameVariables.setValue(1 && 4 && 7, $gameVariables.value(1 && 4 && 7) + 1) ; 1

For the 1st formula, only the 2nd variable(the 5) is modified. For the other formula, only the third variable(the 7) is modified. Is it because of the && in the formula? What am I doing wrong?


EDIT2: Nvm. I found the problem. Using the two following formulas instead of the ones above did the trick.

$gameVariables.setValue(2, $gameVariables.value(2) + 1) ; $gameVariables.setValue(5, $gameVariables.value(5) + 1) ; 200

$gameVariables.setValue(1, $gameVariables.value(1) + 1) ; $gameVariables.setValue(4, $gameVariables.value(4) + 1) ; $gameVariables.setValue(7, $gameVariables.value(7) + 1) ; 1

The system is working well. This is how it looks:

Original thread: https://forums.rpgmakerweb.com/threads/ff2-saga-stat-system.131096/