MV Galv's weapon proficiency script call help

Solved, but in case other search here is the problem I was having.

I am using Galv's weapon proficiency and wanted a way to apply weapon xp to any actor who uses a skill without having to make multiple copies of the skill to apply to each individual actor.

by putting $gameVariables.setValue(1, a.actorId()); in the skill's damage formula, one can call the variable into the Galv script call with the following in a common event

$gameActors.actor($gameVariables.value(1)).gainWProfXp(100,01);

This allows one to use the variable to update the actor ID on the fly, and using the corresponding skill will add weapon proficiency to the weapon (01 in this case).

Note: In using Yanfly's battle engine core, this will show a hit to an enemy that deals 0 damage. To hide this, there is a section of Yanfly's BattleCore plugin that can be edited.

Change

} else if (result.hpAffected) {

to

} else if (result.hpAffected && result.hpDamage !== 0) {

Credit to Shaz in another thread for that solution.

This should allow one to make skills that do something other than deal damage (while secretly doing 0 damage unbeknownst to the player) and apply proficiency to the appropriate skill.
You're asking for help with a script call, so

I've moved this thread to JavaScript/Plugin Support. Thank you.

Plugin link in case it's relevant:
I tried using $game_variables[1] = a.id in the skill's damage forumla to assign the actor ID to a variable,
That looks like it might be a VXAce script call; try something like this instead:

v[1] = a.isActor() ? actorId() : 0; damage_formula_goes_here
I.e. "if the user is an actor, store their ID in variable 1, else store 0 in that variable; then do the damage formula stuff".

(v is a shorthand available in the damage formula to access game variables, normally setting a variable to a value in RMMV looks like $gameVariables.setValue(id, value).)
You're asking for help with a script call, so
Moved to: JavaScript/Plugin SupportPlugin link in case it's relevant:
That looks like it might be a VXAce script call; try something like this instead:

v[1] = a.isActor() ? actorId() : 0; damage_formula_goes_here

I.e. "if the user is an actor, store their ID in variable 1, else store 0 in that variable; then do the damage formula stuff".

(v is a shorthand available in the damage formula to access game variables, normally setting a variable to a value in RMMV looks like $gameVariables.setValue(id, value).)
Thank you for the help.

For reference, the way that I fixed it was by changing the portion in the damage formula to


$gameVariables.setValue(1, a.actorId());

and having the Galv scrip call be

$gameActors.actor($gameVariables.value(1)).gainWProfXp(100,01);

Doing this, when I used the skill it applied the correct amount of proficiency to the correct weapon type.

The skill is set to to do 0 damage, so it still registers as a hit (for 0). I am thinking that I can use a plugin to hide the 0 damage from popping up. This should make it so that the skill applies the weapon xp regardless of its effect.
I think this should work to hide all "0" damage popups, just save as a .js file and import as a plugin:
JavaScript:
(function(alias) {
  // Patch - create digits iff value is non-zero
  Sprite_Damage.prototype.createDigits = function(baseRow, value) {
    if (value !== 0) alias.apply(this, arguments);
  }
})(Sprite_Damage.prototype.createDigits);
Or you may be able to find an existing plugin for that.
I think this should work to hide all "0" damage popups, just save as a .js file and import as a plugin:
JavaScript:
(function(alias) {
  // Patch - create digits iff value is non-zero
  Sprite_Damage.prototype.createDigits = function(baseRow, value) {
    if (value !== 0) alias.apply(this, arguments);
  }
})(Sprite_Damage.prototype.createDigits);
Or you may be able to find an existing plugin for that.

That is good to know! Question: Does that assume that one is running the base battle engine?

If one is running Yanfly's Battle Engine Core, for instance, hiding the 0 damage pop-up can be achieved by going into the js file and making a modification:

Change

} else if (result.hpAffected) {

to

} else if (result.hpAffected && result.hpDamage !== 0) {

Credit to Shaz in another thread for that solution.

I found that in a 6 year old thread, but it does appear to work. I'm using the Yanfly Battle engine so that is the solution to hiding the 0 damage numbers that I came ended up using.

As an aside: I apologize if any of my terminology regarding anything is off, I'm pretty new to RPG maker as a whole and have virtually no programming experience.
That is good to know! Question: Does that assume that one is running the base battle engine?
Yes, unless you're having a conversation about a specific plugin that we know you're using, any code advice you're given will have to be based on MV's engine.
Change
} else if (result.hpAffected) {
That does actually exist in the original code, also, just caethyril's code goes at the lower-level function (if you look at the next line of code, you'll see it's calling createDigits(), which is what her snippet modifies).

Also, if you're not talking about code that's already inside of a plugin, it is universally recommended to make changes by copying the entire relevant function and turning it into a plugin, as caethyril did - it's not good practice to directly edit the files in your js folder.

For your purposes, making that edit to the Battle Engine Core should do the trick fine.

Original thread: https://forums.rpgmakerweb.com/threads/galvs-weapon-proficiency-script-call-help.146433/