Skip to content

LOOT_D

object LOOT_D adm/daemons/loot.lpc

Daemon responsible for handling the loot system, including item drops, coin drops, and automatic valuation. Called by the death sequence when an NPC is killed.

inherits STD_DAEMON std/daemon/daemon.lpc
inherits EXT_LOG std/ext/log.lpc
variable log_level int
# public loot_drop

Drops loot from the source’s loot table into the source NPC, whose inventory the death sequence then empties into the corpse. Iterates each entry, rolls against its chance, and creates the item on success.

param tp STD_BODY The player who killed the NPC
std/living/body.lpc
param source STD_NPC The NPC whose loot table to process
std/living/npc.lpc
returns void
# public coin_drop

Drops coins from the source’s coin table into the source. Each coin entry is rolled independently.

param tp STD_BODY The player who killed the NPC
param source STD_NPC The NPC whose coin table to process
returns void
# public determine_value_by_level

Calculates a coin value based on level, applying a configured variance for randomization. Uses COIN_VALUE_PER_LEVEL and COIN_VARIANCE from the MUD configuration.

param level int The NPC’s level
returns int The calculated coin value
# private drop_items

Processes and drops a single loot item into the source. Resolves the item via process_loot_item, creates the object, auto-values it if applicable, and moves it into the source NPC.

param tp STD_BODY The player
param item mixed The loot table entry to resolve
param source STD_NPC The NPC to drop into
returns void
# private process_loot_item

Recursively resolves a loot item. Handles functions (called and re-resolved), arrays (random pick), weighted mappings (element_of_weighted), and plain string paths.

param item mixed The item to resolve — string path, mapping, array, or function
param tp STD_BODY The player
param source STD_NPC The NPC source
returns mixed A file path string, a ({ path, args }) pair, or 0 on failure
# private autovalue_loot_item

Sets the value of a loot item based on the source NPC’s level, if the item has the autovalue loot property enabled.

param item OBJ_LOOT The loot item to value
param tp STD_BODY The player
param source STD_NPC The NPC whose level determines value
returns void
# private drop_coins

Creates a coin object of the given type and amount, and moves it into the source.

param tp STD_BODY The player
param item mixed A ({ currency_type, amount }) pair
param source STD_NPC The NPC to drop coins into
returns void