Using a Common Event to Increase a Variable when Attacking

Hello,

I have a weapon that uses Yanfly's weapon unleash plugin (http://yanfly.moe/2015/12/26/yep-51-weapon-unleash/) to replace the basic attack with something different.

In this new attack, I call a common event. In that common event, I set variable 10 to increase by 1. This is so when the character uses the weapon enough, they can upgrade it.

However, it appears that the variable is not increasing, and I'm not sure if I'm maybe missing a step. I've attached pictures of the attack and the common event.

Thanks for any help.

yJJTQeYnRg_vX2iMws2NAA.png


drXWwcmCQyalBXU9GCbCZg.png
They look fine. Add a Show Text command to the common event so you can be sure that it's running.

Do you have any other plugins that change the way variables behave? I have a "Linked Variables" plugin, for example, and if you were using that and had defined a formula for variable 10, it would cause it to not increase.

Where are you doing the check to see what the variable is? Maybe the problem is in there. If you go into debug (F9, I think) does it show you if the variable is changing?


Note, I am not familiar with Yanfly's plugin, but if it's changing the basic attack, isn't that going to affect enemies as well (enemies use skill 1). And I just noticed that you've got 3 'Attack' skills there, and none of them is skill #1. Are you sure the correct skill is being used? Maybe you haven't set up the plugin correctly.
@Shaz Edit: whoops, hit enter before editing message.

I added a text box, and to my surprise, it did not display! So the issue must be between the attack and the common event.

I am checking the variable with a generic NPC and a textbox that says "\V[10]"

The three attacks that you see replace the basic attack using the yanfly plugin that I mentioned above. The basic attack is only modified for the character using a specific weapon. In this case, the note tag of the weapon says, "<Replace Attack: 270>" I have confirmed that this is functioning as intended by modifying the attack to always do 0 damage.

So, long story short, the weapon is generating the correct attack, for the common event is not occurring.

I do have plugins that affect variables, but nothing that should change this from happening. Especially since I have accounted for the variables that would be modified.
If the common event is not happening, then the attack cannot be happening - or there is an error in the plugin in that it does not look to the correct skill to see if there's a common event to run.

Change your formula box in skill 270 to this:
Code:
$gameVariables.setValue(10, $gameVariables.value(10) + 1)); a.atk * 6 - b.def * 2

use the skill a few times, and then see if the variable is being increased. If it is not, then the skill isn't running correctly.

If that works, then you could simply use that method to change the variable (and report back to Yanfly's thread that the common event associated with the skill isn't being run).
That formula did the trick. The variable increases as it should.

I will pass on the message to yanfly after a bit more testing on my end.

Thanks for your help, as always, Shaz. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/using-a-common-event-to-increase-a-variable-when-attacking.79984/