Requesting a little feature for Vlue randomization script

HI

I'm using Vlue's weapon and armor randomization script in my game. Its a wonderful script, but I need a minor (hopefully its minor) feature added to it. I want to be able to select some affixes, which when spawned on a weapon or armor, it will choose a random name from a set pool. This way, it would be possible to generate items just like the rare items are generated in Diablo 2 and I'm sure a few other RPGs too. I would like to set two pools for names, one for prefixes and one for suffixes.

Heres an example:
Let's say we have a set pool of prefix names with words "Iron", "Jagged" and " Fire", and a pool of suffix names with words "Dog", "Cat" and "Night".
I want the 15., 23. and the 45. affixes to have their names randomly selected from the preset pool of prefix name, and 16., 34. and 67. affixes to have their names randomly selected from the preset pool of suffixes.
Now, a hand axe drops for the player. Vlues script randomly selects the 23. prefix and the 16. suffix for it. Now, because those two affixes were set to have their names to randomly select one from preset pools, the new hand axe's name will be "Jagged Night".

I hope its clear what I wrote. If not, just ask, I will try to explain it a little better.

Vlue weapon/armor randomization script
Correct me if I'm wrong, but are you trying to limit particular equipment to specific affixes, so that you can use them to create a randomized "name"? I presume that you would do that by leaving the equipment name blank and leaving the naming to the specific pool of affixes.

The best way I can see to do this is instead of having just armor affixes and weapon affixes, you would basically just need to create some sort of sub-categories for items like axes, swords, helmets, boots, and the like, while listing specific weapon ids in those categories. (Because having a pair of boots and a hand axe with the same name would be kind of strange)
Correct me if I'm wrong, but are you trying to limit particular equipment to specific affixes, so that you can use them to create a randomized "name"? I presume that you would do that by leaving the equipment name blank and leaving the naming to the specific pool of affixes.

Yes, that is correct. I will leave the names blank for some equipments, so it can be randomized.

The best way I can see to do this is instead of having just armor affixes and weapon affixes, you would basically just need to create some sort of sub-categories for items like axes, swords, helmets, boots, and the like, while listing specific weapon ids in those categories. (Because having a pair of boots and a hand axe with the same name would be kind of strange)

It can basically be done this way too, but in my opinion, having 10+ subcategories to randomly generate names for each separate category of equipments is not necessary. I think that having just only 2 categories, each separate for prefixes and subfixes with 50-100 possible words to create a random name is enough, it will have a pretty low chance to drop you 2 similar names. However, it will not be a problem if it's created for each subcategory of equipments as you mentioned, I can work with that too.
I'm a bit confused. If you change the names of the initial affixes, set their rarities, and whether they are prefixes or suffixes. Depending on how many prefixes/suffixes you plan to add plus the rarities you give them, if you have POOL_RARITY set to true, the chance that a player would receive a blank item is close to none.

That is unless you want to absolutely guarantee that every specific item will have exactly 1 prefix and 1 suffix. In which case, larger changes will probably be needed.
I have multiple types of item rarities: poor, common, uncommon, etc. For each equipment type, i created duplicates of them in the database, for each rarity i have. In this exaple lets say 3: common, uncommon and rare. Thats 3 daggers in the database. As for the affixes: affixes 1-10 are prefixes for common quality of the dagger, affixes 11-20 are suffixes for common quality of the dagger, affixes 21-30 are prefixes for uncommon quality of the dagger, etc, you get the idea. So if lets say a want a rare dagger for the player to drop, i will give the player the third dagger, which will have only the affixes 41-60, which will guarantee me that it will be with the randomized names.
For that, I think it would only take a few small changes in this area here.

Spoiler
Code:
 def edit_affixes(item, subnote = nil)
    note = item.note.clone
    note = subnote.clone if subnote
    affix_pool = []
    while note.include?("<SUF")
      id = note =~ /<SUFFIX(\d+) (\d+)>/
      if !POOL_RARITY
        if !AFFIXES[$~[1].to_i].nil?
          break if add_affix(item, $~[1].to_i, false) if rand(100) < $2.to_i
          note[id] = "N"
        else
          msgbox("Affix #" + $1 + " doesn't exist. \nItem creation failed.")
          return

It's here that the affix for the new item is determined, however you'd need a way to distinguish the rarity affixes from the actual effects. If an arbitrary number was set, (1 for common, 2 for uncommon, 3 for rare) then you could keep the loop active until it hit a particular id number.

For example, if the item had a rarity affix value of 1, you could restrict it so that the loop will only break if the id of the effect affix is less than or equal to 10. if it had a rarity of 2, break the loop only if the id was more than ten, but less than 30. I think you can see where this is going.

Something like this would produce the desired effect so that you won't ever find a dingy rusted blade of legend and destruction.
Thank you, I will try to make the small changes to it when I get home from the work. But I still need the name randomization :LZYsmile:

