Prereqs: customizable conditions

What are Prereq_Record and what's their purpose in-game?

Prereqs is the mechanism used in the tweaks to express conditions, exactly as you would in code with:

if Equals(myVar, n"Something") {
    // do something ...

The primary reason prereqs exist is to allow you to customize a condition's values in tweaks. You could do this all in code, of course, but for "repetitive yet not identical" conditions it turns out being actually very convenient.

All prereqs are of type IPrereq_Record (or of any type that inherit from it).

Prereqs are typically used in conjunction with Effector_Record, StatusEffectAIData_Record, and some other types of tweak records. They contain the logic which decides whether e.g. the effector should be applied or not.

All IPrereq_Record work similarly to Effector_Record: they have an associated class which must be defined in scripts (and you can also create your own). This class name is specified with the property prereqClassName (its full name, including the module where it lives) and must be of type IScriptablePrereq (or any type that inherits from it).

In WolvenKit it looks like so:

In short the IPrereq_Record holds the values, while the IScriptablePrereq describes the logic.

IScriptablePrereq can also sometimes keeps (and caches) a persistent state of type PrereqState (or any type inheriting from it). Internally it might e.g. listen to a IBlackBoard and update the condition when a given value changes. It allows the game to keep listening to a condition for a short span of time, instead of constantly recreating and deleting the same Prereq over and over again. It's typically used for stats and skills checks.

For example, taking a random Prereq with state from WolvenKit:

Kindly note that there's not (always) an(y) indicator whether the Prereq comes with a state or is stateless, but you can check for it in adamsmasher's sources:

Last updated