diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/command.cc | 44 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 287 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 61 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 24 | ||||
-rw-r--r-- | crawl-ref/source/tutorial.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/tutorial.h | 67 |
6 files changed, 176 insertions, 320 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 846e777c45..6a8e953b99 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -18,6 +18,7 @@ #include <stdio.h> #include <string.h> +#include <sstream> #include <ctype.h> #include "externs.h" @@ -1029,27 +1030,28 @@ void list_tutorial_help() cols.set_pagesize(get_number_of_lines()); unsigned short ch, colour; - std::string text = - "<h>Item types (and common commands)\n" - "<cyan>)</cyan> : hand weapons (<w>w</w>ield)\n" - "<brown>(</brown> : missiles (<w>t</w>hrow or <w>f</w>ire)\n" - "<cyan>[</cyan> : armour (<w>W</w>ear and <w>T</w>ake off)\n" - "<brown>%</brown> : food and corpses (<w>e</w>at and <w>D</w>issect)\n" - "<w>?</w> : scrolls (<w>r</w>ead)\n" - "<magenta>!</magenta> : potions (<w>q</w>uaff)\n" - "<blue>=</blue> : rings (<w>P</w>ut on and <w>R</w>emove)\n" - "<red>\"</red> : amulets (<w>P</w>ut on and <w>R</w>emove)\n" - "<darkgrey>/</darkgrey> : wands (<w>z</w>ap)\n" - "<lightcyan>"; + + std::ostringstream text; + text << + "<h>Item types (and common commands)\n" + "<cyan>)</cyan> : hand weapons (<w>w</w>ield)\n" + "<brown>(</brown> : missiles (<w>t</w>hrow or <w>f</w>ire)\n" + "<cyan>[</cyan> : armour (<w>W</w>ear and <w>T</w>ake off)\n" + "<brown>%</brown> : food and corpses (<w>e</w>at and <w>D</w>issect)\n" + "<w>?</w> : scrolls (<w>r</w>ead)\n" + "<magenta>!</magenta> : potions (<w>q</w>uaff)\n" + "<blue>=</blue> : rings (<w>P</w>ut on and <w>R</w>emove)\n" + "<red>\"</red> : amulets (<w>P</w>ut on and <w>R</w>emove)\n" + "<darkgrey>/</darkgrey> : wands (<w>z</w>ap)\n" + "<lightcyan>"; get_item_symbol(DNGN_ITEM_BOOK, &ch, &colour); - snprintf(info, INFO_SIZE, "%c", ch); - text += info; - text += "</lightcyan> : books (<w>r</w>ead, <w>M</w>emorise and <w>Z</w>ap)\n" - "<brown>"; + text << static_cast<char>(ch); + text << "</lightcyan> : books (<w>r</w>ead, <w>M</w>emorise and " + "<w>Z</w>ap)\n" + "<brown>"; get_item_symbol(DNGN_ITEM_STAVE, &ch, &colour); - snprintf(info, INFO_SIZE, "%c", ch); - text += info; - text += "</brown> : staves, rods (<w>w</w>ield and <w>E</w>voke)\n" + text << static_cast<char>(ch); + text << "</brown> : staves, rods (<w>w</w>ield and <w>E</w>voke)\n" "\n" "<h>Movement and attacking\n" "Use the <w>numpad</w> for movement (try both\n" @@ -1064,7 +1066,7 @@ void list_tutorial_help() "<w>Z</w> to cast spells (<w>Z?</w> lists spells).\n", cols.add_formatted( - 0, text.c_str(), + 0, text.str().c_str(), true, true, cmdhelp_textfilter); cols.add_formatted( @@ -1089,7 +1091,7 @@ void list_tutorial_help() "If the previous target is still alive\n" "and in sight, one of <w>f</w>, <w>p</w>, <w>t</w> fires\n" "at it again (without selecting anything).\n", - true, true, cmdhelp_textfilter,40); + true, true, cmdhelp_textfilter, 40); show_keyhelp_menu(cols.formatted_lines(), false); } diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index e635114093..f58041f2e9 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2141,225 +2141,77 @@ static std::string describe_food( const item_def &item ) // describe_potion // //--------------------------------------------------------------- -static std::string describe_potion( const item_def &item ) +static const char* describe_potion( const item_def &item ) { - std::string description; - - description.reserve(64); - if (get_ident_type( OBJ_POTIONS, item.sub_type ) != ID_KNOWN_TYPE) - description += "A small bottle of liquid."; - else - { - description += "A"; - - switch (item.sub_type) - { - case POT_HEALING: - description += " blessed"; - break; - case POT_HEAL_WOUNDS: - description += " magical healing"; - break; - case POT_SPEED: - description += "n enchanted"; - break; - case POT_MIGHT: - description += " magic"; - break; - case POT_POISON: - description += " nasty poisonous"; - break; - case POT_PORRIDGE: - description += " filling"; - break; - case POT_DEGENERATION: - description += " noxious"; - break; - case POT_DECAY: - description += " vile and putrid cursed"; - break; - case POT_WATER: - description += " unique"; - break; - case POT_EXPERIENCE: - description += " truly wonderful and very rare"; - break; - case POT_MAGIC: - description += " valuable"; - break; - case POT_STRONG_POISON: - description += " terribly venomous"; - break; - } - - description += " "; - - switch (item.sub_type) - { - case POT_MIGHT: - case POT_GAIN_STRENGTH: - case POT_GAIN_DEXTERITY: - case POT_GAIN_INTELLIGENCE: - case POT_LEVITATION: - case POT_SLOWING: - case POT_PARALYSIS: - case POT_CONFUSION: - case POT_INVISIBILITY: - case POT_PORRIDGE: - case POT_MAGIC: - case POT_RESTORE_ABILITIES: - case POT_STRONG_POISON: - case POT_BERSERK_RAGE: - case POT_CURE_MUTATION: - case POT_MUTATION: - description += "potion"; - break; - case POT_HEALING: - description += "fluid"; - break; - case POT_HEAL_WOUNDS: - description += "elixir"; - break; - case POT_SPEED: - description += "beverage"; - break; - case POT_POISON: - case POT_DECAY: - description += "liquid"; - break; - case POT_DEGENERATION: - description += "concoction"; - break; - case POT_WATER: - description += "substance"; - break; - case POT_EXPERIENCE: - description += "drink"; - break; - } + return "A small bottle of liquid.$"; - switch (item.sub_type) - { - case POT_HEALING: - case POT_HEAL_WOUNDS: - case POT_SPEED: - case POT_MIGHT: - case POT_LEVITATION: - case POT_SLOWING: - case POT_PARALYSIS: - case POT_CONFUSION: - case POT_INVISIBILITY: - case POT_DEGENERATION: - case POT_DECAY: - case POT_MAGIC: - case POT_RESTORE_ABILITIES: - case POT_BERSERK_RAGE: - case POT_CURE_MUTATION: - case POT_MUTATION: - description += " which "; - break; - case POT_GAIN_STRENGTH: - case POT_GAIN_DEXTERITY: - case POT_GAIN_INTELLIGENCE: - case POT_PORRIDGE: - description += " of "; - break; - } - - switch (item.sub_type) - { - case POT_HEALING: - description += "heals some wounds, clears the mind, " - "and cures diseases"; - break; - case POT_HEAL_WOUNDS: - description += "causes wounds to close and heal " - "almost instantly"; - break; - case POT_SPEED: - description += "speeds the actions of anyone who drinks it"; - break; - case POT_MIGHT: - description += "greatly increases the strength and " - "physical power of one who drinks it"; - break; - case POT_GAIN_STRENGTH: - case POT_GAIN_DEXTERITY: - case POT_GAIN_INTELLIGENCE: - description += "beneficial mutation"; - break; - case POT_LEVITATION: - description += "confers great buoyancy on one who consumes it"; - break; - case POT_SLOWING: - description += "slows your actions"; - break; - case POT_PARALYSIS: - description += "eliminates your control over your own body"; - break; - case POT_CONFUSION: - description += "confuses your perceptions and reduces " - "your control over your own actions"; - break; - case POT_INVISIBILITY: - description += "hides you from the sight of others"; - break; - case POT_PORRIDGE: - description += "sludge, high in cereal fibre"; - break; - case POT_DEGENERATION: - description += "can do terrible things to your " - "body, brain and reflexes"; - break; - case POT_DECAY: - description += "causes your flesh to decay " - "before your very eyes"; - break; - case POT_WATER: - description += ", vital for the existence of most life"; - break; - case POT_MAGIC: - description += "grants a person with an " - "infusion of magical energy"; - break; - case POT_RESTORE_ABILITIES: - description += "restores the abilities of one who drinks it"; - break; - case POT_BERSERK_RAGE: - description += "can send one into an incoherent rage"; - break; - case POT_CURE_MUTATION: - description += "removes some or all of any mutations " - "which may be afflicting you"; - break; - case POT_MUTATION: - description += "does very strange things to you"; - break; - } - - description += ". "; - - switch (item.sub_type) - { - case POT_HEALING: - case POT_HEAL_WOUNDS: - description += "If one uses it when they are " - "at or near full health, it can also "; - - if (item.sub_type == POT_HEALING) - description += "slightly "; - description += "repair permanent injuries. "; - break; - } - - //default: - // DEBUGSTR("Unknown potion"); // I had no idea where to put this back 16jan2000 {dlb} + switch (static_cast<potion_type>(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 NUM_POTIONS: + return "A buggy potion."; } - - description += "$"; - - return (description); + return "A very buggy potion."; } @@ -3269,10 +3121,9 @@ std::string get_item_description( const item_def &item, bool verbose, << std::dec << "$" << "x: " << item.x << " y: " << item.y << " link: " << item.link - << "$" - << "ident_type: " + << " ident_type: " << get_ident_type(item.base_type, item.sub_type) - << "$"; + << "$$"; } #endif diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index faca4e9a64..6640168817 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -3602,6 +3602,67 @@ enum trap_type // env.trap_type[] TRAP_RANDOM = 255 // set at 255 to avoid potential conflicts {dlb} }; +// any change in this list warrants an increase in the +// version number in tutorial.cc +enum tutorial_event_type +{ + TUT_SEEN_FIRST_OBJECT, // 0 + // seen certain items + TUT_SEEN_POTION, + TUT_SEEN_SCROLL, + TUT_SEEN_WAND, + TUT_SEEN_SPBOOK, + TUT_SEEN_JEWELLERY, // 5 + TUT_SEEN_MISC, + TUT_SEEN_STAFF, + TUT_SEEN_WEAPON, + TUT_SEEN_MISSILES, + TUT_SEEN_ARMOUR, // 10 + TUT_SEEN_RANDART, + TUT_SEEN_FOOD, + TUT_SEEN_CARRION, + // encountered dungeon features + TUT_SEEN_STAIRS, + TUT_SEEN_TRAPS, // 15 + TUT_SEEN_ALTAR, + TUT_SEEN_SHOP, + TUT_SEEN_DOOR, + // other 'first events' + TUT_SEEN_MONSTER, + TUT_KILLED_MONSTER, // 20 + TUT_NEW_LEVEL, + TUT_SKILL_RAISE, + TUT_YOU_ENCHANTED, + TUT_YOU_SICK, + TUT_YOU_POISON, // 25 + TUT_YOU_CURSED, + TUT_YOU_HUNGRY, + TUT_YOU_STARVING, + TUT_MULTI_PICKUP, + TUT_HEAVY_LOAD, // 30 + TUT_ROTTEN_FOOD, + TUT_NEED_HEALING, + TUT_NEED_POISON_HEALING, + TUT_RUN_AWAY, + TUT_MAKE_CHUNKS, // 35 + TUT_POSTBERSERK, + TUT_SHIFT_RUN, + TUT_MAP_VIEW, + TUT_DONE_EXPLORE, + TUT_YOU_MUTATED, // 40 + TUT_NEW_ABILITY, + TUT_WIELD_WEAPON, + TUT_EVENTS_NUM // 43 +}; // for numbers higher than 45 change size of tutorial_events in externs.h + +enum tutorial_types +{ + TUT_BERSERK_CHAR, + TUT_MAGIC_CHAR, + TUT_RANGER_CHAR, + TUT_TYPES_NUM // 3 +}; + enum unarmed_attack_type { UNAT_NO_ATTACK, // 0 diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 3132b1669a..07353d6d77 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -1299,18 +1299,20 @@ std::string item_def::name_aux( bool terse, bool ident ) const buff << jewellery_type_name(item_typ); } - - if (item_typ < AMU_RAGE) // rings - { - buff << ring_secondary_string(this->special / 13) - << ring_primary_string(this->special % 13) - << " ring"; - } - else // amulets + else { - buff << amulet_secondary_string(this->special / 13) - << amulet_primary_string(this->special % 13) - << " amulet"; + if (item_typ < AMU_RAGE) // rings + { + buff << ring_secondary_string(this->special / 13) + << ring_primary_string(this->special % 13) + << " ring"; + } + else // amulets + { + buff << amulet_secondary_string(this->special / 13) + << amulet_primary_string(this->special % 13) + << " amulet"; + } } break; diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index a9e4b2eb91..a616a53de1 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -799,7 +799,7 @@ static std::string colour_to_tag(int col, bool closed = false) return tag; } -void tutorial_first_monster(monsters mon) +void tutorial_first_monster(const monsters& mon) { if (!Options.tutorial_events[TUT_SEEN_MONSTER]) return; @@ -849,7 +849,7 @@ void tutorial_first_monster(monsters mon) Options.tut_just_triggered = 1; } -void tutorial_first_item(item_def item) +void tutorial_first_item(const item_def& item) { if (!Options.tutorial_events[TUT_SEEN_FIRST_OBJECT] || Options.tut_just_triggered) return; @@ -873,7 +873,7 @@ void tutorial_first_item(item_def item) } // Here most of the tutorial messages for various triggers are handled. -void learned_something_new(unsigned int seen_what, int x, int y) +void learned_something_new(tutorial_event_type seen_what, int x, int y) { // already learned about that if (!Options.tutorial_events[seen_what]) @@ -1279,10 +1279,11 @@ void learned_something_new(unsigned int seen_what, int x, int y) case TUT_SEEN_MONSTER: case TUT_SEEN_FIRST_OBJECT: break; - default: - text += "You've found something new (but I don't know what)!"; + case TUT_EVENTS_NUM: + text += "You've found something new (but I don't know what)!"; } - if (seen_what != TUT_SEEN_MONSTER && seen_what != TUT_SEEN_FIRST_OBJECT) + + if ( !text.empty() ) print_formatted_paragraph(text, get_tutorial_cols(), MSGCH_TUTORIAL); Options.tut_just_triggered = true; diff --git a/crawl-ref/source/tutorial.h b/crawl-ref/source/tutorial.h index a204c829ed..f78eef61e7 100644 --- a/crawl-ref/source/tutorial.h +++ b/crawl-ref/source/tutorial.h @@ -35,69 +35,8 @@ void tutorial_prayer_reminder(void); void tutorial_healing_reminder(void); void taken_new_item(unsigned char item_type); -void tutorial_first_monster(const monsters mon); -void tutorial_first_item(const item_def item); -void learned_something_new(unsigned int seen_what, int x=0, int y=0); - -// any change in this list warrants an increase in the -// version number in tutorial.cc -enum tutorial_event -{ - TUT_SEEN_FIRST_OBJECT, // 0 - // seen certain items - TUT_SEEN_POTION, - TUT_SEEN_SCROLL, - TUT_SEEN_WAND, - TUT_SEEN_SPBOOK, - TUT_SEEN_JEWELLERY, // 5 - TUT_SEEN_MISC, - TUT_SEEN_STAFF, - TUT_SEEN_WEAPON, - TUT_SEEN_MISSILES, - TUT_SEEN_ARMOUR, // 10 - TUT_SEEN_RANDART, - TUT_SEEN_FOOD, - TUT_SEEN_CARRION, - // encountered dungeon features - TUT_SEEN_STAIRS, - TUT_SEEN_TRAPS, // 15 - TUT_SEEN_ALTAR, - TUT_SEEN_SHOP, - TUT_SEEN_DOOR, - // other 'first events' - TUT_SEEN_MONSTER, - TUT_KILLED_MONSTER, // 20 - TUT_NEW_LEVEL, - TUT_SKILL_RAISE, - TUT_YOU_ENCHANTED, - TUT_YOU_SICK, - TUT_YOU_POISON, // 25 - TUT_YOU_CURSED, - TUT_YOU_HUNGRY, - TUT_YOU_STARVING, - TUT_MULTI_PICKUP, - TUT_HEAVY_LOAD, // 30 - TUT_ROTTEN_FOOD, - TUT_NEED_HEALING, - TUT_NEED_POISON_HEALING, - TUT_RUN_AWAY, - TUT_MAKE_CHUNKS, // 35 - TUT_POSTBERSERK, - TUT_SHIFT_RUN, - TUT_MAP_VIEW, - TUT_DONE_EXPLORE, - TUT_YOU_MUTATED, // 40 - TUT_NEW_ABILITY, - TUT_WIELD_WEAPON, - TUT_EVENTS_NUM // 43 -}; // for numbers higher than 45 change size of tutorial_events in externs.h - -enum tutorial_types -{ - TUT_BERSERK_CHAR, - TUT_MAGIC_CHAR, - TUT_RANGER_CHAR, - TUT_TYPES_NUM // 3 -}; +void tutorial_first_monster(const monsters& mon); +void tutorial_first_item(const item_def& item); +void learned_something_new(tutorial_event_type seen_what, int x=0, int y=0); #endif |