From 47173f1092b4f4f3bdc0da19d6dc4553f62cdee7 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 6 Dec 2007 09:54:50 +0000 Subject: "?/" can now be used to look up items. A side effect of this is that item descriptions have been moved to dat/descript/items.txt and dat/descript/unident.txt. STL maps are now used to look up exact matches for the names of monsters, features and spells, so that looking them up with "?/" won't get too slow if there's a large descriptions DB and each key has to be tested if its a monster/spell/etc. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3009 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 5 + crawl-ref/source/command.cc | 59 +- crawl-ref/source/dat/descript/items.txt | 1478 +++++++++++++++++++++ crawl-ref/source/dat/descript/unident.txt | 79 ++ crawl-ref/source/database.cc | 1 + crawl-ref/source/describe.cc | 2038 ++++------------------------- crawl-ref/source/enum.h | 2 + crawl-ref/source/itemname.cc | 280 +++- crawl-ref/source/itemname.h | 11 + crawl-ref/source/itemprop.cc | 26 +- crawl-ref/source/mon-util.cc | 35 +- crawl-ref/source/mon-util.h | 1 + crawl-ref/source/spl-util.cc | 32 +- crawl-ref/source/spl-util.h | 1 + crawl-ref/source/terrain.cc | 31 + crawl-ref/source/terrain.h | 2 + 16 files changed, 2194 insertions(+), 1887 deletions(-) create mode 100644 crawl-ref/source/dat/descript/unident.txt diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index db89ab8298..90cc3e91d8 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3491,6 +3491,11 @@ static bool initialise(void) // Initialise internal databases. databaseSystemInit(); + + init_feat_desc_cache(); + init_mon_name_cache(); + init_spell_name_cache(); + init_item_name_cache(); cio_init(); diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 32aaf00a4d..289abab104 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -47,6 +47,7 @@ #include "spl-util.h" #include "state.h" #include "stuff.h" +#include "terrain.h" #include "transfor.h" #include "version.h" #include "view.h" @@ -906,10 +907,35 @@ static bool spell_filter(std::string key, std::string body) return (spell_by_name(key) == SPELL_NO_SPELL); } +static bool item_filter(std::string key, std::string body) +{ + return (item_types_by_name(key).base_type == OBJ_UNASSIGNED); +} + static bool feature_filter(std::string key, std::string body) { - return (spell_by_name(key) != SPELL_NO_SPELL - || get_monster_by_name(key.c_str(), true) != MONS_PROGRAM_BUG); + return (feat_by_desc(key) == DNGN_UNSEEN); +} + +typedef void (*db_keys_recap)(std::vector&); + +static void recap_mon_keys(std::vector &keys) +{ + for (unsigned int i = 0, size = keys.size(); i < size; i++) + { + monster_type type = get_monster_by_name(keys[i], true); + keys[i] = mons_type_name(type, DESC_PLAIN); + } +} + +static void recap_feat_keys(std::vector &keys) +{ + for (unsigned int i = 0, size = keys.size(); i < size; i++) + { + dungeon_feature_type type = feat_by_desc(keys[i]); + keys[i] = feature_description(type); + //fprintf(stderr, "%s\n", keys[i].c_str()); + } } static bool do_description(std::string key) @@ -976,17 +1002,19 @@ static bool find_description() clrscr(); viewwindow(true, false); - mpr("Describe a (M)onster, (S)pell, (F)eature, (G)od " + mpr("Describe a (M)onster, (S)pell, (I)tem, (F)eature, (G)od " "or (B)ranch?", MSGCH_PROMPT); int ch = toupper(getch()); std::string type; std::string extra; - db_find_filter filter; + db_find_filter filter = NULL; + db_keys_recap recap = NULL; bool want_regex = true; bool want_sort = true; bool doing_mons = false; + bool doing_items = false; bool doing_gods = false; bool doing_branches = false; @@ -997,15 +1025,24 @@ static bool find_description() extra = " Enter a single letter to list monsters displayed by " "that symbol."; filter = monster_filter; + recap = recap_mon_keys; doing_mons = true; break; case 'S': type = "spell"; filter = spell_filter; break; + case 'I': + type = "item"; + extra = " Enter a single letter to list items displayed by " + "that symbol."; + filter = item_filter; + doing_items = true; + break; case 'F': type = "feature"; filter = feature_filter; + recap = recap_feat_keys; break; case 'G': type = "god"; @@ -1052,7 +1089,8 @@ static bool find_description() } } - bool by_mon_symbol = (doing_mons && regex.size() == 1); + bool by_mon_symbol = (doing_mons && regex.size() == 1); + bool by_item_symbol = (doing_items && regex.size() == 1); if (by_mon_symbol) want_regex = false; @@ -1073,6 +1111,8 @@ static bool find_description() if (by_mon_symbol) key_list = get_monster_keys(regex[0]); + else if (by_item_symbol) + key_list = item_name_list_for_glyph(regex[0]); else if (doing_gods) key_list = get_god_keys(); else if (doing_branches) @@ -1080,6 +1120,9 @@ static bool find_description() else key_list = get_desc_keys(regex, filter); + if (recap != NULL) + (*recap)(key_list); + if (key_list.size() == 0) { if (by_mon_symbol) @@ -1088,6 +1131,12 @@ static bool find_description() list_commands_err += regex; list_commands_err += "'"; } + else if (by_item_symbol) + { + list_commands_err = "No items with symbol '"; + list_commands_err += regex; + list_commands_err += "'"; + } else { list_commands_err = "No matching "; diff --git a/crawl-ref/source/dat/descript/items.txt b/crawl-ref/source/dat/descript/items.txt index e69de29bb2..0f8813be44 100644 --- a/crawl-ref/source/dat/descript/items.txt +++ b/crawl-ref/source/dat/descript/items.txt @@ -0,0 +1,1478 @@ +%%%% +club + +A heavy piece of wood. +%%%% +mace + +A long handle with a heavy lump on one end. +%%%% +flail + +Like a mace, but with a length of chain between the handle and the +lump of metal. +%%%% +dagger + +A long knife or a very short sword, which can be held or thrown. +%%%% +morningstar + +A mace covered in spikes. +%%%% +short sword + +A sword with a short, slashing blade. +%%%% +long sword + +A sword with a long, slashing blade. +%%%% +great sword + +A sword with a very long, heavy blade and a long handle. +%%%% +scimitar + +A long sword with a curved blade. +%%%% +hand axe + +A small axe designed for either hand combat or throwing. +%%%% +battleaxe + +A large axe with a double-headed blade. +%%%% +spear + +A long stick with a pointy blade on one end, to be held or thrown. +%%%% +halberd + +A long pole with a spiked axe head on one end. +%%%% +sling + +A piece of cloth and leather for launching stones, which do a small +amount of damage on impact. +%%%% +bow + +A curved piece of wood and string, for shooting arrows. It does good +damage in combat, and a skilled user can use it to great effect. +%%%% +crossbow + +A piece of machinery used for firing bolts, which takes some time to +load and fire. It does very good damage in combat. +%%%% +hand crossbow + +A small crossbow, for firing darts. +%%%% +glaive + +A pole with a large, heavy blade on one end. +%%%% +quarterstaff + +A sturdy wooden pole. +%%%% +scythe + +A farm implement, usually unsuited to combat. +%%%% +giant club + +A giant lump of wood, shaped for an ogre's hands. +%%%% +giant spiked club + +A giant lump of wood with sharp spikes at one end. +%%%% +eveningstar + +The opposite of a morningstar. +%%%% +quick blade + +A small and magically quick sword. +%%%% +katana + +A very rare and extremely effective imported weapon, featuring a long +single-edged blade. +%%%% +executioner's axe + +A huge axe. +%%%% +double sword + +A magical weapon with two razor-sharp blades. +%%%% +triple sword + +A magical weapon with three great razor-sharp blades. +%%%% +hammer + +The kind of thing you hit nails with, adapted for battle. +%%%% +ancus + +A large and vicious toothed club. +%%%% +whip + +A whip. +%%%% +sabre + +A sword with a medium length slashing blade. +%%%% +demon blade + +A terrible weapon, forged in the fires of Hell. +%%%% +demon whip + +A terrible weapon, woven in the depths of the inferno. +%%%% +demon trident + +A terrible weapon, molded by fire and brimstone. +%%%% +broad axe + +An axe with a large blade. +%%%% +war axe + +An axe intended for hand to hand combat. +%%%% +trident + +A hafted weapon with three points at one end. +%%%% +spiked flail + +A flail with large spikes on the metal lump. +%%%% +great mace + +A large and heavy mace. +%%%% +dire flail + +A flail with spiked lumps on both ends. +%%%% +knife + +A simple survival knife. Designed more for utility than combat, it +looks quite capable of butchering a corpse. +%%%% +blowgun + +A long, light tube, open at both ends. Doing very little damage, its +main use is to fire poisoned needles from afar. It makes very little +noise. +%%%% +falchion + +A sword with a broad slashing blade. +%%%% +blessed blade + +A blade blessed by the Shining One. +%%%% +longbow + +A long, strong bow made of yew. It does excellent damage in combat and +a skilled archer can use it to great effect. +%%%% +lajatang + +A very rare and extremely effective imported weapon, featuring a pole +with half-moon blades at both ends. +%%%% +lochaber axe + +An enormous combination of a pike and a battle axe. +%%%% +stone + +A stone. It can be thrown by hand or fired with a sling. +%%%% +arrow + +An arrow, to be shot with a bow. +%%%% +bolt + +A crossbow bolt. +%%%% +dart + +A small throwing weapon. It can also be fired from a hand crossbow. +%%%% +needle + +A needle. It can be fired with a blowgun. +%%%% +large rock + +A rock, used by giants as a missile. +%%%% +sling bullet + +A small heavy projectile made of lead. It can be fired from a sling. +%%%% +javelin + +A long, light polearm that can be thrown by hand. +%%%% +throwing net + +A throwing net as used by gladiators. +%%%% +robe + +A cloth robe. +%%%% +leather armour + +A suit made of hardened leather. +%%%% +ring mail + +A leather suit covered in little rings. +%%%% +scale mail + +A leather suit covered in little metal plates. +%%%% +chain mail + +A suit made of interlocking metal rings. +%%%% +splint mail + +A suit made of splints of metal. +%%%% +banded mail + +A suit made of bands of metal. +%%%% +plate mail + +A suit of mail and large plates of metal. +%%%% +shield + +A piece of metal, to be strapped on one's arm. It is cumbersome to +wear, and slightly slows the rate at which you may attack. +%%%% +wand of flame + +A magical device which throws little bits of flame. +%%%% +wand of frost + +A magical device which throws little bits of frost. +%%%% +wand of slowing + +A magical device which casts enchantments to slow down the actions of +a creature at which it is directed. +%%%% +wand of hasting + +A magical device which casts enchantments to speed up the actions of a +creature at which it is directed. +%%%% +wand of magic darts + +A magical device which throws small bolts of destructive energy. +%%%% +wand of healing + +A magical device which can heal a creature's wounds. +%%%% +wand of paralysis + +A magical device which can render a creature immobile. +%%%% +wand of fire + +A magical device which throws great bolts of fire. +%%%% +wand of cold + +A magical device which throws great bolts of cold. +%%%% +wand of confusion + +A magical device which induces confusion and bewilderment in a target +creature. +%%%% +wand of invisibility + +A magical device which hides a creature from the view of others. +%%%% +wand of digging + +A magical device which drills tunnels through unworked rock. +%%%% +wand of fireball + +A magical device which throws exploding blasts of flame. +%%%% +wand of teleportation + +A magical device which causes a creature to be randomly translocated. +%%%% +wand of lightning + +A magical device which throws great bolts of lightning. +%%%% +wand of polymorph other + +A magical device which causes a creature to be transmogrified into +another form. It doesn't work on you, so don't even try. +%%%% +wand of enslavement + +A magical device which causes slavish obedience in a creature. +%%%% +wand of draining + +A magical device which throws a bolt of negative energy which drains +the life essences of living creatures, but is useless against the +undead. +%%%% +wand of random effects + +A magical device which can produce a variety of effects. +%%%% +wand of disintegration + +A magical device which disrupts the physical structure of anything but +the hardest walls -- even rigid statues, to say nothing of flesh. +%%%% +meat ration + +A filling ration of dried and preserved meats. +%%%% +bread ration + +A filling ration of breads. +%%%% +pear + +A delicious juicy fruit. +%%%% +apple + +A delicious red or green fruit. +%%%% +choko + +An almost tasteless green vegetable, which grows on a vine. +%%%% +honeycomb + +A lump of the delicious honeycomb made by giant bees. +%%%% +royal jelly + +A lump of the magical substance produced by giant bees to be fed to +their queens. +%%%% +snozzcumber + +A repulsive cucumber-shaped vegetable. +%%%% +slice of pizza + +A slice of pizza. Don't tell me you don't know what that is! +%%%% +apricot + +A delicious orange fruit. +%%%% +orange + +A delicious juicy orange fruit. +%%%% +banana + +A delicious yellow fruit, probably grown and imported by some amoral +multinational as the result of a corrupt trade deal. +%%%% +strawberry + +A small but delicious red fruit. +%%%% +rambutan + +A small but delicious tropical fruit. How it got into this dungeon is +anyone's guess. +%%%% +lemon + +A yellow fruit. +%%%% +grape + +A small fruit. +%%%% +sultana + +A dried fruit of some sort, possibly a grape. +%%%% +lychee + +A tropical fruit. +%%%% +beef jerky + +A strip of preserved dead cow or bull. +%%%% +cheese + +A lump of cheese. +%%%% +sausage + +An elongated lump of low-grade gristle, entrails and cereal products +encased in an intestine. Yum! +%%%% +chunk of flesh + +A piece of dungeon meat. +%%%% +scroll of identify + +This useful magic scroll allows you to determine the properties of any +object. +%%%% +scroll of teleportation + +Reading the words on this scroll translocates you to a random +position. +%%%% +scroll of fear + +This scroll causes great fear in those who see the one who reads it. +%%%% +scroll of noise + +This prank scroll, often slipped into a wizard's backpack by a devious +apprentice, causes a loud noise. It is not otherwise noted for its +usefulness. +%%%% +scroll of remove curse + +Reading this scroll removes curses from the items you are using. +%%%% +scroll of detect curse + +This scroll allows you to detect the presence of cursed items among +your possessions. +%%%% +scroll of summoning + +This scroll opens a conduit to the Abyss and draws a terrible beast to +this world for a limited time. +%%%% +scroll of enchant weapon i + +This scroll places an enchantment on a weapon, making it more accurate +in combat. It may fail to affect weapons already heavily enchanted. +%%%% +scroll of enchant armour + +This scroll places an enchantment on a piece of armour. +%%%% +scroll of torment + +This scroll calls on the powers of Hell to inflict great pain on any +nearby creature - including you! +%%%% +scroll of random uselessness + +It is easy to be blinded to the essential uselessness of this scroll +by the sense of achievement you get from getting it to work at all. +%%%% +scroll of curse weapon + +This scroll places a curse on a weapon. +%%%% +scroll of curse armour + +This scroll places a curse on a piece of armour. +%%%% +scroll of immolation + +Small writing on the back of the scroll reads: "Warning: contents +under pressure. Do not use near flammable objects." +%%%% +scroll of blinking + +This scroll allows its reader to teleport a short distance, with +precise control. Be wary that controlled teleports will cause the +subject to become contaminated with magical energy. +%%%% +scroll of paper + +Apart from a label, this scroll is blank. +%%%% +scroll of magic mapping + +This scroll reveals the nearby surroundings of one who reads it. +%%%% +scroll of fog + +This scroll surrounds the reader with a dense cloud of fog. +%%%% +scroll of acquirement + +This wonderful scroll causes the creation of a valuable item to appear +before the reader. It is especially treasured by specialist magicians, +as they can use it to obtain the powerful spells of their specialty. +%%%% +scroll of enchant weapon ii + +This scroll places an enchantment on a weapon, making it inflict +greater damage in combat. It may fail to affect weapons already +heavily enchanted. +%%%% +scroll of vorpalise weapon + +This scroll enchants a weapon so as to make it far more effective at +inflicting harm on its wielder's enemies. Using it on a weapon already +affected by some kind of special enchantment (other than that produced +by a normal scroll of enchant weapon) is not advised. +%%%% +scroll of recharging + +This scroll restores the charges of any magical wand wielded by its +reader. +%%%% +scroll of enchant weapon iii + +This scroll enchants a weapon to be far more effective in +combat. Although it can be used in the creation of especially +enchanted weapons, it may fail to affect those already heavily +enchanted. +%%%% +ring of regeneration + +This wonderful ring greatly increases the recuperative powers of its +wearer, but also considerably speeds his or her metabolism. +%%%% +ring of protection + +This ring either protects its wearer from harm or makes them more +vulnerable to injury, to a degree dependent on its power. +%%%% +ring of protection from fire + +This ring provides protection from heat and fire. +%%%% +ring of poison resistance + +This ring provides protection from the effects of poisons and venom. +%%%% +ring of protection from cold + +This ring provides protection from cold. +%%%% +ring of strength + +This ring increases or decreases the physical strength of its wearer, +to a degree dependent on its power. +%%%% +ring of slaying + +This ring increases the hand-to-hand and missile combat skills of its +wearer. +%%%% +ring of see invisible + +This ring allows its wearer to see those things hidden from view by +magic. +%%%% +ring of invisibility + +This powerful ring can be activated to hide its wearer from the view +of others, but increases the speed of his or her metabolism greatly +while doing so. +%%%% +ring of hunger + +This accursed ring causes its wearer to hunger considerably more +quickly. +%%%% +ring of teleportation + +This ring occasionally exerts its power to randomly translocate its +wearer to another place, and can be deliberately activated for the +same effect. +%%%% +ring of evasion + +This ring makes its wearer either more or less capable of avoiding +attacks, depending on its degree of enchantment. +%%%% +ring of sustain abilities + +This ring protects its wearer from the loss of their strength, +dexterity and intelligence. +%%%% +ring of sustenance + +This ring provides energy to its wearer, so that they need eat less +often. +%%%% +ring of dexterity + +This ring increases or decreases the dexterity of its wearer, +depending on the degree to which it has been enchanted. +%%%% +ring of intelligence + +This ring increases or decreases the mental ability of its wearer, +depending on the degree to which it has been enchanted. +%%%% +ring of wizardry + +This ring increases the ability of its wearer to use magical spells. +%%%% +ring of magical power + +This ring increases its wearer's reserves of magical power. +%%%% +ring of levitation + +This ring allows its wearer to hover above the floor. +%%%% +ring of life protection + +This blessed ring protects the life-force of its wearer from negative +energy, making them partially immune to the draining effects of undead +and necromantic magic. +%%%% +ring of protection from magic + +This ring increases its wearer's resistance to hostile enchantments. +%%%% +ring of fire + +This ring brings its wearer more in contact with the powers of +fire. He or she gains resistance to heat and can use fire magic more +effectively, but becomes more vulnerable to the effects of cold. +%%%% +ring of ice + +This ring brings its wearer more in contact with the powers of cold +and ice. He or she gains resistance to cold and can use ice magic more +effectively, but becomes more vulnerable to the effects of fire. +%%%% +ring of teleport control + +This ring allows its wearer to control the destination of any +teleportation, although without perfect accuracy. Trying to teleport +into a solid object will result in a random teleportation, at least in +the case of a normal teleportation. Also be wary that controlled +teleports will contaminate the subject with residual magical energy. +%%%% +amulet of rage + +This amulet enables its wearer to attempt to enter a state of berserk +rage, and increases their chance of successfully doing so. It also +partially protects the user from passing out when coming out of that +rage. +%%%% +amulet of resist slowing + +This amulet protects its wearer from some magically induced forms of +slowness, and increases the duration of enchantments which speed his +or her actions. +%%%% +amulet of clarity + +This amulet protects its wearer from some forms of mental confusion. +%%%% +amulet of warding + +This amulet repels some of the attacks of creatures which have been +magically summoned, and also makes the wearer more resistant to +draining attacks. +%%%% +amulet of resist corrosion + +This amulet protects the wearer and their equipment from corrosion +caused by acids, although not infallibly so. +%%%% +amulet of the gourmand + +This amulet protects its wearer from sickness from eating fresh raw +meat and allows them to digest it when not hungry, but its effects on +the wearer's digestion are cumulative over time, and are initially +small. +%%%% +amulet of conservation + +This amulet protects some of the possessions of its wearer from +outright destruction, but not infallibly so. +%%%% +amulet of controlled flight + +Should the wearer of this amulet be levitated by magical means, he or +she will be able to exercise some control over the resulting +motion. This allows the descent of staircases and the retrieval of +items lying on the ground, for example, but does not deprive the +wearer of the benefits of levitation. +%%%% +amulet of inaccuracy + +This amulet makes its wearer less accurate in hand combat. +%%%% +amulet of resist mutation + +This amulet protects its wearer from mutations, although not +infallibly so. +%%%% +potion of healing + +A blessed fluid which heals some wounds, clears the mind, and cures +diseases. If one uses it when they are at or near full health, it can +also slightly repair permanent injuries. +%%%% +potion of heal wounds + +A magical healing elixir which causes wounds to close and heal almost +instantly. If one uses it when they are at or near full health, it can +also repair permanent injuries. +%%%% +potion of speed + +An enchanted beverage which speeds the actions of anyone who drinks +it. +%%%% +potion of might + +A magic potion which greatly increases the strength and physical power +of one who drinks it. +%%%% +potion of gain strength + +A potion of beneficial mutation. +%%%% +potion of gain dexterity + +A potion of beneficial mutation. +%%%% +potion of gain intelligence + +A potion of beneficial mutation. +%%%% +potion of levitation + +A potion which confers great buoyancy on one who consumes it. +%%%% +potion of poison + +A nasty poisonous liquid. +%%%% +potion of slowing + +A potion which slows your actions. +%%%% +potion of paralysis + +A potion which eliminates your control over your own body. +%%%% +potion of confusion + +A potion which confuses your perceptions and reduces your control over +your own actions. +%%%% +potion of invisibility + +A potion which hides you from the sight of others. +%%%% +potion of porridge + +A filling potion of sludge, high in cereal fibre. +%%%% +potion of degeneration + +A noxious concoction which can do terrible things to your body, brain +and reflexes. +%%%% +potion of decay + +A vile and putrid cursed liquid which causes your flesh to decay +before your very eyes. +%%%% +potion of water + +A unique substance, vital for the existence of most life. +%%%% +potion of experience + +A truly wonderful and very rare drink. +%%%% +potion of magic + +A valuable potion which grants a person with an infusion of magical +energy. +%%%% +potion of restore abilities + +A potion which restores the abilities of one who drinks it. +%%%% +potion of strong poison + +A terribly venomous potion. +%%%% +potion of berserk rage + +A potion which can send one into an incoherent rage. +%%%% +potion of cure mutation + +A potion which removes some or all of any mutations which may be +afflicting you. +%%%% +potion of mutation + +A potion which does very strange things to you. +%%%% +potion of blood + +A potion containing the essence of life. Vital for all living +creatures, as well as some undead ones. +%%%% +potion of resistance + +A potion which grants you temporary resistance to the elements and +poison. +%%%% +book of minor magic + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of conjurations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of flames + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of frost + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of summonings + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of fire + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of ice + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of surveyances + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of spatial translocations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of enchantments + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +young poisoner's handbook + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of the tempests + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of death + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of hinderance + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of changes + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of transfigurations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of practical magic + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of war chants + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of clouds + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of healing + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of necromancy + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +necronomicon + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of callings + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of charms + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of demonology + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of air + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of the sky + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of divinations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of the warp + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of envenomations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of annihilations + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of unlife + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +tome of destruction + +An extremely powerful but unpredictable book of magic. +%%%% +book of control + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of morphology + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of tukima + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of geomancy + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of the earth + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +manual + +A valuable book of magic which allows one to practise a certain skill +greatly. As it is used, it gradually disintegrates and will eventually +fall apart. +%%%% +book of wizardry + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of power + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of cantrips + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of party tricks + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +monster manual + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +book of stalking + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +staff of wizardry + +This staff significantly increases the ability of its wielder to use +magical spells. +%%%% +staff of power + +This staff provides a reservoir of magical power to its wielder. +%%%% +staff of fire + +This staff increases the power of fire spells cast by its wielder, and +protects him or her from the effects of heat and fire. It can burn +those struck by it. +%%%% +staff of cold + +This staff increases the power of ice spells cast by its wielder, and +protects him or her from the effects of cold. It can freeze those +struck by it. +%%%% +staff of poison + +This staff increases the power of poisoning spells cast by its +wielder, and protects him or her from the effects of poison. It can +poison those struck by it. +%%%% +staff of energy + +This staff allows its wielder to cast magical spells without hungering +as a result. +%%%% +staff of death + +This staff increases the power of necromantic spells cast by its +wielder. It can cause great pain in those living souls its wielder +strikes. +%%%% +staff of conjuration + +This staff increases the power of conjurations cast by its wielder. +%%%% +staff of enchantment + +This staff increases the power of enchantments cast by its wielder. +%%%% +staff of summoning + +This staff increases the power of summonings cast by its wielder. +%%%% +staff of air + +This staff increases the power of air spells cast by its wielder. It +can shock those struck by it. +%%%% +staff of earth + +This staff increases the power of earth spells cast by its wielder. It +can crush those struck by it. +%%%% +staff of channeling + +This staff allows its caster to channel ambient magical energy for his +or her own purposes. +%%%% +rod of smiting + +This rod allows its wielder to smite foes from afar. The wielder must +be at least level four to safely use this ability, which drains four +charges. +%%%% +rod of summoning + +This rod contains spells of summoning. +%%%% +rod of destruction + +This rod contains spells of mayhem and destruction. +%%%% +rod of warding + +This rod contains spells designed to repel one's enemies. +%%%% +rod of discovery + +This rod contains spells which reveal various aspects of an explorer's +surroundings to them. +%%%% +rod of demonology + +This rod contains spells of mayhem and destruction. +%%%% +rod of striking + +This rod allows its wielder to strike foes from afar with force bolts. +%%%% +rod of venom + +This rod contains offensive and defensive spells of poison. +%%%% +orb of zot + +Once you have escaped to the surface with this invaluable artefact, +your quest is complete. +%%%% +bottled efreet + +A mighty efreet, captured by some wizard and bound into a bronze +flask. Breaking the flask's seal will release it to wreak havoc - +possibly on you. +%%%% +crystal ball of seeing + +A magical device which allows one to see the layout of their +surroundings. It requires a degree of magical ability to be used +reliably, otherwise it can produce unpredictable and possibly harmful +results. +%%%% +air elemental fan + +A magical device for summoning air elementals. It is rather +unreliable, and usually requires several attempts to function +correctly. Using it carries an element of risk, which is reduced if +one is skilled in the appropriate elemental magic. +%%%% +lamp of fire + +A magical device for summoning fire elementals. It is rather +unreliable, and usually requires several attempts to function +correctly. Using it carries an element of risk, which is reduced if +one is skilled in the appropriate elemental magic. +%%%% +stone of earth elementals + +A magical device for summoning earth elementals. It is rather +unreliable, and usually requires several attempts to function +correctly. Using it carries an element of risk, which is reduced if +one is skilled in the appropriate elemental magic. +%%%% +lantern of shadows + +An unholy device which calls on the powers of darkness to assist its +user, with a small cost attached. +%%%% +horn of geryon + +The horn belonging to Geryon, guardian of the Vestibule of +Hell. Legends say that a mortal who desires access into one of the +Hells must use it in order to gain entry. +%%%% +box of beasts + +A magical box containing many wild beasts. One may allow them to +escape by opening the box's lid. +%%%% +crystal ball of energy + +A magical device which can be used to restore one's reserves of +magical energy, but the use of which carries the risk of draining all +of those energies completely. This risk varies inversely with the +proportion of their maximum energy which the user possesses; a user +near his or her full potential will find this item most beneficial. +%%%% +empty ebony casket + +A magical box after its power is spent. +%%%% +crystal ball of fixation + +A dangerous item which hypnotises anyone so unwise as to gaze into it, +leaving them helpless for a significant length of time. +%%%% +disc of storms + +This extremely powerful item can unleash a destructive storm of +electricity. It is especially effective in the hands of one skilled in +air elemental magic, but cannot be used by one who is not a conductor. +%%%% +deck of escape + +A deck of magical cards, mainly dealing with various forms of +escape. Incautious use may lead to being dumped from the frying pan +into the fire! +%%%% +deck of destruction + +A deck of magical cards, most of which hurl death and destruction at +one's foes (or, if unlucky, at oneself.) +%%%% +deck of dungeons + +A deck of magical cards which deal with shaping the dungeon. Unlike +most other decks, the cards from this deck tend to be ignored by +Nemelex, who prefers more amusing pursuits. +%%%% +deck of summonings + +A deck of magical cards, depicting a range of weird and wondrous +creatures. +%%%% +deck of wonders + +A deck of highly mysterious and magical cards, which can permanently +alter the drawer's physical and mental condition, for better or worse. +%%%% +deck of punishment + +A deck of magical cards which wreak havoc on the user. +%%%% +deck of war + +A deck of magical cards which are useful before and during battle. +%%%% +deck of changes + +A deck of magical cards which induce changes in the user or his +environment. +%%%% +deck of defense + +A deck of magical cards, most of which defend the user from harm in +various ways. +%%%% +rune of zot + +A talisman which allows entry into Zot's domain. +%%%% +helmet + +A piece of metal headgear. +%%%% +helm + +A piece of metal headgear. +%%%% +cap + +A cloth or leather cap. +%%%% +wizard's hat + +A conical cloth hat. +%%%% +gold piece + +A pile of glittering gold coins. +%%%% +corpse + +A corpse +%%%% +skeleton + +A decaying skeleton. +%%%% +eggplant + +A rotten eggplant which you can throw at the Crawl developers. (It's a +bug if you ever see this message). +%%%% +cloak + +A cloth cloak. +%%%% +gloves + +A pair of gloves. +%%%% +centaur barding + +An armour made for centaurs, to wear over their equine half. +%%%% +naga barding + +A special armour made for nagas, to wear over their tails. +%%%% +boots + +A pair of boots. +%%%% +buckler + +A small shield. +%%%% +large shield + +Like a normal shield, only larger. +%%%% +dragon hide + +The scaly skin of a dragon. I suppose you could wear it if you really +wanted to. +%%%% +troll hide + +The stiff and knobbly hide of a troll. I suppose you could wear it if +you really wanted to. +%%%% +crystal plate mail + +An incredibly heavy but extremely effective suit of crystalline +armour. It is somewhat resistant to corrosion. +%%%% +dragon armour + +A magical armour, made from the scales of a fire-breathing dragon. It +provides great protection from the effects of fire, but renders its +wearer more susceptible to the effects of cold. +%%%% +troll leather armour + +A magical armour, made from the stiff and knobbly skin of a common +troll. It magically regenerates its wearer's flesh at a fairly slow +rate (unless already a troll). +%%%% +ice dragon hide + +The scaly skin of a dragon. I suppose you could wear it if you really +wanted to. +%%%% +ice dragon armour + +A magical armour, made from the scales of a cold-breathing dragon. It +provides great protection from the effects of cold, but renders its +wearer more susceptible to the effects of fire and heat. +%%%% +steam dragon hide + +The soft and supple scaly skin of a steam dragon. I suppose you could +wear it if you really wanted to. +%%%% +steam dragon armour + +A magical armour, made from the scales of a steam-breathing +dragon. Although unlike the armour made from the scales of some larger +dragons it does not provide its wearer with much in the way of special +magical protection, it is extremely light and as supple as cloth. +%%%% +mottled dragon hide + +The weirdly-patterned scaley skin of a mottled dragon. I suppose you +could wear it if you really wanted to. +%%%% +mottled dragon armour + +A magical armour made from the scales of a mottled dragon. Although +unlike the armour made from the scales of some larger dragons it does +not provide its wearer with much in the way of special magical +protection, it is as light and relatively uncumbersome as leather +armour. +%%%% +storm dragon hide + +The hide of a storm dragon, covered in extremely hard blue scales. I +suppose you could wear it if you really wanted to. +%%%% +storm dragon armour + +A magical armour made from the scales of a lightning-breathing +dragon. It is heavier than most dragon scale armours, but gives its +wearer great resistance to electrical discharges. +%%%% +gold dragon hide + +The extremely tough and heavy skin of a golden dragon, covered in +shimmering golden scales. I suppose you could wear it if you really +wanted to. +%%%% +gold dragon armour + +A magical armour made from the golden scales of a golden dragon. It is +extremely heavy and cumbersome, but confers resistances to fire, cold, +and poison on its wearer. +%%%% +animal skin + +The skins of several animals. +%%%% +swamp dragon hide + +The slimy skin of a swamp-dwelling dragon. I suppose you could wear it +if you really wanted to. +%%%% +swamp dragon armour + +A magical armour made from the scales of a swamp dragon. It confers +resistance to poison on its wearer. +%%%% diff --git a/crawl-ref/source/dat/descript/unident.txt b/crawl-ref/source/dat/descript/unident.txt new file mode 100644 index 0000000000..3f1e8c312f --- /dev/null +++ b/crawl-ref/source/dat/descript/unident.txt @@ -0,0 +1,79 @@ +%%%% +rod + +A stick imbued with magical properties. +%%%% +staff + +A stick imbued with magical properties. +%%%% +buggy staff + +An OBJ_STAVES which is neither a rod nor a staff; please file a bug +report. +%%%% +book + +A book of magic spells. Beware, for some of the more powerful +grimoires are not to be toyed with. +%%%% +potion + +A small bottle of liquid. +%%%% +wand + +A stick. Maybe it's magical. +%%%% +amulet + +A piece of jewellery. +%%%% +ring + +A piece of jewellery. +%%%% +scroll + +A scroll of paper covered in magical writing. +%%%% +deck of cards + +A deck of cards. +%%%% +crystal ball + +A sphere of clear crystal. +%%%% +small ebony casket + +A small black box. I wonder what's inside? +%%%% +gauzy fan + +A fan. +%%%% +blazing lamp + +A lamp. +%%%% +bone lantern + +A strange lantern made out of ancient bones. +%%%% +silver horn + +A strange lantern made out of ancient bones. +%%%% +grey disc + +A grey disc. +%%%% +nondescript stone + +A lump of rock. +%%%% +sealed bronze flask + +A heavy bronze flask, warm to the touch. +%%%% diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc index 167890deaf..fb695332ee 100644 --- a/crawl-ref/source/database.cc +++ b/crawl-ref/source/database.cc @@ -491,6 +491,7 @@ static std::vector description_txt_paths() txt_file_names.push_back("features"); txt_file_names.push_back("items"); + txt_file_names.push_back("unident"); txt_file_names.push_back("monsters"); txt_file_names.push_back("spells"); txt_file_names.push_back("gods"); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 203f12826f..ba26fc4f6e 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -988,253 +988,6 @@ static std::string describe_weapon( const item_def &item, bool verbose) description += "$This weapon may have some hidden properties.$"; } } - else if (is_unrandom_artefact( item ) - && strlen(unrandart_descrip(1, item)) != 0) - { - description += unrandart_descrip(1, item); - description += "$"; - } - else - { - if (verbose) - { - switch (item.sub_type) - { - case WPN_CLUB: - description += "A heavy piece of wood. "; - break; - - case WPN_MACE: - description += "A long handle " - "with a heavy lump on one end. "; - break; - - case WPN_FLAIL: - description += "Like a mace, but with a length of chain " - "between the handle and the lump of metal. "; - break; - - case WPN_DAGGER: - description += "A long knife or a very short sword, " - "which can be held or thrown. "; - break; - - case WPN_KNIFE: - description += "A simple survival knife. " - "Designed more for utility than combat, " - "it looks quite capable of butchering a corpse. "; - break; - - case WPN_MORNINGSTAR: - description += "A mace covered in spikes. "; - break; - - case WPN_SHORT_SWORD: - description += "A sword with a short, slashing blade. "; - break; - - case WPN_LONG_SWORD: - description += "A sword with a long, slashing blade. "; - break; - - case WPN_GREAT_SWORD: - description += "A sword with a very long, heavy blade " - "and a long handle. "; - break; - - case WPN_SCIMITAR: - description += "A long sword with a curved blade. "; - break; - - case WPN_HAND_AXE: - description += "A small axe designed for either hand combat " - "or throwing. "; - break; - - case WPN_BATTLEAXE: - description += "A large axe with a double-headed blade. "; - break; - - case WPN_SPEAR: - description += "A long stick with a pointy blade on one end, " - "to be held or thrown. "; - break; - - case WPN_TRIDENT: - description += - "A hafted weapon with three points at one end. "; - break; - - case WPN_HALBERD: - description += - "A long pole with a spiked axe head on one end. "; - break; - - case WPN_SLING: - description += - "A piece of cloth and leather for launching stones, " - "which do a small amount of damage on impact. "; - break; - - case WPN_BOW: - description += "A curved piece of wood and string, " - "for shooting arrows. It does good damage in combat, " - "and a skilled user can use it to great effect. "; - break; - - case WPN_LONGBOW: - description += "A long, strong bow made of yew. " - "It does excellent damage in combat " - "and a skilled archer can use it to great effect. "; - break; - - case WPN_BLOWGUN: - description += "A long, light tube, open at both ends. Doing " - "very little damage, its main use is to fire poisoned " - "needles from afar. It makes very little noise. "; - break; - - case WPN_CROSSBOW: - description += "A piece of machinery used for firing bolts, " - "which takes some time to load and fire. " - "It does very good damage in combat. "; - break; - - case WPN_HAND_CROSSBOW: - description += "A small crossbow, for firing darts. "; - break; - - case WPN_GLAIVE: - description += - "A pole with a large, heavy blade on one end. "; - break; - - case WPN_QUARTERSTAFF: - description += "A sturdy wooden pole. "; - break; - - case WPN_SCYTHE: - description += - "A farm implement, usually unsuited to combat. "; - break; - - case WPN_GIANT_CLUB: - description += "A giant lump of wood, " - "shaped for an ogre's hands. "; - break; - - case WPN_GIANT_SPIKED_CLUB: - description += - "A giant lump of wood with sharp spikes at one end. "; - break; - - case WPN_EVENINGSTAR: - description += "The opposite of a morningstar. "; - break; - - case WPN_QUICK_BLADE: - description += "A small and magically quick sword. "; - break; - - case WPN_KATANA: - description += "A very rare and extremely effective " - "imported weapon, featuring a long " - "single-edged blade. "; - break; - - case WPN_LAJATANG: - description += "A very rare and extremely effective " - "imported weapon, featuring a pole with half-moon blades " - "at both ends. "; - break; - - case WPN_LOCHABER_AXE: - description += "An enormous combination of a pike " - "and a battle axe."; - break; - - case WPN_EXECUTIONERS_AXE: - description += "A huge axe. "; - break; - - case WPN_DOUBLE_SWORD: - description += - "A magical weapon with two razor-sharp blades. "; - break; - - case WPN_TRIPLE_SWORD: - description += "A magical weapon with three " - "great razor-sharp blades. "; - break; - - case WPN_HAMMER: - description += "The kind of thing you hit nails with, " - "adapted for battle. "; - break; - - case WPN_ANCUS: - description += "A large and vicious toothed club. "; - break; - - case WPN_WHIP: - description += "A whip. "; - break; - - case WPN_SABRE: - description += "A sword with a medium length slashing blade. "; - break; - - case WPN_DEMON_BLADE: - description += - "A terrible weapon, forged in the fires of Hell. "; - break; - - case WPN_BLESSED_BLADE: - description += "A blade blessed by the Shining One. "; - break; - - case WPN_DEMON_WHIP: - description += "A terrible weapon, woven " - "in the depths of the inferno. "; - break; - - case WPN_DEMON_TRIDENT: - description += - "A terrible weapon, molded by fire and brimstone. "; - break; - - case WPN_BROAD_AXE: - description += "An axe with a large blade. "; - break; - - case WPN_WAR_AXE: - description += "An axe intended for hand to hand combat. "; - break; - - case WPN_SPIKED_FLAIL: - description += - "A flail with large spikes on the metal lump. "; - break; - - case WPN_GREAT_MACE: - description += "A large and heavy mace. "; - break; - - case WPN_DIRE_FLAIL: - description += "A flail with spiked lumps on both ends."; - break; - - case WPN_FALCHION: - description += "A sword with a broad slashing blade. "; - break; - - default: - DEBUGSTR("Unknown weapon"); - } - - description += "$"; - } - } if (verbose) { @@ -1666,217 +1419,6 @@ static std::string describe_armour( const item_def &item, bool verbose ) description.reserve(200); - if (is_unrandom_artefact( item ) - && strlen(unrandart_descrip(1, item)) != 0) - { - description += unrandart_descrip(1, item); - description += "$"; - } - else - { - if (verbose) - { - switch (item.sub_type) - { - case ARM_ROBE: - description += "A cloth robe. "; - break; - case ARM_LEATHER_ARMOUR: - description += "A suit made of hardened leather. "; - break; - case ARM_RING_MAIL: - description += "A leather suit covered in little rings. "; - break; - case ARM_SCALE_MAIL: - description += - "A leather suit covered in little metal plates. "; - break; - case ARM_CHAIN_MAIL: - description += "A suit made of interlocking metal rings. "; - break; - case ARM_SPLINT_MAIL: - description += "A suit made of splints of metal. "; - break; - case ARM_BANDED_MAIL: - description += "A suit made of bands of metal. "; - break; - case ARM_PLATE_MAIL: - description += "A suit of mail and large plates of metal. "; - break; - case ARM_SHIELD: - description += - "A piece of metal, to be strapped on one's arm. " - "It is cumbersome to wear, and slightly slows " - "the rate at which you may attack. "; - break; - case ARM_CLOAK: - description += "A cloth cloak. "; - break; - - case ARM_HELMET: - switch (get_helmet_type( item )) - { - case THELM_HELMET: - case THELM_HELM: - description += "A piece of metal headgear. "; - break; - case THELM_CAP: - description += "A cloth or leather cap. "; - break; - case THELM_WIZARD_HAT: - description += "A conical cloth hat. "; - break; - } - break; - - case ARM_GLOVES: - description += "A pair of gloves. "; - break; - - case ARM_CENTAUR_BARDING: - description += "An armour made for centaurs, " - "to wear over their equine half."; - break; - - case ARM_NAGA_BARDING: - description += "A special armour made for nagas, " - "to wear over their tails."; - break; - - case ARM_BOOTS: - description += "A pair of boots."; - break; - - case ARM_BUCKLER: - description += "A small shield. "; - break; - case ARM_LARGE_SHIELD: - description += "Like a normal shield, only larger. "; - if (you.species == SP_TROLL || you.species == SP_OGRE - || you.species == SP_OGRE_MAGE - || player_genus(GENPC_DRACONIAN)) - { - description += "It looks like it would fit you well. "; - } - else - { - description += "It is very cumbersome to wear, and " - "slows the rate at which you may attack. "; - } - break; - case ARM_DRAGON_HIDE: - description += "The scaly skin of a dragon. I suppose " - "you could wear it if you really wanted to. "; - break; - case ARM_TROLL_HIDE: - description += "The stiff and knobbly hide of a troll. " - "I suppose you could wear it " - "if you really wanted to. "; - break; - case ARM_CRYSTAL_PLATE_MAIL: - description += "An incredibly heavy but extremely effective " - "suit of crystalline armour. " - "It is somewhat resistant to corrosion. "; - break; - case ARM_DRAGON_ARMOUR: - description += "A magical armour, made from the scales of " - "a fire-breathing dragon. It provides " - "great protection from the effects of fire, " - "but renders its wearer more susceptible to " - "the effects of cold. "; - break; - case ARM_TROLL_LEATHER_ARMOUR: - description += "A magical armour, made from the stiff and " - "knobbly skin of a common troll. It magically regenerates " - "its wearer's flesh at a fairly slow rate " - "(unless already a troll). "; - break; - case ARM_ICE_DRAGON_HIDE: - description += "The scaly skin of a dragon. I suppose " - "you could wear it if you really wanted to. "; - break; - case ARM_ICE_DRAGON_ARMOUR: - description += "A magical armour, made from the scales of " - "a cold-breathing dragon. It provides " - "great protection from the effects of cold, " - "but renders its wearer more susceptible to " - "the effects of fire and heat. "; - break; - case ARM_STEAM_DRAGON_HIDE: - description += "The soft and supple scaly skin of " - "a steam dragon. I suppose you could " - "wear it if you really wanted to. "; - break; - case ARM_STEAM_DRAGON_ARMOUR: - description += "A magical armour, made from the scales of " - "a steam-breathing dragon. Although unlike " - "the armour made from the scales of some " - "larger dragons it does not provide its wearer " - "with much in the way of special magical " - "protection, it is extremely light and " - "as supple as cloth. "; - break; /* Protects from steam */ - case ARM_MOTTLED_DRAGON_HIDE: - description += "The weirdly-patterned scaley skin of " - "a mottled dragon. I suppose you could " - "wear it if you really wanted to. "; - break; - case ARM_MOTTLED_DRAGON_ARMOUR: - description += "A magical armour made from the scales of a " - "mottled dragon. Although unlike the armour " - "made from the scales of some larger dragons " - "it does not provide its wearer with much in " - "the way of special magical protection, it is " - "as light and relatively uncumbersome as " - "leather armour. "; - break; /* Protects from napalm */ - case ARM_STORM_DRAGON_HIDE: - description += "The hide of a storm dragon, covered in " - "extremely hard blue scales. I suppose " - "you could wear it if you really wanted to. "; - break; - case ARM_STORM_DRAGON_ARMOUR: - description += "A magical armour made from the scales of " - "a lightning-breathing dragon. It is heavier " - "than most dragon scale armours, but gives " - "its wearer great resistance to " - "electrical discharges. "; - break; - case ARM_GOLD_DRAGON_HIDE: - description += "The extremely tough and heavy skin of a " - "golden dragon, covered in shimmering golden " - "scales. I suppose you could wear it if " - "you really wanted to. "; - break; - case ARM_GOLD_DRAGON_ARMOUR: - description += "A magical armour made from the golden scales " - "of a golden dragon. It is extremely heavy and " - "cumbersome, but confers resistances to fire, " - "cold, and poison on its wearer. "; - break; - case ARM_ANIMAL_SKIN: - description += "The skins of several animals. "; - break; - case ARM_SWAMP_DRAGON_HIDE: - description += "The slimy"; - if (player_can_smell()) - description += ", smelly"; - description += " skin of a swamp-dwelling dragon. I suppose " - "you could wear it if you really wanted to. "; - break; - case ARM_SWAMP_DRAGON_ARMOUR: - description += "A magical armour made from the scales of " - "a swamp dragon. It confers resistance to " - "poison on its wearer. "; - break; - default: - DEBUGSTR("Unknown armour"); - } - - description += "$"; - } - } - if (verbose && item.sub_type != ARM_SHIELD && item.sub_type != ARM_BUCKLER @@ -2041,1086 +1583,97 @@ static std::string describe_armour( const item_def &item, bool verbose ) //--------------------------------------------------------------- // -// describe_stick +// describe_jewellery // //--------------------------------------------------------------- -static std::string describe_stick( const item_def &item ) +static std::string describe_jewellery( const item_def &item, bool verbose) { std::string description; - description.reserve(64); + description.reserve(200); - if ( !item_type_known(item) ) - description += "A stick. Maybe it's magical. "; - else + if ((verbose || is_random_artefact( item )) + && item_ident( item, ISFLAG_KNOW_PLUSES )) { - description += "A magical device which "; - switch (item.sub_type) + // Explicit description of ring power (useful for randarts) + // Note that for randarts we'll print out the pluses even + // in the case that its zero, just to avoid confusion. -- bwr + if (item.plus != 0 + || (item.sub_type == RING_SLAYING && item.plus2 != 0) + || is_random_artefact( item )) { - case WAND_FLAME: - description += "throws little bits of flame. "; - break; + switch (item.sub_type) + { + case RING_PROTECTION: + description += "$It affects your AC ("; + append_value( description, item.plus, true ); + description += ")."; + break; - case WAND_FROST: - description += "throws little bits of frost. "; - break; + case RING_EVASION: + description += "$It affects your evasion ("; + append_value( description, item.plus, true ); + description += ")."; + break; - case WAND_SLOWING: - description += "casts enchantments to slow down the actions of " - "a creature at which it is directed. "; - break; + case RING_STRENGTH: + description += "$It affects your strength ("; + append_value( description, item.plus, true ); + description += ")."; + break; - case WAND_HASTING: - description += "casts enchantments to speed up the actions of " - "a creature at which it is directed. "; - break; + case RING_INTELLIGENCE: + description += "$It affects your intelligence ("; + append_value( description, item.plus, true ); + description += ")."; + break; - case WAND_MAGIC_DARTS: - description += "throws small bolts of destructive energy. "; - break; + case RING_DEXTERITY: + description += "$It affects your dexterity ("; + append_value( description, item.plus, true ); + description += ")."; + break; - case WAND_HEALING: - description += "can heal a creature's wounds. "; - break; + case RING_SLAYING: + if (item.plus != 0 || is_random_artefact( item )) + { + description += "$It affects your accuracy ("; + append_value( description, item.plus, true ); + description += ")."; + } - case WAND_PARALYSIS: - description += "can render a creature immobile. "; - break; + if (item.plus2 != 0 || is_random_artefact( item )) + { + description += "$It affects your damage-dealing abilities ("; + append_value( description, item.plus2, true ); + description += ")."; + } + break; + + default: + break; + } + } + } - case WAND_FIRE: - description += "throws great bolts of fire. "; - break; + // randart properties + if (is_random_artefact( item )) + { + description += randart_descrip(item); + if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) + { + if (jewellery_is_amulet(item)) + description += "$This amulet may have hidden properties.$"; + else + description += "$This ring may have hidden properties.$"; + } + } - case WAND_COLD: - description += "throws great bolts of cold. "; - break; - - case WAND_CONFUSION: - description += "induces confusion and bewilderment in " - "a target creature. "; - break; - - case WAND_INVISIBILITY: - description += "hides a creature from the view of others. "; - break; - - case WAND_DIGGING: - description += "drills tunnels through unworked rock. "; - break; - - case WAND_FIREBALL: - description += "throws exploding blasts of flame. "; - break; - - case WAND_TELEPORTATION: - description += "causes a creature to be randomly translocated. "; - break; - - case WAND_LIGHTNING: - description += "throws great bolts of lightning. "; - break; - - case WAND_POLYMORPH_OTHER: - description += "causes a creature to be transmogrified into " - "another form. " - "It doesn't work on you, so don't even try. "; - break; - - case WAND_ENSLAVEMENT: - description += "causes slavish obedience in a creature. "; - break; - - case WAND_DRAINING: - description += "throws a bolt of negative energy which " - "drains the life essences of living creatures, " - "but is useless against the undead. "; - break; - - case WAND_RANDOM_EFFECTS: - description += "can produce a variety of effects. "; - break; - - case WAND_DISINTEGRATION: - description += "disrupts the physical structure of " - "anything but the hardest walls -- even rigid " - "statues, to say nothing of flesh. "; - break; - - default: - DEBUGSTR("Unknown stick"); - } - - if (item_ident( item, ISFLAG_KNOW_PLUSES ) && item.plus == 0) - description += "Unfortunately, it has no charges left. "; - } - - return description; -} - - -//--------------------------------------------------------------- -// -// describe_food -// -//--------------------------------------------------------------- -static std::string describe_food( const item_def &item ) -{ - std::string description; - - description.reserve(100); - - switch (item.sub_type) - { - // rations - case FOOD_MEAT_RATION: - case FOOD_BREAD_RATION: - description += "A filling ration of "; - switch (item.sub_type) - { - case FOOD_MEAT_RATION: - description += "dried and preserved meats"; - break; - case FOOD_BREAD_RATION: - description += "breads"; - break; - } - description += ". "; - break; - - // fruits - case FOOD_PEAR: - case FOOD_APPLE: - case FOOD_APRICOT: - case FOOD_ORANGE: - case FOOD_BANANA: - case FOOD_STRAWBERRY: - case FOOD_RAMBUTAN: - case FOOD_LEMON: - case FOOD_GRAPE: - case FOOD_LYCHEE: - case FOOD_SULTANA: - description += "A"; - switch (item.sub_type) - { - case FOOD_PEAR: - description += " delicious juicy"; - break; - case FOOD_APPLE: - description += " delicious red or green"; - break; - case FOOD_APRICOT: - description += " delicious orange"; - break; - case FOOD_ORANGE: - description += " delicious juicy orange"; - break; - case FOOD_BANANA: - description += " delicious yellow"; - break; - case FOOD_STRAWBERRY: - description += " small but delicious red"; - break; - case FOOD_RAMBUTAN: - description += " small but delicious tropical"; - break; - case FOOD_LEMON: - description += " yellow"; - break; - case FOOD_GRAPE: - description += " small"; - break; - case FOOD_LYCHEE: - description += " tropical"; - break; - case FOOD_SULTANA: - description += " dried"; - break; - } - - description += " fruit"; - - switch (item.sub_type) - { - case FOOD_BANANA: - description += ", probably grown and imported by " - "some amoral multinational as the " - "result of a corrupt trade deal"; - break; - case FOOD_RAMBUTAN: - description += ". How it got into this dungeon " - "is anyone's guess"; - break; - case FOOD_SULTANA: - description += " of some sort, possibly a grape"; - break; - } - description += ". "; - break; - - // vegetables - case FOOD_CHOKO: - case FOOD_SNOZZCUMBER: - description += "A"; - switch (item.sub_type) - { - case FOOD_CHOKO: - description += "n almost tasteless green"; - break; - case FOOD_SNOZZCUMBER: - description += " repulsive cucumber-shaped"; - break; - } - description += " vegetable"; - switch (item.sub_type) - { - case FOOD_CHOKO: - description += ", which grows on a vine"; - break; - } - description += ". "; - break; - - // lumps, slices, chunks, and strips - case FOOD_HONEYCOMB: - case FOOD_ROYAL_JELLY: - case FOOD_PIZZA: - case FOOD_CHEESE: - case FOOD_BEEF_JERKY: - case FOOD_SAUSAGE: - case FOOD_CHUNK: - description += "A"; - switch (item.sub_type) - { - case FOOD_SAUSAGE: - description += "n elongated"; - break; - } - switch (item.sub_type) - { - case FOOD_HONEYCOMB: - case FOOD_ROYAL_JELLY: - case FOOD_CHEESE: - case FOOD_SAUSAGE: - description += " lump"; - break; - case FOOD_PIZZA: - description += " slice"; - break; - case FOOD_BEEF_JERKY: - description += " strip"; - break; - case FOOD_CHUNK: - description += " piece"; - } - description += " of "; - switch (item.sub_type) - { - case FOOD_SAUSAGE: - description += "low-grade gristle, entrails and " - "cereal products encased in an intestine"; - break; - case FOOD_HONEYCOMB: - description += "the delicious honeycomb made by giant bees"; - break; - case FOOD_ROYAL_JELLY: - description += "the magical substance produced by giant bees " - "to be fed to their queens"; - break; - case FOOD_PIZZA: - description += "pizza"; - break; - case FOOD_CHEESE: - description += "cheese"; - break; - case FOOD_BEEF_JERKY: - description += "preserved dead cow or bull"; - break; - case FOOD_CHUNK: - description += "dungeon meat"; - break; - } - description += ". "; - switch (item.sub_type) - { - case FOOD_SAUSAGE: - description += "Yum! "; - break; - case FOOD_PIZZA: - description += "Don't tell me you don't know what that is! "; - break; - case FOOD_CHUNK: - if (you.mutation[MUT_SAPROVOROUS] < 3) - description += "It looks rather unpleasant. "; - - if (item.special < 100) - { - if (you.mutation[MUT_SAPROVOROUS] == 3) - description += "It looks nice and ripe. "; - else if (you.is_undead != US_UNDEAD) - { - description += "In fact, it is " - "rotting away before your eyes. " - "Eating it would probably be unwise. "; - } - } - break; - } - break; - - default: - DEBUGSTR("Unknown food"); - } - - description += "$"; - - return (description); -} - -//--------------------------------------------------------------- -// -// describe_potion -// -//--------------------------------------------------------------- -static const char* describe_potion( const item_def &item ) -{ - if ( !item_type_known(item) ) - return "A small bottle of liquid.$"; - - switch (static_cast(item.sub_type)) - { - case POT_HEALING: - return "A blessed fluid which heals some wounds, clears the mind, " - "and cures diseases. If one uses it when they are at or near " - "full health, it can also slightly repair permanent injuries.$"; - case POT_HEAL_WOUNDS: - return "A magical healing elixir which causes wounds to close and " - "heal almost instantly. If one uses it when they are at or near " - "full health, it can also repair permanent injuries.$"; - case POT_SPEED: - return "An enchanted beverage which speeds the actions of anyone who " - "drinks it.$"; - case POT_MIGHT: - return "A magic potion which greatly increases the strength and " - "physical power of one who drinks it.$"; - case POT_GAIN_STRENGTH: - return "A potion of beneficial mutation.$"; - case POT_GAIN_DEXTERITY: - return "A potion of beneficial mutation.$"; - case POT_GAIN_INTELLIGENCE: - return "A potion of beneficial mutation.$"; - case POT_LEVITATION: - return "A potion which confers great buoyancy " - "on one who consumes it.$"; - case POT_POISON: - return "A nasty poisonous liquid.$"; - case POT_SLOWING: - return "A potion which slows your actions.$"; - case POT_PARALYSIS: - return "A potion which eliminates your control over your own body.$"; - case POT_CONFUSION: - return "A potion which confuses your perceptions and " - "reduces your control over your own actions.$"; - case POT_INVISIBILITY: - return "A potion which hides you from the sight of others.$"; - case POT_PORRIDGE: - return "A filling potion of sludge, high in cereal fibre.$"; - case POT_DEGENERATION: - return "A noxious concoction which can do terrible things " - "to your body, brain and reflexes.$"; - case POT_DECAY: - return "A vile and putrid cursed liquid which causes your " - "flesh to decay before your very eyes.$"; - case POT_WATER: - return "A unique substance, vital for the existence of most life.$"; - case POT_EXPERIENCE: - return "A truly wonderful and very rare drink.$"; - case POT_MAGIC: - return "A valuable potion which grants a person with an " - "infusion of magical energy.$"; - case POT_RESTORE_ABILITIES: - return "A potion which restores the abilities of one who drinks it.$"; - case POT_STRONG_POISON: - return "A terribly venomous potion.$"; - case POT_BERSERK_RAGE: - return "A potion which can send one into an incoherent rage.$"; - case POT_CURE_MUTATION: - return "A potion which removes some or all of any mutations " - "which may be afflicting you.$"; - case POT_MUTATION: - return "A potion which does very strange things to you.$"; - case POT_BLOOD: - return "A potion containing the essence of life. Vital for all living " - "creatures, as well as some undead ones.$"; - case POT_RESISTANCE: - return "A potion which grants you temporary resistance to the elements " - "and poison.$"; - case NUM_POTIONS: - return "A buggy potion."; - } - return "A very buggy potion."; -} - - -//--------------------------------------------------------------- -// -// describe_scroll -// -//--------------------------------------------------------------- -static std::string describe_scroll( const item_def &item ) -{ - std::string description; - - description.reserve(64); - - if ( !item_type_known(item) ) - description += "A scroll of paper covered in magical writing."; - else - { - switch (item.sub_type) - { - case SCR_IDENTIFY: - description += "This useful magic scroll allows you to " - "determine the properties of any object. "; - break; - - case SCR_TELEPORTATION: - description += "Reading the words on this scroll " - "translocates you to a random position. "; - break; - - case SCR_FEAR: - description += "This scroll causes great fear in those " - "who see the one who reads it. "; - break; - - case SCR_NOISE: - description += "This prank scroll, often slipped into a wizard's " - "backpack by a devious apprentice, causes a loud noise. " - "It is not otherwise noted for its usefulness. "; - break; - - case SCR_REMOVE_CURSE: - description += "Reading this scroll removes curses from " - "the items you are using. "; - break; - - case SCR_DETECT_CURSE: - description += "This scroll allows you to detect the presence " - "of cursed items among your possessions. "; - break; - - case SCR_SUMMONING: - description += "This scroll opens a conduit to the Abyss " - "and draws a terrible beast to this world " - "for a limited time. "; - break; - - case SCR_ENCHANT_WEAPON_I: - description += "This scroll places an enchantment on a weapon, " - "making it more accurate in combat. It may fail " - "to affect weapons already heavily enchanted. "; - break; - - case SCR_ENCHANT_ARMOUR: - description += "This scroll places an enchantment " - "on a piece of armour. "; - break; - - case SCR_TORMENT: - description += "This scroll calls on the powers of Hell to " - "inflict great pain on any nearby creature - " - "including you! "; - break; - - case SCR_RANDOM_USELESSNESS: - description += "It is easy to be blinded to the essential " - "uselessness of this scroll by the sense of achievement " - "you get from getting it to work at all."; - // -- The Hitchhiker's Guide to the Galaxy (paraphrase) - break; - - case SCR_CURSE_WEAPON: - description += "This scroll places a curse on a weapon. "; - break; - - case SCR_CURSE_ARMOUR: - description += "This scroll places a curse " - "on a piece of armour. "; - break; - - case SCR_IMMOLATION: - description += "Small writing on the back of the scroll reads: " - "\"Warning: contents under pressure. Do not use near" - " flammable objects.\""; - break; - - case SCR_BLINKING: - description += "This scroll allows its reader to teleport " - "a short distance, with precise control. Be wary that " - "controlled teleports will cause the subject to " - "become contaminated with magical energy. "; - break; - - case SCR_PAPER: - description += "Apart from a label, this scroll is blank. "; - break; - - case SCR_MAGIC_MAPPING: - description += "This scroll reveals the nearby surroundings " - "of one who reads it. "; - break; - - case SCR_FOG: - description += "This scroll surrounds the reader " - "with a dense cloud of fog. "; - break; - - case SCR_ACQUIREMENT: - description += "This wonderful scroll causes the " - "creation of a valuable item to " - "appear before the reader. " - "It is especially treasured by specialist " - "magicians, as they can use it to obtain " - "the powerful spells of their specialty. "; - break; - - case SCR_ENCHANT_WEAPON_II: - description += "This scroll places an enchantment on a weapon, " - "making it inflict greater damage in combat. " - "It may fail to affect weapons already " - "heavily enchanted. "; - break; - - case SCR_VORPALISE_WEAPON: - description += "This scroll enchants a weapon so as to make " - "it far more effective at inflicting harm on " - "its wielder's enemies. Using it on a weapon " - "already affected by some kind of special " - "enchantment (other than that produced by a " - "normal scroll of enchant weapon) is not advised. "; - break; - - case SCR_RECHARGING: - description += "This scroll restores the charges of " - "any magical wand wielded by its reader. "; - break; - - case SCR_ENCHANT_WEAPON_III: - description += "This scroll enchants a weapon to be " - "far more effective in combat. Although " - "it can be used in the creation of especially " - "enchanted weapons, it may fail to affect those " - "already heavily enchanted. "; - break; - - default: - DEBUGSTR("Unknown scroll"); - } - } - - description += "$"; - - return (description); -} - - -//--------------------------------------------------------------- -// -// describe_jewellery -// -//--------------------------------------------------------------- -static std::string describe_jewellery( const item_def &item, bool verbose) -{ - std::string description; - - description.reserve(200); - - if (is_unrandom_artefact( item ) && strlen(unrandart_descrip(1, item)) != 0) - { - description += unrandart_descrip(1, item); - description += "$"; - } - else if ( !item_type_known(item) ) - { - description += "A piece of jewellery."; - } - else if (verbose || is_random_artefact( item )) - { - switch (item.sub_type) - { - case RING_REGENERATION: - description += "This wonderful ring greatly increases the " - "recuperative powers of its wearer, but also " - "considerably speeds his or her metabolism. "; - break; - - case RING_PROTECTION: - description += - "This ring either protects its wearer from harm or makes " - "them more vulnerable to injury, to a degree dependent " - "on its power. "; - break; - - case RING_PROTECTION_FROM_FIRE: - description += - "This ring provides protection from heat and fire. "; - break; - - case RING_POISON_RESISTANCE: - description += - "This ring provides protection from the effects of poisons and venom. "; - break; - - case RING_PROTECTION_FROM_COLD: - description += "This ring provides protection from cold. "; - break; - - case RING_STRENGTH: - description += - "This ring increases or decreases the physical strength " - "of its wearer, to a degree dependent on its power. "; - break; - - case RING_SLAYING: - description += - "This ring increases the hand-to-hand and missile combat " - "skills of its wearer."; - break; - - case RING_SEE_INVISIBLE: - description += - "This ring allows its wearer to see those things hidden " - "from view by magic. "; - break; - - case RING_INVISIBILITY: - description += - "This powerful ring can be activated to hide its wearer " - "from the view of others, but increases the speed of his " - "or her metabolism greatly while doing so. "; - break; - - case RING_HUNGER: - description += - "This accursed ring causes its wearer to hunger " - "considerably more quickly. "; - break; - - case RING_TELEPORTATION: - description += - "This ring occasionally exerts its power to randomly " - "translocate its wearer to another place, and can be " - "deliberately activated for the same effect. "; - break; - - case RING_EVASION: - description += - "This ring makes its wearer either more or less capable " - "of avoiding attacks, depending on its degree " - "of enchantment. "; - break; - - case RING_SUSTAIN_ABILITIES: - description += - "This ring protects its wearer from the loss of their " - "strength, dexterity and intelligence. "; - break; - - case RING_SUSTENANCE: - description += - "This ring provides energy to its wearer, so that they " - "need eat less often. "; - break; - - case RING_DEXTERITY: - description += - "This ring increases or decreases the dexterity of its " - "wearer, depending on the degree to which it has been " - "enchanted. "; - break; - - case RING_INTELLIGENCE: - description += - "This ring increases or decreases the mental ability of " - "its wearer, depending on the degree to which it has " - "been enchanted. "; - break; - - case RING_WIZARDRY: - description += - "This ring increases the ability of its wearer to use " - "magical spells. "; - break; - - case RING_MAGICAL_POWER: - description += - "This ring increases its wearer's reserves of magical " - "power. "; - break; - - case RING_LEVITATION: - description += - "This ring allows its wearer to hover above the floor. "; - break; - - case RING_LIFE_PROTECTION: - description += - "This blessed ring protects the life-force of its wearer " - "from negative energy, making them partially immune to " - "the draining effects of undead and necromantic magic. "; - break; - - case RING_PROTECTION_FROM_MAGIC: - description += - "This ring increases its wearer's resistance to " - "hostile enchantments. "; - break; - - case RING_FIRE: - description += - "This ring brings its wearer more in contact with " - "the powers of fire. He or she gains resistance to " - "heat and can use fire magic more effectively, but " - "becomes more vulnerable to the effects of cold. "; - break; - - case RING_ICE: - description += - "This ring brings its wearer more in contact with " - "the powers of cold and ice. He or she gains resistance " - "to cold and can use ice magic more effectively, but " - "becomes more vulnerable to the effects of fire. "; - break; - - case RING_TELEPORT_CONTROL: - description += "This ring allows its wearer to control the " - "destination of any teleportation, although without " - "perfect accuracy. Trying to teleport into a solid " - "object will result in a random teleportation, at " - "least in the case of a normal teleportation. Also " - "be wary that controlled teleports will contaminate " - "the subject with residual magical energy."; - break; - - case AMU_RAGE: - description += - "This amulet enables its wearer to attempt to enter " - "a state of berserk rage, and increases their chance " - "of successfully doing so. It also partially protects " - "the user from passing out when coming out of that rage. "; - break; - - case AMU_RESIST_SLOW: - description += - "This amulet protects its wearer from some magically " - "induced forms of slowness, and increases the duration " - "of enchantments which speed his or her actions. "; - break; - - case AMU_CLARITY: - description += - "This amulet protects its wearer from some forms of " - "mental confusion. "; - break; - - case AMU_WARDING: - description += - "This amulet repels some of the attacks of creatures " - "which have been magically summoned, and also " - "makes the wearer more resistant to draining attacks. "; - break; - - case AMU_RESIST_CORROSION: - description += - "This amulet protects the wearer and their equipment " - "from corrosion caused by acids, although not " - "infallibly so. "; - break; - - case AMU_THE_GOURMAND: - description += - "This amulet protects its wearer from " - "sickness from eating fresh raw meat and allows them to " - "digest it when not hungry, but its effects on the wearer's " - "digestion are cumulative over time, and are initially " - "small."; - break; - - case AMU_CONSERVATION: - description += - "This amulet protects some of the possessions of " - "its wearer from outright destruction, but not " - "infallibly so. "; - break; - - case AMU_CONTROLLED_FLIGHT: - description += - "Should the wearer of this amulet be levitated " - "by magical means, he or she will be able to exercise " - "some control over the resulting motion. This allows " - "the descent of staircases and the retrieval of items " - "lying on the ground, for example, but does not " - "deprive the wearer of the benefits of levitation. "; - break; - - case AMU_INACCURACY: - description += - "This amulet makes its wearer less accurate in hand combat. "; - break; - - case AMU_RESIST_MUTATION: - description += - "This amulet protects its wearer from mutations, " - "although not infallibly so. "; - break; - - default: - DEBUGSTR("Unknown jewellery"); - } - - description += "$"; - } - - if ((verbose || is_random_artefact( item )) - && item_ident( item, ISFLAG_KNOW_PLUSES )) - { - // Explicit description of ring power (useful for randarts) - // Note that for randarts we'll print out the pluses even - // in the case that its zero, just to avoid confusion. -- bwr - if (item.plus != 0 - || (item.sub_type == RING_SLAYING && item.plus2 != 0) - || is_random_artefact( item )) - { - switch (item.sub_type) - { - case RING_PROTECTION: - description += "$It affects your AC ("; - append_value( description, item.plus, true ); - description += ")."; - break; - - case RING_EVASION: - description += "$It affects your evasion ("; - append_value( description, item.plus, true ); - description += ")."; - break; - - case RING_STRENGTH: - description += "$It affects your strength ("; - append_value( description, item.plus, true ); - description += ")."; - break; - - case RING_INTELLIGENCE: - description += "$It affects your intelligence ("; - append_value( description, item.plus, true ); - description += ")."; - break; - - case RING_DEXTERITY: - description += "$It affects your dexterity ("; - append_value( description, item.plus, true ); - description += ")."; - break; - - case RING_SLAYING: - if (item.plus != 0 || is_random_artefact( item )) - { - description += "$It affects your accuracy ("; - append_value( description, item.plus, true ); - description += ")."; - } - - if (item.plus2 != 0 || is_random_artefact( item )) - { - description += "$It affects your damage-dealing abilities ("; - append_value( description, item.plus2, true ); - description += ")."; - } - break; - - default: - break; - } - } - } - - // randart properties - if (is_random_artefact( item )) - { - description += randart_descrip(item); - if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) - { - if (jewellery_is_amulet(item)) - description += "$This amulet may have hidden properties.$"; - else - description += "$This ring may have hidden properties.$"; - } - } - - if (item_known_cursed( item )) - description += "$It has a curse placed upon it."; - - return (description); -} // end describe_jewellery() - -//--------------------------------------------------------------- -// -// describe_staff -// -//--------------------------------------------------------------- -static std::string describe_staff( const item_def &item ) -{ - std::string description; - - description.reserve(200); - - if (item_type_known(item)) - { - // NB: the leading space is here {dlb} - description += "This " + std::string( item_is_staff( item ) ? "staff " - : "rod " ); - - switch (item.sub_type) - { - case STAFF_WIZARDRY: - description += - "significantly increases the ability of its wielder to use " - "magical spells. "; - break; - - case STAFF_POWER: - description += - "provides a reservoir of magical power to its wielder. "; - break; - - case STAFF_FIRE: - description += - "increases the power of fire spells cast by its wielder, " - "and protects him or her from the effects of heat and fire. " - "It can burn those struck by it. "; - break; - - case STAFF_COLD: - description += - "increases the power of ice spells cast by its wielder, " - "and protects him or her from the effects of cold. It can " - "freeze those struck by it. "; - break; - - case STAFF_POISON: - description += - "increases the power of poisoning spells cast by its " - "wielder, and protects him or her from the effects of " - "poison. It can poison those struck by it. "; - break; - - case STAFF_ENERGY: - description += - "allows its wielder to cast magical spells without " - "hungering as a result. "; - break; - - case STAFF_DEATH: - description += - "increases the power of necromantic spells cast by its " - "wielder. It can cause great pain in those living souls " - "its wielder strikes. "; - break; - - case STAFF_CONJURATION: - description += - "increases the power of conjurations cast by its wielder. "; - break; - - case STAFF_ENCHANTMENT: - description += - "increases the power of enchantments cast by its wielder. "; - break; - - case STAFF_SUMMONING: - description += - "increases the power of summonings cast by its wielder. "; - break; - - case STAFF_SMITING: - description += - "allows its wielder to smite foes from afar. The wielder " - "must be at least level four to safely use this ability, " - "which drains four charges. "; - break; - - case STAFF_VENOM: - description += - "contains offensive and defensive spells of poison."; - break; - - case STAFF_STRIKING: - description += "allows its wielder to strike foes from afar " - "with force bolts. "; - break; - - case STAFF_SPELL_SUMMONING: - description += "contains spells of summoning. "; - break; - - case STAFF_WARDING: - description += - "contains spells designed to repel one's enemies. "; - break; - - case STAFF_DISCOVERY: - description += - "contains spells which reveal various aspects of " - "an explorer's surroundings to them. "; - break; - - case STAFF_AIR: - description += - "increases the power of air spells cast by its wielder. " - "It can shock those struck by it. "; - break; - - case STAFF_EARTH: - description += - "increases the power of earth spells cast by its wielder. " - "It can crush those struck by it. "; - break; - - case STAFF_CHANNELING: - description += - "allows its caster to channel ambient magical energy for " - "his or her own purposes. "; - break; - - default: - description += - "contains spells of mayhem and destruction. "; - break; - } - - if (item_is_rod( item )) - { - description += - "$$It uses its own mana reservoir for casting spells, and " - "recharges automatically by channeling mana from its " - "wielder."; - } - else - { - description += - "$$Damage rating: 7 $Accuracy rating: +6 $Attack delay: 120%"; - - description += "$$It falls into the 'staves' category. "; - } - } - else - { - description += "A stick imbued with magical properties.$"; - } + if (item_known_cursed( item )) + description += "$It has a curse placed upon it."; return (description); -} +} // end describe_jewellery() static bool compare_card_names(card_type a, card_type b) { @@ -3132,272 +1685,68 @@ static bool compare_card_names(card_type a, card_type b) // describe_misc_item // //--------------------------------------------------------------- -static std::string describe_misc_item( const item_def &item ) +static std::string describe_deck( const item_def &item ) { std::string description; description.reserve(100); - const misc_item_type subtype = static_cast(item.sub_type); - - if (item_type_known(item)) - { - switch (subtype) - { - case MISC_BOTTLED_EFREET: - description += - "A mighty efreet, captured by some wizard and bound into " - "a bronze flask. Breaking the flask's seal will release it " - "to wreak havoc - possibly on you. "; - break; - case MISC_CRYSTAL_BALL_OF_SEEING: - description += - "A magical device which allows one to see the layout of " - "their surroundings. It requires a degree of magical " - "ability to be used reliably, otherwise it can produce " - "unpredictable and possibly harmful results. "; - break; - case MISC_AIR_ELEMENTAL_FAN: - description += "A magical device for summoning air " - "elementals. It is rather unreliable, and usually requires " - "several attempts to function correctly. Using it carries " - "an element of risk, which is reduced if one is skilled in " - "the appropriate elemental magic. "; - break; - case MISC_LAMP_OF_FIRE: - description += "A magical device for summoning fire " - "elementals. It is rather unreliable, and usually " - "requires several attempts to function correctly. Using " - "it carries an element of risk, which is reduced if one " - "is skilled in the appropriate elemental magic."; - break; - case MISC_STONE_OF_EARTH_ELEMENTALS: - description += "A magical device for summoning earth " - "elementals. It is rather unreliable, and usually " - "requires several attempts to function correctly. " - "Using it carries an element of risk, which is reduced " - "if one is skilled in the appropriate elemental magic."; - break; - case MISC_LANTERN_OF_SHADOWS: - description += - "An unholy device which calls on the powers of darkness " - "to assist its user, with a small cost attached. "; - break; - case MISC_HORN_OF_GERYON: - description += - "The horn belonging to Geryon, guardian of the Vestibule " - "of Hell. Legends say that a mortal who desires access " - "into one of the Hells must use it in order to gain entry. "; - break; - case MISC_BOX_OF_BEASTS: - description += - "A magical box containing many wild beasts. One may " - "allow them to escape by opening the box's lid. "; - break; - case MISC_DECK_OF_ESCAPE: - description += - "A deck of magical cards, mainly dealing with various " - "forms of escape. Incautious use may lead to being " - "dumped from the frying pan into the fire! "; - break; - case MISC_DECK_OF_DESTRUCTION: - description += - "A deck of magical cards, most of which hurl death " - "and destruction at one's foes (or, if unlucky, at oneself.) "; - break; - case MISC_DECK_OF_DUNGEONS: - description += - "A deck of magical cards which deal with shaping the " - "dungeon. Unlike most other decks, the cards from this deck " - "tend to be ignored by Nemelex, who prefers more amusing " - "pursuits. "; - break; - case MISC_DECK_OF_SUMMONING: - description += - "A deck of magical cards, depicting a range of weird and " - "wondrous creatures. "; - break; - - case MISC_DECK_OF_WONDERS: - description += - "A deck of highly mysterious and magical cards, which can " - "permanently alter the drawer's physical and mental " - "condition, for better or worse. "; - break; - - case MISC_DECK_OF_PUNISHMENT: - description += - "A deck of magical cards which wreak havoc on the user. "; - break; - - case MISC_DECK_OF_WAR: - description += - "A deck of magical cards which are useful before and during " - "battle. "; - break; - - case MISC_DECK_OF_CHANGES: - description += - "A deck of magical cards which induce changes in the user " - "or his environment. "; - break; - - case MISC_DECK_OF_DEFENSE: - description += - "A deck of magical cards, most of which defend the user " - "from harm in various ways. "; - break; - - case MISC_CRYSTAL_BALL_OF_ENERGY: - description += - "A magical device which can be used to restore one's " - "reserves of magical energy, but the use of which carries " - "the risk of draining all of those energies completely. " - "This risk varies inversely with the proportion of their " - "maximum energy which the user possesses; a user near his " - "or her full potential will find this item most beneficial. "; - break; - case MISC_EMPTY_EBONY_CASKET: - description += "A magical box after its power is spent. "; - break; - case MISC_CRYSTAL_BALL_OF_FIXATION: - description += - "A dangerous item which hypnotises anyone so unwise as " - "to gaze into it, leaving them helpless for a significant " - "length of time. "; - break; - case MISC_DISC_OF_STORMS: - description += - "This extremely powerful item can unleash a destructive " - "storm of electricity. It is especially effective in the " - "hands of one skilled in air elemental magic, but cannot " - "be used by one who is not a conductor. "; - break; - - case MISC_RUNE_OF_ZOT: - description += - "A talisman which allows entry into Zot's domain. "; - break; + description += "$"; - case NUM_MISCELLANY: - description += "A buggy miscellaneous item."; - break; - } - } - else + const std::vector drawn_cards = get_drawn_cards(item); + if ( !drawn_cards.empty() ) { - switch (subtype) + description += "Drawn card(s): "; + for ( unsigned int i = 0; i < drawn_cards.size(); ++i ) { - case MISC_BOTTLED_EFREET: - description += "A heavy bronze flask, warm to the touch. "; - break; - case MISC_CRYSTAL_BALL_OF_ENERGY: - case MISC_CRYSTAL_BALL_OF_FIXATION: - case MISC_CRYSTAL_BALL_OF_SEEING: - description += "A sphere of clear crystal. "; - break; - case MISC_AIR_ELEMENTAL_FAN: - description += "A fan. "; - break; - case MISC_LAMP_OF_FIRE: - description += "A lamp. "; - break; - case MISC_STONE_OF_EARTH_ELEMENTALS: - description += "A lump of rock. "; - break; - case MISC_LANTERN_OF_SHADOWS: - description += "A strange lantern made out of ancient bones. "; - break; - case MISC_HORN_OF_GERYON: - description += "A great silver horn, radiating unholy energies. "; - break; - case MISC_BOX_OF_BEASTS: - case MISC_EMPTY_EBONY_CASKET: - description += "A small black box. I wonder what's inside? "; - break; - - case MISC_DECK_OF_ESCAPE: - case MISC_DECK_OF_DESTRUCTION: - case MISC_DECK_OF_DUNGEONS: - case MISC_DECK_OF_SUMMONING: - case MISC_DECK_OF_WONDERS: - case MISC_DECK_OF_PUNISHMENT: - case MISC_DECK_OF_WAR: - case MISC_DECK_OF_CHANGES: - case MISC_DECK_OF_DEFENSE: - description += "A deck of cards. "; - break; - case MISC_RUNE_OF_ZOT: - description += "A talisman of some sort. "; - break; - case MISC_DISC_OF_STORMS: - description += "A grey disc. "; - break; - case NUM_MISCELLANY: - description += "A buggy miscellaneous item. "; - break; + if ( i != 0 ) + description += ", "; + description += card_name(drawn_cards[i]); } + description += "$"; } - description += "$"; - - if ( is_deck(item) ) + const int num_cards = cards_in_deck(item); + if ( top_card_is_known(item) ) { - const std::vector drawn_cards = get_drawn_cards(item); - if ( !drawn_cards.empty() ) - { - description += "Drawn card(s): "; - for ( unsigned int i = 0; i < drawn_cards.size(); ++i ) - { - if ( i != 0 ) - description += ", "; - description += card_name(drawn_cards[i]); - } - description += "$"; - } - - const int num_cards = cards_in_deck(item); - if ( top_card_is_known(item) ) - { - description += "Next card(s): "; - for ( int i = 0; i < num_cards; ++i ) - { - unsigned char flags; - const card_type card = get_card_and_flags(item, -i-1, flags); - if ( flags & CFLAG_MARKED ) - { - if ( i != 0 ) - description += ", "; - description += card_name(card); - } - else - break; - } - description += "$"; - } - - std::vector seen_cards; + description += "Next card(s): "; for ( int i = 0; i < num_cards; ++i ) { unsigned char flags; const card_type card = get_card_and_flags(item, -i-1, flags); - // This *might* leak a bit of information...oh well. - if ( (flags & CFLAG_SEEN) && !(flags & CFLAG_MARKED) ) - seen_cards.push_back(card); - } - if ( !seen_cards.empty() ) - { - std::sort(seen_cards.begin(), seen_cards.end(), - compare_card_names); - description += "Seen card(s): "; - for ( unsigned int i = 0; i < seen_cards.size(); ++i ) + if ( flags & CFLAG_MARKED ) { if ( i != 0 ) description += ", "; - description += card_name(seen_cards[i]); + description += card_name(card); } - description += "$"; + else + break; + } + description += "$"; + } + + std::vector seen_cards; + for ( int i = 0; i < num_cards; ++i ) + { + unsigned char flags; + const card_type card = get_card_and_flags(item, -i-1, flags); + // This *might* leak a bit of information...oh well. + if ( (flags & CFLAG_SEEN) && !(flags & CFLAG_MARKED) ) + seen_cards.push_back(card); + } + if ( !seen_cards.empty() ) + { + std::sort(seen_cards.begin(), seen_cards.end(), + compare_card_names); + description += "Seen card(s): "; + for ( unsigned int i = 0; i < seen_cards.size(); ++i ) + { + if ( i != 0 ) + description += ", "; + description += card_name(seen_cards[i]); } + description += "$"; } return (description); @@ -3471,75 +1820,154 @@ std::string get_item_description( const item_def &item, bool verbose, } #endif + if (is_unrandom_artefact( item ) + && strlen(unrandart_descrip(1, item)) != 0) + { + description << unrandart_descrip(1, item); + description << "$"; + } + else if (is_fixed_artefact(item) && item_type_known(item)) + { + // Known fixed artifacts are handled elsewhere. + } + else if (verbose && is_fixed_artefact(item)) + { + description << article_a(item.name(DESC_CAP_A, true, + false, false), false); + description << ".$"; + } + else if (verbose || (item.base_type != OBJ_WEAPONS + && item.base_type != OBJ_ARMOUR)) + { + std::string db_name = item.name(DESC_DBNAME, true, false, false); + std::string db_desc = getLongDescription(db_name); + + if (db_desc == "") + { + if (item_type_known(item)) + { + description << "[ERROR: no desc for item name '" << db_name + << "']"; + } + else + { + description << article_a(item.name(DESC_CAP_A, true, + false, false), false); + description << "."; + } + } + else + description << db_desc; + + if (item.base_type == OBJ_WANDS + || (item.base_type == OBJ_FOOD && item.sub_type == FOOD_CHUNK) + || (item.base_type == OBJ_ARMOUR && + item.sub_type == ARM_LARGE_SHIELD)) + { + // Get rid of newline at end of description, so that + // either the wand "no charges left", the meat chunk + // "unpleasent", or the large shield "cumbersome" + // description can follow on the same line. + description.seekp(description.tellp() - (std::streamoff)1); + description << " "; + } + else + description << "$"; + } + switch (item.base_type) { case OBJ_WEAPONS: description << describe_weapon( item, verbose ); break; + case OBJ_MISSILES: description << describe_ammo( item ); break; + case OBJ_ARMOUR: + if (item.sub_type == ARM_LARGE_SHIELD) + { + if (you.species == SP_TROLL || you.species == SP_OGRE + || you.species == SP_OGRE_MAGE + || player_genus(GENPC_DRACONIAN)) + { + description << "It looks like it would fit you well. "; + } + else + { + description << "It is very cumbersome to wear, and " + "slows the rate at which you may attack. "; + } + } + description << describe_armour( item, verbose ); break; + case OBJ_WANDS: - description << describe_stick( item ); + if (item_ident( item, ISFLAG_KNOW_PLUSES ) && item.plus == 0) + description << "Unfortunately, it has no charges left. "; + description << "$"; break; + case OBJ_FOOD: - description << describe_food( item ); - break; - case OBJ_SCROLLS: - description << describe_scroll( item ); + if (item.sub_type == FOOD_CHUNK) + { + if (you.mutation[MUT_SAPROVOROUS] < 3) + description << "It looks rather unpleasant. "; + + if (item.special < 100) + { + if (you.mutation[MUT_SAPROVOROUS] == 3) + description << "It looks nice and ripe. "; + else if (you.is_undead != US_UNDEAD) + { + description << "In fact, it is " + "rotting away before your eyes. " + "Eating it would probably be unwise. "; + } + } + description << "$"; + } break; + case OBJ_JEWELLERY: description << describe_jewellery( item, verbose ); break; - case OBJ_POTIONS: - description << describe_potion( item ); - break; - case OBJ_STAVES: - description << describe_staff( item ); - break; - case OBJ_BOOKS: - switch (item.sub_type) + case OBJ_STAVES: + if (item_type_known(item)) { - case BOOK_DESTRUCTION: - description << "An extremely powerful but unpredictable book " - "of magic. "; - break; - - case BOOK_MANUAL: - description << "A valuable book of magic which allows one to " - "practise a certain skill greatly. As it is used, it " - "gradually disintegrates and will eventually fall apart. "; - break; + if (item_is_rod( item )) + { + description << + "$It uses its own mana reservoir for casting spells, and " + "recharges automatically by channeling mana from its " + "wielder.$"; + } + else + { + description << + "$Damage rating: 7 $Accuracy rating: +6 " + "$Attack delay: 120%"; - default: - description << "A book of magic spells. Beware, for some of the " - "more powerful grimoires are not to be toyed with. "; - break; + description << "$$It falls into the 'staves' category. "; + } } break; - case OBJ_ORBS: - description << "Once you have escaped to the surface with " - "this invaluable artefact, your quest is complete. "; - break; - case OBJ_MISCELLANY: - description << describe_misc_item( item ); + if (is_deck(item)) + description << describe_deck( item ); break; + case OBJ_BOOKS: + case OBJ_SCROLLS: + case OBJ_POTIONS: + case OBJ_ORBS: case OBJ_CORPSES: - if ( item.sub_type == CORPSE_BODY) - description << "A corpse. "; - else - description << "A decaying skeleton. "; - break; - case OBJ_GOLD: - description << "A pile of glittering gold coins. "; + // No extra processing needed for these item types. break; default: diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 918da756b5..1d1f912c63 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -712,6 +712,8 @@ enum description_level_type DESC_BASENAME, // Base name of item subtype DESC_QUALNAME, // Name without articles, quantities, // enchantments. + DESC_DBNAME, // Name with which to look up item + // description in the db. DESC_NONE }; diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 0e25c80fde..bc56985edc 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -33,14 +33,20 @@ #include "it_use2.h" #include "itemprop.h" #include "macro.h" +#include "makeitem.h" #include "mon-util.h" #include "notes.h" #include "randart.h" #include "skills2.h" +#include "state.h" #include "stuff.h" #include "view.h" #include "items.h" + +#include "describe.h" + + id_arr type_ids; static bool is_random_name_space( char let ); @@ -99,7 +105,7 @@ std::string item_def::name(description_level_type descrip, descrip = DESC_CAP_A; } - if (terse) + if (terse && descrip != DESC_DBNAME) descrip = DESC_PLAIN; if (this->base_type == OBJ_ORBS @@ -148,7 +154,8 @@ std::string item_def::name(description_level_type descrip, break; } - if (descrip != DESC_BASENAME && descrip != DESC_QUALNAME) + if (descrip != DESC_BASENAME && descrip != DESC_QUALNAME + && descrip != DESC_DBNAME) { if (quantity_words) buff << number_in_words(this->quantity) << " "; @@ -962,25 +969,32 @@ std::string item_def::name_aux( description_level_type desc, const int it_plus = this->plus; const int item_plus2 = this->plus2; - const bool basename = desc == DESC_BASENAME; + const bool know_type = ident || item_type_known(*this); + + const bool dbname = desc == DESC_DBNAME; + const bool basename = (desc == DESC_BASENAME || (dbname && !know_type)); const bool qualname = desc == DESC_QUALNAME; const bool know_curse = - !basename && !qualname && !testbits(ignore_flags, ISFLAG_KNOW_CURSE) + !basename && !qualname && !dbname + && !testbits(ignore_flags, ISFLAG_KNOW_CURSE) && (ident || item_ident(*this, ISFLAG_KNOW_CURSE)); - const bool know_type = ident || item_type_known(*this); const bool __know_pluses = - !basename && !qualname + !basename && !qualname && !dbname && (ident || item_ident(*this, ISFLAG_KNOW_PLUSES)); - const bool know_cosmetic = !__know_pluses && !terse & !basename; + const bool know_brand = ident && !basename && !qualname && !dbname; + const bool know_ego = know_brand; + + const bool know_cosmetic = !__know_pluses && !terse & !basename + && !qualname && !dbname; // So that know_cosmetic won't be affected by ignore_flags const bool know_pluses = __know_pluses && !testbits(ignore_flags, ISFLAG_KNOW_PLUSES); - bool need_plural = true; + const bool need_plural = !basename && !dbname; int brand; std::ostringstream buff; @@ -1015,13 +1029,13 @@ std::string item_def::name_aux( description_level_type desc, buff << " "; } - if (is_random_artefact( *this )) + if (is_random_artefact( *this ) && !dbname) { buff << randart_name(*this); break; } - if (is_fixed_artefact( *this )) + if (is_fixed_artefact( *this ) && !dbname) { buff << fixed_artefact_name( *this, know_type ); break; @@ -1045,31 +1059,28 @@ std::string item_def::name_aux( description_level_type desc, } } - if (!basename) - { + if (!basename && !dbname) // always give racial type (it does have game effects) buff << racial_description_string(*this, terse); - if (know_type && !terse && + if (know_brand && !terse && (get_weapon_brand(*this) == SPWPN_VAMPIRICISM)) + { buff << "vampiric "; } buff << item_base_name(*this); - if (!basename) - { - if ( know_type ) - buff << weapon_brand_name(*this, terse); + if (know_brand) + buff << weapon_brand_name(*this, terse); - if (know_curse && item_cursed(*this) && terse) - buff << " (curse)"; - } + if (know_curse && item_cursed(*this) && terse) + buff << " (curse)"; break; case OBJ_MISSILES: brand = get_ammo_brand( *this ); - if (!basename) + if (know_brand) { if (brand == SPMSL_POISONED) buff << ((terse) ? "poison " : "poisoned "); @@ -1089,7 +1100,7 @@ std::string item_def::name_aux( description_level_type desc, buff << ammo_name(static_cast(item_typ)); - if (know_type && !basename) + if (know_brand) { switch (brand) { @@ -1128,7 +1139,7 @@ std::string item_def::name_aux( description_level_type desc, buff << "pair of "; // When asking for the base item name, randartism is ignored. - if (is_random_artefact( *this ) && !basename) + if (is_random_artefact( *this ) && !basename && !dbname) { buff << randart_armour_name(*this); break; @@ -1173,19 +1184,40 @@ std::string item_def::name_aux( description_level_type desc, } } - if (!basename) + if (!basename && !dbname) { // always give racial description (has game effects) buff << racial_description_string(*this, terse); } + if (!basename && !dbname && sub_type == ARM_HELMET) + { + if (get_helmet_type(*this) == THELM_HELM || + get_helmet_type(*this) == THELM_HELMET) + { + const short dhelm = get_helmet_desc( *this ); + + buff << + ( + (dhelm == THELM_DESC_PLAIN) ? "" : + (dhelm == THELM_DESC_WINGED) ? "winged " : + (dhelm == THELM_DESC_HORNED) ? "horned " : + (dhelm == THELM_DESC_CRESTED) ? "crested " : + (dhelm == THELM_DESC_PLUMED) ? "plumed " : + (dhelm == THELM_DESC_SPIKED) ? "spiked " : + (dhelm == THELM_DESC_VISORED) ? "visored " : + (dhelm == THELM_DESC_JEWELLED) ? "jewelled " + : "buggy "); + } + } + buff << item_base_name(*this); - if (!basename) + if (know_ego) { const special_armour_type sparm = get_armour_ego_type( *this ); - if (know_type && sparm != SPARM_NORMAL) + if (sparm != SPARM_NORMAL) { if ( !terse ) buff << " of "; @@ -1193,7 +1225,7 @@ std::string item_def::name_aux( description_level_type desc, } } - if (know_curse && item_cursed(*this) && terse && !basename) + if (know_curse && item_cursed(*this) && terse) buff << " (curse)"; break; @@ -1291,12 +1323,17 @@ std::string item_def::name_aux( description_level_type desc, case FOOD_CHEESE: buff << "cheese"; break; case FOOD_SAUSAGE: buff << "sausage"; break; case FOOD_CHUNK: - if (this->special < 100) - buff << "rotting "; + if (!basename && !dbname) + { + if (this->special < 100) + buff << "rotting "; - buff << "chunk of " - << mons_type_name(it_plus, DESC_PLAIN) - << " flesh"; + buff << "chunk of " + << mons_type_name(it_plus, DESC_PLAIN) + << " flesh"; + } + else + buff << "chunk of flesh"; break; } @@ -1351,7 +1388,7 @@ std::string item_def::name_aux( description_level_type desc, } } - if (is_random_artefact( *this )) + if (is_random_artefact( *this ) && !dbname) { buff << randart_jewellery_name(*this); break; @@ -1359,7 +1396,7 @@ std::string item_def::name_aux( description_level_type desc, if (know_type) { - if (know_pluses && ring_has_pluses(*this) && !basename && !qualname) + if (know_pluses && ring_has_pluses(*this)) { output_with_sign(buff, it_plus); @@ -1392,7 +1429,11 @@ std::string item_def::name_aux( description_level_type desc, case OBJ_MISCELLANY: if ( item_typ == MISC_RUNE_OF_ZOT ) - buff << rune_type_name(it_plus) << " rune of Zot"; + { + if (!dbname) + buff << rune_type_name(it_plus) << " "; + buff << "rune of Zot"; + } else { if ( is_deck(*this) ) @@ -1407,10 +1448,11 @@ std::string item_def::name_aux( description_level_type desc, buff << "BUGGY deck of cards"; break; } - buff << deck_rarity_name(deck_rarity(*this)) << ' '; + if (!dbname) + buff << deck_rarity_name(deck_rarity(*this)) << ' '; } buff << misc_type_name(item_typ, know_type); - if ( is_deck(*this) + if ( is_deck(*this) && !dbname && (top_card_is_known(*this) || this->plus2 != 0)) { buff << " {"; @@ -1439,14 +1481,21 @@ std::string item_def::name_aux( description_level_type desc, break; case OBJ_BOOKS: - if (!know_type) + if (basename) + buff << (item_typ == BOOK_MANUAL ? "manual" : "book"); + else if (!know_type) { buff << book_secondary_string(this->special / 10) << book_primary_string(this->special % 10) << (item_typ == BOOK_MANUAL ? "manual" : "book"); } else if (item_typ == BOOK_MANUAL) - buff << "manual of " << skill_name(it_plus); + { + if (dbname) + buff << "manual"; + else + buff << "manual of " << skill_name(it_plus); + } else if (item_typ == BOOK_NECRONOMICON) buff << "Necronomicon"; else if (item_typ == BOOK_DESTRUCTION) @@ -1472,7 +1521,7 @@ std::string item_def::name_aux( description_level_type desc, buff << (item_is_rod( *this ) ? "rod" : "staff") << " of " << staff_type_name(item_typ); - if (item_is_rod(*this) && !basename) + if (item_is_rod(*this) && !basename && !qualname && !dbname) { buff << " (" << (this->plus / ROD_CHARGE_MULT) << "/" << (this->plus2 / ROD_CHARGE_MULT) @@ -1496,12 +1545,13 @@ std::string item_def::name_aux( description_level_type desc, break; case OBJ_CORPSES: - if (item_typ == CORPSE_BODY && this->special < 100) + if (item_typ == CORPSE_BODY && this->special < 100 && !dbname) { buff << "rotting "; } { - buff << mons_type_name(it_plus, DESC_PLAIN) << ' '; + if (!dbname) + buff << mons_type_name(it_plus, DESC_PLAIN) << ' '; if (item_typ == CORPSE_BODY) buff << "corpse"; else if (item_typ == CORPSE_SKELETON) @@ -1520,7 +1570,7 @@ std::string item_def::name_aux( description_level_type desc, buff.str( pluralise(buff.str()) ); // Disambiguation - if (!terse && !basename && know_type) + if (!terse && !basename && !dbname && know_type) { switch (this->base_type) { @@ -2092,3 +2142,147 @@ const std::string menu_colour_item_prefix(const item_def &item) return str; } +typedef std::map item_names_map; +static item_names_map item_names_cache; + +typedef std::map > item_names_by_glyph_map; +static item_names_by_glyph_map item_names_by_glyph_cache; + +void init_item_name_cache() +{ + const int sub_type_limits[] = { + NUM_WEAPONS, + NUM_MISSILES, + NUM_ARMOURS, + NUM_WANDS, + NUM_FOODS, + 0, // Unknown I + NUM_SCROLLS, + NUM_JEWELLERY, + NUM_POTIONS, + 0, // Unknown II + NUM_BOOKS, + NUM_STAVES, + 1, // Orbs + NUM_MISCELLANY, + 0, // Corpses + 1, // Gold + -1 + }; + + for (int i = 0; sub_type_limits[i] != -1; i++) + { + object_class_type base_type = static_cast(i); + unsigned char num_sub_types = (unsigned char) sub_type_limits[i]; + + for (unsigned char sub_type = 0; sub_type < num_sub_types; sub_type++) + { + int o = items(0, base_type, sub_type, true, 1, + MAKE_ITEM_NO_RACE); + + if (o == NON_ITEM) + continue; + + item_def &item(mitm[o]); + item_types_pair pair = {base_type, sub_type}; + + // Make sure item isn't an artifact + item.flags &= ~ISFLAG_ARTEFACT_MASK; + item.special = 0; + + std::string name = item.name(DESC_DBNAME, true, true); + unsigned glyph; + unsigned short colour; + get_item_glyph(&item, &glyph, &colour); + destroy_item(o); + lowercase(name); + + if (base_type == OBJ_JEWELLERY && name == "buggy jewellery") + continue; +// else if (base_type == OBJ_MISSILES && name == "eggplant") +// continue; + else if (item.base_type == OBJ_ARMOUR + && get_armour_slot( item ) == EQ_HELMET) + { + // Why do we handle helmets this way? + continue; + } + else if (name.find("buggy") != std::string::npos) + { + crawl_state.add_startup_error("Bad name for item name " + " cache: " + name); + continue; + } + + if (item_names_cache.find(name) == item_names_cache.end()) + { + item_names_cache[name] = pair; + item_names_by_glyph_cache[glyph].push_back(name); + } + } + } + + ASSERT(item_names_cache.size() > 0); + + int o = items(0, OBJ_ARMOUR, ARM_HELMET, true, 1, + MAKE_ITEM_NO_RACE); + + if (o == NON_ITEM) + { + crawl_state.add_startup_error("Couldn't cache helmet names."); + return; + } + + item_def &item(mitm[o]); + + // Make sure item isn't an artifact + item.flags &= ~ISFLAG_ARTEFACT_MASK; + item.special = 0; + + // Now handle the helmets + for (int i = 0; i < THELM_NUM_TYPES; i++) + { + set_helmet_type(item, i); + + item_types_pair pair = {item.base_type, item.sub_type}; + + std::string name = item.name(DESC_DBNAME, true, true); + unsigned glyph; + unsigned short colour; + get_item_glyph(&item, &glyph, &colour); + lowercase(name); + + if (item_names_cache.find(name) == item_names_cache.end()) + { + item_names_cache[name] = pair; + item_names_by_glyph_cache[glyph].push_back(name); + } + } + destroy_item(o); +} + +item_types_pair item_types_by_name(std::string name) +{ + lowercase(name); + + item_names_map::iterator i = item_names_cache.find(name); + + if (i != item_names_cache.end()) + return (i->second); + + item_types_pair err = {OBJ_UNASSIGNED, 0}; + + return (err); +} + +std::vector item_name_list_for_glyph(unsigned glyph) +{ + item_names_by_glyph_map::iterator i; + i = item_names_by_glyph_cache.find(glyph); + + if (i != item_names_by_glyph_cache.end()) + return (i->second); + + std::vector empty; + return empty; +} diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h index a885693cf5..713189df24 100644 --- a/crawl-ref/source/itemname.h +++ b/crawl-ref/source/itemname.h @@ -16,6 +16,12 @@ #include "externs.h" +struct item_types_pair +{ + object_class_type base_type; + unsigned char sub_type; +}; + enum item_type_id_type { IDTYPE_WANDS = 0, @@ -119,4 +125,9 @@ void set_ident_type( object_class_type basetype, int subtype, * *********************************************************************** */ const std::string menu_colour_item_prefix(const item_def &item); +void init_item_name_cache(); +item_types_pair item_types_by_name(std::string name); + +std::vector item_name_list_for_glyph(unsigned glyph); + #endif diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 69da6bcc42..2ec3b99dfc 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -766,10 +766,8 @@ void set_helmet_type( item_def &item, short type ) // make sure we have the right sub_type (to get properties correctly) if (type == THELM_HELMET || type == THELM_HELM) item.sub_type = ARM_HELMET; - - // [dshaligram] FIXME: This is for when we import caps - // else - // item.sub_type = ARM_CAP; + else + item.sub_type = ARM_CAP; item.plus2 &= ~THELM_TYPE_MASK; item.plus2 |= type; @@ -2437,30 +2435,14 @@ std::string item_base_name(const item_def &item) case OBJ_MISSILES: return Missile_prop[Missile_index[item.sub_type]].name; case OBJ_ARMOUR: - if ( item.sub_type != ARM_HELMET ) + if ( item.sub_type != ARM_HELMET && item.sub_type != ARM_CAP ) { return Armour_prop[Armour_index[item.sub_type]].name; } else { std::string result; - if (get_helmet_type(item) == THELM_HELM || - get_helmet_type(item) == THELM_HELMET) - { - const short dhelm = get_helmet_desc( item ); - - result += - (dhelm == THELM_DESC_PLAIN) ? "" : - (dhelm == THELM_DESC_WINGED) ? "winged " : - (dhelm == THELM_DESC_HORNED) ? "horned " : - (dhelm == THELM_DESC_CRESTED) ? "crested " : - (dhelm == THELM_DESC_PLUMED) ? "plumed " : - (dhelm == THELM_DESC_SPIKED) ? "spiked " : - (dhelm == THELM_DESC_VISORED) ? "visored " : - (dhelm == THELM_DESC_JEWELLED) ? "jewelled " - : "buggy "; - } - + const short helm_type = get_helmet_type( item ); if (helm_type == THELM_HELM) result += "helm"; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 2510ed4c63..3fe34bb2f7 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -162,10 +162,37 @@ monster_type random_monster_at_grid(int grid) : valid_mons[ random2(valid_mons.size()) ]; } +typedef std::map mon_name_map; +static mon_name_map mon_name_cache; + +void init_mon_name_cache() +{ + for (unsigned i = 0; i < sizeof(mondata) / sizeof(*mondata); ++i) + { + std::string name = mondata[i].name; + lowercase(name); + + const int mtype = mondata[i].mc; + const monster_type mon = monster_type(mtype); + + mon_name_cache[name] = mon; + } +} + monster_type get_monster_by_name(std::string name, bool exact) { lowercase(name); + if (exact) + { + mon_name_map::iterator i = mon_name_cache.find(name); + + if (i != mon_name_cache.end()) + return static_cast(i->second); + + return MONS_PROGRAM_BUG; + } + monster_type mon = MONS_PROGRAM_BUG; for (unsigned i = 0; i < sizeof(mondata) / sizeof(*mondata); ++i) { @@ -174,14 +201,6 @@ monster_type get_monster_by_name(std::string name, bool exact) const int mtype = mondata[i].mc; - if (exact) - { - if (name == candidate) - return monster_type(mtype); - - continue; - } - const std::string::size_type match = candidate.find(name); if (match == std::string::npos) continue; diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index df9fe62f34..74dfe8ef2a 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -619,6 +619,7 @@ monster_type draco_subspecies( const monsters *mon ); monster_type random_monster_at_grid(int x, int y); monster_type random_monster_at_grid(int grid); +void init_mon_name_cache(); monster_type get_monster_by_name(std::string name, bool exact = false); std::string do_mon_str_replacements(const std::string &msg, diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 9cbaace2df..1a35365798 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -76,13 +76,39 @@ void init_spell_descs(void) spell_list[spelldata[i].id] = i; } // end init_spell_descs() +typedef std::map spell_name_map; +static spell_name_map spell_name_cache; + +void init_spell_name_cache() +{ + for (int i = 0; i < NUM_SPELLS; i++) + { + spell_type type = static_cast(i); + const char *sptitle = spell_title(type); + if (!sptitle) + continue; + + const std::string spell_name = lowercase_string(sptitle); + spell_name_cache[spell_name] = type; + } +} + spell_type spell_by_name(std::string name, bool partial_match) { if (name.empty()) return (SPELL_NO_SPELL); - lowercase(name); + if (!partial_match) + { + spell_name_map::iterator i = spell_name_cache.find(name); + + if (i != spell_name_cache.end()) + return (i->second); + + return (SPELL_NO_SPELL); + } + int spellmatch = -1; for (int i = 0; i < NUM_SPELLS; i++) { @@ -92,10 +118,8 @@ spell_type spell_by_name(std::string name, bool partial_match) continue; const std::string spell_name = lowercase_string(sptitle); - if (name == spell_name) - return (type); - if (partial_match && spell_name.find(name) != std::string::npos) + if (spell_name.find(name) != std::string::npos) spellmatch = i; } diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index 1f3ce8219e..8cce405ad9 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -64,6 +64,7 @@ struct spell_desc //* * called from: acr void init_spell_descs(void); +void init_spell_name_cache(); spell_type spell_by_name(std::string name, bool partial_match = false); int get_spell_slot_by_letter( char letter ); diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc index fd0a9e0ff6..79e10609ae 100644 --- a/crawl-ref/source/terrain.cc +++ b/crawl-ref/source/terrain.cc @@ -16,6 +16,7 @@ #include "terrain.h" #include "dgnevent.h" +#include "direct.h" #include "itemprop.h" #include "items.h" #include "message.h" @@ -554,3 +555,33 @@ bool fall_into_a_pool( int entry_x, int entry_y, bool allow_shift, return (false); } // end fall_into_a_pool() +typedef std::map feat_desc_map; +static feat_desc_map feat_desc_cache; + +void init_feat_desc_cache() +{ + for (int i = 0; i < NUM_FEATURES; i++) + { + dungeon_feature_type grid = static_cast(i); + std::string desc = feature_description(grid); + + lowercase(desc); + if (feat_desc_cache.find(desc) == feat_desc_cache.end()) + feat_desc_cache[desc] = grid; + } +} + +dungeon_feature_type feat_by_desc(std::string desc) +{ + lowercase(desc); + + if (desc[desc.size() - 1] != '.') + desc += "."; + + feat_desc_map::iterator i = feat_desc_cache.find(desc); + + if (i != feat_desc_cache.end()) + return (i->second); + + return (DNGN_UNSEEN); +} diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h index 16b728c5c4..24724a5713 100644 --- a/crawl-ref/source/terrain.h +++ b/crawl-ref/source/terrain.h @@ -57,4 +57,6 @@ void dungeon_terrain_changed(const coord_def &pos, bool is_critical_feature(dungeon_feature_type feat); +void init_feat_desc_cache(); +dungeon_feature_type feat_by_desc(std::string desc); #endif -- cgit v1.2.3-54-g00ecf