Skip to content

Instantly share code, notes, and snippets.

@C-ffeeStain
Last active March 7, 2021 20:13
Show Gist options
  • Save C-ffeeStain/88ad0d7644cbd29b2804d972dd26a847 to your computer and use it in GitHub Desktop.
Save C-ffeeStain/88ad0d7644cbd29b2804d972dd26a847 to your computer and use it in GitHub Desktop.
Crate chances for the game Spelunky 2.

Crate Chances

I have created a python script that generates a item or list of items that could be in a crate with their respective properties from the Spelunky 2 fandom. Thanks to Cloppershy for the crate chances.

Code

from random import choices
import sys
items = {
    "Bomb Bag": 34.06,
    "Rope Pile": 34.06,
    "Parachute": 7.57,
    "Compass": 3.98,
    "Machete": 2.1,
    "Bomb Box": 2.04,
    "Bomb Paste": 1.49,
    "Spring Shoes": 1.47,
    "Spike Shoes": 1.44,
    "Boomerang": 1.42,
    "Webgun": 1.16,
    "Camera": 1.15,
    "Pitcher's Mitt": 1.13,
    "Climbing Gloves": 1.06,
    "Spectacles": 1.05,
    "Shotgun": 0.98,
    "Mattock": 0.97,
    "Teleporter": 0.96,
    "Crossbow": 0.5,
    "Freeze Ray": 0.5,
    "Cape": 0.49,
    "Powerpack": 0.2,
    "Jetpack": 0.2,
    "Plasma Cannon": 0.01,
}
print(choices(list(items.keys()),list(items.values()), k=int(sys.argv[1])))

Usage

To use the script above, copy and paste the text in the Code section above and make sure you have Python installed. Then create a new file called crate_chances.py and open a command prompt there. Type py crate_chances.py <number> and there you go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment