[Solved]State Category Rate?

For those people who made to much debuff state, and don't wan't to add state rates one by one, I think State Category Rate is a good idea. If you don't know what's that mean because my poor English or something, I'll explain for you.

First, we have State Rate, right?
and we have Yanfly's State Categories.
How about combine them?
Then we'll got State Category Rate!
We can make a poison rate that can effect on a lot of poison state, like Lv1 and Lv2. Or some debuff rates effect on states that lower your DEF and ATK.
*Bump*
bump again
3rd bump

jack2396, please do not bump your topic unless it has been 24 hours later since your last post. You can review our forum rules here. Thank you.



Note that we are 72 hours not 48 hours like most sites. I think you were going by 48 hours judging by your timestamps.
[bump]jack2396[/bump]

Note that we are 72 hours not 48 hours like most sites. I think you were going by 48 hours judging by your timestamps.

Sorry, I forget it. 🙁
Thanks for reminding me!
Not a problem. Too bad I have no idea how to make this plug-in, I never learned how to code JavaScript.
bump......
anybody here?
Hey there...

Couldn't test it properly and since I rarely work with javascript I hope I remember the function names correctly, but you could try this:
Spoiler
Code:
(function() {

var extractMetadataWithoutStateCategory = DataManager.extractMetadata;
DataManager.extractMetadata = function(object) {
   extractMetadataWithoutStateCategory.call(DataManager, object);
   object.stateCategoryRates = {};
   var regex = /<state category rate:([^,]*),([^%>]*)(%?)>/ig;
   var match;
   while ((match = regex.exec(object.note))) {
       object.stateCategoryRates[match[1].trim().toUpperCase()] =
           parseFloat(match[2]) / (match[3] ? 100 : 1);
   }
};

var stateRateWithoutCategory = Game_BattlerBase.prototype.stateRate;
Game_BattlerBase.prototype.stateRate = function(stateId) {
   var oldRate = stateRateWithoutCategory.call(this, stateId);
   var state = $dataStates[stateId];
   if (state) {
       var multiplyCategoryFunc = function(result, category) {
           var multiplyRateFunc = function(res, object) {
               var rate = object.stateCategoryRates[category];
               return (rate === undefined) ? res : res * rate;
           };
           return this.traitObjects().reduce(multiplyRateFunc, result);
       }.bind(this);
       return state.category.reduce(multiplyCategoryFunc, oldRate);
   } else {
       return oldRate;
   }
};

})();
You should be able to use
<state category rate: Category, Rate>
in your note fields (of any object that does also have traits) to set a rate for an entire state category. If it doesn't work I'll just have to look over it again... (or someone else who is faster) 😀
The rate can be a percentage or a decimal (1.0 equate to 100%).

Edit: Fixed an error.
Hey there...

Couldn't test it properly and since I rarely work with javascript I hope I remember the function names correctly, but you could try this:
You should be able to use
<state category rate: Category, Rate>
in your note fields (of any object that does also have traits) to set a rate for an entire state category. If it doesn't work I'll just have to look over it again... (or someone else who is faster) 😀
The rate can be a percentage or a decimal (1.0 equate to 100%).

Thank god and you, I knew that waiting is right!
But there are some errors......
I'm using chinese system so there are a lot of unicode......



EDIT: Nevermind! I fix it myself.

EDIT2: It looks like...... no effect......
I type <state category rate: Debuff, 0%> on a character, but every time he always got debuff!
Uh, right, forgot you had to bind functions in order to use "this"... Woops 😀
Tried to fix the error in the original post, but still can't test anything properly right now... Sorry. 🙂

In theory, the note tag should work for actors, classes, equipment, enemies and states (anything that also provides traits by default).
Uh, right, forgot you had to bind functions in order to use "this"... Woops 😀
Tried to fix the error in the original post, but still can't test anything properly right now... Sorry. 🙂

In theory, the note tag should work for actors, classes, equipment, enemies and states (anything that also provides traits by default).

It's not a big deal, thank you again for helping me.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/solved-state-category-rate.91003/