Need Negative Params akin to HIME_ElementNegation

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
So I've edited my rpg_objects.js to make both ParamRate and ElementRate calculate additively instead of multiplicatively by changing the following code from this:
JavaScript:
//Lines 2442-2444
Game_BattlerBase.prototype.paramRate = function(paramId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_PARAM, paramId);
};

//Lines 2466-2468
Game_BattlerBase.prototype.elementRate = function(elementId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
};
To this:
JavaScript:
//Lines 2442-2444
Game_BattlerBase.prototype.paramRate = function(paramId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_PARAM, paramId);
};

//Lines 2466-2468
Game_BattlerBase.prototype.elementRate = function(elementId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_ELEMENT_RATE, elementId);
};
The key difference is changing "Pi" to "Sum". Anyways, this part works fine, its only when I get to the editor do I need help. Basically, the editor is built assuming these are multiplicative, so it doesn't let you input negative values. I was able to circumvent this for ElementRate w/ HIME_ElementNegation, which lets me use notetags to give negative values. However, no such plugins exist for ParamRate. I've looked inside HIM_ElementNegation.js and it's super short, so I imagine it wouldn't be too hard to adapt it for ParamRate. I'm just not adept enough with JS to do so...

I've attached HIME_ElementNegation.js for convenience. Looks like I can't attach .js files, so here's the link instead.
Site: http://himeworks.com/2015/12/elemental-negation/
Direct: http://himeworks.com/redirect.php?type=mvscript&name=elemental_negation

If someone could create a similar plugin to allow me to use notetags to input negative values for ParamRate, that'd be much appreciated.

To clarify ParamRate is when you give ATK/DEF/MAT/MDF/AGI/LUK % to the traits section.

Edit: I've included Hime's plugin in this spoiler...
/*:
-------------------------------------------------------------------------
@title Elemental Negation
@Author Hime --> HimeWorks (http://himeworks.com)
@version 1.0
@date Dec 4, 2015
@filename HIME_ElementalNegation.js
@url http://himeworks.com/2015/12/elemental-negation/

If you enjoy my work, consider supporting me on *******!

* https://www.*******.com/himeworks

If you have any questions or concerns, you can contact me at any of
the following sites:

* Main Website: http://himeworks.com
* Facebook: https://www.facebook.com/himeworkscom/
* Twitter: https://twitter.com/HimeWorks
* Youtube: https://www.youtube.com/c/HimeWorks
* Tumblr: http://himeworks.tumblr.com/

-------------------------------------------------------------------------------
@plugindesc Allows you to specify negative element rates, which will negate
the damage or recovery of elemental skills.
@Help
-------------------------------------------------------------------------------
== Description ==

Element rates determine the multiplier effect on skill or item damage.

For example, if you have 200% element rate towards fire, any fire damage
inflicted against you will be 200% effective, or double the damage.

Similarly, if you have 0% element rate towards fire, any fire damage
inflifcted to you will be 0% effective, or result in no damage.

However, what happens if you have negative element rates? This means that you
will actually absorb the damage! -100% element rate towards fire would mean
you would absorb all of the damage, while -50% element rate means you would
absorb half of the damage.

This plugin allows you to specify negative element rates.

== Terms of Use ==

- Free for use in non-commercial projects with credits
- Contact me for commercial use

== Change Log ==

1.0 Dec 4, 2015
- initial release

== Usage ==

Note-tag any objects that have traits with

<element rate: ELEMENT_TYPE, RATE% />

Where the ELEMENT_TYPE is either the name or the ID of the element, and
the RATE is a number.

For example, if the Fire element is ID 2 in your terms database and you want
to absorb 100% of fire, you can say either of the following:

<element rate: Fire, -100% />
<element rate: 2, -100% />

-------------------------------------------------------------------------------
*/
var Imported = Imported || {} ;
var TH = TH || {};
Imported.TraitValues = 1;
TH.TraitValues = TH.TraitValues || {};

