Help with writing a small plugin

I'm trying to write a small plugin that creates an array of variables I can access when calculating a damage formula. I'm using Yanfly's Skill Learn system to create a system where actor's can upgrade their skills, and I want the Attack skill to be upgradeable. The obvious issue is that Attack is hard coded to skill #1, and while I thought about using Yanfly's Weapon Unleash, I feel it's unnecessary because the only functional difference between the base Attack and its higher levels is a single variable. So I was thinking of simply writing a plugin to give me a function that creates an array where each index is equal to an Actor ID. I've written the function, but I don't know how to give it access to Game_Actor or $dataActors so that it can properly execute. The code is posted below.
MAX_ACTORS = 10; //The current max Actor ID, increase manually if more actors are added
const arrayAtkPower = new Array(MAX_ACTORS); //Declares global array userAtkPower, which stores the multiplier of Attack for each actor

function initAtkPower() {
for (let i = 0; i < MAX_ACTORS; i++) {
if (i == 0) {
arrayAtkPower[i] = -1; //Empty Actors and head of list designated with -1
}
else {
arrayAtkPower[i] = 0.65;
}
}
}

$gameParty.allMembers().forEach(function(m) {
var userAttackPower = 0.65;

if (m.isLearnedSkill(13)) {
userAttackPower = 2.9;
} else if (m.isLearnedSkill(12)) {
userAttackPower = 2.45;
} else if (m.isLearnedSkill(11)) {
userAttackPower = 2.05;
} else if (m.isLearnedSkill(10)) {
userAttackPower = 1.7;
} else if (m.isLearnedSkill(9)) {
userAttackPower = 1.4;
} else if (m.isLearnedSkill(8)) {
userAttackPower = 1.15;
} else if (m.isLearnedSkill(7)) {
userAttackPower = 0.95;
} else if (m.isLearnedSkill(6)) {
userAttackPower = 0.8;
} else if (m.isLearnedSkill(5)) {
userAttackPower = 0.7;
}

arrayAtkPower[m.actorId()] = userAttackPower; //Sets value of actor's attack power at a position in the array that correlates to their ID
});
The damage formula for Attack is: (a.atk * arrayAtkPower[a.actorId()]) - b.def

This is also my first time writing a plugin for RPG Maker from scratch. Any advise is welcome!
The damage formula for Attack is: (a.atk * arrayAtkPower[a.actorId()]) - b.def
It doesn't seem necessary to make an entire plugin for this, but we'll get back to that after I've read through the whole thing.

I don't know how to give it access to Game_Actor or $dataActors so that it can properly execute.
I don't know what you mean by "give access to" - Game_Actor is a data type, and $dataActors is a global variable. Both are freely accessible by anything in MV's code.

MAX_ACTORS = 10; //The current max Actor ID, increase manually if more actors are added
Why make a new global variable that you need to manually fiddle with? Just use $dataActors.length

const arrayAtkPower = new Array(MAX_ACTORS); //Declares global array userAtkPower, which stores the multiplier of Attack for each actor
Okay...another global variable.

function initAtkPower() {
for (let i = 0; i < MAX_ACTORS; i++) {
if (i == 0) {
arrayAtkPower[i] = -1; //Empty Actors and head of list designated with -1
Why? Just start the loop at 1. There's no reason you can't just leave element 0 as undefined.

Or use a forEach() and set everything to .65, I don't see why it matters whether the first element is different. If the indices correspond to actor IDs, that will simply never be looked at.

$gameParty.allMembers().forEach(function(m) {
This isn't correct - just having this floating in the middle of your plugin means the game will attempt to perform it upon booting up when plugin files are loaded, and at that time there is no $gameParty, no members in it, and they don't have any learned skills, etc.

This is clearly something intended to be executed at specific times during gameplay. So you would encapsulate it inside another function to call, or just paste it into Script boxes in a common event.

-----------------------------------------------------------------------------------------------------

So I wouldn't use this approach at all.
- It is always preferable to place properties directly onto their relevant object rather than add things to the global namespace

- I don't think you need this array at all

Given: You have all these potentially learned skills with sequential IDs.
Also given: I presume you are handling the actors only learning these skills in their specific order.

If those are true, then you don't need this array at all, you can just use math in your damage formula.
Code:
let atkPow = .65; for (let skill = 1; skill <= 8; skill++) {if (a.isLearnedSkill(skill+4)) atkPow += .5 * skill;}; a.atk * atkPow - b.def

If there were a reason you couldn't do it like that - such as it was a progression of multipliers that couldn't be expressed in a simple equation - I would prefer to use an existing plugin to calculate the modifier on the individual actor when they learned a new skill.

Then you'd just reference a.atkPow or whatever in your damage formula.
I used your suggestion and it works how I want it to! Thank you for your advise again!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-writing-a-small-plugin.167034/