|
Atrinik Server 2.5
|
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) |
| artifact * | find_artifact_type (const char *name, int type) |
| 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_environment_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 57 of file treasure.c.
| #define CHANCE_FIX (-1) |
Chance fix.
Definition at line 60 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 1922 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 1190 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 3283 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 Treasure generation flags values. |
| difficulty | Map difficulty. |
| t_style | Treasure style. |
| a_chance | Artifact chance. |
| tries | To avoid infinite recursion. |
| change_arch | Arch change. |
Definition at line 894 of file treasure.c.
Create an artifact.
| op | Object to turn into an artifact. |
| artifactname | Artifact to create. |
Definition at line 3257 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 192 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 Treasure generation flags values. |
| difficulty | Map difficulty. |
| t_style | Treasure style. |
| a_chance | Artifact chance. |
| tries | To avoid infinite recursion. |
| change_arch | Arch change. |
Definition at line 999 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 Treasure generation flags values. |
| difficulty | Map difficulty. |
| t_style | Treasure style. |
| a_chance | Artifact chance. |
| tries | To avoid infinite recursion. |
| arch_change | Arch change. |
Definition at line 856 of file treasure.c.
| void dump_artifacts | ( | ) |
For debugging purposes. Dumps all tables.
Definition at line 2574 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 3171 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 2608 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 2519 of file treasure.c.
| artifact* find_artifact_type | ( | const char * | name, |
| int | type | ||
| ) |
Find an artifact by its name and type (as there are several lists of artifacts, depending on their types).
| name | Name of the artifact to find. |
| type | Type of the artifact to find. |
Definition at line 2549 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 2499 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 785 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 Treasure generation flags |
Definition at line 1947 of file treasure.c.
| void free_all_treasures | ( | ) |
Free all treasure related memory.
Definition at line 2959 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 2907 of file treasure.c.
| static void free_artifactlist | ( | ) | [static] |
Free the artifact list.
Definition at line 2938 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 2891 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 2864 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 2765 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 823 of file treasure.c.
| static artifact * get_empty_artifact | ( | void | ) | [static] |
Allocate and return the pointer to an empty artifact structure.
Definition at line 2474 of file treasure.c.
| static artifactlist * get_empty_artifactlist | ( | ) | [static] |
Allocate and return the pointer to an empty artifactlist structure.
Definition at line 2455 of file treasure.c.
| static treasure * get_empty_treasure | ( | ) | [static] |
Allocate and return the pointer to an empty treasure structure.
Definition at line 743 of file treasure.c.
| static treasurelist * get_empty_treasurelist | ( | ) | [static] |
Allocate and return the pointer to an empty treasurelist structure.
Definition at line 718 of file treasure.c.
| int get_environment_level | ( | object * | op | ) |
Gets the environment level for treasure generation for the given object.
| op | Object to get environment level of. |
Definition at line 3210 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 1866 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 1894 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 2729 of file treasure.c.
| void init_archetype_pointers | ( | ) |
Initialize global archetype pointers.
Definition at line 672 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 417 of file treasure.c.
Checks if op can be combined with art.
Definition at line 2683 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 215 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 95 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 Treasure generation flags values. |
Definition at line 1164 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 1270 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 Treasure generation flags flags. |
Definition at line 1219 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 2985 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 1350 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 1775 of file treasure.c.
archetype* amulet_arch = NULL [static] |
Pointer to the 'amulet_generic' archetype.
Definition at line 67 of file treasure.c.
archetype* amulet_arch_normal = NULL [static] |
Pointer to the 'amulet_normal' archetype.
Definition at line 69 of file treasure.c.
| char* coins[NUM_COINS+1] |
{
"mitcoin",
"goldcoin",
"silvercoin",
"coppercoin",
NULL
}
All the coin arches.
Definition at line 44 of file treasure.c.
| archetype* coins_arch[NUM_COINS] |
Pointers to coin archetypes.
Definition at line 54 of file treasure.c.
Pointer to the 'ring_generic' archetype.
Definition at line 63 of file treasure.c.
archetype* ring_arch_normal = NULL [static] |
Pointer to the 'ring_normal' archetype.
Definition at line 65 of file treasure.c.
1.7.4