[MV]Random Augments per Instanced item(Yanfly Item Core/Attachable Augments)

Hi!

Using these plugins:
http://www.yanfly.moe/wiki/Item_Core_(YEP)
http://www.yanfly.moe/wiki/Attachable_Augments_(YEP)

I want to make instanced items with random Augment slots. For example, I want the base item to have two Orb slots, with a chance of adding a third Orb slot.

I figured I need to use the <On Creation Eval> tags to do this. Now my idea was to have the Augment generation happen in these tags. Like...

Code:
<On Creation Eval>
- Random number between 1 and 10 (Math.random(0,10);
- If Math.random = 1
<Augment Slots>
Orb
Orb
Orb
</Augment Slots>
- Else
<Augment Slots>
Orb
Orb
</Augment Slots>
</On Creation Eval>

The problem is: I don't know how to write this in the RPGmaker(My head hurts even when I try to understand the math.random function...) nor do I know if this even would work!
Could anyone have a look at this, and help me with the correct input?


Thanks a bunch!!
Your problem here is that you can't use an if statement to optionally parse different sets of note tags.

<On Creation Eval> is the right note tag to be using to do what you want, but you'll need to look at the attachable augments plugin and determine what happens when it parses note tags for augment slots, and use those functions to add more.

After taking a quick look at a copy of the plugin I already have, it looks like something like this will work:
Code:
<On Creation Eval>
if (Math.random() * 10 >= 9){
item.augmentSlots.push("Orb")
item.augmentSlotEnable.push(true)
}
</On Creation Eval>
Thank you so much! It's working like a charm!

I did have another question..
These additional augments items are going to be a big find, so I wanted to give players a quick heads-up if they found one of those improved items. I figured boost counts wouldn't work(I read they can only be used if an item gets updated)so I resorted to prefixes/suffixes.

I dug into the code(Having your lunatic code as an example is super helpful!)and tried the following:

Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)

newItem.nameSuffix = 'Enhanced';
item.namePrefix = Empowered;
this.updateItemName(item);
this.updateItemName(newItem);
}
</On Creation Eval>

Note: I don't need both a prefix and suffix, I just wanted to see if either version would work.

Sadly, neither code is working, not by themselves as well. I don't understand what I'm doing wrong here. Did I pick the wrong lines from the .ys? Or aren't they supposed to be called this way?
Your tag is all over the place, alternating this, and item, and newitem. The reason we use item in my tag is because 'item' on the <on creation eval> function refers to the item being created. It looks like the new functions you're using are from ItemManager, which 'this' is referring to, in what you pasted. You're on the right track though.
Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)

ItemManager.setNamePrefix(item, "Enhanced");
ItemManager.updateItemName(item);
}
</On Creation Eval>
Basically the function you found was meant to be called from ItemManager, not from the item's notetag, so we have to call ItemManager instead of 'this' (because 'this' is not the ItemManager object).
Looking at the function, we can update the name of the item without wasting an augment slot, or whatever just by calling the functions that change it's name directly, where 'mainItem' in the original function was a variable set by the function, we can just directly feed it the item itself, and we don't bother declaring a string first for the name, just feed it one directly.
Hihi, I bet they are all over the place. It's nice to know I was at least on the right track 🙂

Thank you so much.
The code doesn't seem to work, however. The name doesn't get updated whenever an item gets more augment slots. I tried a couple more things, but none of them seems to work.
If it's easier, a +1 boostcount or another color would be perfect as well, instead of an added prefix/suffix
Well, I'm not sure why it doesn't work that way, so the set up or the update functions must be checking to see if any of the already applied augments have a prefix name, and clear what we did.

What we can do instead is rename the item directly:
Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)

item.name = item.name + "+"
}
</On Creation Eval>
That's going to give the item a + at the end of it's name, and should bypass the augment system entirely to do so. You could also add something to the beginning instead, any old string will work.
Sadly nothing seems to be working. I tried diving into some other options, like changing the colors. I can change the colors with the notetag(<Text Color: 3>). Obviously, when I tried to use this in the notetag, it simply changed the color of every armour piece regardless.

I tried the following, which also didn't seem to work.

Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)

obj.textColor = parseInt(RegExp.$1);
}
</On Creation Eval>

