Fhizban 96 Posted July 1, 2014 (edited) Hi, First things first: This script was not written by me, it's a script by Galv. I got his permission to slightly modify and re-distribute the script with some minor adjustments. Original credit goes to Galv, I merely did some tiny changes. You can find the most recent script version (1.4) plus a updated demo project on my DropBox: https://dl.dropboxusercontent.com/u/18289607/RPGMakersScripts/Random%20Loot%20v1.4.rar The updated, 1.4 Version of the script (just the script) can be found on pastebin: http://pastebin.com/khU50cuy Important Note!The oder of function arguments changed from 1.1 to 1.2, you might have to re-order your script calls. Introduction This is a random loot drop script that lets the player find items according to a rarity system. It enables you to create random loot of different rarity levels without eventing/scripting endless loot tables. Instead of spawning item with ID X, this script spawns items according to their type (item, weapon or armor), family (scroll, potion etc.), rarity and player level restrictions. All in all very simple changes but it should do the job! Cheers -Fhizban (also known as Malagar) Version 1.2 Changes A. How the loot is selected has been altered a little bit by changing the starting item as well as the next item if the starting item is skipped due to some reason. With larger databases this caused the same item to drop over and over again, it also resulted into many "empty" treasure chests. This should be fixed now (my project uses several dozens of items with large spaces of padding between and the script works like a charm). B. I was not satisfied that you could only state to drop ITEMS, WEAPONS or ARMOR. There was no method to further refine the loot drop (e.g. drop only potions, or helmets, or heavy armor or mage weapons or missile weapons). This was changed by adding another note tag to items (the family tag). You can now assign a family tag to your items in form of a integer number. When using the loot drop you can optionally state the item family you want to spawn. This grants you additional freedom, for example you can have the script only spawn potions or scrolls. Just add <family: X> to your potions (replace X with a number) and state that number when calling the script. Voila! C. The Lucky Tag for items is functional again. Version 1.3 Changes A. The documentation was rewritten and is now much more detailled. B. The sample project was updated and reflects now all changes. C. Added some more security checks to the system. D. You can now filter loot by weapon/armor subtypes as well (thats the ones defined in the Terms section of the database). Version 1.4 Changes Added Sixth's compatibility changes Full Documentation #=============================================================================== # +++ GALV'S RANDOM LOOT +++ #=============================================================================== # + Original Script by Galv # + Extended by Fhizban (also known as Malagar) # + Version 1.4 # + Updated August 2015 # + For RPGMaker VX Ace # + Free for Non-Commercial and Commercial use # + Requires no other scripts #=============================================================================== # DESCRIPTION #=============================================================================== # This script allows you to have a script call to gain random loot from chests. # Add notetags to items to specify level requirements and rarity values. # A notetag can also be added to items that you want to increase the chance to # find rarer loot. Random loot can be limited to certain types of items too. #=============================================================================== # INSTALLATION #=============================================================================== # + Put this script after Material but before main. # + Add some of the notetags (described below) to the items in the database. # + Add a new event that represents a chest or other container to your map. # + Add a script call to the event that will generate random loot (see below). #=============================================================================== # DOCUMENTATION #=============================================================================== # You are required to setup two different parts to make this script work: # 1) Add Notetags to your items in the database. # 2) Add the script call to your events (chests). # 3) Optionally you can change the configuration below to your taste. # # 1) Editing Notetags: # You must specify the following notetags for all ITEMS, WEAPONS and ARMOR that # you want to randomly appear in your events (chests). If any items do not have # these tags, they will just not appear in a random chest at all. # # <family: x> # The group or family the item belongs to # # You define these families yourself (1-99) # <rarity: x> # The rarity value (1+ higher is rarer) # <level-min: x> # Min level of player for item to show (1-99) # <level-max: x> # Max level of player for item to show (1-99) # # Optional notetag for ARMORS and WEAPONS only: # # <lucky: x> # All equipped lucky items of the party are added to # # calculate the total chance to get rarer items. # # 2) Using the script call: # By using this script call, you can randomly obtain an item. Go to your event and add # a new command to it, choose script from the very last command tab and insert the # following line. # # EXAMPLE: # # random_item(0, 1, 10, 50, 1, 1) # # SYNTAX: # # random_item(type, rarity_min, rarity_max, subtype=0, monster_id=0, family=0) # # type # The type of item to be found: # # 0 = Random/any type (you can also use numbers 4+) # # 1 = Item # # 2 = Armor # # 3 = Weapon # # rarity_min # Min and Max Rareness determine the item rarity that # rarity_max # the script call will obtain when successful. You can # # state any number that you also use on the notetags # # of your items. Example: # # rarity_min=10, rarity_max=50 # # The script call will generate a random number 1-50. # # An item can only be obtained if it has a rarity # # EQUAL or LESS than the generated number. # # subtype # OPTIONAL. This only applies to WEAPONS or ARMOR and # # will be ignored otherwise. Filters the random loot # # to drop only items of the stated type. # # (e.g. 1 = General Armour) # # monster_id # OPTIONAL. This ID is used to decide what TROPP id # # will be used when a monster-in-a-box is encountered. # # Otherwise the standard troop will be used. Ignored # # if encounter chance is set to zero. # # family # OPTIONAL. Family can be any number or 0. # # 0 = drops any item of the stated type/subtype # # x = drops only items of the stated type/subtype that # # share the family. # # Using a clever combination of type, subtype and families - you can tailor the random # loot spawn to create only items of a very specific type. Like only Armors of the Small # Shield type, or just Weapons of the Sword type and so on. #=============================================================================== Edited August 19, 2015 by Fhizban 3 Mikoto, JiM and Sughayyer reacted to this Share this post Link to post Share on other sites
Sophien 0 Posted July 2, 2014 Hey there I like it, but i can't exchange it with my other Script. Maybe (Really only if you want, and you can xD) you can make more like Item Drop Ranks? From Modern Algebra? The Problem is, that i want, that you can get the Diamond Sword as Example, if you are Lvl 50. But i Schould be harder to get, as the Gold Sword, or anything like that. In the Item Drop Ranks, you can set Ranks (who thought it xD) It looks like this as example. Drop Rank 8 = 10% and Drop Rank 9 = 2,5%.So if Diamond Sword has Drop Rank 9 and you need to be Lvl 50, and the Gold Sword has Drop Rank and you need Lvl 50, the Chance is higher to get the Gold Sword.Or can i do something like that, with that Script? O.o xDAnd what i like too, is that i want to have Mimics. Not only one.If you are min. Lvl 1, you fight against a normal Mimic. If you are Lvl 15 you fight against a silver one You know what i mean? I hope you like it, or can give me some answers Share this post Link to post Share on other sites
Fhizban 96 Posted July 2, 2014 Hi, Yes you can. The drop ranks are quite easy as the script already allows you to define a rarity. There is min-rarity and max-rarity and they can be any number. Next, when dropping an item you state a min and max rarity. Every item has a rarity associated to it. What i do: My rarity numbers are always % based (like in your modern algebra script). therefore you could say 10% or 2% or whatever (not sure if float values work like 2,5 etc.). So you can basically copycat the Drop ranks of the modern algebra script. The mimic is a bit harder, you will need another script for this: You can specify a troop ID in every loot drop. But you need a way to determine what kind of troop appears before spawning the loot. This can be done using a event and a bunch of forks. Level 1-5 = Troop-ID 1 (mimic) Level 6-20 = Troop-ID 2 (silver mimic) Level 21-50 = Troop-ID 3 (gold mimic) Again: You have to use events and forks to do this. the script itself wont be able to. What you can also do is using another script to expand the capabilities like HIME Troop Placeholders. Hope this helps a bit. PS: Im already working on a new version, but it will focus on other things first. Share this post Link to post Share on other sites
Sophien 0 Posted July 2, 2014 Ahh okay... now i understand, and i think the Problem with the mimic should't be so hard.Create a Event with random Variable. If it is a.E 1-45, its a Chest and you get random loot,If it is 46-50 its a mimic and then he check with Common Event, which lvl the Main Caracter is So should it work right? I love random thing )Thx Share this post Link to post Share on other sites
Mikoto 1 Posted July 31, 2014 Thanks for this, I'm lucky it came around when I needed it since the bug in v1.0 of Galv's script was really starting to get hard to cope with (Still pleased that the script was made in the first place even with the bug). It's been working well so far. 1 Fhizban reacted to this Share this post Link to post Share on other sites
korosuu 0 Posted August 19, 2014 Hello! I've been using this script for random loot but run into a problem, when I open a chest, quite often I will get a "chest is empty" message. Even when I set the min and max rarity to a value of "10" in the chest and only have 1 item with the rarity of "10" in my database, I only get that item about 50% of the time when opening the chest. I already removed the possibility of monster spawn by making a change in the script, not sure if its a bug or if getting no item when opening a chest is something I can disable by changing something in the script? Thank you to Galv for making the script and to Malagar for updating it! Share this post Link to post Share on other sites
Fhizban 96 Posted August 19, 2014 Welll, I was not able to solve the "empty" issue completely. Its because of the nature of this script. For example the position of your items in the database also seems to play a role (although it should not according to the updates I made). I will see what I can do, for now I dont recommend to use the script with the min/max values set to the same number (or a very close number range). Share this post Link to post Share on other sites
korosuu 0 Posted August 19, 2014 Hey Malagar, I've tried differnet min/max values and different positions in the database etc. but the problem seems to persist. I mainly decided to try the script because I read its free for commercial use and after trying it and understanding it better, I really do like the script but the "empty" issue is the only problem I have with it. I'll try some different things on my end, don't mean to cause you a headache by trying to solve the issue, was mainly wondering if there was a very simple solution that I had missed somewhere . Share this post Link to post Share on other sites
Kayzee 3,815 Posted August 19, 2014 I made a script that did something like this once, though mine worked a bit differently. I think it might be better to use ($data_items | $data_armors | $data_weapons).compact rather then choosing a random type there, that way you don't have to make sure that one item of each type is available at every level. Personally I wouldn't have a max level at all but eh. Also that loop used there is pretty funky... I would use @loot.shuffle.each or something. Share this post Link to post Share on other sites
bloodyliao 5 Posted August 19, 2014 I made a script that did something like this once, though mine worked a bit differently. I think it might be better to use ($data_items | $data_armors | $data_weapons).compact rather then choosing a random type there, that way you don't have to make sure that one item of each type is available at every level. Personally I wouldn't have a max level at all but eh. Also that loop used there is pretty funky... I would use @loot.shuffle.each or something. May i have a look on yours? Can't find it in your 'posts'>.< Share this post Link to post Share on other sites
Fhizban 96 Posted August 19, 2014 Galv wanted to re-code that script someday. What i did are just tiny tweaks but it solved 99% of the issues for me. I use a pretty extensive database with lots of items at various rarity levels and the script works quite well. I can add the compact and shuffle change suggestions later, but my hands are currently tied with my main script project. the code is available at paste bin and Galv gave his official "yes" to modify it, as long as his credits stay intact and it is made available to the public for free. Share this post Link to post Share on other sites
Kayzee 3,815 Posted August 19, 2014 I never released mine because it's kinda hacky and tied into a lot of other scripts I use. I really have to recode mine as well. I am not saying mine is any better, just saying I tried solving the same problem. Share this post Link to post Share on other sites
Mikoto 1 Posted September 27, 2014 I'm having experiencing a bit of a problem with the use of item family types. I'm trying to make it so that when you open an event it gives you a family type (based around mining). It has multiple outcomes based on rarity and level, two outcomes being: Getting a rock and a stone, these two items having the same rarity's with slight differences. Issue: While using family types I've been having the same problem as I used to have when I used the v1.0 of Galvs Random Loot Drops. An item that's higher up has more priority of being generated when I open a family set loot. I don't believe I've encountered this problem without the family loot set. I've run the same event that should have an even chance of generating each item with a 50% chance 10 times. I've even duplicated the items in different slots once, but I practically always get the one higher up. Here's a diagram of my problem: ("Call Common Event: Mine" is just sounds) Thanks for reading, if this has already been solved, sorry for asking, otherwise, I hope you can solve the solution. NOTE(s): I am using the correct and latest version of this script. From what I've seen it seems that the family system still uses the same system as v1.0 of Galv's Random Loot Drops. Share this post Link to post Share on other sites
Galv 1,386 Posted September 27, 2014 This is one of my very first scripts and not very good so I wouldn't recommend it at this time until I get to scripting a better one. This script doesn't make use of <family> tags so I assume you are using another script in conjunction. I highly doubt they are compatible. Share this post Link to post Share on other sites
Mikoto 1 Posted September 27, 2014 This is one of my very first scripts and not very good so I wouldn't recommend it at this time until I get to scripting a better one. This script doesn't make use of <family> tags so I assume you are using another script in conjunction. I highly doubt they are compatible. The family tags are involved in this version due to this being a permissibly edited version of your script by Malagar with credit of the actual script to you. I think it's a misunderstanding of this being the unedited version of your script, which seems understandable. Thank you for making the original script by the way, it's been very helpful. Share this post Link to post Share on other sites
Fhizban 96 Posted September 27, 2014 @OffstageWings: Thats right, you are using my modified version of the script. I built it upon Galvs Original Random loot with just minor tweaks applied to it. It was built using the most recent version but maybe the concept of families introduced another error to the script as well. Sadly my personal experience is that even the 1.1 Version of the script is not working as expected (even without families) thats due to how the random items are selected. I have to see what I can do. 1 Mikoto reacted to this Share this post Link to post Share on other sites
Mikoto 1 Posted September 27, 2014 @OffstageWings: Thats right, you are using my modified version of the script. I built it upon Galvs Original Random loot with just minor tweaks applied to it. It was built using the most recent version but maybe the concept of families introduced another error to the script as well. Sadly my personal experience is that even the 1.1 Version of the script is not working as expected (even without families) thats due to how the random items are selected. I have to see what I can do. Alright, thanks and good luck. Share this post Link to post Share on other sites
Kayzee 3,815 Posted September 27, 2014 (edited) Issue: While using family types I've been having the same problem as I used to have when I used the v1.0 of Galvs Random Loot Drops. An item that's higher up has more priority of being generated when I open a family set loot. I don't believe I've encountered this problem without the family loot set. I've run the same event that should have an even chance of generating each item with a 50% chance 10 times. I've even duplicated the items in different slots once, but I practically always get the one higher up. Here's a diagram of my problem: ("Call Common Event: Mine" is just sounds) Yeah I think the item list probably should be shuffled at some point. Let me see if I can help rewrite that funky loop to something that makes more sense... this version of the random_item method may work better, but I haven't tested it. class Game_Interpreter def random_item(family, type, rarity_min, rarity_max, monster_id) if type == 1 items = $data_items elsif type == 2 items = $data_armors elsif type == 3 items = $data_weapons else items = $data_items | $data_armors | $data_weapons end mem = 0 eqs = 0 luck_bonus = 0 #no_equips = ($game_party.members.count) * ($game_party.members[0].equips.count) #no_equips.times do |i| # if $game_party.members[mem].equips[eqs] != nil # luck_bonus += $game_party.members[mem].equips[eqs].loot_lucky # end # if eqs < 5 # eqs += 1 # else # eqs = 1 # mem += 1 # end #end rare_chance = rand(rarity_max - rarity_min) + rarity_min + luck_bonus + 1 found_item = items.shuffle.find do |item| item.loot_level_max >= $game_party.leader.level && @loot[i].loot_level_min <= $game_party.leader.level && (item.loot_family == family || family == 0) && item.loot_rarity <= rare_chance end if found_item $game_party.gain_item(@loot[i], 1) RPG::SE.new(Random_Loot::SOUND_EFFECT[0], Random_Loot::SOUND_EFFECT[1], Random_Loot::SOUND_EFFECT[2]).play $game_message.add(Random_Loot::GET_MESSAGE + "\\I[" + @loot[i].icon_index.to_s + "]" + @loot[i].name.to_s + Random_Loot::GET_MESSAGE_AFTER) wait_for_message return else monster_chance = rand(100) + 1 if monster_chance <= Random_Loot::MONSTER_CHANCE if Random_Loot::MONSTER_MESSAGE != "" $game_message.add("\\>" + Random_Loot::MONSTER_MESSAGE + "\\.\\.\\.\\^") wait_for_message end BattleManager.setup(monster_id, Random_Loot::ESCAPE_MONSTER, false) SceneManager.call(Scene_Battle) else $game_message.add(Random_Loot::FAIL_MESSAGE) wait_for_message end end end end # Game_Interpreter Edited September 27, 2014 by KilloZapit Share this post Link to post Share on other sites
Fhizban 96 Posted August 11, 2015 Hey guys, Im back (kind of) and will start to finally debug this script. Should be done soon! Any other wishes for this script? Its still the only real random loot generator out there without requiring extensive lists of items to be maintainted. 1 Mikoto reacted to this Share this post Link to post Share on other sites
Fhizban 96 Posted August 16, 2015 (edited) Okay, so I updated this script once more. * Reorganized a few things * Increased randomness with proper shuffling and random selection of items * Re-Activated the Lucky tag for equipment again This is the complete project folder (1.2): https://dl.dropboxusercontent.com/u/1828…m Loot v1.2.rar Here is just the script (1.2): http://pastebin.com/khU50cuy EDIT: Actually, seems to be bugfree and more or less completed! Edited August 18, 2015 by Fhizban Share this post Link to post Share on other sites
Fhizban 96 Posted August 18, 2015 (sorry double-post) Script was updated to v1.3 - this will be the last version for a while (aside from bug-fixes). You can now filter the loot even more to just show up items of a specific subtype (thats the ones you define in the Terms tab of the database). Documentation was updated as well and there is now a proper sample project. ---please check out the opening (top) post for all the details--- Share this post Link to post Share on other sites
Sixth 113 Posted August 18, 2015 Just a note, it's not compatible with any Equip Manager scripts, due to the "funky" (I read that word here, kinda fits well ) code part of getting the luck bonus. Fixing that will actually shorten the script too (I did this a long time ago, and remembered after seeing this topic, might as well share the fix, right?). Change this part in the script: no_equips.times { |i| if $game_party.members[mem].equips[eqs] != nil luck_bonus += $game_party.members[mem].equips[eqs].loot_lucky end if eqs < 5 eqs += 1 else eqs = 1 mem += 1 end }To this: $game_party.members.each do |mem| mem.equips.each do |eq| next if eq.nil? luck_bonus += eq.loot_lucky end end Doing the above will make sure that it works with scripts which create extra equip slots for actors. I saw that KilloZapit got rid of this "funky" luck bonus calculation, but he simply got rid of it altogether, so the luck bonus feature is disabled for good that way. Doing the above keeps the luck bonus, and gets rid of the old and quite messy calculation for it. I didn't look into your changes, since I made my own randomizer for my game, but they sound good regardless. Share this post Link to post Share on other sites
Fhizban 96 Posted August 18, 2015 Thanks a bunch! Galv commented that part out, and I totally did not think about other scripts. It seems he knew that it wont work. Your solution is perfect, will be integrated into 1.4 Share this post Link to post Share on other sites
ChuckLee 0 Posted October 26, 2015 (edited) This is excellent!Thanks buddy, now I can make my player loot corpses I've encountered an issue though: I don't use the troop-mode (turn-based) battling mode so I'd like to set the troop spawn probability to zero. But if I set the fifth number to 0 (which is supposed to be the troop number, right?) it still generates random troops...Can you help me here? EDIT: I think I found it Edited October 26, 2015 by ChuckLee Share this post Link to post Share on other sites
bloodyliao 5 Posted August 12, 2016 I've got a problem about this script. If I set 5 or even more different items with a same rarity, say 5, and run the script, it seems that the items i'll get are not really random. Actually, the first item whose item ID is the smallest has a rather high chance. I make a loop to run the script call as " random_item(1, 1, 80) " for many times, and it seems that items with smaller ID are more likely to be obtained. Is there anything to do with that? Share this post Link to post Share on other sites