Skip to content

Carving

A player with a knife, a dagger or a sword, carried or equipped, double clicks it and picks the corpse of a creature within 2 tiles: what the creature gives, such as meat, hides, wool or feathers, appears inside the corpse. A corpse is carved once. A player’s corpse, the corpse of a pet (tamed or bonded) and the corpse of a summoned creature cannot be carved.

What a creature gives is a carve table in templates/carves/*.toml, subfolders included. A mobile template names its table with carve, and the corpse of the creature keeps the name when it dies:

[[carve]]
id = "cow"
entries = [
{ item = "cut_of_raw_ribs", amount = "8", message = 500467 },
{ item = "pile_of_hides", amount = "12", message = 500471 },
]
[[mobile]]
id = "cow"
carve = "cow"

Each entry is rolled on its own, so a carve may give all of them, some or none:

Field Meaning
id The name of the table, which a mobile template’s carve gives
entries What the table gives
item An item template id
amount A number or dice such as 1d3, from 1 to 65535; unset is 1. An item that stacks is made as one stack, one that does not as that many items
chance The percent chance that the entry gives anything, from 1 to 100; unset is 100
message The client text (cliloc) the carver is told when the entry gave something, such as 500467 for meat; entries with the same number tell it once. Unset says nothing

The server stops at startup when an id is empty or used twice, an item is not an item template, an amount can roll outside 1 to 65535, a chance is outside 1 to 100, a message is below 0, or a mobile template’s carve names no table. A mobile template without carve takes its parent’s, and a corpse with none gives nothing useful; carve = "" takes the parent’s table away, as the ethereal mounts, the fire steed, the giant beetle and Exodus do. The corpse of a pet (a creature with an owner or bonded) or of a summoned creature keeps no table, whatever its template says.

The distribution ships two sets. animals.toml has the cow, the bull, the pig, the sheep, the chicken and the fire beetle, with the amounts of the classic rules (a pig is one cut of ribs and no hides, a sheep three legs of lamb and its wool), and a template of those names them. uox3.toml has the 100 tables of UOX3’s carve.dfn, named uox3_<n> and set on 105 other creatures by moongate-convert uox-carves (see Migrate from UOX3): meat, hides, feathers, scales and the spined, horned and barbed hides.

  1. The blade asks the player what to use it on. The corpse must lie within 2 tiles and one storey (16 in height); otherwise the player is told it is too far. A corpse out of sight, behind a wall, cannot be seen.
  2. carve.corpse(corpse, user) refuses what is no corpse, a corpse that does not lie on the ground, a player’s corpse (it has a corpse.owner), a pet’s (it has a corpse.pet_owner) and a corpse that is carved already.
  3. The table is rolled, and on_carving is asked of the corpse’s script. The corpse is judged again once the hook has answered: a hook that carved the corpse itself, or took it away, leaves nothing more to do.
  4. The items are made inside the corpse, the corpse is marked corpse.carved, the carver is told the message of each entry that gave something, and the corpse_carved event is published.
  5. The blade shows the corpse to the carver again, so that a corpse the carver had open shows what was found.

A corpse with no table, or whose roll gave nothing, is marked carved all the same, and the carver is told there is nothing useful to carve. A corpse holds 125 items: what does not fit is laid on the ground at the corpse’s tile and shown to the players around, and an entry of an item that does not stack makes at most 125 items.

The script of the corpse is scripts/items/corpse.lua. It defines no hook, and a script of your own may add on_carving(serial, carver, items):

-- a sheep that gives a second pile of wool
function corpse.on_carving(serial, carver, items)
if item.get_prop(serial, "corpse.template") == "sheep" then
table.insert(items, { item = "pile_of_wool_2", amount = 3 })
return items
end
end

items is the roll, an array of { item = template id, amount = n }. Return false to cancel: nothing is made, the corpse is not marked carved and the carver is told it cannot use the blade on that. Return a table of the same shape to replace the roll; an entry that is not well formed or names no item template is left out. Anything else keeps the roll. The hook runs inside the action and must not wait: see Script hooks.

carve.corpse(corpse, user) is the function a script of your own calls to carve a corpse by other means; it gives "carved", "nothing_useful", "already_carved", "not_carvable" or "cancelled", and the range and what the player is told are the script’s. A script that listens with events.on("corpse_carved", ...) gets serial (the corpse), carver and items (how many items were made, inside the corpse or beside it, a stack counting as one); see Events and timers.

  • Carving a human corpse into a torso and limbs.
  • A sheep that gives wool only while it is unshorn: a sheep always gives its wool.
  • Showing the new items to another player who has the corpse open: they appear when the corpse is opened again.
  • A race, a facet or a skill that changes the amounts.
  • UOX3’s human table (a torso and limbs) and the entries of its tables that pick one item of a list.

Made with ❤️ by Tom

Buy me a coffee