I'm really new to scripting and fairly new to VX Ace in general, though please don't let that influence you to ignore this question because I've been scouring online forums and have yet to find a solution to my problem.
Basically, I had an idea for the combat in my game where each skill would leave the caster in a position (apply a state to them) and that would give them certain advantages, like a reckless attack might do more damage but put the caster in a vulnerable position, lowering their defense.
Unfortunately though, there seems to be no good way to do this. There isn't an option to apply a state to the caster in the skill menu. In searching for a solution to this, I've found that most people will put the state in the damage formula, something like
The problem with this is that this only applies the state if the attack lands, not if it misses. I need it to apply either way.
My next idea was to use a common event triggered by the skill to apply the state, but this didn't work either. There isn't a way in the event commands to find the caster that triggered the event. So, I figured maybe I could write a script for this. Thus arose another issue; I can only reference the actor ID of a caster DURING THE DAMAGE CALCULATION. The value is wiped immediately after. I have no idea why they did this instead of just overwriting the value but I'm not that fluent in ruby so maybe I'm missing something here. As a note, I would go in and change this myself but the default scripts are kind of insane and really hard for me to understand and navigate.
I figured okay, maybe I can set a variable to the actor ID in the damage calculation, since that's the only time it can be accessed, and then from there, reference the variable in the common event and add the state to that actor. Unfortunately, no matter what I do, I can't seem to get the damage formula to actually change the value of the variable. I've tried
and
and neither work.
Again, I'm pretty new to ruby and not super familiar with all the RMVXA systems so there might be something really obvious I'm missing, but I'm stumped. Any advice or workarounds welcome.
TLDR
I want to set a game variable to the actor ID of the caster of a skill, but I can't figure out how.
Basically, I had an idea for the combat in my game where each skill would leave the caster in a position (apply a state to them) and that would give them certain advantages, like a reckless attack might do more damage but put the caster in a vulnerable position, lowering their defense.
Unfortunately though, there seems to be no good way to do this. There isn't an option to apply a state to the caster in the skill menu. In searching for a solution to this, I've found that most people will put the state in the damage formula, something like
a.add_state(1); a.atk*4 - b.def*2The problem with this is that this only applies the state if the attack lands, not if it misses. I need it to apply either way.
My next idea was to use a common event triggered by the skill to apply the state, but this didn't work either. There isn't a way in the event commands to find the caster that triggered the event. So, I figured maybe I could write a script for this. Thus arose another issue; I can only reference the actor ID of a caster DURING THE DAMAGE CALCULATION. The value is wiped immediately after. I have no idea why they did this instead of just overwriting the value but I'm not that fluent in ruby so maybe I'm missing something here. As a note, I would go in and change this myself but the default scripts are kind of insane and really hard for me to understand and navigate.
I figured okay, maybe I can set a variable to the actor ID in the damage calculation, since that's the only time it can be accessed, and then from there, reference the variable in the common event and add the state to that actor. Unfortunately, no matter what I do, I can't seem to get the damage formula to actually change the value of the variable. I've tried
v[1] = a.actor_id; 100and
$game_variables[1] = a.actor_id; 100and neither work.
Again, I'm pretty new to ruby and not super familiar with all the RMVXA systems so there might be something really obvious I'm missing, but I'm stumped. Any advice or workarounds welcome.
TLDR
I want to set a game variable to the actor ID of the caster of a skill, but I can't figure out how.