(function ($) {

$.Regex = /<element[-_ ]rate:\s*(\w+)\s*,\s*(.+)%\s*\/>/img

$.loadElementMap = function() {
$.elementMap = {}
var elements = $dataSystem.elements;
for (var i = 1, len = elements.length; i < len; i++) {
var name = elements.toUpperCase();
$.elementMap[name] = i;
$.elementMap = i;
}
};

$.getElementId = function(name) {
return $.elementMap[name];
};

$.loadNegativeElementRate = function(obj) {
var res;
while (res = $.Regex.exec(obj.note)) {
var id = $.getElementId(res[1].toUpperCase());
var value = res[2];
trait = { code: 11, dataId: id, value: value / 100 }
obj.traits.push(trait);
};
};

DataManager.loadAllNegativeElementRates = function() {
$.dataLoaded = true;
var data;
var obj;
for (var i = 0; i < this._databaseFiles.length; i++) {
data = window[this._databaseFiles.name];
if (Array.isArray(data)) {
for (var j = 0, len = data.length; j < len; j++) {
obj = data[j];
if (obj && obj.traits !== undefined) {
$.loadNegativeElementRate(obj);
}
}
}
};
};

var TH_DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
var res = TH_DataManager_isDatabaseLoaded.call(this);
if (res && !$.dataLoaded) {
$.loadElementMap();
this.loadAllNegativeElementRates();
}
return res;
};

})(TH.TraitValues);
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
533
Reaction score
235
First Language
English
Primarily Uses
RMMV
With that plugin you don't set additive parameters as regular traits at all, so this mod probably becomes redundant:
JavaScript:
Game_BattlerBase.prototype.paramRate = function(paramId) {
    return this.traitsSum(Game_BattlerBase.TRAIT_PARAM, paramId);
};
The plugin is effectively implemented as a permanent buff/debuff.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
Nvm, that plugin only modifies the parameters by integers, I need it to add/subtract by %...
Can someone modify that plugin to make it % instead of flat #?
JavaScript:
/*:
@plugindesc [v1.0] Adds a trait that adds to a parameter instead of multiplying it
@author Solar Flare Games

@param traitId
@text Trait ID
@desc The ID of the trait for adding to a parameter. This exists to resolve plugin conflicts.
@type number
@min 100
@max 999
@default 100

@help

This adds a fixed amount to a parameter, instead of multiplying the parameter.

<add_xxx:4> (anything with traits)
  Adds 4 to parameter xxx (for example atk, mhp, or def).
  Can also be a negative number.

*/

(function() {
    const TRAIT_PARAM_PLUS = Number(PluginManager.parameters('SFG_ParamAdd').traitId) || 100;
    const params = ['mhp', 'mmp', 'atk', 'def', 'mat', 'mdf', 'agi', 'luk'];

    const parseParamAdd = function(obj) {
        if(!obj || !obj.meta) return;
        for(let param = 0; param < params.length; param++) {
            let value = Number(obj.meta['add_' + params[param]]);
            if(value) {
                obj.traits.push({
                    "code": TRAIT_PARAM_PLUS,
                    "dataId": param,
                    "value": value,
                });
            }
        }
    };

    var old_startup = Scene_Boot.prototype.start;
    Scene_Boot.prototype.start = function() {
        old_startup.call(this);
        for(var i = 1; i < $dataStates.length; i++) {
            parseParamAdd($dataStates[i]);
        }
        for(var i = 1; i < $dataActors.length; i++) {
            parseParamAdd($dataActors[i]);
        }
        // These already offer additive parameters so not much point, but what the heck, can't hurt
        for(var i = 1; i < $dataClasses.length; i++) {
            parseParamAdd($dataClasses[i]);
        }
        for(var i = 1; i < $dataWeapons.length; i++) {
            parseParamAdd($dataWeapons[i]);
        }
        for(var i = 1; i < $dataArmors.length; i++) {
            parseParamAdd($dataArmors[i]);
        }
        for(var i = 1; i < $dataEnemies.length; i++) {
            parseParamAdd($dataEnemies[i]);
        }
    };
 
    const old_paramPlus = Game_BattlerBase.prototype.paramPlus;
    Game_BattlerBase.prototype.paramPlus = function(param) {
        return old_paramPlus.call(this, param) + this.traitsSum(TRAIT_PARAM_PLUS, param);
    };
})();
Or if we make a new plugin based on Hime's Element Negation, I believe we mostly need to change:
Code:
//line 100
      trait = { code: 11, dataId: id, value: value / 100 }
//to something like this...
      trait = { code: 21, dataId: id, value: value / 100 }
But it's all the other stuff, mostly the parts the refer to other code that I don't know how to adapt.
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
533
Reaction score
235
First Language
English
Primarily Uses
RMMV
I guess if you change both instances of paramPlus to paramRate at the end of my plugin, that should do what you want.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,626
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
wut about old_paramplus? do I change that too?

Edit: Sweet! I got everything working as I intended, although I had to retain the changes to rpg_objects.js, or else it gives me different numbers than what I want. Anyways, thx!

Edit2: @Solar_Flare Btw, I wanted to ask...is there any situation where "Trait ID" in the plugin options be changed?
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
533
Reaction score
235
First Language
English
Primarily Uses
RMMV
wut about old_paramplus? do I change that too?
That's just a name. You can change it, but it won't make any difference. The only reason to do so would be for clarity.

Edit: Sweet! I got everything working as I intended, although I had to retain the changes to rpg_objects.js, or else it gives me different numbers than what I want. Anyways, thx!
The change to Game_BattlerBase.prototype.paramRate is almost meaningless if you're using my plugin exclusively, because you wouldn't have any TRAIT_PARAM traits so it would always return 1 (without the change) or 0 (with the change); and furthermore, with the mod I gave you for my plugin, it would never be called at all. If you're adding Parameter traits in the database, it won't go through my plugin at all. My plugin only works from the note tags.

Edit2: @Solar_Flare Btw, I wanted to ask...is there any situation where "Trait ID" in the plugin options be changed?
If you use another of my plugins that has a Trait ID parameter. (I think I haven't released any others yet though.) Or if some other plugin adds new traits in the same way.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,033
Messages
1,018,441
Members
137,820
Latest member
georg09byron
Top