I'm trying to have attacks check which weapon a character is using when they attack and increase a hidden proficiency value. The roadblock I'm running into is how to get the ID of the character using the attack. Is there any way to check either the ID of the person using the skill, or at least which actor's turn it is?
Attempting to store the ID of an actor using a skill in battle
RPG Maker VXAce SupportYou can do that through Damage Formula, a is the user so a.id will return the actor ID. But remember, if the enemy also can use the skill, you have to check whether the user is an actor or not. Here's an example:
Code:
a.actor? ? do_something : do_something_else; actual_damage_formula
I've almost got it working, but I'm trying to save the ID as a variable in the damage formula but it doesn't seem to be carrying over. My current formula looks like this:
I've seen a lot of guides on using variables in damage formulas, but nothing about saving a variable in one, so I'm not even sure this is valid.
Edit: scratch that, it doesn't do damage when I set it up that way either.
Code:
a.id = V[2]; 20 * a.atk - b.def
Edit: scratch that, it doesn't do damage when I set it up that way either.
Well, your code is "almost" right. To save the ID to a variable is like this:
Code:
$game_variables[VARIABLEID] = a.id
Awesome, not only did that save the variable but the rest of the formula started working again too! Thanks for the help!
You're welcome 😀
Actually since you're in the damage formula, you can use v (not capital V) as shorthand for game variables.. just in case using $game_variables makes your formula too long
Also just to explain why your previous formula doesnt even do damage: The damage formula is set to deal no damage if it encounters an error rather than showing an error message. Now, on your fomula you used V[2], V is something that isnt defined before hand so it would be throwing out an error which then causes the damage formula's safety block to engage causing your skill to deal no damage
Also just to explain why your previous formula doesnt even do damage: The damage formula is set to deal no damage if it encounters an error rather than showing an error message. Now, on your fomula you used V[2], V is something that isnt defined before hand so it would be throwing out an error which then causes the damage formula's safety block to engage causing your skill to deal no damage
You are also using = which is attempting to set the actor's ID to whatever is in the variable. You either need to have it the other way (if you're trying to set the variable to the actor's id), or if you're doing a condition and what to check if the actor's ID is the same as what's in the variable, you need to use == rather than =
Apparently it was the capital V that got me. It's much prettier now, much appreciated!
Original thread: https://forums.rpgmakerweb.com/threads/attempting-to-store-the-id-of-an-actor-using-a-skill-in-battle.102556/