quxios / QMV-Master-Demo

Master demo of QPlugins for RPG Maker MV
https://quxios.github.io/#/plugins
38 stars 71 forks source link

QParams - Bug using ratesFormula tag #25

Open Roguedeus opened 2 years ago

Roguedeus commented 2 years ago

qParam_bug_21_1012a

I can only imagine that no one has tried to use that note tag, because merely removing it from the trait object removes the error.

use in question is this, on a State.

<ratesFormula>
mcr: a._turnUsedBP * 1.5
</ratesFormula>

I realize you are not exactly active in the community at the moment, but this isn't a small bug. Nor one that I think I am easily able to isolate myself. As a matter of fact, I'm not sure whats going on there except that the trait object 23 is the SPARAM group, and MCR is in it.

Thanks for any time you can spare here.

Roguedeus commented 2 years ago

The problem appears to be this:

 * ============================================================================
 * ## Notetags
 * ============================================================================
 * We can modify all parameters (mv built in and custom ones) with some notetags
 * inside the Actor, Class, Equipment, Weapons, Enemies and State databases.
 * ----------------------------------------------------------------------------

States are supposed to be included in all Param and Rates formulas. But...

  var Alias_DataManager_extractQData = DataManager.extractQData;
  DataManager.extractQData = function(data, object) {
    Alias_DataManager_extractQData.call(this, data);
    if (data.qmeta['params']) {
      var value = QParams.stringToParamsObj(data.qmeta['params']);
      if (object === $dataStates) {
        QParams._states[data.id] = value;
      } else if (object === $dataWeapons) {
        QParams._equips.weps[data.id] = value;
      } else if (object === $dataArmors) {
        QParams._equips.armor[data.id] = value;
      } else if (object === $dataActors) {
        QParams._charas.actor[data.id] = value;
      } else if (object === $dataClasses) {
        QParams._charas.class[data.id] = value;
      } else if (object === $dataEnemies) {
        QParams._charas.enemy[data.id] = value;
      }
    }
    if (data.qmeta['rates']) {
      var value = QParams.stringToRatesObj(data.qmeta['rates']);
      if (object === $dataActors) {
        QParams._rates.actor[data.id] = value;
      } else if (object === $dataClasses) {
        QParams._rates.class[data.id] = value;
      } else if (object === $dataEnemies) {
        QParams._rates.enemy[data.id] = value;
      }
    }
    if (data.qmeta['ratesFormula']) {
      var value = QParams.stringToRatesForumlaObj(data.qmeta['ratesFormula']);
      console.log(object);
      console.log(value);
      var prop;
      if (object === $dataActors) {
        prop = 'actor';
      } else if (object === $dataClasses) {
        prop = 'class';
      } else if (object === $dataEnemies) {
        prop = 'enemy';
      }
      console.log(prop);
      console.log(QParams._rates);
      console.log(data.id);
      var curr = QParams._rates[prop][data.id] || {};
      QParams._rates[prop][data.id] = Object.assign(curr, value);
    }
  };

As you can see... $dataStates is not included in processing rates or rate formulas.

Roguedeus commented 2 years ago

The further I tracked this issue, the more it became obvious I'd be better off writing my own Plugin to do what I need.

It appears you never intended the plugin to allow States to do much, other than give main Param adjustments. Your SParam and XParam (plus) algorithms totally ignore States.

QParams, however, don't.

So, your note tag is erroneously suggesting all functions should apply to all trait objects.