Modding:Weapon data

From Stardew Valley Wiki
Jump to: navigation, search

Index

This page explains how the game stores and parses weapon data. This is an advanced guide for mod developers.

Raw data

Weapon sprites are in TileSheets\Weapons.xnb, and weapon data (parsed by the MeleeWeapon constructor) is in Data\Weapons.xnb. The files can be unpacked for editing. Here's the raw data as of 1.3.36 for reference:

Data 
{
  "0": "Rusty Sword/A rusty, dull old sword./2/5/1/0/0/0/3/-1/-1/0/.02/3",
  "1": "Silver Saber/Plated with silver to deter rust./8/15/1/0/1/1/0/50/45/0/.02/3",
  "2": "Dark Sword/It's glowing with a mysterious energy./10/30/1/0/0/0/0/-1/-1/0/.05/3.5",
  "3": "Holy Blade/It feels hopeful to wield./18/24/1.2/0/5/0/3/-1/-1/0/.02/3",
  "4": "Galaxy Sword/It's unlike anything you've ever seen./60/80/1/8/0/0/0/-1/-1/0/.02/3",
  "5": "Bone Sword/A very light piece of sharpened bone./20/30/.8/8/5/0/0/74/50/0/.02/3",
  "6": "Iron Edge/A heavy broadsword./12/25/1.2/-4/0/1/3/44/-1/0/.02/3",
  "7": "Templar's Blade/It once belonged to an honorable knight./22/29/1/0/10/1/3/90/50/0/0/3",
  "8": "Obsidian Edge/It's incredibly sharp./30/45/1/-2/0/0/0/121/100/0/.02/3.2",
  "9": "Lava Katana/A powerful blade forged in a pool of churning lava./55/64/1.2/0/0/3/0/-1/-1/2/.015/3.5",
  "10": "Claymore/It's really heavy./20/32/1.3/-8/0/2/3/86/50/0/.02/3",
  "11": "Steel Smallsword/A standard metal blade./4/8/1/4/0/0/0/26/-1/0/.02/3",
  "12": "Wooden Blade/Not bad for a piece of carved wood./3/7/1/0/0/0/0/3/-1/0/.02/3",
  "13": "Insect Head/Not very pleasant to wield./10/20/1/4/9/0/0/-1/-1/0/.04/3",
  "14": "Neptune's Glaive/An heirloom from beyond the Gem Sea./18/35/1.4/-2/6/2/3/-1/-1/0/.02/3",
  "15": "Forest Sword/Made powerful by forest magic./8/18/1/4/5/1/0/-1/-1/0/.02/3",
  "16": "Carving Knife/A small, light blade./1/3/.5/0/0/0/1/18/-1/0/.04/3",
  "17": "Iron Dirk/A common dagger./2/4/.5/0/0/0/1/62/50/0/.03/3",
  "18": "Burglar's Shank/A weapon of choice for the swift and silent./7/12/.5/0/5/0/1/114/100/0/.04/3.5",
  "19": "Shadow Dagger/When you hold the blade to your ear you can hear 1,000 souls shrieking./10/20/.5/0/0/0/1/80/50/0/.04/3",
  "20": "Elf Blade/Only the nimble hands of an elf could craft this./3/5/.5/0/5/0/1/-1/-1/0/.04/3",
  "21": "Crystal Dagger/The blade is made of purified quartz./4/10/1/0/10/0/1/-1/-1/0/.03/4",
  "22": "Wind Spire/A swift little blade./1/5/1/0/0/0/1/-1/-1/0/.02/3.2",
  "23": "Galaxy Dagger/It's unlike anything you've seen./30/40/1/3/0/0/1/-1/-1/0/.02/3",
  "24": "Wood Club/A solid piece of wood, crudely chiseled into a club shape./9/16/1.5/-8/0/0/2/32/-1/0/.02/3",
  "25": "Alex's Bat/The sweet spot is dented from Alex's famous Grand Slam./1/3/1/-8/0/0/2/-1/-1/0/.02/3",
  "26": "Lead Rod/It's incredibly heavy./18/27/1.5/-16/0/0/2/56/50/1/.02/3",
  "27": "Wood Mallet/The solid head packs a punch. Relatively light for a club./15/24/1.3/-4/1/0/2/68/50/0/.02/3",
  "28": "The Slammer/An extremely heavy gavel that'll send foes flying./40/55/1.5/-12/0/0/2/128/100/2/.02/3",
  "29": "Galaxy Hammer/It's made from an ultra-light material you've seen before./70/90/1/-4/0/0/2/-1/-1/0/.02/3",
  "30": "Sam's Old Guitar/It's seen better days./1/3/1/-6/0/0/2/-1/-1/0/.02/3",
  "31": "Femur/An old, heavy bone caked in centuries of grime./6/11/1.5/-4/0/0/2/10/-1/0/.02/3",
  "32": "Slingshot/Requires stones for ammo./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "33": "Master Slingshot/Requires stones for ammo./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "34": "Galaxy Slingshot/It looks really powerful./1/3/1/308/0/0/4/-1/-1/0/.02/3",
  "35": "Elliott's Pencil/Elliott used this to write his book. It's sharp!/1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "36": "Maru's Wrench/A big, metal wrench. It smells like Maru./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "37": "Harvey's Mallet/It brings back memories of Harvey's clinic./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "38": "Penny's Fryer/Penny's favorite frying pan. There's some rubbery gunk stuck to the inside./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "39": "Leah's Whittler/Leah's favorite tool for shaping driftwood./1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "40": "Abby's Planchette/It's made from fine marblewood./1/3/1/308/0/0/1/-1/-1/0/.02/3",
  "41": "Seb's Lost Mace/One of Sebastian's medieval replicas./1/3/1/308/0/0/2/-1/-1/0/.02/3",
  "42": "Haley's Iron/It's searing hot and smells like Haley's hair./1/3/1/308/0/0/0/-1/-1/0/.02/3",
  "43": "Pirate's Sword/It looks like a pirate owned this once./8/14/1/4/0/0/3/40/-1/0/.02/3",
  "44": "Cutlass/A finely crafted blade./9/17/1/4/0/0/0/-1/-1/0/.02/3",
  "45": "Wicked Kris/The blade is made of an iridium alloy./24/30/.5/0/8/0/1/-1/-1/2/.06/3",
  "46": "Kudgel/A brute's companion./27/40/1.6/-10/0/0/2/107/100/0/.02/3.1",
  "47": "Scythe/It can cut grass into hay, if you've built a silo./1/3/1/0/0/0/0/-1/-1/0/.02/3",
  "48": "Yeti Tooth/It's icy cold to the touch./26/42/1/0/0/4/0/-1/-1/0/.02/3.2",
  "49": "Rapier/An elegant blade./15/25/1/4/0/0/0/100/95/2/.02/3",
  "50": "Steel Falchion/Light and powerful./26/38/1/8/5/0/0/142/100/0/.02/3.4",
  "51": "Broken Trident/It came from the sea, but it's still sharp./15/26/.5/0/8/0/1/-1/-1/2/.02/3",
  "52": "Tempered Broadsword/It looks like it could withstand anything./29/44/1.2/-6/0/3/0/135/100/1/.02/3"
}

