[Question] YEP Equip Core - Conditional Stat Boosts based on Armor Type

Keystone

Warper
Member
Joined
Nov 6, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
I am trying to create a system where armors can get a "set bonus" of sorts when the user equips multiple of the same type. So for example, let's say we have a Helmet of Fire (Armor Type: Fire) which grants +2 DEF and a Tunic of Flame (Also Armor Type: Fire) which grants +5 DEF. If the user equips both, then they will get an additional +10 ATK on top of the +7 DEF from their default stats.

I feel like I'm close to figuring this out but I need some pointers on finishing up the code I wrote to achieve this. Here's what I have (Note: I am using Yanfly's Equip Core):

Code:
<Custom Parameters>
user.equips().forEach(function(item) { if (item !== null) { if (item.atypeId === 7 && item.id !== 4) { atk = 10; }}});
</Custom Parameters>
What this does is it parses through the user's equipment and checks the armor type ID of each equipment (in this case, the Fire armor type is ID = 7. Now, I don't want this to activate when I equip only one of the required items, so I am also checking to make sure the item.id is not the item this code is on, in this case the item that this script is attached to has ID = 4.

I don't like the fact that I have to hardcode the item.id check; I'd much prefer something like item.id !== this.id, but I can't do that since "this" refers to the actor equipping the armor, not the armor itself. I am curious to see if anyone can come up with a better solution than this.
 

Sakusphere

Warper
Member
Joined
Nov 12, 2018
Messages
1
Reaction score
0
First Language
English
Primarily Uses
RMMV
I hope this is what you were asking.
You should be able to compare the item to itself if you set the item to a variable prior to the start of the function. I modified it slightly to add attack for every piece so it was easier to verify how it took affect.

Code:
<Custom Parameters>
var checkUsingThis = item;
user.equips().forEach(function(item) {
  if (item !== null) {
    if (item.atypeId === 7
         && item !== checkUsingThis) {
      atk += 10;
    }
  }
});
</Custom Parameters>
I put this code on one piece of gear with armor type 7 then equipped it. My attack was not changed because the item === checkUsingThis. I equipped another 2 pieces with armor type 7 and my attack was increased by 20. When I removed the piece with this code, my attack went back to normal since it was the piece getting the attack bonus for having more of the armor type equipped.
 

Keystone

Warper
Member
Joined
Nov 6, 2018
Messages
3
Reaction score
0
First Language
English
Primarily Uses
RMMV
Yup, this is exactly what I was looking for! Thanks a ton!
 

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

Latest Threads

Latest Profile Posts

Here it is in all its leggy glory! I apologize in advance.
Suggestion for the name for the new RM, RPG Maker Re-MV (Re-Mastered Version)
A guide on Furry Potatoes.

I apparently need to send photo ID to Blizzard to change my phone number. I don't even need to do this to change my number with my bank or PayPal

Forum statistics

Threads
98,175
Messages
950,087
Members
129,473
Latest member
Soulbanana
Top