summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 11:57:14 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 11:57:14 +0000
commit89adf4610b5206a5f42187ee90cd01e54583f5d9 (patch)
treeb1964ae7a858303a2f52c7c71fc0b95346276a54 /crawl-ref/source
parentac38a5b60508bcd3b0a6a3537469513c94b79130 (diff)
downloadcrawl-ref-89adf4610b5206a5f42187ee90cd01e54583f5d9.tar.gz
crawl-ref-89adf4610b5206a5f42187ee90cd01e54583f5d9.zip
Add food-item-based hunger descriptions to spells.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7210 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/beam.cc4
-rw-r--r--crawl-ref/source/mstuff2.cc7
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/spl-cast.cc32
4 files changed, 21 insertions, 24 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 0ecfe0b823..7c378bc163 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2872,8 +2872,8 @@ static bool _affects_wall(const bolt &beam, int wall)
if (beam.flavour == BEAM_DIGGING)
return (true);
- // Isn't this much nicer than the hack to remove ice bolts, disrupt,
- // and needles (just because they were also coloured "white") -- bwr
+ // FIXME: There should be a better way to test for ZAP_DISRUPTION
+ // vs. ZAP_DISINTEGRATION.
if (beam.flavour == BEAM_DISINTEGRATION && beam.damage.num >= 3)
return (true);
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 8ef197979a..e969ee8869 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -576,7 +576,6 @@ void setup_mons_cast(monsters *monster, bolt &pbolt,
pbolt.type = theBeam.type;
pbolt.flavour = theBeam.flavour;
pbolt.thrower = theBeam.thrower;
- pbolt.aux_source.clear();
pbolt.name = theBeam.name;
pbolt.is_beam = theBeam.is_beam;
pbolt.source = monster->pos();
@@ -586,7 +585,7 @@ void setup_mons_cast(monsters *monster, bolt &pbolt,
pbolt.foe_ratio = theBeam.foe_ratio;
- if (pbolt.name.length() && pbolt.name[0] != '0')
+ if (!pbolt.is_enchantment())
pbolt.aux_source = pbolt.name;
else
pbolt.aux_source.clear();
@@ -807,9 +806,6 @@ void setup_generic_throw(struct monsters *monster, struct bolt &pbolt)
bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
{
- // XXX: Ugly hack, but avoids adding dynamic allocation to this code.
- char throw_buff[ITEMNAME_SIZE];
-
bool returning = (get_weapon_brand(mitm[hand_used]) == SPWPN_RETURNING
|| get_ammo_brand(mitm[hand_used]) == SPMSL_RETURNING);
@@ -1100,6 +1096,7 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used)
// [dshaligram] When changing bolt names here, you must edit
// hiscores.cc (scorefile_entry::terse_missile_cause()) to match.
+ char throw_buff[ITEMNAME_SIZE];
if (projected == LRET_LAUNCHED)
{
snprintf(throw_buff, sizeof(throw_buff), "Shot with a%s %s by %s",
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index e921e7d7d9..533790577c 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -6147,7 +6147,7 @@ int god_colour(god_type god) // mv - added
int piety_rank(int piety)
{
const int breakpoints[] = { 161, 120, 100, 75, 50, 30, 6 };
- const int numbreakpoints = sizeof(breakpoints) / sizeof(int);
+ const int numbreakpoints = ARRAYSZ(breakpoints);
if (piety < 0)
piety = you.piety;
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 611e227a68..0074ab92eb 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -4541,22 +4541,27 @@ const char* failure_rate_to_string( int fail )
"Perfect"; // 100%
}
+static unsigned int _breakpoint_rank(int val, const int breakpoints[],
+ unsigned int num_breakpoints)
+{
+ unsigned int result = 0;
+ while (result < num_breakpoints && val >= breakpoints[result])
+ ++result;
+ return result;
+}
+
const char* spell_hunger_string( spell_type spell )
{
if ( you.is_undead == US_UNDEAD )
return "N/A";
const int hunger = spell_hunger(spell);
- if ( hunger == 0 )
- return "None";
- else if ( hunger < 25 )
- return "Minor";
- else if ( hunger < 150 )
- return "Moderate";
- else if ( hunger < 500 )
- return "Major";
- else
- return "Extreme";
+ const char* hunger_descriptions[] = {
+ "None", "Grape", "Apple", "Choko", "Ration"
+ };
+ const int breakpoints[] = { 1, 25, 150, 500 };
+ return (hunger_descriptions[_breakpoint_rank(hunger, breakpoints,
+ ARRAYSZ(breakpoints))]);
}
int spell_power_colour(spell_type spell)
@@ -4580,12 +4585,7 @@ static int _power_to_barcount( int power )
return -1;
const int breakpoints[] = { 5, 10, 15, 25, 35, 50, 75, 100, 150 };
- int result = 0;
- for (unsigned int i = 0; i < ARRAYSZ(breakpoints); ++i)
- if (power > breakpoints[i])
- ++result;
-
- return (result + 1);
+ return (_breakpoint_rank(power, breakpoints, ARRAYSZ(breakpoints)) + 1);
}
int spell_power_bars( spell_type spell )