Item Affixes

This script introduces the concept of “item affixes”. Prefixes and suffixes may be assigned to your equips to provide additional parameter bonuses or features.

For example, you might have a prefix called “Fiery ” that gives a +20 bonus to ATK and adds a fire elemental damage. When your Short Sword has this prefix, its atk power will be higher than regular Short Swords and will deal more damage to targets that are weak against fire.

You may also like...

91 Responses

I have 2 issues with the script.
1. If I set both prefix and suffix for an equipment, the prefix will be repeated. For example: “Sharp Sharp Short Sword of Knight” (equipment is “Short Sword”, prefix is “Sharp “, suffix is ” of Knight”)
2. I need a way to reset the item back to its original form (including name, description, params, features, etc.)

I love this script, but I sometimes cannot load my save file when its inventory contains an item with an affix. When I say “sometimes” I mean I can test the game, try loading it, and it crashes, but then after changing nothing I can try again and it will work, then the next time it won’t (the pattern isn’t exactly every other try). This is the error I am getting:

Script ‘Weapon Affixes (Hime)’ line 189: ArgumentError occurred.

malformated format string – %C

I know this script hasn’t received much activity, but I am still using VX Ace and would appreciate any help you could give!

Sorry for all of these messages: just got a new error in the same line while testing with a new save file. I don’t have any items with affixes in the inventory, and it came up with “too few arguments” instead of “malformated (etc)”

Maybe I look like a retard… But I don’t understand how to use this script. I’m referring to where I need to put the script calls. It’s kinda unclear to me. Also I didn’t understand the example of Instance Items… So maybe the problem is there. Or maybe not.

You could make the script calls in events. In order to reference specific equips, you would typically use another script to call the affix functions, or you could reference for example the weapon that an actor is currently holding.

eg: set_prefix($game_actors[1].weapons[0], 34)

Would set prefix 34 to actor 1’s first weapon (assuming one exists)

It isn’t necessary to understand what instance items are in this case.

I think I get it. But, there is a way to choose the weapon or armor or even the actor using the equip item to apply an affix? Sorry, I’m so skillful in Ruby as a golden fish in the middle of Sahara desert.

i’m a newb and just don’t understand something.. so, i’m using the random affix suggested by you, and it works, I can find two daggers, both with random affixes. It doesn’t apply the names of said affixes (fiery, icy) to the prefix of the “dagger” All the stats are right, all the scripts are right, i’m just not understanding how to add the prefix (or suffix) name to the instanced “dagger”. All I get is “dagger” but the description shows correctly (ex. a simple dagger infused with fire!)

Determine that the actor you have selected has equips. Maybe you are choosing an actor that does not exist, which causes it to be initialized and just happens to have no equips.
Your variable may be pointing to the wrong ID.

That’s actually correct (thought of it just before I saw your reply), I was going off the skill’s user instead of its target.
Anyway, it works now! Thanks a lot for your help. It took me forever to find a way to do what I want, and this is perfect.

I am actually really new to scripting so I am trying not to do too much crazy shit but I want to learn so here is my problem…
I have absolutely no idea how to “reference” a certain item when applying an affix. Here’s what’s I’ve tried:
set_prefix(Long Sword, prefix_302)
set_prefix(RPG::Weapon, 302)
set_prefix(Long Sword, 302)
set_prefix(RPG::Weapon, prefix_302)

To follow up with this, I really like the random affixes script that goes with this. I would still like an answer for the purpose of awards during quests such as earning a specific prefix/suffixed weapon or armor

I have a question involving this script. Would there be a way to show the player what they received from the monster they killed or the chest they looted or whatever? I am using random affixes, and what I’d like is that upon killing something, they know post-combat whether they have an Acidic Hand Axe or a Mighty Hand Axe, without having to look at their inventory. This way, they might be of a mind to either look, or ignore it.

The first three lines are the usual way for creating an instance and adding an item using script calls. The last line is the whole point of this: you have stored the name inside variable 14, so now you can use the \v message code to display the name in your message.

Alright, cool. Might get daunting if I decide to implement random loot, but I’ll cross that bridge when/if I come to it.

