Action XP plugin

This is my first real attempt at a plug in so I'm trying to do something simple but useful.  Looking to be pointed in the right direction. Hopefully this is the right place to post it.  There are active mods here they'll make sure I get it right.


Goal:


To keep track of the number of uses for a skill, item or weapon.  This number can than be used in the effect formula. 


Example:


Skill Fire has been used by Actor George 100 times.  His damage for the skill fire is more effective than for Actor Marian who has only used it 50 times. 


Simple Damage formula a.mat + a.actionXP/5


In our example above, assuming both George and Marian both have a magic attack of 50, then George would do 70 damage and Marian would do 60.


After the call skill use gets ticked up one.  This is all handled behind the scenes by the battle manager.


I'm going to start with skills and then use the same theory for items and weapons later.


What I have so far:

Spoiler
(function() {
var parameters = PluginManager.parameters('EffectXp');
// So the game recognizes my code right?


}
//================================================================================
//Array that is attached to actor?
//================================================================================
Game_Actor.prototype.skillXP(actorId) = [null, XP] {
var XP = 0;
}
//================================================================================
//Game_Battler.prototype.effectSkill
//================================================================================
Game_Battler.prototype.effectXP = function(a) {
var x = a.actorId(); //grabs actorId to tick up corresponding effectXP param.
var y = a.skillId(); //grabs skillId to tick up corresponding effectXP param.
return $gameActor.actor(x).skillXP[y];
}

What I know I'm missing:


--- For every skill in skillXP for the actor I need to add a spot in the array.  I don't know if I should do that when the game first loads... or if maybe I can push into the array an object with the skills name and then save the xp variable in that object each time I call the effect in the damage. I'm not sure. Any suggestions? I'm going to play with it, but any help is appreciated. 


--- I know I'm missing other stuff too, but I'm unconsciously incompetent on a lot of this, so I have no idea what else I could be missing. I'm just aware of my own shortcomings.
So you want to create a system that tracks skill, weapon, and item uses by a specific actor? 


I think it's good to use the array; makes your life easier.


Now, when a skill is used, you could use the skillID as an array Index and update the counter. This will keep the indexes and searches simple.


Hopefully this helps; I'll add code also if you'd like.
Thank you for the reply. 

Actually... Yanfly just posted a tips and trick regarding what I was trying to do...







This was for MP cost, but was essentially the same concept with creating an array that stored the variables... and hashes(array indexes?  Not sure the vocab I should be using.) to keep track of #times uses.  So I took this and adapted it with Yanfly's existing plugins to the damage formulas.  This is what I've come up with so far and it works for the one skill.  I'm going to change it to look up skill name and use that for an index, so that way I don't cause problems when I move on to also adapting this to items and weapons. 

.



<damage formula>
user._timesUsedSkill = user._timesUsedSkill || {};
user._timesUsedSkill["fire"] = user._timesUsedSkill["fire"] || 0;
var times = user._timesUsedSkill["fire"];
value = 1 + times;
user._timesUsedSkill["fire"] += 1;
</damage formula>

Spoiler
This doesn't actually accomplish me doing my first plugin, but atleast I'm still applying the bit of javascript I know and seeing it in action.

Again thanks for the response

Original thread: https://forums.rpgmakerweb.com/threads/action-xp-plugin.73464/