Crossfire Server, Trunk
Treasure Lists

Introduction

Treasure lists specify what items an object can have when it is first created during a map initialisation.

Treasure lists contain items with a certain probability of apparition. When the list is instancied, so that for instance a monster can receive its items, the items are randomly chosen based on this probability, and inserted at the desired location.

Lists can reference other lists to group commony-used definitions.

The list format enables a yes-no structure, so that the presence of an item implies the presence of another (so arrows are given with a bow) or the absence of an item enables another item to be present (so a bow or a crossbow can be given, but not both).

Each item in the list has a chance factor, that determines its probability to be generated.

Treasure lists exist in two variations:

  • a treasure list will try to insert all its items in the object. Each item has a probability chance % to be generated.
  • a treasureone list will only select a random item to be inserted. An item has a probability of chance on (sum of all chance for the items in the list) to be generated

Treasure files

Treasures are defined in .trs files in the archetypes tree. For historical reasons, many are groupes in treasures.trs at the root or archetypes.

Treasure generation

When a treasure must be generated, a magic level is used to determine what items are eligible for generation. An item on a treasure list can only be generated if its magic field is less then the magic level specified.

Some flags can alter the generating behaviour. In particular, GT_ONLY_GOOD will forbid the generation of cursed or damned items.

A maximum of 100 tries will be done to generate an item, after which the generation is considered to have failed.

Treasure file format

The format is a line by line description of the treasure, and its options. The text before the first space is the field, remaining of the line is the value.

A treasure list definition starts by a treasure, treasureone, yes, no or more parameter. If treasure or treasureone is used, the part on the right of the first space is the treasure list name. The definition must end by a end line.

The line can start by spaces that will be ignored. A line starting by # is a comment and will be totally ignored.

The following fields are available:

  • treasure: starts a new treasure list, from which all items may be generated
  • treasureone: starts a new treasure list, from which only one item may be generated
  • arch: archetype name of the item to generate
  • artifact: name of the artifact to make arch of; in this case magic is ignored. If the item is incompatible with artifact, then no item is generated
  • list: treasure list name to reference
  • list_magic_value: if non-zero, list will be generated with this difficulty instead of the current one
  • list_magic_adjustment: if list_magic_value is 0, this value is added (it can be negative) to the current difficulty to generate list
  • change_name: what name to give to the generated item
  • change_title: what title to give to the generated item
  • change_slaying: what slaying to give to the generated item
  • chance: probability of the item appearing, in % for a treasure list or relative to the sum of all chance for treasureone. Defaults to 100
  • nrof: maximum number of items to generate. Omitted means archetype default
  • magic: for a list, minimum magic required for this list to be generated; for an item, the maximum magic it can have (capping the magic from the difficulty), this may restrict artifacts which may be generated; does not apply if artifact is set
  • yes: starts a new treasure that will be generated if the current item is generated
  • no: starts a new treasure that will be generated if the current item is not generated
  • end: ends the current treasure definition
  • more: starts a new treasure that will be in the same list as the current one

Either arch or list must be set.

Simple example

treasure rod
 arch rod_light
 chance 2
 no
  arch rod_heavy
  chance 1
  end
end

This treasure means:

  • there's a probability of 2% to give a rod_light
  • if no rod_light is given, then there is a probability of 1% to give a rod_heavy

Complex example

 treasure poor_old
   arch bow
   chance 5
   yes
    arch arrow
     nrof 6
     end
   more
   arch b_ssword_2
   magic 1
   chance 5
   no
     arch b_ssword_1
     chance 10
     no
       arch b_dagger
       chance 15
       no
         arch stoneaxe
        chance 20
        no
          arch club
          chance 25
          end
        end
      end
    end
  more
  arch b_small_shield
  chance 4
  more
  arch silvercoin
  nrof 8
  chance 10
  end

Given the magic of 1 or more, this list has:

  • a 5% chance of generating a bow and up to 6 arrows
  • a 5% chance of generating a b_ssword_2
  • a 95% * 10% chance of generating a b_ssword_1
  • a 95% * 90% * 15% chance of generating a b_dagger
  • (and so on)
  • a 4% chance of generating a b_small_shield
  • a 10% chance of generating silver coins, from 1 to 8