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.
An item may have at most one prefix and one suffix.
Script: download here
Required: Instance Items
- Selchar’s Random Equip Affixes
In the script editor, place this script below Instance Items and above Main
Prefixes and Suffixes are created as Armors into your database.
- 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 a price increases the buy/sell value of the equip
Applying Placeholder Descriptions
Placeholder descriptions are special descriptions for your affixes. They allow you to add new text to an equip’s description without overwriting
the original description.
For example, if you add a prefix to an equip, you might want to show both the original equip’s description as well as the prefix’s description. To do this, use a special symbol: %s
The %s is the placeholder that will be replaced with the original equip’s description. So if you had a short sword with a description
Basic short sword.
and you had a prefix with the description
%s Adds fire elemental damage.
When the prefix is added to the short sword, the short sword will now have the resulting description
Basic short sword. Adds fire elemental damage.
For a more detailed description, take a look at this tutorial.
Note that if you would like to use regular % sign in your description, you must write %%.
Setting affixes to your equips
To set prefixes or suffixes, use the script calls
set_prefix(equip, prefix_id) set_suffix(equip, suffix_id)
Where the equip is an RPG::Weapon or RPG::Armor object, and the ID is just the ID of the affix in your armor database.
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:
I know this script hasn’t received much activity, but I am still using VX Ace and would appreciate any help you could give!
Update: I rescind the statement about sometimes being able to load. I don’t know why I was able to once, but I now cannot load at all. Please help!
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)”
Do you have percentages in your name or description? If you do, you will need to write %% instead of just %.
This did the trick! Thank you so much!
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.weapons, 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.
What are you trying to do?
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!)
to be more specific, the random affix script, along with yours, works great, I just can’t get the affixes to rename the item correctly.
Nevermind, scripts were not in correct order, I suck.
Unfortunately script order makes a big difference. I would prefer that it didn’t but haven’t found a way to get around it!
Is there any way I can use a script Conditional Branch simply to check whether a prefix exists on equipment? I absolutely cannot figure out how to do that.
The closest I can figure so far is:
but that doesn’t work at all. Any help is appreciated.
For reference, variable 12 is simply storing an actor id and can just be considered ‘x’ or whatever.
Context is checking in a common event whether or not the weapon has a prefix before applying one or displaying a ‘impossible’ message.
Any help is greatly appreciated.
Try checking if it’s 0. A prefix ID of 0 means there is no prefix.
Thanks for the tip (makes sense to do it that way), but that’s not where the problem is.
The console is giving me
“Game_Interpreter:450:in ‘eval’: undefined method ‘prefix_id’ for nil:NilClass (NoMethodError)”
I’m not sure if that helps at all. I can try and provide any other information if you need it.
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(Long Sword, 302)
I am sorry if this looks retarded as I am new to scripting. Here’s my database values:
Prefix: “Disrupting” armor_id: 302
Weapon id: 2
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
$data_weapons is an array that represents the weapons database. You can use
to reference the weapon with ID 2. So the script call would be
hello! I am sorry but I can’t get it to work.
what should I write instead of equip, exactly?
I mean how could I set a suffix to a weapon in my inventory?
You need to get a reference to the weapon and then replace
equipwith that. I don’t know how you are planning to get the weapon.
I referenced the actors’ equipped weapons in the end.
Just use that reference in place of
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.
Are you using any custom victory message scripts?
By default it displays what you obtain, but I’m assuming that the random affix is selected AFTER the message has been shown, which might be why it is not displayed.
Mm, yeah. Neon Black’s Grade System, found here: http://forums.rpgmakerweb.com/index.php?/topic/3439-grade-victory-screen/.
But I also have no feasible way (unless I am missing something) to immediately tell the player what they might have found in a chest or something, seeing as how that is a message I have to write in myself.
Yes, there is no easy way to retrieve the item that you just received.
For this, I would use script calls. For example, suppose you want to give one instance of weapon 12
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.
Sweet. Daunting, when considering my idea to randomize all my loot, but…sweet nonetheless. Thanks
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.
“A simple sword.
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?
Can you provide an example of how you are planning to use those conditions?
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.
Although making all those affix properties for all those different pieces of equipment sounds overwhelming, so maybe your original idea is better. Hmhm.
Besides weapons and armours, would be possible to add affixes to regular itens (like, to create different kinds of minerals, gems, etc)
It could be done (fairly easily as well, based on the existing weapon/armor implementation), but let's see if someone else wants to try to implement it.
I would encourage you to make the request on one of the forums.
With items, you don't have access to params. The way the affixes are designed is specifically for equips (so "equip affixes" likely would have been a more suitable name).
Actually I might change the name of the script in that case, since an "item affix" script would be for (usable) items…
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?
Ok I don't know what I'm not getting.
— Creating affixes —
Prefixes and Suffixes are created as Armors into your database.
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)
Where the equip is an RPG::Weapon or RPG::Armor object.
Sorry I Think I'm starting to be a bother
I'm an Idiot XI
Nver mind i saw your point dont reply O.o
Actually please do tell me where the script call is to go.
My i have a little question. I wanted to use a gems for adding affixes.
For example: Gem of Power would add +15 ATK and a preffix "Powerfull" or something else. How could i solve this? I have no idea.
You would need to figure out how to use a gem to modify an equip, but for the most part you would just check what gem you're adding and what prefix to add to the equip using script calls.
Thanks for the fast answer
Your script call will not work or?
I can't test it this week.
The script call only sets the affix. You need to figure out how to use it because it doesn't know what you want to actually add.
Question: If I make say the fiery stat above it does not seem to show on the item. ie hand axe plain atk pwr 12 fiery hand axe shows atk pwr 12. Is the stat working but hidden?
The stats should be visible since the equip's stats are re-calculated. Presumably you're not simply modifying the name of the equip, since that doesn't do anything.
lol was script order thing . Working perfect now :-). My script writing head took a lunch break. lol Thanks for making me kick it into gear.
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?
if prefix?($game_actors.equips, 63)
Your help is appreciated as always.
You can access an equip's prefix using
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.
When an affix is attached to an equip using
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.
You should check whether the note-tag exists on the equip.
I think I get it.
I've been setting the affix using:
Instead, I should use:
$game_actors[x].equips[y].prefix_id = z
to ensure the note tags from the affixes get transferred.
Thanks for the tip.
There should be a note in the script if these methods achieve different results.
Thank you for the help.
Actually that's what set_prefix does.
I have in the use the neccesary scripts and I have the random affixes implemented and are working fine, just not quite how I would like.
It kinda does what I want thus far, because every time a weapon or armor is found from a chest or dropped or stolen from an enemy a random affix and suffix are applied and stats changes are in effect.
My problems are these.
I want the ATK parameter and Elemental Atk changes to only appear on my weapons.
2..I want the DEF parameter changes and Elemental Def to only appear on my defensive gear.
How would I go about having it so is it a simple scripting change? I am still new to this scripting format and its syntax.
There is no such thing as "elemental atk feature"
For params, there is a method called “apply_prefix_params”
Instead of just adding everything, you need to be selective about it
You should do this for suffixes as well.
Heya. Would it be possible to instead of adding on words, to change the color of the item's name (in vein of item qualities in Diablo, for example)?
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.
I don’t understand how you would use a crafting system to add affixes though.
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.
What i would do for the crafting would be to have prefixes named after the material of what your craftig like ‘Iron ” or ‘Mithril ‘
May I suggest an addition?
It would be nice to have the instance item also inherit the affix’s notes.
This would greatly promote synergy with other scripts that work with notetags.
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 don’t know if that would happen in a legitimate use case though.
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, 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 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.
That would depend on how sophisticated you want your crafting system to behave. If you want a full crafting scene with custom UI, you will need to request a script that will do that.
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 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
Someone’s been making use of my instance items script so it’s gotten some productivity.
Nope. However, at this point, it is not very easy to use. Other scripts will be needed to make it easier for your to apply affixes to your equips.