diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-31 13:31:38 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-31 13:31:38 +0000 |
commit | 975dfb5b89862bcd298805c206ad1cc2ac34f048 (patch) | |
tree | a93c2e9a42a2ba9b3a505dd093f0cb6d7955a1eb /crawl-ref/source/spells3.cc | |
parent | 64b141991066a155ff820ffdc30e919550b9a8cd (diff) | |
download | crawl-ref-975dfb5b89862bcd298805c206ad1cc2ac34f048.tar.gz crawl-ref-975dfb5b89862bcd298805c206ad1cc2ac34f048.zip |
Portal no longer works once you have the Orb.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2706 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells3.cc')
-rw-r--r-- | crawl-ref/source/spells3.cc | 121 |
1 files changed, 52 insertions, 69 deletions
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 0f875cea30..78501fe6ed 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -951,13 +951,10 @@ bool recall(char type_recalled) return (success); } // end recall() -int portal(void) +// Restricted to main dungeon for historical reasons, probably for +// balance: otherwise you have an instant teleport from anywhere. +int portal() { - char dir_sign = 0; - unsigned char keyi; - int target_level = 0; - int old_level = you.your_level; - if (!player_in_branch( BRANCH_MAIN_DUNGEON )) { mpr("This spell doesn't work here."); @@ -968,84 +965,70 @@ int portal(void) mpr("You must find a clear area in which to cast this spell."); return (-1); } - else + else if (you.char_direction == GDT_ASCENDING) { - // the first query {dlb}: - mpr("Which direction ('<' for up, '>' for down, 'x' to quit)?", MSGCH_PROMPT); + // be evil if you've got the Orb + mpr("An empty arch forms before you, then disappears."); + return 1; + } - for (;;) + mpr("Which direction ('<' for up, '>' for down, 'x' to quit)?", + MSGCH_PROMPT); + + int dir_sign = 0; + while (dir_sign == 0) + { + const int keyin = getch(); + switch ( keyin ) { - keyi = get_ch(); + case '<': + if (you.your_level == 0) + mpr("You can't go any further upwards with this spell."); + else + dir_sign = -1; + break; - if (keyi == '<') - { - if (you.your_level == 0) - mpr("You can't go any further upwards with this spell."); - else - { - dir_sign = -1; - break; - } - } + case '>': + if (you.your_level + 1 == your_branch().depth) + mpr("You can't go any further downwards with this spell."); + else + dir_sign = 1; + break; - if (keyi == '>') - { - if (you.your_level == 35) - mpr("You can't go any further downwards with this spell."); - else - { - dir_sign = 1; - break; - } - } + case 'x': + canned_msg(MSG_OK); + return (-1); - if (keyi == 'x') - { - canned_msg(MSG_OK); - return (-1); // an early return {dlb} - } + default: + break; } + } - // the second query {dlb}: - mpr("How many levels (1 - 9, 'x' to quit)?", MSGCH_PROMPT); - - for (;;) - { - keyi = get_ch(); - - if (keyi == 'x') - { - canned_msg(MSG_OK); - return (-1); // another early return {dlb} - } - - if (!(keyi < '1' || keyi > '9')) - { - target_level = you.your_level + ((keyi - '0') * dir_sign); - break; - } - } + mpr("How many levels (1 - 9, 'x' to quit)?", MSGCH_PROMPT); - // actual handling begins here {dlb}: - if (player_in_branch( BRANCH_MAIN_DUNGEON )) + int amount = 0; + while (amount == 0) + { + const int keyin = getch(); + if ( isdigit(keyin) ) + amount = (keyin - '0') * dir_sign; + else if (keyin == 'x') { - if (target_level < 0) - target_level = 0; - else if (target_level > 26) - target_level = 26; + canned_msg(MSG_OK); + return (-1); } + } - mpr( "You fall through a mystic portal, and materialise at the " - "foot of a staircase." ); - more(); - - you.your_level = target_level - 1; + mpr( "You fall through a mystic portal, and materialise at the " + "foot of a staircase." ); + more(); - down_stairs( old_level, DNGN_STONE_STAIRS_DOWN_I ); - } + const int old_level = you.your_level; + you.your_level = std::max(0, std::min(26, you.your_level + amount)) - 1; + down_stairs( old_level, DNGN_STONE_STAIRS_DOWN_I ); return (1); -} // end portal() +} bool cast_death_channel(int power) { |