summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/artefact.h
blob: 38ee3344d4c975f23800fc1cf9cd62ae47cf1229 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
 *  File:       artefact.h
 *  Summary:    Random and unrandom artefact functions.
 *  Written by: Linley Henzell
 *
 *  Modified for Crawl Reference by $Author$ on $Date$
 */


#ifndef RANDART_H
#define RANDART_H

#include "externs.h"

// NOTE: NO_UNRANDARTS is automatically set by util/art-data.pl
#define NO_UNRANDARTS 76

#define ART_PROPERTIES ARTP_NUM_PROPERTIES

// Reserving the upper bits for later expansion/versioning.
#define RANDART_SEED_MASK  0x00ffffff

enum unrand_special_type
{
    UNRANDSPEC_EITHER,
    UNRANDSPEC_NORMAL,
    UNRANDSPEC_SPECIAL
};

// NOTE: This enumeration is automatically generated from art-data.txt
// via util/art-data.pl
enum unrand_type
{
    UNRAND_START = 180,
    UNRAND_DUMMY1 = UNRAND_START,
    UNRAND_SINGING_SWORD,    // Singing Sword
    UNRAND_TROG,             // Wrath of Trog
    UNRAND_VARIABILITY,      // Mace of Variability
    UNRAND_PRUNE,            // Glaive of Prune
    UNRAND_POWER,            // Sword of Power
    UNRAND_OLGREB,           // Staff of Olgreb
    UNRAND_WUCAD_MU,         // Staff of Wucad Mu
    UNRAND_VAMPIRES_TOOTH,   // Vampire's Tooth
    UNRAND_CURSES,           // Scythe of Curses
    UNRAND_TORMENT,          // Sceptre of Torment
    UNRAND_ZONGULDROK,       // Sword of Zonguldrok
    UNRAND_CEREBOV,          // Sword of Cerebov
    UNRAND_DISPATER,         // Staff of Dispater
    UNRAND_ASMODEUS,         // Sceptre of Asmodeus
    UNRAND_BLOODBANE,        // long sword "Bloodbane"
    UNRAND_FLAMING_DEATH,    // scimitar of Flaming Death
    UNRAND_BRILLIANCE,       // mace of Brilliance
    UNRAND_LEECH,            // demon blade "Leech"
    UNRAND_CHILLY_DEATH,     // dagger of Chilly Death
    UNRAND_MORG,             // dagger "Morg"
    UNRAND_FINISHER,         // scythe "Finisher"
    UNRAND_PUNK,             // sling "Punk"
    UNRAND_KRISHNA,          // bow of Krishna "Sharnga"
    UNRAND_SKULLCRUSHER,     // giant club "Skullcrusher"
    UNRAND_GUARD,            // glaive of the Guard
    UNRAND_JIHAD,            // sword of Jihad
    UNRAND_HELLFIRE,         // crossbow "Hellfire"
    UNRAND_DOOM_KNIGHT,      // sword of the Doom Knight
    UNRAND_EOS,              // "Eos"
    UNRAND_BOTONO,           // spear of the Botono
    UNRAND_OCTOPUS_KING,     // trident of the Octopus King
    UNRAND_ARGA,             // mithril axe "Arga"
    UNRAND_ELEMENTAL_STAFF,  // Elemental Staff
    UNRAND_SNIPER,           // hand crossbow "Sniper"
    UNRAND_PIERCER,          // longbow "Piercer"
    UNRAND_BLOWGUN_ASSASSIN, // blowgun of the Assassin
    UNRAND_WYRMBANE,         // Wyrmbane
    UNRAND_SPRIGGANS_KNIFE,  // Spriggan's Knife
    UNRAND_PLUTONIUM_SWORD,  // plutonium sword
    UNRAND_UNDEADHUNTER,     // great mace "Undeadhunter"
    UNRAND_SERPENT_SCOURGE,  // whip "Serpent-Scourge"
    UNRAND_ACCURACY,         // knife of Accuracy
    UNRAND_CRYSTAL_SPEAR,    // Lehudib's crystal spear
    UNRAND_IGNORANCE,        // shield of Ignorance
    UNRAND_AUGMENTATION,     // robe of Augmentation
    UNRAND_THIEF,            // cloak of the Thief
    UNRAND_BULLSEYE,         // shield "Bullseye"
    UNRAND_DYROVEPREVA,      // crown of Dyrovepreva
    UNRAND_MISFORTUNE,       // robe of Misfortune
    UNRAND_FLASH,            // cloak of Flash
    UNRAND_BOOTS_ASSASSIN,   // boots of the Assassin
    UNRAND_LEAR,             // Lear's chain mail
    UNRAND_ZHOR,             // skin of Zhor
    UNRAND_SALAMANDER,       // salamander hide armour
    UNRAND_WAR,              // gauntlets of War
    UNRAND_RESISTANCE,       // shield of Resistance
    UNRAND_FOLLY,            // robe of Folly
    UNRAND_MAXWELL,          // Maxwell's patent armour
    UNRAND_DRAGONMASK,       // mask of the Dragon
    UNRAND_NIGHT,            // robe of Night
    UNRAND_DRAGON_KING,      // armour of the Dragon King
    UNRAND_ALCHEMIST,        // hat of the Alchemist
    UNRAND_FENCERS_GLOVES,   // Fencer's gloves
    UNRAND_STARLIGHT,        // cloak of Starlight
    UNRAND_RATSKIN_CLOAK,    // ratskin cloak
    UNRAND_AIR,              // amulet of the Air
    UNRAND_SHADOWS,          // ring of Shadows
    UNRAND_CEKUGOB,          // amulet of Cekugob
    UNRAND_FOUR_WINDS,       // amulet of the Four Winds
    UNRAND_BLOODLUST,        // necklace of Bloodlust
    UNRAND_SHAOLIN,          // ring of Shaolin
    UNRAND_ROBUSTNESS,       // ring of Robustness
    UNRAND_MAGE,             // ring of the Mage
    UNRAND_SHIELDING,        // brooch of Shielding
    UNRAND_DUMMY2,           // DUMMY UNRANDART 2
    UNRAND_LAST = UNRAND_DUMMY2
};

