#include <global.h>#include <treasure.h>#include <spellist.h>#include <loader.h>Go to the source code of this file.
Defines | |
| #define | TREASURE_DEBUG |
| #define | ARTIFACT_TRIES 2 |
| #define | CHANCE_FIX (-1) |
| #define | DICE2 (get_magic(2) == 2 ? 2 : 1) |
Functions | |
| static treasure * | load_treasure (FILE *fp, int *t_style, int *a_chance) |
| static void | change_treasure (struct _change_arch *ca, object *op) |
| static treasurelist * | get_empty_treasurelist () |
| static treasure * | get_empty_treasure () |
| static void | put_treasure (object *op, object *creator, int flags) |
| static artifactlist * | get_empty_artifactlist () |
| static artifact * | get_empty_artifact () |
| static void | check_treasurelist (treasure *t, treasurelist *tl) |
| static void | set_material_real (object *op, struct _change_arch *change_arch) |
| static void | create_money_table () |
| static void | create_all_treasures (treasure *t, object *op, int flag, int difficulty, int t_style, int a_chance, int tries, struct _change_arch *change_arch) |
| static void | create_one_treasure (treasurelist *tl, object *op, int flag, int difficulty, int t_style, int a_chance, int tries, struct _change_arch *change_arch) |
| static int | set_ring_bonus (object *op, int bonus, int level) |
| static int | get_magic (int diff) |
| static void | dump_monster_treasure_rec (const char *name, treasure *t, int depth) |
| static void | free_treasurestruct (treasure *t) |
| static void | free_charlinks (linked_char *lc) |
| static void | free_artifactlist () |
| static void | free_artifact (artifact *at) |
| void | load_treasures () |
| void | init_artifacts () |
| void | init_archetype_pointers () |
| treasurelist * | find_treasurelist (const char *name) |
| object * | generate_treasure (treasurelist *t, int difficulty, int a_chance) |
| void | create_treasure (treasurelist *t, object *op, int flag, int difficulty, int t_style, int a_chance, int tries, struct _change_arch *arch_change) |
| static void | set_magic (int difficulty, object *op, int max_magic, int fix_magic, int chance_magic, int flags) |
| void | set_abs_magic (object *op, int magic) |
| static void | set_ring_item_power (object *ob) |
| static int | get_random_spell (int level, int flags) |
| static void | add_random_race (object *op) |
| int | fix_generated_item (object **op_ptr, object *creator, int difficulty, int a_chance, int t_style, int max_magic, int fix_magic, int chance_magic, int flags) |
| artifactlist * | find_artifactlist (int type) |
| archetype * | find_artifact_archtype (const char *name) |
| void | dump_artifacts () |
| static int | legal_artifact_combination (object *op, artifact *art) |
| void | give_artifact_abilities (object *op, artifact *art) |
| int | generate_artifact (object *op, int difficulty, int t_style, int a_chance) |
| void | free_all_treasures () |
| void | dump_monster_treasure (const char *name) |
| int | get_enviroment_level (object *op) |
| object * | create_artifact (object *op, char *artifactname) |
Variables | |
| char * | coins [NUM_COINS+1] |
| archetype * | coins_arch [NUM_COINS] |
| static archetype * | ring_arch = NULL |
| static archetype * | ring_arch_normal = NULL |
| static archetype * | amulet_arch = NULL |
| static archetype * | amulet_arch_normal = NULL |
Everything concerning treasures and artifacts.
Definition in file treasure.c.
| #define ARTIFACT_TRIES 2 |
Give 1 re-roll attempt per artifact
Definition at line 58 of file treasure.c.
| #define CHANCE_FIX (-1) |
Chance fix.
Definition at line 61 of file treasure.c.
| static void add_random_race | ( | object * | op | ) | [static] |
Assign a random slaying race to an object, for weapons, arrows and such.
| op | Object. |
Definition at line 1878 of file treasure.c.
| static void change_treasure | ( | struct _change_arch * | ca, | |
| object * | op | |||
| ) | [static] |
If there are change_xxx commands in the treasure, we include the changes in the generated object.
| ca | Arch to change to. | |
| op | Actual generated treasure. |
Definition at line 1184 of file treasure.c.
| static void check_treasurelist | ( | treasure * | t, | |
| treasurelist * | tl | |||
| ) | [static] |
Checks if a treasure if valid. Will also check its yes and no options.
| t | Treasure to check. | |
| tl | Needed only so that the treasure name can be printed out. |
Definition at line 3199 of file treasure.c.
| static void create_all_treasures | ( | treasure * | t, | |
| object * | op, | |||
| int | flag, | |||
| int | difficulty, | |||
| int | t_style, | |||
| int | a_chance, | |||
| int | tries, | |||
| struct _change_arch * | change_arch | |||
| ) | [static] |
Creates all the treasures.
| t | What to generate. | |
| op | For who to generate the treasure. | |
| flag | Combination of GT_xxx values. | |
| difficulty | Map difficulty. | |
| t_style | Treasure style. | |
| a_chance | Artifact chance. | |
| tries | To avoid infinite recursion. | |
| change_arch | Arch change. |
Definition at line 889 of file treasure.c.
Create an artifact.
| op | Object to turn into an artifact. | |
| artifactname | Artifact to create. |
Definition at line 3173 of file treasure.c.
| static void create_money_table | ( | ) | [static] |
Create money table, setting up pointers to the archetypes.
This is done for faster access of the coins archetypes.
Definition at line 193 of file treasure.c.
| static void create_one_treasure | ( | treasurelist * | tl, | |
| object * | op, | |||
| int | flag, | |||
| int | difficulty, | |||
| int | t_style, | |||
| int | a_chance, | |||
| int | tries, | |||
| struct _change_arch * | change_arch | |||
| ) | [static] |
Creates one treasure from the list.
| tl | What to generate. | |
| op | For who to generate the treasure. | |
| flag | Combination of GT_xxx values. | |
| difficulty | Map difficulty. | |
| t_style | Treasure style. | |
| a_chance | Artifact chance. | |
| tries | To avoid infinite recursion. | |
| change_arch | Arch change. |
Definition at line 994 of file treasure.c.
| void create_treasure | ( | treasurelist * | t, | |
| object * | op, | |||
| int | flag, | |||
| int | difficulty, | |||
| int | t_style, | |||
| int | a_chance, | |||
| int | tries, | |||
| struct _change_arch * | arch_change | |||
| ) |
This calls the appropriate treasure creation function.
| t | What to generate. | |
| op | For who to generate the treasure. | |
| flag | Combination of GT_xxx values. | |
| difficulty | Map difficulty. | |
| t_style | Treasure style. | |
| a_chance | Artifact chance. | |
| tries | To avoid infinite recursion. | |
| arch_change | Arch change. |
Definition at line 851 of file treasure.c.
| void dump_artifacts | ( | ) |
For debugging purposes. Dumps all tables.
Definition at line 2490 of file treasure.c.
| void dump_monster_treasure | ( | const char * | name | ) |
For debugging purposes. Dumps all treasures for a given monster.
| name | Name of the monster to dump treasures for. |
Definition at line 3087 of file treasure.c.
| static void dump_monster_treasure_rec | ( | const char * | name, | |
| treasure * | t, | |||
| int | depth | |||
| ) | [static] |
For debugging purposes. Dumps all treasures recursively.
Definition at line 2524 of file treasure.c.
| archetype* find_artifact_archtype | ( | const char * | name | ) |
Find the default archetype from artifact by internal artifact list name.
| name | Name. |
Definition at line 2464 of file treasure.c.
| artifactlist* find_artifactlist | ( | int | type | ) |
Searches the artifact lists and returns one that has the same type of objects on it.
| type | Type to search for. |
Definition at line 2444 of file treasure.c.
| treasurelist* find_treasurelist | ( | const char * | name | ) |
Searches for the given treasurelist in the globally linked list of treasure lists which has been built by load_treasures().
| name | Treasure list to search for. |
Definition at line 780 of file treasure.c.
| int fix_generated_item | ( | object ** | op_ptr, | |
| object * | creator, | |||
| int | difficulty, | |||
| int | a_chance, | |||
| int | t_style, | |||
| int | max_magic, | |||
| int | fix_magic, | |||
| int | chance_magic, | |||
| int | flags | |||
| ) |
This is called after an item is generated, in order to set it up right. This produced magical bonuses, puts spells into scrolls/books/wands, makes it unidentified, hides the value, etc.
| op_ptr | Object to fix. | |
| creator | For who op was created. Can be NULL. | |
| difficulty | Difficulty level. | |
| a_chance | Artifact chance. | |
| t_style | Treasure style. | |
| max_magic | Maximum magic for the item. | |
| fix_magic | Fixed magic value. | |
| chance_magic | Chance of magic. | |
| flags | One of GT_xxx |
Definition at line 1903 of file treasure.c.
| void free_all_treasures | ( | ) |
Free all treasure related memory.
Definition at line 2875 of file treasure.c.
| static void free_artifact | ( | artifact * | at | ) | [static] |
Totally frees an artifact, its next items, and such.
| at | Artifact to free. Pointer is free()d too, so becomes invalid. |
Definition at line 2823 of file treasure.c.
| static void free_artifactlist | ( | ) | [static] |
Free the artifact list.
Definition at line 2854 of file treasure.c.
| static void free_charlinks | ( | linked_char * | lc | ) | [static] |
Frees a link structure and its next items.
| lc | Item to free. Pointer is free()d too, so becomes invalid. |
Definition at line 2807 of file treasure.c.
| static void free_treasurestruct | ( | treasure * | t | ) | [static] |
Frees a treasure, including its yes, no and next items.
| t | Treasure to free. Pointer is free()d too, so becomes invalid. |
Definition at line 2780 of file treasure.c.
| int generate_artifact | ( | object * | op, | |
| int | difficulty, | |||
| int | t_style, | |||
| int | a_chance | |||
| ) |
Decides randomly which artifact the object should be turned into. Makes sure that the item can become that artifact (means magic, difficulty, and Allowed fields properly). Then calls give_artifact_abilities() in order to actually create the artifact.
| op | Object. | |
| difficulty | Difficulty. | |
| t_style | Treasure style. | |
| a_chance | Artifact chance. |
Definition at line 2681 of file treasure.c.
| object* generate_treasure | ( | treasurelist * | t, | |
| int | difficulty, | |||
| int | a_chance | |||
| ) |
This is similar to the old generate treasure function. However, it instead takes a treasurelist. It is really just a wrapper around create_treasure(). We create a dummy object that the treasure gets inserted into, and then return that treasure.
| t | Treasure list to generate from. | |
| difficulty | Treasure difficulty. |
Definition at line 818 of file treasure.c.
| static artifact * get_empty_artifact | ( | void | ) | [static] |
Allocate and return the pointer to an empty artifact structure.
Definition at line 2419 of file treasure.c.
| static artifactlist * get_empty_artifactlist | ( | ) | [static] |
Allocate and return the pointer to an empty artifactlist structure.
Definition at line 2400 of file treasure.c.
| static treasure * get_empty_treasure | ( | ) | [static] |
Allocate and return the pointer to an empty treasure structure.
Definition at line 738 of file treasure.c.
| static treasurelist * get_empty_treasurelist | ( | ) | [static] |
Allocate and return the pointer to an empty treasurelist structure.
Definition at line 713 of file treasure.c.
| int get_enviroment_level | ( | object * | op | ) |
Gets the environment level for treasure generation for the given object.
| op | Object to get environment level of. |
Definition at line 3126 of file treasure.c.
| static int get_magic | ( | int | diff | ) | [static] |
Will return a random number between 0 and 4.
It is only used in fix_generated_treasure() to set bonuses on rings and amulets. Another scheme is used to calculate the magic of weapons and armours.
| diff | Any value above 2. The higher the value, the higher is the chance of returning a low number. |
Definition at line 1822 of file treasure.c.
| static int get_random_spell | ( | int | level, | |
| int | flags | |||
| ) | [static] |
Get a random spell from the spell list.
Used for item generation which uses spells like wands, rods, etc.
| level | Level of the spell. | |
| flags | Spell use flags to check for. |
Definition at line 1850 of file treasure.c.
Fixes the given object, giving it the abilities and titles it should have due to the second artifact template.
Definition at line 2645 of file treasure.c.
| void init_archetype_pointers | ( | ) |
Initialize global archetype pointers.
Definition at line 667 of file treasure.c.
| void init_artifacts | ( | ) |
Builds up the lists of artifacts from the file in the libdir.
Can be called multiple times without ill effects.
Definition at line 418 of file treasure.c.
Checks if op can be combined with art.
Definition at line 2599 of file treasure.c.
| static treasure * load_treasure | ( | FILE * | fp, | |
| int * | t_style, | |||
| int * | a_chance | |||
| ) | [static] |
Reads one treasure from the file, including the 'yes', 'no' and 'more' options.
| fp | File to read from. | |
| t_style | Treasure style. | |
| a_chance | Artifact chance. |
Definition at line 216 of file treasure.c.
| void load_treasures | ( | ) |
Opens LIBDIR/treasure and reads all treasure declarations from it.
Each treasure is parsed with the help of load_treasure().
Definition at line 96 of file treasure.c.
Inserts generated treasure where it should go.
| op | Treasure just generated. | |
| creator | For which object the treasure is being generated. | |
| flags | Combination of GT_xxx values. |
Definition at line 1158 of file treasure.c.
| void set_abs_magic | ( | object * | op, | |
| int | magic | |||
| ) |
Sets magical bonus in an object, and recalculates the effect on the armour variable, and the effect on speed of armour.
This function doesn't work properly, should add use of archetypes to make it truly absolute.
| op | Object we're modifying. | |
| magic | Magic modifier. |
Definition at line 1264 of file treasure.c.
| static void set_magic | ( | int | difficulty, | |
| object * | op, | |||
| int | max_magic, | |||
| int | fix_magic, | |||
| int | chance_magic, | |||
| int | flags | |||
| ) | [static] |
Sets a random magical bonus in the given object based upon the given difficulty, and the given max possible bonus.
Item will be cursed if magic is negative.
| difficulty | Difficulty we want the item to be. | |
| op | The object. | |
| max_magic | What should be the maximum magic of the item. | |
| fix_magic | Fixed value of magic for the object. | |
| chance_magic | Chance to get a magic bonus. | |
| flags | Combination of GT_xxx flags. |
Definition at line 1213 of file treasure.c.
| static void set_material_real | ( | object * | op, | |
| struct _change_arch * | change_arch | |||
| ) | [static] |
Set object's object::material_real.
| op | Object to set material_real for. | |
| change_arch | Change arch. |
Definition at line 2901 of file treasure.c.
| static int set_ring_bonus | ( | object * | op, | |
| int | bonus, | |||
| int | level | |||
| ) | [static] |
Randomly adds one magical ability to the given object.
Modified for Partial Resistance in many ways:
Changes the item's value.
| op | Ring or amulet to change. | |
| bonus | Bonus to add to item. | |
| level | Level. |
Definition at line 1344 of file treasure.c.
| static void set_ring_item_power | ( | object * | ob | ) | [static] |
Calculate the item power of the given ring/amulet.
| ob | The ring/amulet. |
Definition at line 1736 of file treasure.c.
archetype* amulet_arch = NULL [static] |
Pointer to the 'amulet_generic' archetype.
Definition at line 68 of file treasure.c.
archetype* amulet_arch_normal = NULL [static] |
Pointer to the 'amulet_normal' archetype.
Definition at line 70 of file treasure.c.
| char* coins[NUM_COINS+1] |
{
"mitcoin",
"goldcoin",
"silvercoin",
"coppercoin",
NULL
}
All the coin arches.
Definition at line 45 of file treasure.c.
| archetype* coins_arch[NUM_COINS] |
Pointers to coin archetypes.
Definition at line 55 of file treasure.c.
Pointer to the 'ring_generic' archetype.
Definition at line 64 of file treasure.c.
archetype* ring_arch_normal = NULL [static] |
Pointer to the 'ring_normal' archetype.
Definition at line 66 of file treasure.c.
1.6.2