Using variables in states

So i tried a lot of things but i just can't get this right...

I'm trying to make a skill as follows:

Speed Share - The user grants a temporary AGI buff to all his allies equal to 20% of his own AGI.

The way i thought of doing this is making the skill add a state with the same name, and the state would give an increase in AGI equal to 20% of users AGI. But there is no way of using variables inside of the Features box of states.

Any ideas how to do this?
You can assign variables in the damage formula of a skill (which presupposes that there is some kind of damage, though, which can include recovery or drain). You'd begin the formula with v[n] = a.param(6) - n is the number/ID of the variable, a is the attacker (user of the skill), param is parameter and 6 is for agility (FYI 0 = MHP, 1 = MMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK). This will store the user's agility in a variable.
(the whole damage formula would look like this:
v[n] = a.param(6); 250
where 250 would be the damage/recovery/drain)

Now for the buff, I'd use a common event, in which there would be a script, which would do agility increase for each of the party members. I'm sure someone who is good at scripting can give you the exact text that should go in the script window, or even make a script for what you need without the need for the damage formula use :LZSwink:
You can assign variables in the damage formula of a skill (which presupposes that there is some kind of damage, though, which can include recovery or drain). You'd begin the formula with v[n] = a.param(6) - n is the number/ID of the variable, a is the attacker (user of the skill), param is parameter and 6 is for agility (FYI 0 = MHP, 1 = MMP, 2 = ATK, 3 = DEF, 4 = MAT, 5 = MDF, 6 = AGI, 7 = LUK). This will store the user's agility in a variable.
(the whole damage formula would look like this:
v[n] = a.param(6); 250
where 250 would be the damage/recovery/drain)

Now for the buff, I'd use a common event, in which there would be a script, which would do agility increase for each of the party members. I'm sure someone who is good at scripting can give you the exact text that should go in the script window, or even make a script for what you need without the need for the damage formula use :LZSwink:
oh i see... Thanks for all the help ^^

And i hope someone will aid me with the script too ^^
Speed Share - The user grants a temporary AGI buff to all his allies equal to 20% of his own AGI.
I think you can use the variable in the formula and using Yanfly Target Manager and Follow Up skill scripts you can specify that the follow up skill is only usable to all allies except the user.

But yes the hard part will be to have the value increase based on the variable.
...
Maybe shaz onadd / remove script.

When the state is removed run a skill to remove the bonus agility
but for adding it the follow up skill can simply be b.agi += \v[X];0 in the formula.

Works in my head, whether or not it does in reality, not sure.
I think you can use the variable in the formula and using Yanfly Target Manager and Follow Up skill scripts you can specify that the follow up skill is only usable to all allies except the user.

But yes the hard part will be to have the value increase based on the variable.
...
Maybe shaz onadd / remove script.

When the state is removed run a skill to remove the bonus agility
but for adding it the follow up skill can simply be b.agi += \v[X];0 in the formula.

Works in my head, whether or not it does in reality, not sure.
this is getting a little too confusing for me
At this point I'm starting to question whether creating such skill altogether is worth all this effort...
Shaz's script might work, but I had problems with it when the target was set to all (it only executed the state command on the last target). @WitchAmy how many actors do you have? Can they all use and be affected by this skill? I mean, is there maybe only one actor that does the skill and are there maybe only 2/3/4 other actors that would be with that actor and can be the targets of the skill?
Shaz's script might work, but I had problems with it when the target was set to all (it only executed the state command on the last target). @WitchAmy how many actors do you have? Can they all use and be affected by this skill? I mean, is there maybe only one actor that does the skill and are there maybe only 2/3/4 other actors that would be with that actor and can be the targets of the skill?
as of now, there's only one actor. The skill in question is actually a type of skill i called an "Ultimate" (uses TP instead of MP and is mostly an end-game skill). As of now i do not have plans for actors to share Ultimates but that might change.

The party is going to be 4 actors most of the time but there can be summonable pets that can increase that number temporarily
OK, so what I would do, in my usual clunky way, is this:

I'd make a common event that would be called by the skill (at this point, you don't even need the damage formula, since there will be only one possible user). In the common event, I'd first set the variable to the user's AGI. Then, divide the variable by 5, to get 20%. Then for each party member, add the variable to their AGI. So one by one, for all possible actors except the user, but including the pets, Change parameters and increase AGI by the variable (it doesn't matter if they are in the battle in question or not). Set a switch to remember if the skill was used or not (if the skill can be used multiple times, use a variable and increase it by one after each use).

To return the agility back to the original in this scenario, you'd need to add to all the troops (but since it's end-game, it might not be that many and that bad) a check if the switch is on/the variable is not zero and then decrease the AGI back (again, for all the possible actors and pets). Then turn off the switch/set variable to zero. For this, you'd probably need a script for post-battle events (unless all your battles are evented).

I hope it's understandable :LZSsmile:

Edit: There might be a problem if you want visual representation of what happened. Maybe you could add an empty state, just with an icon, so that it's visible to the player that there was an increase.
Ok I have a solution - *updated - found the formula was actually not working.
Just like EntangledPear said have the skill call a common event.
In the damage formula of the skill do this
$game_variables[5] = a.id; a.atk * 5 - b.def * 2
where 5 is the game variable, this will get the actor id
in the common event make a script entry like this

Ruby:
$game_party.members.each_with_index do |mem, i|
next if mem.id == $game_variables[5]
mem.add_param(6, ($game_party.members[$game_variables[5]].agi * 0.2).to_i)
end
Now when the skill is used all party members except the user gets a bonus of 20% agi to them.

You can see the 0.2, you can change it to whatever you want.
And change the variable number to whatever you want.
the add_param(6 is the reference to agi.

This can probably put shortened, but this was the first attempt that worked.
You do notice that you could have done all of that processing in a single each_with_index loop right?

Original thread: https://forums.rpgmakerweb.com/threads/using-variables-in-states.161101/