RMMV YEP_X_EquipRequirements - Need Help...

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,519
Reaction score
1,110
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,059
Reaction score
1,483
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,519
Reaction score
1,110
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,059
Reaction score
1,483
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,519
Reaction score
1,110
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,059
Reaction score
1,483
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,519
Reaction score
1,110
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,059
Reaction score
1,483
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

All of the auditions for our game are so good, I'm so glad I'm not in charge of choosing completely. lol I just can't with some of them. I listen to them on repeat. XD
Working on a Patch to integrate AlphaABS into random generated Dungeons. Was a bit tricky, but the outcome is a real Life Changer!!

Will release it the next days!
Been pretty busy... but I got a better headset for recording and listening today. Dad says that he'll consider taking me to Great Wolf Lodge for the first time once I finish summer classes (my final semester!) I'll be taking my plushie friends with me: Bendy, Lolbit, and Helen Henny. (I WUV PLUSHIES!)
SF_Monster3,4 added!


My only regret is the portal mirror effect is too subtle to show up in these GIFs. It probably just needs more sparkles. :LZSwink:

Forum statistics

Threads
105,649
Messages
1,015,285
Members
137,326
Latest member
tobirama
Top