RMMV YEP_X_EquipRequirements - Need Help...

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,531
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
So I'm using Yanfly's EquipRequirements plugin and wanted to give weapons a "soft" Strength (STR aka ATK) requirement, which isn't too hard. However, I was wondering if it was possible to have it so that if the user's STR stat is lower than the required value, the difference would be deducted from the user's Speed (SPD aka LUK) stat. So if a Greatsword had a STR req of 25 but the wielder only has a STR of 20, the wielder would suffer a -5 SPD penalty. How would I implement such a mechanic?
JavaScript:
<Custom Equip Requirement Condition>
if (user.paramBase(2) >= 10) {
   condition = true;
} else {
   ???; //I need something here for the penalty mechanic
}
</Custom Equip Requirement Condition>
Edit: I just realized that maybe using <Custom Parameters> would be more appropriate. Thoughts?
JavaScript:
<Custom Parameters>
luk = user.paramBase(2) - "requirement"
</Custom Parameters>
I'm not sure the correct way to implement this though. How would I reference the weapon's STR requirement? Or can I use a conditional within <Custom Parameters>?

Edit2: Ok, I just tried the following, but it doesn't seem to be working. What am I doing wrong?...
JavaScript:
<Custom Parameters>
var weaponWeight = 10;
luk = user.paramBase(2) - weaponWeight;
</Custom Parameters>
Edit3: Nvm, I got it working by removing the var and hard coding a value.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,061
Reaction score
1,484
First Language
EN
Primarily Uses
RMMZ
Yep, looks like the <Custom Parameters> tag block from Yanfly's Equip Core is basically treated as an eval, i.e. any valid JS should work~ :kaothx:

I feel like you're trying to implement: "anyone can equip this, but they'll incur penalties if they're below the recommended stats". That sounds like you're removing equip requirements altogether, in which case the "requirement" you're seeking will just be a fixed number: 25 in this case, right? But you'll probably want to cap it at zero so the user doesn't get buffed by being overqualified, e.g.
Code:
luk = Math.min(0, user.paramBase(2) - 25);
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,531
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
I feel like you're trying to implement: "anyone can equip this, but they'll incur penalties if they're below the recommended stats".
Yes, that is precisely what I'm trying to do. I just called it a "requirement" even though I didn't mean it literally. Thanks for the Math.min idea btw!
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,061
Reaction score
1,484
First Language
EN
Primarily Uses
RMMZ
Just saw the second edit to your opening post...the code is correct, but it failed because of how Yanfly parses the notetag block: it looks for lines in the format "text: X" where X is an integer, and treats those as individual stat values (mhp, mmp, atk, def, etc) rather than evals...not sure why. :kaoswt2:

Good to hear you got it working, though; happy RPG Making! :kaojoy:
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,531
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
So I noticed something strange in regard to "paramBase". So let's say our Hero has 10 ATK and the weapon in question has a "soft req" of 15 ATK. This would result in -5 AGI (10 - 15). However, when I give our Hero some stat allocation and boost his ATK a bit (let's say to 15 ATK), there should no longer be an AGI penalty. Unfortunately, it doesn't seem like the +1 ATK gained from each repeatable stat boosts counts toward the Hero's "paramBase(2)"... The stat boosts are gained like so:

◆Control Variables:#0001 ActorID = $gameParty._targetActorId
◆Change Parameter:{ActorID}, Attack + 1
◆Change Skill:{ActorID}, - Boost Strength

The middle line is the part that actually increases our Hero's ATK. Why does this not count toward paramBase?

Edit: Damn, I think the stat boost counts as paramPlus and not paramBase. Hmm, I can't use paramPlus since that would include equipment as well...
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,061
Reaction score
1,484
First Language
EN
Primarily Uses
RMMZ
Yea, it's a bit awkward, paramBase is literally the stat value from their class at their current level. :kaoswt: To include the raw paramPlus bonus, as used by the Change Parameter command, I think you could do this:
JavaScript:
user.paramBase(2) + user._paramPlus[2]
To include the parameter rate (stuff like ATK * 50% traits) and buff rate as well:
JavaScript:
(user.paramBase(2) + user._paramPlus[2]) * user.paramRate(2) * user.paramBuffRate(2)
Here's some related methods for reference, but of course plugins can change/add to these:
JavaScript:
Game_BattlerBase.prototype.paramPlus = function(paramId) {
    return this._paramPlus[paramId];
};

Game_Actor.prototype.paramPlus = function(paramId) {
    var value = Game_Battler.prototype.paramPlus.call(this, paramId);
    var equips = this.equips();
    for (var i = 0; i < equips.length; i++) {
        var item = equips[i];
        if (item) {
            value += item.params[paramId];
        }
    }
    return value;
};

Game_BattlerBase.prototype.addParam = function(paramId, value) {
    this._paramPlus[paramId] += value;
    this.refresh();
};

Game_BattlerBase.prototype.paramRate = function(paramId) {
    return this.traitsPi(Game_BattlerBase.TRAIT_PARAM, paramId);
};

Game_BattlerBase.prototype.paramBuffRate = function(paramId) {
    return this._buffs[paramId] * 0.25 + 1.0;
};

Game_BattlerBase.prototype.param = function(paramId) {
    var value = this.paramBase(paramId) + this.paramPlus(paramId);
    value *= this.paramRate(paramId) * this.paramBuffRate(paramId);
    var maxValue = this.paramMax(paramId);
    var minValue = this.paramMin(paramId);
    return Math.round(value.clamp(minValue, maxValue));
};
...and here's the paramPlus method from Yanfly's Equip Core plugin, for comparison:
JavaScript:
Yanfly.Equip.Game_Actor_paramPlus = Game_Actor.prototype.paramPlus;
Game_Actor.prototype.paramPlus = function(paramId) {
    value = Yanfly.Equip.Game_Actor_paramPlus.call(this, paramId);
    var equips = this.equips();
    for (var i = 0; i < equips.length; i++) {
      var item = equips[i];
      if (!item) continue;
      value += this.customParamPlus(item, paramId);
      value += this.evalParamPlus(item, paramId);
    }
    return value;
};
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,531
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
@caethyril Out of curiosity, what's the difference between user._paramPlus[2] vs user.paramPlus(2)?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,061
Reaction score
1,484
First Language
EN
Primarily Uses
RMMZ
  • _paramPlus is an array of numbers. These numbers are altered by addParam (e.g. via the Change Parameter event command).

  • paramPlus is a method. For actors, it returns _paramPlus plus the stats from current equipment. Yanfly's Equip Core extends this method to account for the <Custom Parameters> notetag.
For details, see the first two methods in my previous post's "rpg_objects.js stuff" spoiler~ :)
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Evil7 added!


I did a bit of a remake on one of the maps, also I made a particle for jumping into the portal, and one for traveling through the portal. I'll probably add more sparkles later to embellish it. :LZSwink:
Polished the animation and added details :kaojoy:
Ami
What do you think about the Wood Bridge inside of Volcano?
Yet another gaming question, i'm currently playing Last of Us 2 and want to get another game to play next but can't decide between Ghost of Tsushima, Miles Morales & Jedi Fallen Order. After the latest mandalorian i AM on a star wars kick, but i also LOVED the last spiderman game that prequels Miles Morales. Ghost of Tsushima is the bottom of my list but i heard it was AWESOME. Just want a good story & fun gameplay.

Forum statistics

Threads
105,677
Messages
1,015,496
Members
137,353
Latest member
vongolavxv
Top