But will that work even if I have odd numbers for each rarity affixes? Meaning like 18 for poor quality, 23 for common and say 37 for rare?
The numbers for the rarity affixes don't actually matter, you can make them whatever you want based on how many names you actually have. It's just preventing affixes you don't want from showing up, but you need to make sure POOL_RARITY is set to true, because that's what begins the loop. As said in the directions up top, POOL_RARITY gives every affix a chance to appear, which gives a more accurate percentage based way of defining drops. We're just making it so that depending on the rarity, not every affix will appear, just the ones you set the guidelines for.
Ok, but where do I define the names? I dont want the items to have the names of other affixes, I want the rare items to have just the names randomly selected from a totally different pool of names.
You define the names in the same place as you normally would. Make affixes 1-20 names you want for poor rarity, 21-40 for uncommon, 41-259 for rare, substituting the numbers for whatever you want. The names will all be in the same pool, but we're just sectioning parts of it off to make the names specific to the rarities. Using the numbers from earlier, if the quality value is 1 (poor) break the loop only if all the affixes have an ID of 1-20. If the quality is 2, break it if all the affixes have an ID of 21-40. If 3, break only for IDs 41-259. That way, the names will be rarity exclusive, without having to create a whole bunch more pools.
Ok, but will it work that way only for the rare items, because I want the randomized names only for the rare items. For the others, I want the names to be which I set for the affix. I imagined it doing something like this:

Somewhere in the beginning of the script: Prefixnames = "Little","Big","Huge"
Suffixnames = "Apple","Pear","Cherry"

Then, when I set affixes:


15 => { :name => " of Piety", :Smdf => 1,
:features => [[21,5,1.25]] },
16 => { :name => Prefixnames, :Sagi => 1,
:features => [[21,6,1.25]] },
17 => { :name => " of Luck", :Sluk => 1,
:features => [[21,7,1.25]] },

Meaning, that the 16 Affix, when it drops on a weapon, it will randomly select one from the Prefixnames set in the beginning of the script, or something like this, I think, easy to do change.
Search this part of the script:
Spoiler
Code:
    if prefix && !affix[:name].nil?
      item.name = affix[:name] + item.name
    elsif !affix[:name].nil?
      item.name = item.name + affix[:name]
    end
Replace that part with this:
Spoiler
Code:
    case affix[:name]
    when Array
      anm = affix[:name].sample
      item.name = prefix ? anm + item.name : item.name + anm
    when String
      anm = affix[:name]
      item.name = prefix ? anm + item.name : item.name + anm
    end
Now you can set arrays for the :name option.
This means you can set it up like this, for example:
Code:
:name => ["Apple","Pear","Cherry"],
But you can also do what you wanted to do.
Make an array setting at the beginning of the script and add in all the names you want there. For example:
Code:
AryName = ["Apple","Peach","Cherry"]
After this, you can simply re-use this array for any :name option, just like this:
Code:
:name => AryName,
You can name that array setting however you want, just use something unique to avoid compatibility issues.
You can also make multiple of these array settings and use them the same way.

But I don't know if it's a good idea to just randomly name your equipment. From what I know, all equipment in Diablo get their name from their affixes plus their base names. The only exceptions are the rare items (forgot how they call that tier) and set items, but those got static names anyway, only their affixes may vary in some cases. I haven't played Diablo since... I don't even know how many years, so my memory may trick me here.
I can imagine getting a "Speedy Bow of Bloodlust" which only gives attack and defense, in which case the name doesn't fit at all. I mean, you can use meaningful names only for specific affixes, but isn't that the thing you normally do with this script anyway? And it's hard enough to memorize 100+ affix types, let alone doing that with 500+. 😀
Just wanted to share my view on this naming thing. 😛
This is from the diablo2 gamepedia page:

Rare Items (Diablo II)

Rare items are just that--higher in rarity than Magic Items, thus appearing less often. Rare items are denoted by their name being shown in yellow. Like Magic items, Rares have randomly selected magical attributes. The difference is, Rares can have 2 to 6 affixes to them. The two-word name added to a Rare item is randomly generated, and has no bearing on the affixes on it.

Meaning that even in the Diablo 2, the names of the rare items are randomly selected from a pool (in this case, from a txt file with words), just as I want. The blue colored magic items have the original prefix and suffix names for them, the others, the even rarer unique and set items have specific names to them.

Anyway, thank you, Sixth, I'm going to try it out.


EDIT: Tried it out, it gives this error when generating an equipment:

Script 'Game_Interpreter' line 1411: TypeError occurred.
can't convert Array into String
How did you setup your array setting and :name settings in the script?

Edit:
Nevermind that, I goofed a bit back there. Fixed the replacement part in my previous post, so copy and paste it again where it belongs.
Thank you Sixth, it worked like a charm 🙂

One more request: Can you please make it compatible with your Negative Bonus Fix for Vlue's W/A Randomizer Sixth? When your Negative Bonus fix is installed too, it gives the previous "Game Interpreter cant convert Array into String" error too.

Link to Negative Stat fix
You can replace the same part in that script with the code I wrote above.
That script overwrites the method from Vlue's original script, that's why you have to do it there too.
Yep, worked like a charm, thank you Tehprince and Sixth for your help 🙂
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/requesting-a-little-feature-for-vlue-randomization-script.89272/