As this was the only mention of changing text colors I could find. I replaced the RegExp part with a number, similar to the parseInt part, but nothing seems to work.

What I'm trying to say is, I'm totally happy if it'd be the item color that changes, if nothing else works ahah..

- Thank you so much for spending time on my query 🙂
Sadly nothing seems to be working. I tried diving into some other options, like changing the colors. I can change the colors with the notetag(<Text Color: 3>). Obviously, when I tried to use this in the notetag, it simply changed the color of every armour piece regardless.

I tried the following, which also didn't seem to work.

Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)

obj.textColor = parseInt(RegExp.$1);
}
</On Creation Eval>

As this was the only mention of changing text colors I could find. I replaced the RegExp part with a number, similar to the parseInt part, but nothing seems to work.

What I'm trying to say is, I'm totally happy if it'd be the item color that changes, if nothing else works ahah..

- Thank you so much for spending time on my query 🙂
I think what you've done might work if you use 'item' instead of 'obj', and give it a number instead of the Regular Expression. But the main problem we seem to be having is that most things we've tried to modify the item directly haven't worked. It doesn't make sense that we could push new values to the augment arrays, but not modify the item's name directly, so I suspect whatever is causing that to not work is also causing us to be unable to directly modify properties on the items.

I had a super janky workaround in my own project, where I called a function to directly apply an augment to an item if it was made in the crafting scene, to ensure that the created item appeared different. It used all the standard augment note tags, so there was none of this unsupported note tags 'hacking' to get it to work, either:
Code:
<On Creation Eval>
if (SceneManager._scene.constructor.name == "Scene_Crafting"){
 ItemManager.checkIUSEffects(item, $dataItems[101])
}
</On Creation Eval>

So if we look at that, I'm applying an augment item (101) to this item on creation in the crafting scene. This code works, I've been using it successfully for months, so we should be able to use it on your item in addition to what we already have:

Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)
ItemManager.checkIUSEffects(item, $dataItems[X])
}
</On Creation Eval>
Then we just need to make an augment item in slot X, and put a name change or text color update in it. Because we're not actually attaching an augment item, it doesn't use a slot, and should still successfully add the augments we need. For reference, my augment item has this note tag:
Code:
<Upgrade Effect>
CURRENT: +2
Reset Boost Count
Text Color: 29
</Upgrade Effect>
Yours should just suffice by changing the color.
Isn't that the upgrade function instead of augments? 😀
Nevertheless, it's working! This is great, I can do a lot more using this method if I wish to 🙂

Thank you so much! I mean it, I've been messing around with this for so long now haha
I think what you've done might work if you use 'item' instead of 'obj', and give it a number instead of the Regular Expression. But the main problem we seem to be having is that most things we've tried to modify the item directly haven't worked. It doesn't make sense that we could push new values to the augment arrays, but not modify the item's name directly, so I suspect whatever is causing that to not work is also causing us to be unable to directly modify properties on the items.

I had a super janky workaround in my own project, where I called a function to directly apply an augment to an item if it was made in the crafting scene, to ensure that the created item appeared different. It used all the standard augment note tags, so there was none of this unsupported note tags 'hacking' to get it to work, either:
Code:
<On Creation Eval>
if (SceneManager._scene.constructor.name == "Scene_Crafting"){
 ItemManager.checkIUSEffects(item, $dataItems[101])
}
</On Creation Eval>

So if we look at that, I'm applying an augment item (101) to this item on creation in the crafting scene. This code works, I've been using it successfully for months, so we should be able to use it on your item in addition to what we already have:

Code:
<On Creation Eval>
//Ty Lunatic Coder Ramza !!
if (Math.random() * 5 >= 4){
item.augmentSlots.push("Defence Tier 1")
item.augmentSlotEnable.push(true)
ItemManager.checkIUSEffects(item, $dataItems[X])
}
</On Creation Eval>
Then we just need to make an augment item in slot X, and put a name change or text color update in it. Because we're not actually attaching an augment item, it doesn't use a slot, and should still successfully add the augments we need. For reference, my augment item has this note tag:
Code:
<Upgrade Effect>
CURRENT: +2
Reset Boost Count
Text Color: 29
</Upgrade Effect>
Yours should just suffice by changing the color.
Hey guys,