Format

Melee weapons

The weapon data in Data\Weapons.xnb contains fifteen fields for melee weapons: 308/0/0/4/-1/-1/0/.02/3

index example value description
0 Bone Sword name
1 A very light piece of sharpened bone. description
2 20 minimum damage ouput
3 30 maximum damage output
4 .8 knockback (weight) - determines how far the target will get pushed away when hit
5 8 speed - determines how fast the user can attack
6 5 added precision - decreases the chance that a strike will cause no damage
7 0 added defense - affects how much damage the user takes
8 0 type ("0" for stabbing sword, "1" for dagger, "2" for club/hammer, "3" for slashing sword, "4" for slingshot)
9 74 The base mine level which affects the probability of mine container drops.
10 50 The minimum mine level for mine container drops.
11 0 added area of effect
12 .02 critical chance
13 3 critical multiplier
14 display name (non-English files only)

Weapons have a hardcoded category of -98 (Object.weaponCategory).

Slingshot

The slingshot has initial ID 32 in the weapon data, which increases by one for each upgrade level (up to 34 in the weapon data, though only 32 and 33 are obtainable without mods). All weapon fields must be specified in the weapon data to avoid errors, but only these are actually used for slingshots:

index example value description
0 Master Slingshot name
1 Requires stones for ammo. description
9 74 The base mine level which affects the probability of mine container drops.
10 50 The minimum mine level for mine container drops.
14 display name (non-English files only)

Slingshot damage is calculated dynamically regardless of the weapon data.

Mine container drops

When the player breaks a container in the mines, there's a chance it will drop a weapon. Here's how the weapon to drop is chosen[1]:

  1. Match weapons whose minimum mine level (field 10) is less than the current mine level.
  2. From that list, match weapons with a probability check based on the gap between the base mine level (field 9) and current mine level. The probability is a bell curve centered on the base mine level:
    level difference probability
    0 100%
    5 92%
    10 71%
    15 46%
    20 25%
    25 4%
    The difference applies in both directions; for example, two weapons whose base levels are 5 below and 5 above the current level both have a 92% chance. (The probability is calculated with a Gaussian function e-(current mine level - base mine level)2 / (2 * 122).)
  3. Find the weapon with the smallest gap between the current and base mine levels, and add it to the list. (If the item was also selected in step 2, it has two chances to drop.)
  4. From the remaining list of weapons, randomly choose one to drop.

References

  1. See Utility.getUncommonItemForThisMineLevel in the game code.