Question #2: Do parameter changes on affixes base themselves off the parameter changes of their host weapon, or the actor? Meaning.

If I had an Iron Axe that added 10 ATK, and a “Mighty” prefix that added 100% ATK power. I’d want this to mean a Mighty Iron Axe would add 20, making it better than a standard Steel Axe at 15 ATK. Should you find a Mighty Steel Axe, it would give you 30 ATK.

But, if the Mighty prefix would base its 100% ATK increase off an actor’s ATK stat, rather than change the ATK variance of the weapon, it would ruin that.

This script transfers features from the affix to the equip it is attached to and will not change the behavior. This means that a 100% ATK feature will apply to the actor, and not the equip, and unfortunately as you suspect it would not change the ATK of the weapon that holds the feature.

However, it may be possible to write an add-on that will tell the engine to apply features to items and not actors.

I absolutely love this script. Well, I love all of your scripts, and I’ve included more than a few in my current project. 🙂
I’m using this one with Selchar’s random add-on, and I was wondering if there was a way to add a line to the item’s description with the affixes. Like, say the item is a sword with the description “A simple sword,” but when it’s got the prefix “Dirty,” the text added to that prefix in the armor database would show up as a second line in the item’s description.
i.e.
“A simple sword.
Earth attack.”
It doesn’t actually have to be on a separate line. I’d just really like to add a bit to the descriptions with each affix, to make it’s effects clear. Would this be possible?

This is somewhat tricky to generalize because there are any number of ways a description could be modified: appending things, prepending things, modifying things, deleting things, etc. So this is what I’ll do: “format strings”. Here is an example of how it works:

Your sword has the description “A simple sword.” You create a prefix called “Dirty” with a description “%s Earth attack!!”. Notice the %s.

This tells the engine “take the existing description and substitute it here” The final description you get will be the combined

A simple sword. Earth attack!!

Now, you can chain this. Suppose you add a suffix with the description “My suffix description. %s” Now your final description will be “

My suffix description: A simple sword. Earth attack!!

Looks cool? It doesn’t support removing or modifying words but it’s halfway there.

What if I wanted to simply use conditional traits in order to give custom features to equipment based on what affixes they have, such as the condition:
if prefix != nil then prefix == “Fiery” else return false end
Is that possible?

I’m not sure if I plan to use this script or not, but if I did, instead of creating a piece of armor called “Blazing”, I’d, say, have it
so that affixes vary from weapon to weapon, say, with the blazing prefix, it multiplies the weapon’s ATK bonus by 10% and let’s say for an axe it gives x1.3% TP Charge to the wielder, for an arrow it gives the skill Phoenix Arrow, and for a shield it gives 40% Fire resistance. I would use the trait conditions and param bonus formulas for such. I was just asking if there was such a term to be used in a condition.

This script assumes that when you attach an affix to an equip, the affix will be attached to the equip's name and all of the properties transferred over.

It is possible to write an add-on that will allow you to attach an affix to an equip, but change how the properties are transferred based on a set of conditions.

The way I would implement this is to sort properties into different groups based on condition. One group might have the condition "wtype is axe", and so when the axe has this affix attached, it would pull all of the axe properties and ignore the rest.

Setting up the affix itself may be tedious but it would be a clean way to achieve what you want.
Issues that you would have to consider include how to convey this information to players.

Say if I named a affix corrosive and had 2 axes. 1 axe had no Prefix and the other
had corrosive. would the regular one strike an animation normally while I could
make the corrosive prefix change the animation to a deadlier animation?

Choose a name. You must manually add in the appropriate spaces before or
after the name so it will be displayed properly in the game
Choose parameter bonuses for your affix.
Choose feature bonuses for your affix

— Setting affixes to your equips —

