Skip to main content

Mask Generators

Float Masks can be used to change weights/counts in nearly any way imagineable. However, how do we get the data into the mask in the first place? Most commonly, the data you want is stored inside of the sources2. This is where mask generators come in: They compare data from each source and store the results into the loot table template as a mask. Then you can access these stored masks at runtime.

Usage

We'll start with something relatively simple: for each data asset in our loot table, we want a mask that's 1.0 if the asset has Flammable == true and 0.0 otherwise. We'll include three items:

ItemFlammable
Flowertrue
Ironfalse
Woodtrue

In our loot table, we'll set some weights for these rows:

Loot Table Weights

Next we'll add a mask generator. These are found in the Details tab in your loot table template. We'll add a Bool mask generator that will compare the Flammable boolean on each item:

Flammable Mask

  • Tag: Gameplay tag that identifies the mask; we'll use this to get it later.
  • False Value: Value when Flammable == false.
  • True Value: Value when Flammable == true.
  • Property: Property being compared. In our case this is Flammable.

Masks generally extract info from each source row: that is, each row in the Built Table tab. After compiling, we can view the mask by enabling it in the View Options:

Show Flammable Mask

It will display as a column in the built table:

Flammable Mask

note

Mask generators are always evaluated at Design Time; their results are outputted to a float mask and stored on the LootTableTemplate. Each time you compile the loot table, its masks get reevaluated.

To get the mask from its loot table, we use the FindMask function:

Get and Apply Mask

To apply the mask at runtime to a loot table, we have several options available to us:

  1. We can use the MaskedSample function(s) on a loot table. These will temporarily apply the mask, sample, and then remove the mask from the loot table. This lets us reuse the unmasked table for other operations.
  2. We can apply the mask to a loot table's weights or counts directly with ApplyMaskToWeights and ApplyMaskToCounts, respectively. This causes a permanent change which is useful if we need to reuse the modified table.

In most scenarios, we recommend MaskedSample.

Using the example above, we would sample from a table with just Flower and Wood. Iron would be filtered out because it wasn't flammable.

note

Float Masks are quite versatile. You can see other ways to use them in the float mask page.

Built-In Generators

Stoch includes many built-in mask generators:

  • Bool: Evaluates a boolean property from the source.
  • Copy Data: Copies a numeric property from the source.
  • Curve: Uses a source's numeric property as a key into a curve.
  • Gameplay Tag Compare: Compares a source's tag property.
  • Gameplay Tag Enumerate: Creates a mask for each unique tag stored in the source's property.
  • Loot Table Count: Copies the loot table's count for that row.
  • Loot Table Weight: Copies the loot table's weight for that row.
  • Manual: Stores manually defined data.
  • Numeric Compare: Compares numeric property(s) from the source.
  • Row Filter: Evaluates a row filter on each source.

Bool

Evaluates a boolean property from the source. We used this in our example above to compare against the Flammable property.

Copy Data

This copies a numeric property (integer or float) from the source. For example, our item might have a Weight property for its weight in kilograms. We could copy this to a mask and filter items by their weight at runtime.

Curve

Applies a curve using one of the source's properties as a key.

Gameplay Tag Compare

Compares a gameplay tag on the source's property. The ARPG Loot Generation uses this to filter affixes.

Gameplay Tag Enumerate

Creates a mask for each unique tag in the source's GameplayTagContainer property. Then it stores PassValue if that source had the tag and FailValue otherwise. The ARPG Loot Generation guide uses this to denote which affixes have specific tags like Dexterity, Strength, etc. Then it uses them to filter rows at runtime. It's quite useful if you have many tags that you need to process later.

Loot Table Count

Copies the loot table's Count for that row. Useful if you want to Restock the loot table after sampling.

Loot Table Weight

Copies the loot table's Weight for that row. The ARPG Loot Generation uses this to modify rarities with an advanced formula that wouldn't be possible with a simple operation like Add or Multiply.

Manual

Lets you manually enter data for each loot table row.

Numeric Compare

Compares a numeric property (float or integer) on the source. For example, if you want items with ItemLevel greater than 50, you could use this.

Row Filter

caution

This exists mostly for backwards-compatibility. We don't recommend using this generator unless you already have row filters from previous versions of Stoch.

Sets the mask value based on whether the row passed the filter.

Custom Generators

You can also create custom mask generators in C++ or Blueprint. Simply subclass STMaskGenerator and override the GenerateMasks function. The example map includes a demo mask generator, BP_MaskGen_Demo, to show you the syntax.


  1. The Data Table Row(s) or Data Asset(s) being referenced by your loot table.