ItemGenerator ​
Inherits: RefCounted
Makes an item with a roll: its quality, its affixes (and so its stats and effects), its item level, its name, its sockets.
Description ​
generate(definition, context) returns an ItemInstance whose roll is stored on it (ItemInstance.get_generated). roll(definition, context) is the same roll as plain data, so it can be checked without a scene. Everything an affix does is decided by the budget of the item (ItemBudget):
- the item level L (the context's
item_level, else the item's own) 2. the quality: the one of the item, or one rolled from the qualities it can have (drop weights, magic find, the quality's lowest item level) 3. the budget of the item, minus what its written stats and effects cost 4. the affixes: how many of each kind the quality says, picked by weight from the pool of the item (no two of an exclusive group) 5. the effects of the effect affixes are paid from the budget first, then the stat affixes share what is left 6. the name, the extra sockets, and the custom rules of the quality
Context keys (all optional): item_level int, magic_find float (percent), quality_id int (forces a quality), min_quality_tier int, rng RandomNumberGenerator. See docs/systems/ability-ranks-and-item-generation.md.
Methods ​
ItemInstance | generate( definition: ItemDefinition, context: Dictionary = {} ) static |
Array[ItemInstance] | make_instances( definition: ItemDefinition, quantity: int, item_level: int = 0, context: Dictionary = {} ) static |
void | apply_roll( instance: ItemInstance, data: Dictionary ) static |
String | compose_name( definition: ItemDefinition, quality: Quality, data: Dictionary ) static |
String | describe_roll( definition: ItemDefinition, data: Dictionary ) static |
Dictionary | roll( definition: ItemDefinition, context: Dictionary = {} ) static |
int | weighted_index( weights: Array[float], rng: RandomNumberGenerator ) static |
Method descriptions ​
ItemInstance generate( definition: ItemDefinition, context: Dictionary = {} ) ​
Makes the item. Without a definition that needs generation it is a plain instance of the definition
Array[ItemInstance] make_instances( definition: ItemDefinition, quantity: int, item_level: int = 0, context: Dictionary = {} ) ​
The instances of quantity items of a definition, made at an item level. An item that is generated (it rolls or scales) gets its own roll in every instance (a stackable one stacks up to its stack size: one roll for each stack); any other item is plain instances. context is what generate takes (magic find ...)
void apply_roll( instance: ItemInstance, data: Dictionary ) ​
Puts a roll on an instance:the stat points and effects go where the equipment code reads them, the rest stays in the generated data
String compose_name( definition: ItemDefinition, quality: Quality, data: Dictionary ) ​
The name of a generated item: the name of the definition with the names of its affixes, as the name mode of its quality says (data is the roll: the ids of its name_prefix and name_suffix affixes). The names are read when the name is asked for, so the item shows in the language of the player; the order of the words is the template "{prefix} {item} {suffix}" (or "{quality} {item}") of the toolkit words, which a language can change. A roll saved by an older version has only the finished texts (name_prefix, name_suffix): they are used when the affix ids are not there.
String describe_roll( definition: ItemDefinition, data: Dictionary ) ​
A roll as one line of text for the editors: "Heavy Great Axe of the Monkey (Rare, level 25): +240 Strength, +160 Agility, Burning"
Dictionary roll( definition: ItemDefinition, context: Dictionary = {} ) ​
The roll as data:{"item_level", "quality_id", "scale_factor", "stat_bonuses", "effect_ids", "affixes", "name_prefix", "name_prefix_id", "name_suffix", "name_suffix_id", "extra_sockets"}
int weighted_index( weights: Array[float], rng: RandomNumberGenerator ) ​
An index picked by weight (0 when every weight is 0)