To set prefixes or suffixes, use the script calls (I'm super confused why script call if
it could just go into the notes of the object. And where exactly do i put the calls?it go's where the equip is an RPG weapon. I lost myself and all sense in the script when I read this)

One thing I was hoping you could help with.
I'm trying to make affixes upgradeable.
I know I can just replace an affix with another one, but I need to know which one is on a given weapon at the time.
Is there a check for it?

Thank you for the quick reply.
I got everything working the way I needed to.

Now, I noticed something else that came up.

When I use an affix that attaches an armor with an effect requiring a note tag, the effect does not work.

I am currently using YanFly's Element Absorb and it seems to work fine, except when attempting to use the effects via this script.
Is there away around this issue that you are aware of.
If there is a script of yours available that will allow this effect and will work with your script, please let me know and I'll switch.

It calls a refresh method, where the parameters and features are transferred to the equip, as well as any note-tags. This is done because most scripts only check the equip, and do not care about the affixes, nor was I interested in patching every script to read an equip's affxes.

I’ll provide it as a separate script “Item Rarity Color” script where you tag items with certain rarities and you assign a color to each rarity level.

An add-on will then be written for affixes so that the item’s rarity is either the max or the sum of the rarities of all its parts. So for example if a “Short Sword” has rarity of 1, but it has a prefix that has rarity of 3, then your sword would now have a rarity of 3 if you decide to take the highest, or a rarity of 4 if you decide to add them together.

Really great script, Hime! I am just having trouble on using it, pretty much as Dugald was. I’m looking out for a system that allows me to work with forging, a similar one to the Dark Souls (PS3 game) system. I found this script:

And was using it in my project. Your affixes, however, are the perfect complement, so I don’t need to build 999 new weapons and 999 armors. It’s just an idea, please don’t understand it as laziness by my part, but you could build an add-on based on that script. It would be a really complete and interesting crafting sys. Some script comments are in portuguese, I’m brazilian, if you need any help with translation, call me out. Of course I’ll understand if it’s not possible, so I already thank you for your time.

Basically, forging an item (armor/weapon) with other items (shards, idk) will increase the first item’s powers. For example, crafting a ‘Short Sword’ with a ‘Ruby’ will result in a ‘Short Sword +1’. To obtain a ‘Short Sword +2’, 2 ‘Rubys’ and a ‘Short Sword +1’ will have to be merged. Gathering suffixes with prefixes, there are lots of combinations that can be build.

So your suffixes will simply be numbers, where a different suffix is attached to the equip that you are forging. I would consider looking for an equip upgrading script in that case, though this affix system definitely provides more control over what the bonuses are.

You should make a request on the issue tracker or the forums with details on how it should function and whether someone wants to do it before I get around to doing it (which I’m not sure when atm)

Numbers can be used in my case, but both affixes are useful. Let’s say that ‘+5’ weapons can be forged to ‘Fiery X’, and ‘Fiery X +10’ can be forged into new legendary items… the bonuses are contained into each affix, they just have got to be replaced, so there won’t be necessary to create 200 templates for a single weapon. I’m not a scripter, but I’ll look for it, as you said. Thank you!

I have not looked at the crafting system that you had referenced but the way I am thinking is that a “normal” crafting system usually requires you to specify the materials and the result. The result is typically a different item. My own add-on would introduce two options: prefix and suffix. Instead of specifying that you gain a new item, you simply specify an affix, and the script would know that you want to change the affix.

However, requiring a material with a specific affix is something to think about. For example, if you say that you need a Sword+1 and a ruby to create a Sword+2, you would need to somehow indicate that the weapon is a Sword and it has a +1 suffix attached to it.

I’ve updated the script so the equips inherit notes (basically adding them on to their own notes), but I doubt scripts are going to automatically re-parse the notes. At least, I know none of my scripts would, because I only load it once and then cache it for performance reasons.

Actually, I just got it working and it is as I thought – running the script makes all future instances of the item referenced that are added to the inventory have that affix. However, it appears that for some reason it is able to stack prefixes or suffixes multiple times – I just tested it out and ended up getting a weapon with the same prefix stacked onto it 10 times, and it appears that the prefix’s effects are able to pile up. Given what you said above about items being only able to have one prefix and one suffix there must be some glitchiness; is there a script call that can clear out the affixes assigned to an item?

Yes, I didn’t expect anyone to add a prefix or suffix to a template, although that is a perfectly legal use case I suppose. Basically, you added a prefix to a template, and then when an instance is created, it copies all of the attributes from the template (including the prefix), and then applies the prefix onto itself again.

However, another problem arises if I decide that templates should not have affixes: what if you want every instance to have the same affixes?

I can definitely see what you’re saying; it just seemed to me that the Instance Items and Item Affixes scripts are sort of designed to go together – to allow for a way to have a great degree of item customizability without requiring a staggering number of different items to represent all the possible combinations (which only so much of can be done anyway due to the database’s 999-item limit for each type of game object). Though from the looks of things, your work on these scripts is still in its early stages without much applicability yet, so I’ll shut up for now :p.

Instance Items is pretty much required for most of the equip/item related scripts unless you’re fine with just having at most one copy of any item throughout your entire game. Once you introduce two hand axes, you need a way to distinguish them. There have been several implementations, but I was not satisfied with any of them in various ways.

I’m probably not going to be making any scenes for these scripts so you should look for any request takers to tackle these problems.

So, otherwise, if you put, like in your example, $data_weapons[71], in the script and then ran the script through event code, it would make any weapon added to your inventory whose index number was 71 have that affix until the affix for that weapon index was changed by script again, and then future weapons of that index number would have the different affix? I’m mostly having a hard time figuring out how this script ‘targets’ a particular individual weapon or armor piece to modify.

$data_weapons is a list of all of the weapons in the game. My Instance Items script distinguishes between “template weapons” and “instance weapons”. by default, all of the weapons you created in the database are templates, and any weapons created in-game are instances.

For example, if your last weapon ID in the database was 60, then the first instance created is ID 61. If you pass this particular weapon to the script call, then that weapon will be given a prefix.

Because instance items are dynamic objects generated at run-time, you are unable to hardcode a specific ID in your event. Instead, you need to either use a script that will allow the player to choose a weapon, or use references like $game_party.leader.weapons[0] to modify the first weapon that the party leader is holding.

For the most part, this script provides the framework for affixes, but it doesn’t provide a lot of ways to use it that people could just plug into their project.

What you can do is search for a crafting script that you like and I could probably write an add-on for it that will provide affix-modifying functions.

The main way I was thinking of using it was in a sort of item crafting scenario – you choose what type of item to create and are able to spend additional optional materials (i.e. magical essences of various types) in order to add a prefix and/or suffix to the item, so I guess in this context, it would be adding prefixes and suffixes to an item you are about to receive through event code. Sorry, I’m not too up on RPG Maker’s scripting language just yet; I’ve been using RPG Maker products for the last 15 years but haven’t invested a lot of time in learning the scripting language since it’s somewhat newer to the product line.

This looks like a great script (as do all of yours), but I’m kind of fuzzy on what exactly you’re supposed to enter for the ‘equip’ space in the script call. Assuming you’re also using Instanced Items, how do you get it to target a particular instanced item in either the player’s inventory, a particular character’s equipment, or on an item that is about to be given to the player?

“equip” refers to an actual equip object. For example, assuming it exists, $data_weapons[71] would be a valid object.

The problem is that, as you have noted, it is not obvious how you are supposed to specify this. There are many different ways to do it, and I chose to simply provide the functionality required and the script calls to do so.

An obvious way is to provide a scene that allows users to choose which equip they want to modify. For example, if you were using some sort of upgrading mechanic.

However, not everyone wants that kind of mechanic, so I didn’t feel it was useful enough to create one. If you have a particular use case in mind I can consider how it might be done.

It seems pretty understandable to me~
This sounds great, Hime! I swear, every time I visit this blog I consider warping my game’s dynamics just to make use of the stuff I find here, lol. I can’t help it; this place begs for me to be irresponsible. Q.Q
Joking aside, I can see this being extremely useful in a game with alchemy at it’s core; or in an mmorpg type of thing, where finding weapons and armor was the standard rather than buying them. You’ve been on a roll lately~! =D

To create code blocks or other preformatted text, indent by four spaces:

This will be displayed in a monospaced font. The first four
spaces will be stripped off, but all other whitespace
will be preserved.
Markdown is turned off in code blocks:
[This is not a link](http://example.com)