aeroblastt

scavenger.py

Jul 3rd, 2020 (edited)
1,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.10 KB | None | 0 0
  1. # This seems to have gotten a lot more views than any other public paste I've made for some reason. If you know why, please ping me in the official Risk of Rain 2 Discord @Grey#2542.
  2. # Also note that this was not made exactly fitting RoR2 specifications; this was for a Risk of Rain-based fan project that I and several of my friends worked on. The numbers of items of each rarity given to a Scavenger are accurate to RoR2, but the items generated in the bag use the rates normally used for item drops with the Artifact of Sacrifice. Additionally, the item list is a mix of selected RoR1 and RoR2 items.
  3. # If you wish to generate a game-accurate Scavenger or its bag with this program, you'll need to update the item lists under def genitem(type) to reflect the game you want to mimic.
  4. # You'll also need to change some numbers for each rarity if you're not generating specifically a RoR2 Scavenger; search this program for "Rarity chances" and "Rarity numbers" to find the relevant sections of code as well as basic instructions on what to do.
  5. # If there's demand, I'm perfectly willing to make a game-accurate version of this program, but until I know where the traffic is coming from I'm going to hold off for now.
  6.  
  7. import random
  8.  
  9. def genitem(type):
  10.         common = ["Backup Magazine", "Crowbar", "Focus Crystal", "Gasoline", "Lens-Maker’s Glasses", "Meat Nugget", "Medkit", "Monster Tooth", "Paul’s Goat Hoof", "Soldier’s Syringe", "Sticky Bomb", "Taser", "Topaz Brooch", "Tougher Times", "Tri-Tip Dagger"]
  11.         uncommon = ["Arms Race", "AtG Missile Launcher Mk. 1", "Berserker’s Pauldron", "Boxing Gloves", "Chronobauble", "Dead Man’s Foot", "Death Mark", "Fuel Cell", "Golden Gun", "Harvester’s Scythe", "Infusion", "Kjaro’s Band", "Runald’s Band", "Leeching Seed", "Predatory Instincts", "Red Whip", "Time Keeper’s Secret", "Ukulele", "Will-o’-the-Wisp"]
  12.         legendary = ["57 Leaf Clover", "Aegis", "Alien Head", "Brilliant Behemoth", "Dio’s Best Friend", "Happiest Mask", "Hardlight Afterburner", "Heaven Cracker", "Interstellar Desk Plant", "Old Jack-In-The-Box", "Permafrost", "Rejuvenation Rack", "Shattering Justice (Light)", "Soulbound Catalyst", "Thallium", "Unstable Tesla Coil"]
  13.         equipment = ["Blast Shower", "Crudely Drawn Buddy", "Disposable Missile Launcher", "Foreign Fruit", "Jade Elephant", "Ocular HUD", "Rotten Brain", "Sawmerang", "Snowglobe", "The Back-up"]
  14.         types = [common, uncommon, legendary, equipment]
  15.  
  16.         return random.choice(types[type])
  17.  
  18. def genscav(items): # Rarity numbers for Scav items. If you want a Scav with different counts of items of each rarity, edit these.
  19.         for i in range (0,3): # Number of white items
  20.             item = genitem(0)
  21.             if item in items:
  22.                 i -= 1
  23.             else:
  24.                 items[item] = 3
  25.  
  26.         for i in range (0,2): # Number of green items
  27.             item = genitem(1)
  28.             if item in items:
  29.                 i -= 1
  30.             else:
  31.                 items[item] = 2
  32.  
  33.         items[genitem(2)] = 1 # Scavengers in RoR2 get only one red item and one equipment, so the code in these two lines (legendary, then equipment) is simplified from above.
  34.         items[genitem(3)] = 1 # If for whatever reason you want to change that, copy the code blocks for white/green items, change the second number in the "for i in range" statement to the desired number of items, and change the number in the parentheses after "genitem" to 2 for legendary and 3 for equipment.
  35.  
  36. def genbag(items):
  37.         size = random.randint(8,12)
  38.         print(size)
  39.         for i in range (0,size):
  40.                 r = random.random()
  41.                 if r < .63: # Rarity chances for Scav bag items. This is the probability of a white item out of 1.
  42.                         item = genitem(0)
  43.                         if item in items:
  44.                                 items[item] += 1
  45.                         else:
  46.                                 items[item] = 1
  47.                 elif r < .9: # This is not the chance of a white item, but the chance of a white item plus that of a green one.
  48.                         item = genitem(1)
  49.                         if item in items:
  50.                                 items[item] += 1
  51.                         else:
  52.                                 items[item] = 1
  53.                 elif r < .99: # White + green + orange. Note that this is orange, not red as above.
  54.                         item = genitem(3)
  55.                         if item in items:
  56.                                 items[item] += 1
  57.                         else:
  58.                                 items[item] = 1
  59.                 else: # Any value of the randomly generated number r above .99 falls into here, meaning that 1-.99 is the chance of a red item.
  60.                         item = genitem(2)
  61.                         if item in items:
  62.                                 items[item] += 1
  63.                         else:
  64.                                 items[item] = 1
  65.  
  66. random.seed()
  67. items = {}
  68. bag = True
  69.  
  70. if bag:
  71.         genbag(items)
  72. else:
  73.         genscav(items)
  74.  
  75.  
  76. for i in items:
  77.     print(i + ": " + str(items[i]))
Advertisement
Add Comment
Please, Sign In to add comment