Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // MalVarianceVZ
- // MalVarianceVZ.js
- // version 1.0b
- //=============================================================================
- /*:
- * @plugindesc Allows Actors, enemies, weapons, classes, armors and states to influnce damage variance independently.
- *
- * @author Maliki79
- * @param variDamageReversal
- * @desc If 0, will allow variance to go into the negative, converting damage to healing and vice-versa.
- * Else will set damage to 0.
- * Default: 1
- * @default 1
- * @help
- * Actor, Enemy, Class, Weapon, Armor and State Notetags :
- * <malvariP: integer, integer>
- * <malvariM: integer, integer>
- * <malvariC: integer, integer>
- *
- * Where integers are typically from lowest to highest.
- * Note that 100 is the normal damage.
- * The malvariP tag will affect all skill noted as Physical skills, malvariM, Magical and malvariC for Certain Hit skills.
- * Note that database items do NOT need to have all three tags. Any missing tags will default to 100% for their respective skills.
- * Only the FIRST tag listed per type on an object will have an effect.
- *
- * Examples:
- * Notetag: <malvariP: 100, 200>
- * Result: ALL physical skills from the applied user will have their damage adjusted by up to 100%
- *
- * Notetag: <malvariM: 10, 90>
- * Result: ALL magical skills from the applied user will have their damage adjust to between 10 and 90%
- *
- * Tags placed on equipment will each be taken into account as will tags placed on states that are present on the battler.
- *
- * Negative numbers can be used in tags. They will allow damage to potentially be a negative number.
- * The param variDamageReversal if set to 1, will reset the damage to 0, disallowing unintentional healing.
- *
- * Note that this plugin's filename must not be changed.
- */
- var Mal = Mal || {};
- Mal.VarianceParameters = PluginManager.parameters('MalVarianceVZ');
- Mal.Param = Mal.Param || {};
- //Mal.Param.allowRevesal = Number(Mal.DurabilityParameters['variDamageReversal']);
- var MalVariDatabaseLoad = DataManager.isDatabaseLoaded;
- DataManager.isDatabaseLoaded = function() {
- if (!MalVariDatabaseLoad.call(this)) return false;
- if (!DataManager._malVari_DatabaseLoaded) {
- this.processMalVariNotetags($dataActors);
- this.processMalVariNotetags($dataClasses);
- this.processMalVariNotetags($dataWeapons);
- this.processMalVariNotetags($dataArmors);
- this.processMalVariNotetags($dataEnemies);
- this.processMalVariNotetags($dataStates);
- DataManager._malVari_DatabaseLoaded = true;
- }
- return true;
- };
- DataManager.processMalVariNotetags = function(object) {
- for (var n = 1; n < object.length; n++) {
- var weaponset = [100, 100];
- var magicSet = [100, 100];
- var certainSet = [100, 100];
- var obj = object[n];
- var noteread = obj.note;
- while(noteread.indexOf("malvariP") > -1) {
- var notereg = noteread.split("<malvariP: ");
- var match = notereg[1].split(" ");
- weaponset = [parseInt(match[0]), parseInt(match[1])];
- noteread = noteread.replace("malvariP", " ");
- };
- while(noteread.indexOf("malvariM") > -1) {
- var notereg = noteread.split("<malvariM: ");
- var match = notereg[1].split(" ");
- magicSet = [parseInt(match[0]), parseInt(match[1])];
- noteread = noteread.replace("malvariM", " ");
- };
- while(noteread.indexOf("malvariC") > -1) {
- var notereg = noteread.split("<malvariC: ");
- var match = notereg[1].split(" ");
- certainSet = [parseInt(match[0]), parseInt(match[1])];
- noteread = noteread.replace("malvariC", " ");
- };
- obj._physVariance = weaponset;
- obj._magVariance = magicSet;
- obj._certVariance = certainSet;
- };
- };
- var MalVariActorSetup = Game_Actor.prototype.setup;
- Game_Actor.prototype.setup = function(actorId) {
- MalVariActorSetup.call(this, actorId);
- this.physVariance = $dataActors[actorId]._physVariance;
- this.magVariance = $dataActors[actorId]._magVariance;
- this.certVariance = $dataActors[actorId]._certVariance;
- };
- var MalVariEnemySetup = Game_Enemy.prototype.setup;
- Game_Enemy.prototype.setup = function(enemyId, x, y) {
- MalVariEnemySetup.call(this, enemyId, x, y);
- this.physVariance = $dataEnemies[enemyId]._physVariance;
- this.magVariance = $dataEnemies[enemyId]._magVariance;
- this.certVariance = $dataEnemies[enemyId]._certVariance;
- };
- var MalVariApplyVariance = Game_Action.prototype.applyVariance
- Game_Action.prototype.applyVariance = function(damage, variance) {
- var damage = MalVariApplyVariance.call(this, damage, variance);
- var newDamage = this.varianceEX(damage);
- return newDamage;
- };
- Game_Action.prototype.varianceEX = function(damage) {
- var damage = damage;
- var mode = 0;
- var min = 0;
- var max = 0;
- var diff = 0;
- var subject = this.subject();
- if (this.isPhysical()) mode = 1;
- if (this.isMagical()) mode = 2;
- if (this.isCertainHit()) mode = 3;
- if (mode == 0) return damage;
- //Basic calc of actor/enemy.
- if (mode == 1) {
- min = subject.physVariance[0];
- max = subject.physVariance[1];
- };
- if (mode == 2) {
- min = subject.magVariance[0];
- max = subject.magVariance[1];
- };
- if (mode == 3) {
- min = subject.certVariance[0];
- max = subject.certVariance[1];
- };
- if (min != 100 || max != 100) {
- diff = (Math.randomInt(max - min) + min) / 100.0;
- damage *= diff;
- };
- if (subject.isActor()) { //actor only calc of class and equipment
- if (mode == 1) {
- min = subject.currentClass()._physVariance[0];
- max = subject.currentClass()._physVariance[1];
- };
- if (mode == 2) {
- min = subject.currentClass()._magVariance[0];
- max = subject.currentClass()._magVariance[1];
- };
- if (mode == 3) {
- min = subject.currentClass()._certVariance[0];
- max = subject.currentClass()._certVariance[1];
- };
- if (min != 100 || max != 100) {
- diff = (Math.randomInt(max - min) + min) / 100.0;
- damage *= diff;
- };
- var equips = subject.equips();
- for (var i = 0; i < equips.length; i++) {
- var item = equips[i];
- if (item) {
- if (mode == 1) {
- min = item._physVariance[0];
- max = item._physVariance[1];
- };
- if (mode == 2) {
- min = item._magVariance[0];
- max = item._magVariance[1];
- };
- if (mode == 3) {
- min = item._certVariance[0];
- max = item._certVariance[1];
- };
- if (min != 100 || max != 100) {
- diff = (Math.randomInt(max - min) + min) / 100.0;
- damage *= diff;
- };
- }
- }
- }
- //Calc for Actor/Enemy States
- var states = subject.states();
- for (var i = 0; i < states.length; i++) {
- var item = states[i];
- if (item) {
- if (mode == 1) {
- min = item._physVariance[0];
- max = item._physVariance[1];
- };
- if (mode == 2) {
- min = item._magVariance[0];
- max = item._magVariance[1];
- };
- if (mode == 3) {
- min = item._certVariance[0];
- max = item._certVariance[1];
- };
- if (min != 100 || max != 100) {
- diff = (Math.randomInt(max - min) + min) / 100.0;
- damage *= diff;
- };
- }
- };
- //if(Mal.Param.allowRevesal != 0 && damage < 0) damage = 0;
- return damage;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement