(I apologize in advance if I posted in the wrong forum section -- this is only my second time posting)
Hello!
Does anyone know how to get a current battler's ID and their target(s) ID(s), store them as variables, and use them in a formula?
Background:
I am trying to create a custom "hit chance" formula, using VisuStella action sequences to implement it. My end goal is to have actor parameters influence the chance of successfully hitting an enemy. For simplicity while testing the concept, the initial formula is just (user's Attack / Target's defense) * 0.75 (as in, when the user's Attack equals the target's Defense, the chance of landing a hit is 75%).
My plan to implement this is to ignore the Evasion parameter (all classes and enemies have an Evasion of 0%) and set everyone's base Hit Rate to 0%, then do all the formula calculations in custom action sequences for each skill and add it to the user's Hit Rate using the MECH: Multipliers plugin command (adding to the Flat of Hit Rate).
The formula I wrote was this:
($gameActors.actor($gameVariables.value(1)).atk / $gameTroop.members()[$gameVariables.value(2)].def) * 0.75
Where control variables 1 and 2 are the current battler/user and the target of the skill, respectively.
Problem is that after hours of searching online -- MZ/VisuStella script call lists and forum posts -- I have not found a way to get the actor ID of the current battler and the enemy ID of the targeted enemy.
I frequently get an error when performing the test skill saying that it is unable to get the property "atk" of either "null" or "undefined", depending on the method I was testing, implying that whatever calls I was using were not grabbing any usable data. "null" occurred when using stuff like BattleManager._subject or this._targetIndex to set the variables. "undefined" occurred when attempting some of the shortcuts used for other formulas, such as the damage formula (using 'a' for current battler, 'b' for target; or 'user' for current battler and 'target' for target).
One post suggested using MV's built-in "last" options to set control variables, but it looks like they only refer to prior actions and are incapable of referring to the actor and enemy in the skill being actively used. (This method would not produce an error if at least one other character acted first before testing the skill; otherwise, if the skill was the first one used, it returned an error).
Another post suggested setting variables in the damage formula, as that uses the 'a' and 'b' setup, but that returned an "undefined" error. I think that either the suggested v[1] = a._actorId and v[2] = b._enemyId formulas are incorrect, or VisuStella's action sequences operate first before reading the skill's damage formula, and thus the variables are never set up.
If anybody knows how to get the IDs of the current battler and their current target, I would be very appreciative.
(Or if anybody knows a better way of implementing this concept, which I failed to stumble across in my search of the internet for solutions).
Thanks in advance!
Hello!
Does anyone know how to get a current battler's ID and their target(s) ID(s), store them as variables, and use them in a formula?
Background:
I am trying to create a custom "hit chance" formula, using VisuStella action sequences to implement it. My end goal is to have actor parameters influence the chance of successfully hitting an enemy. For simplicity while testing the concept, the initial formula is just (user's Attack / Target's defense) * 0.75 (as in, when the user's Attack equals the target's Defense, the chance of landing a hit is 75%).
My plan to implement this is to ignore the Evasion parameter (all classes and enemies have an Evasion of 0%) and set everyone's base Hit Rate to 0%, then do all the formula calculations in custom action sequences for each skill and add it to the user's Hit Rate using the MECH: Multipliers plugin command (adding to the Flat of Hit Rate).
The formula I wrote was this:
($gameActors.actor($gameVariables.value(1)).atk / $gameTroop.members()[$gameVariables.value(2)].def) * 0.75
Where control variables 1 and 2 are the current battler/user and the target of the skill, respectively.
Problem is that after hours of searching online -- MZ/VisuStella script call lists and forum posts -- I have not found a way to get the actor ID of the current battler and the enemy ID of the targeted enemy.
I frequently get an error when performing the test skill saying that it is unable to get the property "atk" of either "null" or "undefined", depending on the method I was testing, implying that whatever calls I was using were not grabbing any usable data. "null" occurred when using stuff like BattleManager._subject or this._targetIndex to set the variables. "undefined" occurred when attempting some of the shortcuts used for other formulas, such as the damage formula (using 'a' for current battler, 'b' for target; or 'user' for current battler and 'target' for target).
One post suggested using MV's built-in "last" options to set control variables, but it looks like they only refer to prior actions and are incapable of referring to the actor and enemy in the skill being actively used. (This method would not produce an error if at least one other character acted first before testing the skill; otherwise, if the skill was the first one used, it returned an error).
Another post suggested setting variables in the damage formula, as that uses the 'a' and 'b' setup, but that returned an "undefined" error. I think that either the suggested v[1] = a._actorId and v[2] = b._enemyId formulas are incorrect, or VisuStella's action sequences operate first before reading the skill's damage formula, and thus the variables are never set up.
If anybody knows how to get the IDs of the current battler and their current target, I would be very appreciative.
(Or if anybody knows a better way of implementing this concept, which I failed to stumble across in my search of the internet for solutions).
Thanks in advance!