Sry to jump into your thread. I have also been trying to have a system in my game where weapons and armor have a random chance to hold augment slots. So this thread was super helpful, thank you vert much.

I was wondering, instead of changing the weapon's name color when it gets augment slots assigned, is it possible to show a little icon or symbol next to it's icon or name?
Im thinking similar to how the Diablo games are handling it.

Appreciate any response, thank you.
Hey guys,

Sry to jump into your thread. I have also been trying to have a system in my game where weapons and armor have a random chance to hold augment slots. So this thread was super helpful, thank you vert much.

I was wondering, instead of changing the weapon's name color when it gets augment slots assigned, is it possible to show a little icon or symbol next to it's icon or name?
Im thinking similar to how the Diablo games are handling it.

Appreciate any response, thank you.
Can you not just add the escape code for an icon into the name of the item and have it do that?

Code:
\i[iconId]
That'd insert an icon into an item's name. replace iconId with the number of the icon to use.
Can you not just add the escape code for an icon into the name of the item and have it do that?

Code:
\i[iconId]
That'd insert an icon into an item's name. replace iconId with the number of the icon to use.
Hi ramza,
Thx for your answer.
Yes, I understand but the same weapon or armor would have a chance of either having augment slots or not.
So, what I am struggling with is how to add that icon to the item's name when a random augment slot is awarded, using the code provided above.

From my understanding the escape code I would have to add to the items name, meaning that every item would have the icon next to its name not only one that had augments awarded to it.

If there is a way to change the items icon via script call, I could potentially create a different icon for the same item with a little golden rune or something in the corner and change it to that icon when augments are awarded... gosh I hope that made sense 🙄
Something like this:

<On Creation Eval>

if (Math.random() * 10 >= 4){

item.augmentSlots.push("Rune")

item.icon = New Icon

}
</On Creation Eval>
You might find this useful perhaps. Allowing random prefix and suffix to items that you can setup to have their own traits to add to items. As well as changing the icons.


Spoiler: How it works
* If the base item is named "Sword", the prefix item is named "Strong"
* and the suffix item is named "Of Fire"
* You would get Strong Sword Of Fire.
* The new item have the traits of both prefix and suffix items and add their
* params. For example, if the prefix item has +10 ATK and the base item has
* +20 ATK, the new item wil have +30 ATK.
* Meta will be a combination of the prefix and suffix item meta, in other words,
* the notetags.
* Price will be the original plus the prices of the prefix and suffix item.
* Note will be the notes of the original, the prefix and the suffix items
* except that the meta and prefix notetag portions will be removed.

For example:

Step 1:
So you start with an item called Rune with these notetags:
<Prefixes>
10 25%
</Prefixes>
Item ID 10 has a 25% chance to apply its traits to the Rune item.

Step 2:
Then make whatever item ID you used above into a new item with the traits you want then give it notetags to edit the name/icon of the original item it's affecting:
<prefixSuffixName: Greater>
<OverlayIcon>
<Augment Attach Eval: Rune>
Slots: 0;
Eval: item.augmentSlots += 1;
</Augment Attach Eval: Rune>

Step 3:
You're done. Now give the player a way to get the augment. It should work as follows:

Rune augment item has a 25% chance to apply traits from Item ID 10.
Item ID 10 will add the suffix "Greater" to the Rune augment so it is now called "Greater Rune."
Item ID 10 will overlay its icon over the Rune augment so it will now have whatever icon you want overlayed on top of the original icon.
Item ID 10 will add 1 augment slot to the Rune augment so it will provide 1 more slot.


Some notetags from the plugin file:
Code:
<prefixSuffixReplaceIcon>
The new item will have the icon of the prefix/suffix item.
---
<prefixSuffixName:x>
The prefix/suffix item name when added to the new item will be x.
This is useful if you want to have a different name in the database.
---
<OverlayIcon>
This will allow the new item derived from this item to have its icon
overlay or by overlayed with another item. It must exist on at least two of
the following items when the new item is being made: the base item, prefix
item or suffix item.
---
<OverlayIconOrder: x> with x as the order. This will determine the order
in which the icons are overlayed. Lower values are placed first, with
higher values overlayed on top of those.

Original thread: https://forums.rpgmakerweb.com/threads/mv-random-augments-per-instanced-item-yanfly-item-core-attachable-augments.114887/