State change depending on equipment.

Hello everyone.
I'm using Yanfly's Skill Learn System, Auto Passive States and Equip Battle Skills in my project and I'd like to make a tiered equipment mystery system which will increase stats as higher tiered mastery is learned. So if someone learns a skill and then equip it and then equip certain equipment their states will increase or will decrease if that certain skill in not equipped.
For example :
A character has learned 'Sword Mastery' and has it equipped it, then if it equipes a sword it will receive a bonus of 10% in atk, whereas if it equipes the sword without that skill equipped it will not receive the bonus, on the other hand some swords will require that particular skill to be equipped if not then they will reduce stats like atk, agi, etc..
You're going to need a script like the one below, run in parallel. You probably want to write or request a plugin to make this more manageable.

In this example, skill 'Dual Attack' and weapon type 1(Sword) must be equipped for atk to be increased by 10. When skill/weapon is unequipped, atk is decreased by 10.
Code:
var skillname = 'Dual Attack';
var weaponTypeId = 1;
var paramToAdd = 2; //Params: 0-MaxHP, 1-MaxMP, 2-ATK, 3-DEF, 4-MAT, 5-MDEF, 6-AGI, 7-LUK
var amountToAdd = 10;
var actorParamAdded = [];
for (i = 0; i < $gameParty.size(); i++) { //for entire party
    for (j = 0; j < $gameParty.members()[i].battleSkills().length; j++) { //for each party member's equipped skills
        //check if 1) their battle skill matches skillname 2) they have a weapon equipped in main hand 3) weapon type id matches
        var check1 = $gameParty.members()[i].battleSkills()[0].name === skillname;
        var check2 = $gameParty.members()[i].equips()[0];
        var check3 = $gameParty.members()[i].equips()[0].wtypeId === weaponTypeId;
        if (check1 && check2 && check3) {
            $gameParty.members()[i].addParam(paramToAdd, amountToAdd); //add 10 to ATK
            actorParamAdded.push($gameParty.members()[i]); //record who has attack increased
        }
    }
}
for (k = actorParamAdded.length - 1; k >= 0; k--) {
    //check if 1) their battle skill no longer matches skillname 2) they have no weapons equipped 3) weapon type has changed
    var check1 = actorParamAdded[k].battleSkills()[0].name === skillname;
    var check2 = actorParamAdded[k].equips()[0];
    var check3 = actorParamAdded[k].equips()[0].wtypeId === weaponTypeId;
    if (!check1 || !check2 || !check3) {
        actorParamAdded[k].addParam(paramToAdd, -amountToAdd); //subtract 10 from ATK
        actorParamAdded.splice(k, 1); //remove from actorParamAdded list
    }
}
@dahlys
Thank you very much for the help, I will surely put a request in the plugin request section.

Original thread: https://forums.rpgmakerweb.com/threads/state-change-depending-on-equipment.85388/