summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/notes.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-14 15:00:11 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-14 15:00:11 +0000
commitee2afdbd1610f7a204808056bf1a5826085b89c8 (patch)
treedebd3aee3946d707716e13b86e53d3b8539a29a0 /crawl-ref/source/notes.cc
parent4d430b2328d6922783a0dd256428de1585691eb9 (diff)
downloadcrawl-ref-ee2afdbd1610f7a204808056bf1a5826085b89c8.tar.gz
crawl-ref-ee2afdbd1610f7a204808056bf1a5826085b89c8.zip
FR 1962016: Make hydra headedness more obvious.
You now get messages like "The seven-headed hydra bites." and "You slice the 12-headed hydra." FR 1963606: Take a note when you pick up a rune (or the Orb!) for the first time. There are a couple of other files I changed, but I can't remember any big stuff, so it was probably just cleanup. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5029 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/notes.cc')
-rw-r--r--crawl-ref/source/notes.cc194
1 files changed, 107 insertions, 87 deletions
diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc
index 901fe8ea0b..3b269070dd 100644
--- a/crawl-ref/source/notes.cc
+++ b/crawl-ref/source/notes.cc
@@ -34,26 +34,29 @@ std::vector<Note> note_list;
// return the real number of the power (casting out nonexistent powers),
// starting from 0, or -1 if the power doesn't exist
-static int real_god_power( int religion, int idx )
+static int _real_god_power( int religion, int idx )
{
- if ( god_gain_power_messages[religion][idx][0] == 0 )
+ if (god_gain_power_messages[religion][idx][0] == 0)
return -1;
+
int count = 0;
- for ( int j = 0; j < idx; ++j )
- if ( god_gain_power_messages[religion][j][0] )
+ for (int j = 0; j < idx; ++j)
+ if (god_gain_power_messages[religion][j][0])
++count;
+
return count;
}
-static bool is_noteworthy_skill_level( int level )
+static bool _is_noteworthy_skill_level( int level )
{
- for ( unsigned int i = 0; i < Options.note_skill_levels.size(); ++i )
- if ( level == Options.note_skill_levels[i] )
+ for (unsigned int i = 0; i < Options.note_skill_levels.size(); ++i)
+ if (level == Options.note_skill_levels[i])
return true;
+
return false;
}
-static bool is_highest_skill( int skill )
+static bool _is_highest_skill( int skill )
{
for ( int i = 0; i < NUM_SKILLS; ++i )
{
@@ -65,135 +68,149 @@ static bool is_highest_skill( int skill )
return true;
}
-static bool is_noteworthy_hp( int hp, int maxhp )
+static bool _is_noteworthy_hp( int hp, int maxhp )
{
- return (hp > 0 && Options.note_hp_percent &&
- hp <= (maxhp * Options.note_hp_percent) / 100);
+ return (hp > 0 && Options.note_hp_percent
+ && hp <= (maxhp * Options.note_hp_percent) / 100);
}
-static int dungeon_branch_depth( unsigned char branch )
+static int _dungeon_branch_depth( unsigned char branch )
{
if ( branch >= NUM_BRANCHES )
return -1;
return branches[branch].depth;
}
-static bool is_noteworthy_dlevel( unsigned short place )
+static bool _is_noteworthy_dlevel( unsigned short place )
{
const unsigned char branch =
static_cast<unsigned char>((place >> 8) & 0xFF);
const int lev = (place & 0xFF);
/* Special levels (Abyss, etc.) are always interesting */
- if ( lev == 0xFF )
+ if (lev == 0xFF)
return true;
-
- if ( lev == dungeon_branch_depth(branch) ||
- (branch == BRANCH_MAIN_DUNGEON && (lev % 5) == 0) ||
- (branch != BRANCH_MAIN_DUNGEON && lev == 1) )
+
+ if (lev == _dungeon_branch_depth(branch)
+ || branch == BRANCH_MAIN_DUNGEON && (lev % 5) == 0
+ || branch != BRANCH_MAIN_DUNGEON && lev == 1)
+ {
return true;
+ }
return false;
}
-/* Is a note worth taking?
- This function assumes that game state has not changed since
- the note was taken, e.g. you.* is valid.
- */
-static bool is_noteworthy( const Note& note )
+// Is a note worth taking?
+// This function assumes that game state has not changed since
+// the note was taken, e.g. you.* is valid.
+static bool _is_noteworthy( const Note& note )
{
/* always noteworthy */
- if ( note.type == NOTE_XP_LEVEL_CHANGE ||
- note.type == NOTE_GET_GOD ||
- note.type == NOTE_GOD_GIFT ||
- note.type == NOTE_GET_MUTATION ||
- note.type == NOTE_LOSE_MUTATION ||
- note.type == NOTE_GET_ITEM ||
- note.type == NOTE_ID_ITEM ||
- note.type == NOTE_SEEN_MONSTER ||
- note.type == NOTE_KILL_MONSTER ||
- note.type == NOTE_POLY_MONSTER ||
- note.type == NOTE_USER_NOTE ||
- note.type == NOTE_MESSAGE ||
- note.type == NOTE_LOSE_GOD ||
- note.type == NOTE_PENANCE ||
- note.type == NOTE_MOLLIFY_GOD ||
- note.type == NOTE_DEATH )
+ if (note.type == NOTE_XP_LEVEL_CHANGE
+ || note.type == NOTE_GET_GOD
+ || note.type == NOTE_GOD_GIFT
+ || note.type == NOTE_GET_MUTATION
+ || note.type == NOTE_LOSE_MUTATION
+ || note.type == NOTE_GET_ITEM
+ || note.type == NOTE_ID_ITEM
+ || note.type == NOTE_SEEN_MONSTER
+ || note.type == NOTE_KILL_MONSTER
+ || note.type == NOTE_POLY_MONSTER
+ || note.type == NOTE_USER_NOTE
+ || note.type == NOTE_MESSAGE
+ || note.type == NOTE_FOUND_ORB_OR_RUNE
+ || note.type == NOTE_LOSE_GOD
+ || note.type == NOTE_PENANCE
+ || note.type == NOTE_MOLLIFY_GOD
+ || note.type == NOTE_DEATH)
+ {
return true;
-
+ }
+
/* never noteworthy, hooked up for fun or future use */
- if ( note.type == NOTE_MP_CHANGE ||
- note.type == NOTE_MAXHP_CHANGE ||
- note.type == NOTE_MAXMP_CHANGE )
+ if (note.type == NOTE_MP_CHANGE
+ || note.type == NOTE_MAXHP_CHANGE
+ || note.type == NOTE_MAXMP_CHANGE)
+ {
return false;
+ }
/* god powers might be noteworthy if it's an actual power */
- if ( note.type == NOTE_GOD_POWER &&
- real_god_power(note.first, note.second) == -1 )
+ if (note.type == NOTE_GOD_POWER
+ && _real_god_power(note.first, note.second) == -1)
+ {
return false;
+ }
/* hp noteworthiness is handled in its own function */
- if ( note.type == NOTE_HP_CHANGE &&
- !is_noteworthy_hp(note.first, note.second) )
+ if (note.type == NOTE_HP_CHANGE
+ && !_is_noteworthy_hp(note.first, note.second))
{
return false;
}
/* skills are noteworthy if in the skill value list or if
it's a new maximal skill (depending on options) */
- if ( note.type == NOTE_GAIN_SKILL )
+ if (note.type == NOTE_GAIN_SKILL)
{
- if ( Options.note_all_skill_levels )
- return true;
- if ( is_noteworthy_skill_level(note.second) )
- return true;
- if ( Options.note_skill_max && is_highest_skill(note.first) )
+ if (Options.note_all_skill_levels
+ || _is_noteworthy_skill_level(note.second)
+ || Options.note_skill_max && _is_highest_skill(note.first))
+ {
return true;
+ }
return false;
}
- if ( note.type == NOTE_DUNGEON_LEVEL_CHANGE )
+ if (note.type == NOTE_DUNGEON_LEVEL_CHANGE)
{
- if ( !is_noteworthy_dlevel(note.packed_place) )
+ if (!_is_noteworthy_dlevel(note.packed_place))
return false;
+
// labyrinths are always interesting
- if ( (note.packed_place & 0xFF) == 0xFF &&
- (note.packed_place >> 8) == LEVEL_LABYRINTH )
+ if ((note.packed_place & 0xFF) == 0xFF
+ && (note.packed_place >> 8) == LEVEL_LABYRINTH)
+ {
return true;
+ }
}
-
+
/* Learning a spell is always noteworthy if note_all_spells is set */
- if ( note.type == NOTE_LEARN_SPELL && Options.note_all_spells )
+ if (note.type == NOTE_LEARN_SPELL && Options.note_all_spells)
return true;
- for ( unsigned i = 0; i < note_list.size(); ++i )
+ for (unsigned i = 0; i < note_list.size(); ++i)
{
- if ( note_list[i].type != note.type )
+ if (note_list[i].type != note.type)
continue;
+
const Note& rnote( note_list[i] );
- switch ( note.type )
+ switch (note.type)
{
case NOTE_DUNGEON_LEVEL_CHANGE:
- if ( rnote.packed_place == note.packed_place )
+ if (rnote.packed_place == note.packed_place)
return false;
break;
case NOTE_LEARN_SPELL:
- if (spell_difficulty(static_cast<spell_type>(rnote.first)) >=
- spell_difficulty(static_cast<spell_type>(note.first)))
+ if (spell_difficulty(static_cast<spell_type>(rnote.first))
+ >= spell_difficulty(static_cast<spell_type>(note.first)))
{
return false;
}
break;
case NOTE_GOD_POWER:
- if ( rnote.first == note.first && rnote.second == note.second )
+ if (rnote.first == note.first && rnote.second == note.second)
return false;
break;
case NOTE_HP_CHANGE:
- /* not if we have a recent warning */
- if ( (note.turn - rnote.turn < 5) &&
- /* unless we've lost half our HP since then */
- (note.first * 2 >= rnote.first) )
+ // Not if we have a recent warning
+ // unless we've lost half our HP since then.
+ if (note.turn - rnote.turn < 5
+ && note.first * 2 >= rnote.first)
+ {
return false;
+ }
break;
default:
mpr("Buggy note passed: unknown note type");
@@ -205,13 +222,13 @@ static bool is_noteworthy( const Note& note )
return true;
}
-static const char* number_to_ordinal( int number )
+static const char* _number_to_ordinal( int number )
{
- const char* ordinals[5] = { "first", "second", "third", "fourth",
- "fifth" };
- if ( number < 1)
+ const char* ordinals[5] = { "first", "second", "third", "fourth", "fifth" };
+
+ if (number < 1)
return "[unknown ordinal (too small)]";
- if ( number > 5 )
+ if (number > 5)
return "[unknown ordinal (too big)]";
return ordinals[number-1];
}
@@ -221,16 +238,16 @@ std::string Note::describe( bool when, bool where, bool what ) const
std::ostringstream result;
- if ( when )
+ if (when)
result << std::setw(6) << turn << " ";
- if ( where )
+ if (where)
{
result << "| " << std::setw(7) << std::left
<< short_place_name(packed_place) << " | ";
}
- if ( what )
+ if (what)
{
switch ( type )
{
@@ -308,7 +325,7 @@ std::string Note::describe( bool when, bool where, bool what ) const
case NOTE_GOD_POWER:
result << "Acquired "
<< god_name(static_cast<god_type>(first)) << "'s "
- << number_to_ordinal(real_god_power(first, second)+1)
+ << _number_to_ordinal(_real_god_power(first, second)+1)
<< " power";
break;
case NOTE_GET_MUTATION:
@@ -324,6 +341,9 @@ std::string Note::describe( bool when, bool where, bool what ) const
case NOTE_DEATH:
result << name;
break;
+ case NOTE_FOUND_ORB_OR_RUNE:
+ result << "Found " << name;
+ break;
case NOTE_USER_NOTE:
result << Options.user_note_prefix << name;
break;
@@ -368,15 +388,15 @@ void Note::check_milestone() const
std::string branch = place_name(packed_place, true, false).c_str();
if (branch.find("The ") == 0)
branch[0] = tolower(branch[0]);
-
+
if (dep == 1)
mark_milestone("enter", "entered " + branch + ".");
- else if (dep == dungeon_branch_depth(br))
+ else if (dep == _dungeon_branch_depth(br))
{
std::string level = place_name(packed_place, true, true);
if (level.find("Level ") == 0)
level[0] = tolower(level[0]);
-
+
std::ostringstream branch_finale;
branch_finale << "reached " << level << ".";
mark_milestone("branch-finale", branch_finale.str());
@@ -410,26 +430,26 @@ void Note::load(reader& inf)
bool notes_active = false;
-bool notes_are_active()
+bool notes_are_active()
{
return notes_active;
}
void take_note( const Note& note, bool force )
{
- if ( notes_active && (force || is_noteworthy(note)) )
+ if ( notes_active && (force || _is_noteworthy(note)) )
{
note_list.push_back( note );
note.check_milestone();
}
}
-void activate_notes( bool active )
+void activate_notes( bool active )
{
notes_active = active;
}
-void save_notes(writer& outf)
+void save_notes(writer& outf)
{
marshallLong( outf, NOTES_VERSION_NUMBER );
marshallLong( outf, note_list.size() );
@@ -437,7 +457,7 @@ void save_notes(writer& outf)
note_list[i].save(outf);
}
-void load_notes(reader& inf)
+void load_notes(reader& inf)
{
if ( unmarshallLong(inf) != NOTES_VERSION_NUMBER )
return;