# Any way to swap stat values on the fly?

#### Helio

##### Villager
In the game I'm making, there's a character who I want to assign a unique gimmick. He normally has an Attack of 300 and a magic attack of 75. He has decent magical and physical attacks. I want him to have a skill that allows him to switch his attack and magic attack stat in the middle of battle so that he instead has a magic attack stat of 300 and an attack stat of 75. Is there any way to do this?

#### JohnDoeNews

##### Steam mod (MV/MZ)
Yeah, sure. I don't really understand why you would want to switch them, but I am sure your idea is great. I can tell you how to do it, though

First you make a skill, the skill that you just described, and you make that skill trigger a common event.
We come back at the common event in a minute, but first lets talk about the skill formula.

To make this skill, we need to use 1 variable in the formula. For this formula I will use variable 1. If you use another variable, simply change the 1 to the id of the variable you use. The formula should be like this:

v[1] = a.atk - a.mat ; 0

This makes that variable 1 is not the difference between ATK and MAT of the spell caster. It is important that you make the skill target anything (friend or foe) and that the type is set to damage. (If you set it to heal, the formula would not set Var 1 if the target is at full health.)

Best to target the caster if the skill does nothing else. But you can also have the skill target an enemy, do damage and then AFTER the damage is done, it will trigger the common event. (In this case replace the 0 in my formula with the actual battle formula)

Now, for the common event. You just need 2 little commands:
Change ATK of actor: - variable 1
Change MAT of actor: + variable 1

That is all you need to do. The same skill will switch the values back if triggered again.

#### pawsplay

##### Veteran
create two passive states, one that adds +200 to each stat. Swap them as needed.

#### Sullien

##### Dev Wannabe
What was mentioned above could work but it would be more versatile if you added a variable amount so you could keep track of each stat and apply accordingly.

#### Helio

##### Villager
Yeah, sure. I don't really understand why you would want to switch them, but I am sure your idea is great. I can tell you how to do it, though

First you make a skill, the skill that you just described, and you make that skill trigger a common event.
We come back at the common event in a minute, but first lets talk about the skill formula.

To make this skill, we need to use 1 variable in the formula. For this formula I will use variable 1. If you use another variable, simply change the 1 to the id of the variable you use. The formula should be like this:

v[1] = a.atk - a.mat ; 0

This makes that variable 1 is not the difference between ATK and MAT of the spell caster. It is important that you make the skill target anything (friend or foe) and that the type is set to damage. (If you set it to heal, the formula would not set Var 1 if the target is at full health.)

Best to target the caster if the skill does nothing else. But you can also have the skill target an enemy, do damage and then AFTER the damage is done, it will trigger the common event. (In this case replace the 0 in my formula with the actual battle formula)

Now, for the common event. You just need 2 little commands:
Change ATK of actor: - variable 1
Change MAT of actor: + variable 1

View attachment 209156

That is all you need to do. The same skill will switch the values back if triggered again.
I tried this, and I believe I followed your instructions correctly, but all that happens is it says that the user took no damage and doesn't swap the stats. I have the target set to user. The attack stat is 2, and mat is 100. The common event looks exactly like the screenshot you sent. I do have the common event trigger in the skill (almost forgot to at first ) and the formula is v[1] = a.atk - a.mat ; 0. It's set to HP damage. Is there anything I might be missing?

#### JohnDoeNews

##### Steam mod (MV/MZ)
Did you also target the caster with scope?

The scope can't be "none" or "the user". That will skip the selection part of the skill. And you need to select anything. I don't know why that is, but if you skip, your might still have your variable a 0 when the common event runs. Set the scope to "1 ally" instead.

I hope that works, otherwise I have to think real hard what part I was missing.

#### Helio

##### Villager
Did you also target the caster with scope?

The scope can't be "none" or "the user". That will skip the selection part of the skill. And you need to select anything. I don't know why that is, but if you skip, your might still have your variable a 0 when the common event runs. Set the scope to "1 ally" instead.

I hope that works, otherwise I have to think real hard what part I was missing.
It didn't work. Do I need to change the variable somehow? I'm also using Variable 1 like you suggested

#### JohnDoeNews

##### Steam mod (MV/MZ)
Hmmm. Well, can you try maybe putting a text message in the common event that says: "\v[1]"

This way you can see what was stored in the variable, that should be the difference between the 2. If the whole message doesn't show up at all, then your common event is not triggered.

Can I see a screenshot of the common event maybe? (Maybe something went wrong and 2 see more than 1)

#### Helio

##### Villager
Here you are good sir, I'll do that text message thing while you look at the screenshot

#### Attachments

• image_2021-12-08_212747.png
13.9 KB · Views: 4

#### Helio

##### Villager
says the difference is -95

#### JohnDoeNews

##### Steam mod (MV/MZ)
Hmmm... I don't immediately see a mistake in your screenshot, and when I try to create the skill myself, it works flawlessly.

Wait... Oh wait... Is it an actor who switches their own stats? Or is it an enemy?
Because until now I thought we were working with actors, until I noticed it was called a sigma slimeset... If this is for enemy stats, then my approach will not work at all.

If it is an enemy changing the players stats, then change the a in the formula into a b.
So then the formula should be v[1] = b.atk - b.mat ; 0 and you also need to make sure it targets the right actor.

#### Attachments

• 1639017829147.png
140.8 KB · Views: 4

#### Helio

##### Villager
Oh god I had it set to the wrong actor the whole time. thank you so much for your help, and sorry for your troubles! After testing again, it definitely worked. by the way, do you know what the 6 pistol salute is?

#### JohnDoeNews

##### Steam mod (MV/MZ)
Whahaha. I had kind of the same thing. Didn't work for me either, cause I accidentally had it set to ATK and DEF. But after about 5 tries I figured it out.

Glad to read it works now. I hope to see the result one day! Good luck!

-

Oh and no idea what the 6 pistol salute is. What is it?

#### Shaz

##### Global Moderators

I've moved this thread to MV Support. Thank you.

### Latest Profile Posts

I'm working with Excel today, and I just hate VBA so much. It's like the designers said "How can we make a programming language that works as obtusely and inefficiently as possible?"

Just finished and uploaded the delivery truck base/sprite sheet. I've been steadily replacing the default assets with early modern alternatives. The air-ship for a biplane, horse-drawn wagon for a delivery truck, and next a sailboat for a steam-powered passenger liner (think of the SS Olympic and RMS Titanic).
I caught a shiny magikarp on pokemonGO today AND finally saw Detective Pikachu and it was so cute and I'm still so hype AHHHHH!!!
one of the coolest things I've learned from the forums is the ability to give yourself a hitbox. I have a move you can do on the fields. shoulder tackle. thanks to the forums, that tackle triggers self A switches on some events. NPC's and the environment now react to the tackle. awesome.
I really liked how this one turned out!

Character (Yes, this is a character): Nibiru the Primal Being from Yugioh.