From 2b214aa07350746941caddf337ab4cd5bc82203d Mon Sep 17 00:00:00 2001 From: mtitus_613 Date: Tue, 6 Mar 2007 20:10:31 +0000 Subject: Add LOW MAGIC WARNING. This involved creating a channel, modifying init.txt, and the crawl_options.txt docs. Message will trigger when player's magic drops below the percentage set in init.txt (default 10%). Nice for making sure casters don't run around with low magic amounts. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@988 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/enum.h | 1 + crawl-ref/source/externs.h | 1 + crawl-ref/source/initfile.cc | 14 +++++++++++++- crawl-ref/source/message.cc | 4 ++++ crawl-ref/source/player.cc | 6 ++++++ 5 files changed, 25 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 16d0e95be6..9e49de664e 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1751,6 +1751,7 @@ enum msg_channel_type MSGCH_MULTITURN_ACTION, // delayed action messages MSGCH_DIAGNOSTICS, // various diagnostic messages MSGCH_TUTORIAL, // messages for tutorial + MSGCH_DANGER_MAGIC, // low magic warning NUM_MESSAGE_CHANNELS // always last }; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index a80061df10..1a96da890f 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1130,6 +1130,7 @@ public: int priest; // choice of god for priests (Zin/Yred) bool random_pick; // randomly generate character int hp_warning; // percentage hp for danger warning + int magic_point_warning; // percentage mp for danger warning char race; // preselected race char cls; // preselected class bool terse_hand; // use terse description for wielded item diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 19296c5644..790bfbfcd5 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -148,7 +148,8 @@ static const std::string message_channel_names[ NUM_MESSAGE_CHANNELS ] = "plain", "prompt", "god", "pray", "duration", "danger", "warning", "food", "recovery", "sound", "talk", "intrinsic_gain", "mutation", "monster_spell", "monster_enchant", "monster_damage", "monster_target", - "rotten_meat", "equipment", "floor", "multiturn", "diagnostic", + "rotten_meat", "equipment", "floor", "multiturn", "diagnostic","tutorial", + "magic_warning", }; // returns -1 if unmatched else returns 0--(NUM_MESSAGE_CHANNELS-1) @@ -591,6 +592,7 @@ void game_options::reset_options() easy_confirm = CONFIRM_SAFE_EASY; easy_quit_item_prompts = true; hp_warning = 10; + magic_point_warning = 10; confirm_self_target = true; default_target = false; safe_autopickup = true; @@ -1672,6 +1674,16 @@ void game_options::read_option_line(const std::string &str, bool runscript) field.c_str() ); } } + else if (key == "mp_warning") + { + magic_point_warning = atoi( field.c_str() ); + if (magic_point_warning < 0 || magic_point_warning > 100) + { + magic_point_warning = 0; + fprintf( stderr, "Bad MP warning percentage -- %s\n", + field.c_str() ); + } + } else if (key == "ood_interesting") { ood_interesting = atoi( field.c_str() ); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 6e2f1aa12a..62fa88ea1c 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -190,6 +190,10 @@ int channel_to_colour( int channel, int param ) ret = CYAN; break; + case MSGCH_DANGER_MAGIC: + ret = LIGHTCYAN; + break; + case MSGCH_DIAGNOSTICS: case MSGCH_MULTITURN_ACTION: ret = DARKGREY; // makes it easier to ignore at times -- bwr diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 08a4d1cd98..1cf91f9dd8 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -3790,6 +3790,12 @@ void dec_mp(int mp_loss) if (you.magic_points < 0) you.magic_points = 0; + if (you.magic_points > 0 && Options.magic_point_warning + && you.magic_points <= (you.max_magic_points * Options.magic_point_warning) / 100) + { + mpr( "* * * LOW MAGIC WARNING * * *", MSGCH_DANGER_MAGIC ); + } + take_note(Note(NOTE_MP_CHANGE, you.magic_points, you.max_magic_points)); you.redraw_magic_points = 1; -- cgit v1.2.3-54-g00ecf