YEP_X_AttachAugments -- Forcing Augments onto Weapons/Armors?

Status
Not open for further replies.

KoriCongo

Villager
Member
Joined
Jul 19, 2012
Messages
14
Reaction score
10
First Language
English
Primarily Uses
Hello! I was wondering if there was a way to force attach augments onto weapons and armors using Yanfly's Attach Augment plugin. I was trying to make cursed augments that would negatively impact weapons and items, as I wasn't satisfied with just simply restricting equipment onto the player.

I believe the process would go as simply as
1) Event starts
2) Event checks to see if actor has a weapon or armor equipped (I do not require looking for specific pieces of equipment, only that it is either a weapon or armor)
3) It adds an augment slot onto that piece of equipment
4) It creates the augment
5) It attaches onto the piece of equipment into the new slot
6) Augment effects activate

I can easily alter the effects of the augment, such as making it add/subtract stats, lock it in place, all that jazz. I would just like to know what coding that needs to be done or an entirely new plugin that needs to be made that would let me do this. Thank you for taking the time to read this.
 

KFDirector

Warper
Member
Joined
Mar 22, 2016
Messages
4
Reaction score
2
First Language
English
Primarily Uses
RMMV
This is an interesting problem and I'm certainly curious to know what kind of solution you can develop - while I'm not one for cursing gear, I feel like it would open up a lot of creative flexibility if you could impose augments by event.

My research to date has brought up this thread - that at least illustrates how to use js to push an augment onto an item (your Step 3-5, I think). However, they're working on a newly created item; what you'll also need is a way to find your candidate item and make sure you're scoped to it (your step 2). I'm curious myself what the proper way to do that would be.
 

Scatkat

Veteran
Veteran
Joined
Jan 26, 2014
Messages
32
Reaction score
38
First Language
English
Primarily Uses
Here's the function that applies augments to gear.
Code:
ItemManager.applyAugmentEffects(item, effectItem, slotId, gain);

