summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-17 19:31:22 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-17 19:31:22 +0000
commit84dc39fcc33652c105bcc13d79d5e119b74ca9ff (patch)
tree474e1dae1ade28f8d7aff7865bf7c63b3a8d31c5
parentb64722cfd0c3c1032ac26df6b54899409ccc253b (diff)
downloadcrawl-ref-84dc39fcc33652c105bcc13d79d5e119b74ca9ff.tar.gz
crawl-ref-84dc39fcc33652c105bcc13d79d5e119b74ca9ff.zip
Minor cleanups.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1891 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc15
-rw-r--r--crawl-ref/source/newgame.cc94
-rw-r--r--crawl-ref/source/religion.cc118
3 files changed, 100 insertions, 127 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 999812bb57..0af35133f6 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -143,7 +143,6 @@ std::string init_file_location; // externed in newgame.cc
char info[ INFO_SIZE ]; // messaging queue extern'd everywhere {dlb}
int stealth; // externed in view.cc
-char use_colour = 1;
// Clockwise, around the compass from north (same order as enum RUN_DIR)
const struct coord_def Compass[8] =
@@ -2838,13 +2837,13 @@ static bool initialise(void)
burden_change();
make_hungry(0,true);
- you.redraw_strength = 1;
- you.redraw_intelligence = 1;
- you.redraw_dexterity = 1;
- you.redraw_armour_class = 1;
- you.redraw_evasion = 1;
- you.redraw_experience = 1;
- you.redraw_gold = 1;
+ you.redraw_strength = true;
+ you.redraw_intelligence = true;
+ you.redraw_dexterity = true;
+ you.redraw_armour_class = true;
+ you.redraw_evasion = true;
+ you.redraw_experience = true;
+ you.redraw_gold = true;
you.wield_change = true;
you.start_time = time( NULL ); // start timer on session
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index f6a2c804bb..245c3300b7 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -709,12 +709,11 @@ bool new_game(void)
{
if (check_saved_game())
{
- textcolor( BROWN );
- cprintf( EOL "Welcome back, " );
- textcolor( YELLOW );
- cprintf( "%s!", you.your_name );
- textcolor( LIGHTGREY );
-
+ // Seems sort of pointless to print this, since the
+ // game start will kill overwrite it immediately...
+ formatted_string::parse_string(
+ "EOL<brown>Welcome back, <yellow>" +
+ std::string(you.your_name) + "!<lightgrey>").display();
save_player_name();
return (false);
}
@@ -2025,64 +2024,31 @@ static void give_basic_spells(job_type which_job)
return;
} // end give_basic_spells()
-
-/* ************************************************************************
-
-// MAKE INTO FUNCTION!!! {dlb}
-// randomly boost stats a number of times based on species {dlb}
- unsigned char points_left = ( you.species == SP_DEMIGOD || you.species == SP_DEMONSPAWN ) ? 15 : 8;
-
- do
- {
- switch ( random2(NUM_STATS) )
- {
- case STAT_STRENGTH:
- if ( you.strength > 17 && coinflip() )
- continue;
- you.strength++;
- break;
- case STAT_DEXTERITY:
- if ( you.dex > 17 && coinflip() )
- continue;
- you.dex++;
- break;
- case STAT_INTELLIGENCE:
- if ( you.intel > 17 && coinflip() )
- continue;
- you.intel++;
- break;
- }
- points_left--;
- }
- while (points_left > 0);
-
-************************************************************************ */
-
-
// eventually, this should be something more grand {dlb}
static void openingScreen(void)
{
- textcolor( YELLOW );
- cprintf("Hello, welcome to " CRAWL " " VERSION "!");
- textcolor( BROWN );
- cprintf(EOL "(c) Copyright 1997-2002 Linley Henzell, 2002-2007 Crawl DevTeam");
- cprintf(EOL
+ std::string msg =
+ "<yellow>Hello, welcome to " CRAWL " " VERSION "!</yellow>" EOL
+ "<brown>(c) Copyright 1997-2002 Linley Henzell, "
+ "2002-2007 Crawl DevTeam" EOL
"Please consult crawl_manual.txt for instructions and legal details."
- EOL);
+ "</brown>" EOL;
- bool init_found = init_file_location.find("not found") == std::string::npos;
+ const bool init_found =
+ (init_file_location.find("not found") == std::string::npos);
+
if (!init_found)
- textcolor( LIGHTRED );
+ msg += "<lightred>Init file ";
else
- textcolor( LIGHTGREY );
+ msg += "<lightgrey>Init file read: ";
- cprintf("Init file %s%s" EOL,
- init_found? "read: " : "",
- init_file_location.c_str());
+ msg += init_file_location;
+ msg += EOL;
+
+ formatted_string::parse_string(msg).display();
textcolor( LIGHTGREY );
-
return;
-} // end openingScreen()
+}
static void show_name_prompt(int where, bool blankOK,
const std::vector<player> &existing_chars,
@@ -2235,14 +2201,10 @@ static void enter_player_name(bool blankOK)
if (existing_chars.size() == 0)
{
gotoxy(1,12);
- cprintf(" If you've never been here before, "
- "you might want to try out" EOL);
- cprintf(" the Dungeon Crawl tutorial. To do this, press ");
- textcolor(WHITE);
- cprintf("T");
- textcolor(LIGHTGREY);
- cprintf(" on the next" EOL);
- cprintf(" screen.");
+ formatted_string::parse_string(
+ " If you've never been here before, you might want to try "
+ "out" EOL " the Dungeon Crawl tutorial. To do this, press "
+ "<white>T</white> on the next" EOL " screen.").display();
}
MenuEntry *title = new MenuEntry("Or choose an existing character:");
@@ -2251,7 +2213,7 @@ static void enter_player_name(bool blankOK)
for (int i = 0, size = existing_chars.size(); i < size; ++i)
{
std::string desc = " " + existing_chars[i].short_desc();
- if ((int) desc.length() >= get_number_of_cols())
+ if (static_cast<int>(desc.length()) >= get_number_of_cols())
desc = desc.substr(0, get_number_of_cols() - 1);
MenuEntry *me = new MenuEntry(desc);
@@ -2502,7 +2464,7 @@ static bool give_wanderer_weapon( int slot, int wpn_skill )
return (ret);
}
-static void make_rod(item_def &item, int rod_type)
+static void make_rod(item_def &item, stave_type rod_type)
{
item.base_type = OBJ_STAVES;
item.sub_type = rod_type;
@@ -4910,12 +4872,10 @@ bool give_items_skills()
// Vampires always start with unarmed combat skill.
if (you.species == SP_VAMPIRE && you.skills[SK_UNARMED_COMBAT] < 2)
- {
you.skills[SK_UNARMED_COMBAT] = 2;
- }
if (weap_skill)
- you.skills[weapon_skill(OBJ_WEAPONS, you.inv[0].sub_type)] = weap_skill;
+ you.skills[weapon_skill(OBJ_WEAPONS, you.inv[0].sub_type)]=weap_skill;
init_skill_order();
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index a4e6bc168e..4ebae224b4 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2470,31 +2470,76 @@ void altar_prayer(void)
offer_items();
} // end altar_prayer()
+static bool god_likes_items(god_type god)
+{
+ switch (god)
+ {
+ case GOD_ZIN: case GOD_KIKUBAAQUDGHA: case GOD_OKAWARU:
+ case GOD_MAKHLEB: case GOD_SIF_MUNA: case GOD_TROG:
+ case GOD_NEMELEX_XOBEH: case GOD_ELYVILON:
+ return true;
+
+ case GOD_SHINING_ONE: case GOD_YREDELEMNUL: case GOD_XOM:
+ case GOD_VEHUMET: case GOD_LUGONU: case GOD_BEOGH:
+ return false;
+
+ case GOD_NO_GOD: case NUM_GODS: case GOD_RANDOM:
+ mprf("Bad god, no biscuit! %d", static_cast<int>(god) );
+ return false;
+ }
+ return false;
+}
+
+static bool god_likes_item(god_type god, const item_def& item)
+{
+ if ( !god_likes_items(god) )
+ return false;
+
+ switch (god)
+ {
+ case GOD_ELYVILON:
+ return
+ item.base_type == OBJ_WEAPONS ||
+ item.base_type == OBJ_MISSILES;
+
+ case GOD_KIKUBAAQUDGHA: case GOD_TROG:
+ return item.base_type == OBJ_CORPSES;
+
+ default:
+ return true;
+ }
+}
+
void offer_items()
{
- if (you.religion == GOD_NO_GOD)
+ if (you.religion == GOD_NO_GOD || !god_likes_items(you.religion))
return;
int i = igrd[you.x_pos][you.y_pos];
while (i != NON_ITEM)
{
- if (one_chance_in(1000))
- break;
-
const int next = mitm[i].link; // in case we can't get it later.
-
const int value = item_value( mitm[i], true );
+ if (!god_likes_item(you.religion, mitm[i]))
+ {
+ i = next;
+ continue;
+ }
+
+ msg::streams(MSGCH_GOD) << mitm[i].name(DESC_CAP_THE)
+ << sacrifice_message(you.religion, mitm[i])
+ << std::endl;
+
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Sacrifice item value: %d", value);
#endif
-
+
switch (you.religion)
{
case GOD_NEMELEX_XOBEH:
you.sacrifice_value[mitm[i].base_type] += value;
- if ( you.attribute[ATTR_CARD_COUNTDOWN] &&
- random2(800) < value )
+ if (you.attribute[ATTR_CARD_COUNTDOWN] && random2(800) < value)
{
you.attribute[ATTR_CARD_COUNTDOWN]--;
#ifdef DEBUG_DIAGNOSTICS
@@ -2502,79 +2547,49 @@ void offer_items()
you.attribute[ATTR_CARD_COUNTDOWN]);
#endif
}
-
- mprf(MSGCH_GOD, "%s%s", mitm[i].name(DESC_CAP_THE).c_str(),
- sacrifice_message(you.religion, mitm[i]).c_str());
if ((mitm[i].base_type == OBJ_CORPSES && coinflip())
// Nemelex piety gain is fairly fast.
|| random2(value) >= random2(60))
{
gain_piety(1);
}
- destroy_item(i);
break;
case GOD_ZIN:
case GOD_OKAWARU:
case GOD_MAKHLEB:
- mprf(MSGCH_GOD, "%s%s", mitm[i].name(DESC_CAP_THE).c_str(),
- sacrifice_message(you.religion, mitm[i]).c_str());
if (mitm[i].base_type == OBJ_CORPSES
|| random2(value) >= 50
|| player_under_penance())
{
gain_piety(1);
}
-
- destroy_item(i);
break;
case GOD_SIF_MUNA:
- mprf(MSGCH_GOD, "%s%s", mitm[i].name(DESC_CAP_THE).c_str(),
- sacrifice_message(you.religion, mitm[i]).c_str());
-
if (value >= 150)
gain_piety(1 + random2(3));
-
- destroy_item(i);
break;
case GOD_KIKUBAAQUDGHA:
case GOD_TROG:
- if (mitm[i].base_type != OBJ_CORPSES)
- break;
-
- mprf(MSGCH_GOD, "%s%s", mitm[i].name(DESC_CAP_THE).c_str(),
- sacrifice_message(you.religion, mitm[i]).c_str());
-
gain_piety(1);
- destroy_item(i);
break;
case GOD_ELYVILON:
- if (mitm[i].base_type != OBJ_WEAPONS
- && mitm[i].base_type != OBJ_MISSILES)
- {
- break;
- }
-
- mprf(MSGCH_GOD, "%s%s", mitm[i].name(DESC_CAP_THE).c_str(),
- sacrifice_message(you.religion, mitm[i]).c_str());
-
if (random2(value) >= random2(50)
|| (mitm[i].base_type == OBJ_WEAPONS
&& (you.piety < 30 || player_under_penance())))
{
gain_piety(1);
}
-
- destroy_item(i);
break;
default:
break;
}
+ destroy_item(i);
i = next;
}
}
@@ -2587,10 +2602,10 @@ void god_pitch(god_type which_god)
// Note: using worship we could make some gods not allow followers to
// return, or not allow worshippers from other religions. -- bwr
- if ((you.is_undead || you.species == SP_DEMONSPAWN)
- && (which_god == GOD_ZIN || which_god == GOD_SHINING_ONE
- || which_god == GOD_ELYVILON) ||
- which_god == GOD_BEOGH && you.species != SP_HILL_ORC)
+ // Gods can be racist...
+ const bool you_evil = you.is_undead || you.species == SP_DEMONSPAWN;
+ if ( (you_evil && is_good_god(which_god)) ||
+ (you.species != SP_HILL_ORC && which_god == GOD_BEOGH) )
{
simple_god_message(" does not accept worship from those such as you!",
which_god);
@@ -2609,23 +2624,21 @@ void god_pitch(god_type which_god)
snprintf( info, INFO_SIZE, "Do you wish to %sjoin this religion?",
(you.worshipped[which_god]) ? "re" : "" );
- if (!yesno( info ))
+ if (!yesno( info ) || !yesno("Are you sure?"))
{
redraw_screen();
return;
}
- if (!yesno("Are you sure?"))
- {
- redraw_screen();
- return;
- }
+ // OK, so join the new religion.
redraw_screen();
+
+ // Leave your prior religion first.
if (you.religion != GOD_NO_GOD)
excommunication();
- //jmf: moved up so god_speaks gives right colour
+ // Welcome to the fold!
you.religion = static_cast<god_type>(which_god);
if (you.religion == GOD_XOM)
@@ -2665,11 +2678,12 @@ void god_pitch(god_type which_god)
if (you.penance[GOD_SHINING_ONE] > 0)
{
inc_penance(GOD_SHINING_ONE, 30);
- god_speaks(GOD_SHINING_ONE, "\"You will pay for your evil ways, mortal!\"");
+ god_speaks(GOD_SHINING_ONE,
+ "\"You will pay for your evil ways, mortal!\"");
}
}
- if ( you.religion == GOD_LUGONU )
+ if ( you.religion == GOD_LUGONU && !you.worshipped[GOD_LUGONU] )
gain_piety(20); // allow instant access to first power
redraw_skill( you.your_name, player_title() );