// The following unrandart bits were taken from $pellbinder's mon-util
// code (see mon-util.h & mon-util.cc) and modified (LRH).
struct unrandart_entry
{
    const char *name;        // true name of unrandart (max 31 chars)
    const char *unid_name;   // un-id'd name of unrandart (max 31 chars)

    object_class_type base_type;        // class of ura
    int sub_type;        // type of ura
    int plus;        // plus of ura
    int plus2;       // plus2 of ura
    int colour;       // colour of ura
    short prpty[ART_PROPERTIES];

    // special description added to 'v' command output (max 31 chars)
    const char *desc;
    // special description added to 'v' command output (max 31 chars)
    const char *desc_id;
    // special description added to 'v' command output (max 31 chars)
    const char *desc_end;
};

bool is_known_artefact( const item_def &item );
bool is_artefact( const item_def &item );
bool is_random_artefact( const item_def &item );
bool is_unrandom_artefact( const item_def &item );
bool is_special_unrandom_artefact( const item_def &item );

unique_item_status_type get_unique_item_status(const item_def& item);
unique_item_status_type get_unique_item_status(int unrand_index);
void set_unique_item_status(const item_def& item,
                            unique_item_status_type status );
void set_unique_item_status(int unrand_index,
                            unique_item_status_type status );

/* ***********************************************************************
 * called from: itemname
 * *********************************************************************** */
std::string get_artefact_name( const item_def &item );

/* ***********************************************************************
 * called from: spl-book
 * *********************************************************************** */
void set_artefact_name( item_def &item, const std::string &name );
void set_artefact_appearance( item_def &item, const std::string &appear );

/* ***********************************************************************
 * called from: effects
 * *********************************************************************** */
std::string artefact_name( const item_def &item, bool appearance = false );

/* ***********************************************************************
 * called from: describe
 * *********************************************************************** */
const char *unrandart_descrip( int which_descrip, const item_def &item );

/* ***********************************************************************
 * called from: dungeon makeitem
 * *********************************************************************** */
int find_okay_unrandart(unsigned char aclass, unsigned char atype = OBJ_RANDOM,
                        unrand_special_type specialness = UNRANDSPEC_EITHER,
                        bool in_abyss = false);

typedef FixedVector< int, ART_PROPERTIES >  artefact_properties_t;
typedef FixedVector< bool, ART_PROPERTIES > artefact_known_props_t;

/* ***********************************************************************
 * called from: describe - fight - it_use2 - item_use - player
 * *********************************************************************** */
void artefact_desc_properties( const item_def        &item,
                              artefact_properties_t &proprt,
                              artefact_known_props_t &known,
                              bool force_fake_props = false);

void artefact_wpn_properties( const item_def       &item,
                             artefact_properties_t &proprt,
                             artefact_known_props_t &known );

void artefact_wpn_properties( const item_def &item,
                             artefact_properties_t &proprt );

int artefact_wpn_property( const item_def &item, artefact_prop_type prop,
                          bool &known );

int artefact_wpn_property( const item_def &item, artefact_prop_type prop );

int artefact_known_wpn_property( const item_def &item,
                                 artefact_prop_type prop );

int artefact_wpn_num_props( const item_def &item );
int artefact_wpn_num_props( const artefact_properties_t &proprt );

void artefact_wpn_learn_prop( item_def &item, artefact_prop_type prop );
bool artefact_wpn_known_prop( const item_def &item, artefact_prop_type prop );

/* ***********************************************************************
 * called from: dungeon
 * *********************************************************************** */
bool make_item_blessed_blade( item_def &item );
bool make_item_randart( item_def &item );
bool make_item_unrandart( item_def &item, int unrand_index );

/* ***********************************************************************
 * called from: randart - debug
 * *********************************************************************** */
bool randart_is_bad( const item_def &item );
bool randart_is_bad( const item_def &item, artefact_properties_t &proprt );

/* ***********************************************************************
 * called from: items
 * *********************************************************************** */
int find_unrandart_index(const item_def& artefact);

unrandart_entry* get_unrand_entry(int unrand_index);

unrand_special_type get_unrand_specialness(int unrand_index);
unrand_special_type get_unrand_specialness(const item_def &item);

/* ***********************************************************************
 * called from: debug
 * *********************************************************************** */
void artefact_set_properties( item_def              &item,
                              artefact_properties_t &proprt );
void artefact_set_property( item_def           &item,
                            artefact_prop_type  prop,
                            int                 val );

/* ***********************************************************************
 * called from: mapdef
 * *********************************************************************** */
int get_unrandart_num( const char *name );
#endif