- 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):
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.
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>
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.
