Storing Values into an actor?

Hello there, makers!


One of my characters is a swordsman, whose skills are divided into two:


 - Slashes, direct hit skills with low-average damage.


 - Blades, special states thar amplify the effectiveness of the next Slash used.


I've been used Yanfly's Damage Core to create custom damage formulas for the Slashes, with many IFs, each one of them checking if the Swordsman has one of the Blade state, changing the final value of the Slash, and, through Action Sequence, removing these states.


So far, so good; the system is working properly, but doesn't looks optimized.


I would like to know if it's possible to do the following:

  • Create variables stored inside the actor (or maybe a hidden auto passive state?), each one for a specific Blade skill.
  • Change the value of each variable by casting the respective Blade skill.
  • Setting a "definitive damage formula", without too many IFs, using these variables as references for the damage.
  • After the Slash skill, setting each one of these variables to 0.



If i learn how to do this, many of my implementation limitations will be surpassed.
Here you go, "Another Fen" made a Self Variables Script for Events and also an extra for Charackter Self Variables.


Its in German but maybe this is still helpfull. Its like Self Switches just that they are Variables insteed. For Events or Actors or Members.


Also very long explaination is added there.


http://rm-vx-ace.de/WBB4/index.php/Thread/120-Einfaches-Self-Variables-Script/


Sorry didnt saw that this is for MV and not Ace. Hope it still helps somehow, maybe someone can convert it.
I will introduce Nekoyoubi's awesome NeMV State Resources plugin


It adds a counter to passive states. 


Using Yanfly's buff and state core and skill core you have quite a powerful tool to control damage, stack 'charges' and modify damage formulae accordingly.

For what you want to achieve:

Each blade skill gets an auto passive state that also has been tagged to be a state resource 
Lets say <Resource 0, 9999, Blade Charge 1>
Use the <Hide State Turns> to hide the state icon if you want to make it hidden.
Your blade skill can simply modify the state 'resource' by adding a.adjustSR(X, Y) where X is the passive state id and Y is the amount of "charges" u want to add.


If you want more power, use yanfly's skill core tag of <Before Eval> user.adjustSR(X, Y) </Before Eval> 
In your damage formula for a slash skill, you can use (a.atk * 4 - b.def * 2) * (a.getSR(X) + 1) to multiply damage by the amount of charges you have
With yanfly's skill core, you can tag the skill with a <After Eval> user.setSR(X, 0) </After Eval> to reset the state 'resource' on that particular state


Tag the passive state with <RESOURCE BATTLEEND: 0> to reset the state resource at the end of battle
Thanks a lot for spending time asnwering my questionário! Is it really necessary to use this plugin? I've seen so many of Yanfly's Tips and Tricks where values are stored, in functions like "this._blablabla" or something.
I read again because my english aint the best, and maybe you can use a Workaround.


In short a Variable Pointer.


For example, you got 500 Skills that means you need 500Variables or $game_variables which allready exist.


In Ace i can also set $game_variables above 10000 and they get properly safed, i wondered because the limit is much smaler.


And you can use them in Battle Formulas.


We use the Skill ID to reference the fitting Variable ID.


Skill 50 got Variable id 50 for example.


You could also start with Skill 50 got variable id "Skill id + 40".


In that case the list with variables would not start with 1 but with 41.


Hope this is not too much chineese.


So you could insert into your formula pseudo code:


$game_variables[Skill_Id_is_var_id_iam_the_pointer]  * (A.atk *4 / B.def*2)


In short


Variable Value multiply with Formula.


But the Formula isnt complete, the changing variable stuff is missing. I never used this just read a few stuff so i dont have final solution, but maybe this helps.
Thanks a lot for spending time asnwering my questionário! Is it really necessary to use this plugin? I've seen so many of Yanfly's Tips and Tricks where values are stored, in functions like "this._blablabla" or something.

If you don't want to use state resources you could attempt the following

Method 1: Use the method that @Bex has suggested (game_variables).
Without using the skill core, each blade skill would need $gameVariables.setValue(var, value); damage formula;
If you want to add say 3 to game variable 1235 whilst doing normal damage, then use: $gameVariables.setValue(1235, $gameVariables.value(1235) + 3); a.atk*4 -b.def*2


For any slash skill that does bonus damage, then you would do damage formula * ($gameVariables.value(var) + 1); to deal bonus damage
Each troop event needs a turn 0 event to process and set such variable to 0
Main issue is resetting the variable after using the slash skill. It is easy to set it before doing damage but then your bonus will be 0. If you use Yanfly's skill core you can insert a script with the  <After Eval>  tag to reset the game variable after damage has been done.
You could replace the above steps by calling a common event if you don't want to use any scripting.

Method 2: Your suggested method using ._this and yanfly's buff and state core.
I'm not sure you you would do this. Your main issue is the damage formula box. How are you going to grab a $._this (or any random variable assigned by the state) value from your state? What are you going write in the formula box to grab the variable attached to a state? Your only option would be using something that can be easily accessed such as a game variable.



You could use these notetags for each 'charge' state and add a 'apply state' to any of your blade skills

<Custom Apply Effect>


$gameVariables.setValue(X, $gameVariables.value(X) + 1);


</Custom Apply Effect>

This means every time this state is applied, it will add 1 to game variable X. Not sure if reapplying states will cause it to apply such effect again.

Again your issue is resetting $gameVariables when you use a slash skill and when the battle ends. Again, you would need the help of skill core and use <after eval> tags to reset $gameVariable as needed.

Both the above methods do not SHOW the player how much 'charges' they have accumilated. Hence my suggestion for Nekoyoubi's state resource plugin.

Original thread: https://forums.rpgmakerweb.com/threads/storing-values-into-an-actor.68147/