1 /** 2 * @file 3 * @brief Random and unrandom artefact functions. 4 **/ 5 6 #pragma once 7 8 #include "artefact-prop-type.h" 9 #include "unique-item-status-type.h" 10 11 #define ART_PROPERTIES ARTP_NUM_PROPERTIES 12 13 #define KNOWN_PROPS_KEY "artefact_known_props" 14 #define ARTEFACT_PROPS_KEY "artefact_props" 15 #define ARTEFACT_NAME_KEY "artefact_name" 16 #define ARTEFACT_APPEAR_KEY "artefact_appearance" 17 18 #define DAMNATION_BOLT_KEY "damnation_bolt" 19 #define EMBRACE_ARMOUR_KEY "embrace_armour" 20 21 struct bolt; 22 23 enum unrand_flag_type 24 { 25 UNRAND_FLAG_NONE = 0x00, 26 UNRAND_FLAG_SPECIAL = 0x01, 27 UNRAND_FLAG_HOLY = 0x02, 28 // = 0x04, // was UNRAND_FLAG_UNHOLY 29 UNRAND_FLAG_EVIL = 0x08, 30 UNRAND_FLAG_UNCLEAN = 0x10, 31 UNRAND_FLAG_CHAOTIC = 0x20, 32 // = 0x40, // was UNRAND_FLAG_CORPSE_VIOLATING 33 UNRAND_FLAG_NOGEN = 0x80, 34 // =0x100, // was UNRAND_FLAG_RANDAPP 35 UNRAND_FLAG_UNIDED =0x200, 36 UNRAND_FLAG_SKIP_EGO =0x400, 37 // Please make sure it fits in unrandart_entry.flags (currently 16 bits). 38 }; 39 40 enum setup_missile_type 41 { 42 SM_CONTINUE, 43 SM_FINISHED, 44 SM_CANCEL, 45 }; 46 47 struct unrandart_entry 48 { 49 const char *name; // true name of unrandart 50 const char *unid_name; // un-id'd name of unrandart 51 const char *type_name; // custom item type 52 const char *inscrip; // extra inscription 53 const char *dbrand; // description of extra brand 54 const char *descrip; // description of extra power 55 56 object_class_type base_type; 57 uint8_t sub_type; 58 object_class_type fallback_base_type; 59 uint8_t fallback_sub_type; 60 int fallback_brand; 61 short plus; 62 short plus2; 63 colour_t colour; 64 65 short value; 66 uint16_t flags; 67 68 short prpty[ART_PROPERTIES]; 69 70 void (*equip_func)(item_def* item, bool* show_msgs, bool unmeld); 71 void (*unequip_func)(item_def* item, bool* show_msgs); 72 void (*world_reacts_func)(item_def* item); 73 void (*melee_effects)(item_def* item, actor* attacker, 74 actor* defender, bool mondied, int damage); 75 setup_missile_type (*launch)(item_def* item, bolt* beam, 76 string* ammo_name, bool* returning); 77 bool (*evoke_func)(item_def *item, bool* did_work, bool* unevokable); 78 bool (*targeted_evoke_func)(item_def *item, bool* did_work, bool* unevokable, dist* target); 79 }; 80 81 bool is_known_artefact(const item_def &item); 82 bool is_artefact(const item_def &item); 83 bool is_random_artefact(const item_def &item); 84 bool is_unrandom_artefact(const item_def &item, int which = 0); 85 bool is_special_unrandom_artefact(const item_def &item); 86 void autoid_unrand(item_def &item); 87 88 void artefact_fixup_props(item_def &item); 89 90 unique_item_status_type get_unique_item_status(int unrand_index); 91 void set_unique_item_status(const item_def& item, 92 unique_item_status_type status); 93 94 string get_artefact_base_name(const item_def &item, bool terse = false); 95 string get_artefact_name(const item_def &item, bool force_known = false); 96 97 void set_artefact_name(item_def &item, const string &name); 98 99 string make_artefact_name(const item_def &item, bool appearance = false); 100 string replace_name_parts(const string &name_in, const item_def& item); 101 102 int find_okay_unrandart(uint8_t aclass, uint8_t atype = OBJ_RANDOM, 103 bool in_abyss = false); 104 105 typedef FixedVector< int, ART_PROPERTIES > artefact_properties_t; 106 typedef FixedVector< bool, ART_PROPERTIES > artefact_known_props_t; 107 108 void artefact_desc_properties(const item_def &item, 109 artefact_properties_t &proprt, 110 artefact_known_props_t &known); 111 112 void artefact_known_properties(const item_def &item, 113 artefact_known_props_t &known); 114 115 void artefact_properties(const item_def &item, 116 artefact_properties_t &proprt); 117 118 int artefact_property(const item_def &item, artefact_prop_type prop); 119 120 bool artefact_property_known(const item_def &item, artefact_prop_type prop); 121 int artefact_known_property(const item_def &item, artefact_prop_type prop); 122 123 void artefact_learn_prop(item_def &item, artefact_prop_type prop); 124 125 bool make_item_randart(item_def &item, bool force_mundane = false); 126 void make_ashenzari_randart(item_def &item); 127 bool make_item_unrandart(item_def &item, int unrand_index); 128 void setup_unrandart(item_def &item, bool creating = true); 129 130 bool randart_is_bad(const item_def &item); 131 bool randart_is_bad(const item_def &item, artefact_properties_t &proprt); 132 133 int find_unrandart_index(const item_def& artefact); 134 135 const unrandart_entry* get_unrand_entry(int unrand_index); 136 137 void artefact_set_property(item_def &item, 138 artefact_prop_type prop, 139 int val); 140 141 /// Type for the value of an artefact property 142 enum artp_value_type 143 { 144 ARTP_VAL_BOOL, ///< bool (e.g. Fly) 145 ARTP_VAL_POS, ///< Positive integer (e.g. x% chance to get angry) 146 ARTP_VAL_BRAND, ///< Brand (e.g. flaming, vorpal). 147 /// See \ref brand_type in item-prop-enum.h 148 ARTP_VAL_ANY, ///< int (e.g. dex-4, AC+4, SH+8) 149 }; 150 artp_value_type artp_potential_value_types(artefact_prop_type prop); 151 152 const char *artp_name(artefact_prop_type prop); 153 bool artp_potentially_good(artefact_prop_type prop); 154 bool artp_potentially_bad(artefact_prop_type prop); 155 156 int get_unrandart_num(const char *name); 157 158 void unrand_reacts(); 159