So to apply augment (#52 in my item database) to the first augment slot in Actor 1's weapon we would use this:
Code:
ItemManager.applyAugmentEffects($gameActors.actor(1).equips()[0], $dataItems[52], 0, 1);

To apply augment (#65 in the database) to the second actor's second armor slot we'd use this:
Code:
ItemManager.applyAugmentEffects($gameActors.actor(2).equips()[3], $dataItems[65], 1, 1);

of course the equips() function depends on your 'Equipment Types' that you've set up in your database.

EDIT: MADE IT EASIER TO READ
 
Last edited:

KoriCongo

Villager
Member
Joined
Jul 19, 2012
Messages
14
Reaction score
10
First Language
English
Primarily Uses
Wow, that worked, thanks!
If I may ask, does the slotID run down the type of augment slot or all slots (By default, a weapon would have Glyph/Orb/Orb/Rune. So would slotID 1 be looking for a Glyph #2 or Orb #1?)?
And how would one use the same or similar method to remove augments as well?

EDIT: Well, I can at least answer my first question, doesn't seem to care the type of augment slot. Fair enough, isn't too much of an issue.

Figuring out Question #2 is the tough part.
 
Last edited:

Scatkat

Veteran
Veteran
Joined
Jan 26, 2014
Messages
32
Reaction score
38
First Language
English
Primarily Uses
My pleasure. Happy to help. Removing augments is a bit more work, so let's find the function that removes
them:
Code:
ItemManager.removeAllAugments(item);

We just need to pass in the item we want to remove the augments from. Something like:
Code:
ItemManager.removeAllAugments($dataWeapons[$gameActors.actor(1).equips()[0].id] );
for Armor we'd use
Code:
ItemManager.removeAllAugments($dataArmors[$gameActors.actor(1).equips()[3].id] );

This would remove all the effects that augments have from actor 1's weapon or armor. The augments, however, still exist equipped to the weapon, even though their effects aren't working on that weapon. Let's change that.

We'll make a variable to check how many slots our weapon has. I called it augmentSlots.
Code:
var augmentSlots = $gameActors.actor(1).equips()[0].augmentSlotItems.length;

Next, we'll make a for loop that sets all the augments to 'none' for each slot in the weapon.
Code:
for(i=0;i<augmentSlots;i++){
$gameActors.actor(1).equips()[0].augmentSlotItems[i] ='none';
}

And we're done!
So the script call would look something like this:
Code:
ItemManager.removeAllAugments($dataWeapons[$gameActors.actor(1).equips()[0].id] );
var augmentSlots = $gameActors.actor(1).equips()[0].augmentSlotItems.length;
for(i=0;i<augmentSlots;i++){
$gameActors.actor(1).equips()[0].augmentSlotItems[i] ='none';
}

EDIT: FIXED AN ERROR.
 
Last edited:

KoriCongo

Villager
Member
Joined
Jul 19, 2012
Messages
14
Reaction score
10
First Language
English
Primarily Uses
That one appears to destroy every augment slot on a weapon, making it so that you can't ever equip an augment on it again. It leaves the string "none" in the slot, instead of actually clearing the slot of an augment.

1590840131215.png

I would think the .removeAugmentFromSlot() function would be more effective in ejecting augments, but I wouldn't know how to use it like that.
 

Scatkat

Veteran
Veteran
Joined
Jan 26, 2014
Messages
32
Reaction score
38
First Language
English
Primarily Uses
Link me a picture of your script call.
 

Scatkat

Veteran
Veteran
Joined
Jan 26, 2014
Messages
32
Reaction score
38
First Language
English
Primarily Uses
Code:
Apparently, [i] is code for using italics in the forum coding, which messed up the code. Here's what the script call should look like:
Code:
ItemManager.removeAllAugments($dataWeapons[$gameActors.actor(1).equips()[0].id]);
var augmentSlots = $gameActors.actor(1).equips()[0].augmentSlotItems.length;
for(i=0;i<augmentSlots;i++){
$gameActors.actor(1).equips()[0].augmentSlotItems[i] ='none';
}
I'll change it in my previous post as well.

Also, I forgot about your step 2, so we have one more step to make before we're done.
We simply need to see if the actor has a weapon/armor equipped before we try to remove the augments from it. We can do this by using a conditional statement with our previous code:
Code:
if($gameActors.actor(1).equips()[0] !== null){
   ItemManager.removeAllAugments($dataWeapons[$gameActors.actor(1).equips()[0].id]);
   var augmentSlots = $gameActors.actor(1).equips()[0].augmentSlotItems.length;
      for(i=0;i<augmentSlots;i++){
      $gameActors.actor(1).equips()[0].augmentSlotItems[i] ='none';
      }
}
Just be sure to swap out $dataWeapons and $dataArmors depending on your 'Equipment Type.'

Alright, one last thing. If you want to be able to give the augment back to the player we need to edit God's...er Yanfly's code a little. If we open his YEP_X_AttachAugments.js file in notepad, we can find the function:
Code:
ItemManager.removeAllAugments = function(item) {
    var augments = [];
    this.checkAugmentSlots(item);
    var length = item.augmentSlotItems.length;
    for (var i = 0; i < length; ++i) {
      var augment = this.removeAugmentFromSlot(item, i);
      augments.push(augment);
    }
    return augments;
};
All we have to do is add one line to it:
$gameParty.gainItem(augment, 1);
So the function would look like this:
Code:
ItemManager.removeAllAugments = function(item) {
    var augments = [];
    this.checkAugmentSlots(item);
    var length = item.augmentSlotItems.length;
    for (var i = 0; i < length; ++i) {
      var augment = this.removeAugmentFromSlot(item, i);
      augments.push(augment);
      $gameParty.gainItem(augment, 1);
    }
    return augments;
};

I know this has been super long winded, but done correctly, it should work. Good luck!
 
Last edited:

KoriCongo

Villager
Member
Joined
Jul 19, 2012
Messages
14
Reaction score
10
First Language
English
Primarily Uses
Much better! It works like a charm! Thank you so much!
 

Scatkat

Veteran
Veteran
Joined
Jan 26, 2014
Messages
32
Reaction score
38
First Language
English
Primarily Uses
No problem. Hopefully it'll help others as well. :rock-right:
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,734
Reaction score
4,573
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

made a bio for the protag in my project!
Beggar : "I haven't eat for days..."
Kid : "Just do crime! You will get daily necessity for free in prison~"
Stream is a bit late but will be live shortly with some game development! Feel free to drop by!
omg, why persona 5 is so good?

Forum statistics

Threads
99,158
Messages
962,438
Members
130,725
Latest member
teendinsaikha
Top