Script that increase stat based on variable

Did you know a script that can increase weapon stat based on the value of a variable^
I use a script for day night, and I want some weapon to be stronger in day or night.
Thanks
I played around with this and I learned how to add a variable value to the attack of a certain weapon id with this simple plugin.
PHP:
Game_Action.prototype.executeHpDamageCached = Game_Action.prototype.executeHpDamage;
Game_Action.prototype.executeHpDamage = function(target, value) {
   if($dataActors[this._subjectActorId] !== null) {
       if($dataActors[this._subjectActorId].equips[0] === 5) // id of day/night weapon (5 for example)
           value += $gameVariables.value(69); // variable of weapon increase
   }
   return this.executeHpDamageCached.apply(this, arguments);
};

This is the plugin you describe, but you might consider an if boolean with two values based on a variable from your day/night script instead of a game variable, unless of course if your day/night plugin automatically changes the variable.
I played around with this and I learned how to add a variable value to the attack of a certain weapon id with this simple plugin.
PHP:
Game_Action.prototype.executeHpDamageCached = Game_Action.prototype.executeHpDamage;
Game_Action.prototype.executeHpDamage = function(target, value) {
   if($dataActors[this._subjectActorId] !== null) {
       if($dataActors[this._subjectActorId].equips[0] === 5) // id of day/night weapon (5 for example)
           value += $gameVariables.value(69); // variable of weapon increase
   }
   return this.executeHpDamageCached.apply(this, arguments);
};

This is the plugin you describe, but you might consider an if boolean with two values based on a variable from your day/night script instead of a game variable, unless of course if your day/night plugin automatically changes the variable.

Yes actually, my pluggin automaticly change value from 1 o 4 depending of the period of the day.
Your code was really helpfull for start my coding. In fact what i wnt exactly, is to be able to put in note of weapon additional parameter.
For exemple: if a sppecified variable = a specified value, then a spefic stat increate or decrease by a specific value.
exemple of a possible comment; <Change_Attack:77,4,5>
where 77 was the variable, 4 was the value, 5 was the change.
I will try to do something, but any help will be apreciate =:0)
A light way to do this is simply add the bonus number context to $dataWeapons.
PHP:
window.metaWeapon = $dataWeapons[5].note.split(":")[1].split(",");
for(var i = 0; i < metaWeapon.length; i++) metaWeapon[i] = parseInt(metaWeapon[i]);
$dataWeapons[5].name = "Sword2 +" + metaWeapon[$gameVariables.value(metaWeapon[0])];
$dataWeapons[5].params[2] += metaWeapon[$gameVariables.value(metaWeapon[0])]; // attack increase
Where 5 is the Id. I'm not sure how to plugin this because I only did one weapon, so I simply called it by event script. You'll probably want to plugin it.

If gameVariable 77 is going to be 1,2,3,4 then you can use that to reference a meta array of five.
Screen Shot 2017-02-23 at 11.43.02 PM.png

Where Sword2 has an average attack of 26, when gameVariable 77 is 1 it will show this in status.
Screen Shot 2017-02-23 at 11.42.19 PM.png


And then of course the attack plugin is still slightly the same.
PHP:
Game_Action.prototype.executeHpDamageCached = Game_Action.prototype.executeHpDamage;
Game_Action.prototype.executeHpDamage = function(target, value) {
   if($dataActors[this._subjectActorId] !== null) {
       if($dataActors[this._subjectActorId].equips[0] === 5) // id of day/night weapon
           value += metaWeapon[$gameVariables.value(metaWeapon[0])]; // variable of weapon increase
   }
   return this.executeHpDamageCached.apply(this, arguments);
};
A light way to do this is simply add the bonus number context to $dataWeapons.
PHP:
window.metaWeapon = $dataWeapons[5].note.split(":")[1].split(",");
for(var i = 0; i < metaWeapon.length; i++) metaWeapon[i] = parseInt(metaWeapon[i]);
$dataWeapons[5].name = "Sword2 +" + metaWeapon[$gameVariables.value(metaWeapon[0])];
$dataWeapons[5].params[2] += metaWeapon[$gameVariables.value(metaWeapon[0])]; // attack increase
Where 5 is the Id. I'm not sure how to plugin this because I only did one weapon, so I simply called it by event script. You'll probably want to plugin it.

If gameVariable 77 is going to be 1,2,3,4 then you can use that to reference a meta array of five.
View attachment 58664
Where Sword2 has an average attack of 26, when gameVariable 77 is 1 it will show this in status.
View attachment 58667

And then of course the attack plugin is still slightly the same.
PHP:
Game_Action.prototype.executeHpDamageCached = Game_Action.prototype.executeHpDamage;
Game_Action.prototype.executeHpDamage = function(target, value) {
   if($dataActors[this._subjectActorId] !== null) {
       if($dataActors[this._subjectActorId].equips[0] === 5) // id of day/night weapon
           value += metaWeapon[$gameVariables.value(metaWeapon[0])]; // variable of weapon increase
   }
   return this.executeHpDamageCached.apply(this, arguments);
};

I try to understand your solution. I get hard time trying haha. If I understand the first part, its like a manual way of doing it with a specific weapon right^ The comment box its exactly like I want it to be. But Its can be used for any weapon, not just a specific one^ And what will happen if I have many comment in my weapon(other plugging)^

Thanks for your help.

Original thread: https://forums.rpgmakerweb.com/threads/script-that-increase-stat-based-on-variable.75069/