summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 22:15:47 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-26 22:15:47 +0000
commitea6a050bf6b67faf4f9cce0cd8ee802f75ba21e3 (patch)
tree309adb196c85da7453ffb81628e0b1af85afe294 /crawl-ref
parentab091d9b7fca62f5bd9082624132f30a43fb49db (diff)
downloadcrawl-ref-ea6a050bf6b67faf4f9cce0cd8ee802f75ba21e3.tar.gz
crawl-ref-ea6a050bf6b67faf4f9cce0cd8ee802f75ba21e3.zip
Summon Animal ('The Herd') and Summon Any ('summoning') implemented.
They need balancing, of course. Only the Spade, dancing weapon, and Blade to go, I think... git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1662 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/decks.cc52
-rw-r--r--crawl-ref/source/spells2.cc65
-rw-r--r--crawl-ref/source/spells2.h2
3 files changed, 94 insertions, 25 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 835c757303..4421f45553 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -965,6 +965,51 @@ static void summon_demon_card(int power, deck_rarity_type rarity)
BEH_FRIENDLY, you.x_pos, you.y_pos, MHITYOU, 250 );
}
+static void summon_any_monster(int power, deck_rarity_type rarity)
+{
+ const int power_level = get_power_level(power, rarity);
+ monster_type mon_chosen = NUM_MONSTERS;
+ int chosen_x, chosen_y;
+ int num_tries;
+
+ if ( power_level == 0 )
+ num_tries = 1;
+ else if ( power_level == 1 )
+ num_tries = 4;
+ else
+ num_tries = 18;
+
+ for ( int i = 0; i < num_tries; ++i ) {
+ int dx, dy;
+ do {
+ dx = random2(3) - 1;
+ dy = random2(3) - 1;
+ } while ( dx == 0 && dy == 0 );
+ monster_type cur_try;
+ do {
+ cur_try = random_monster_at_grid(you.x_pos + dx, you.y_pos + dy);
+ } while ( mons_is_unique(cur_try) );
+
+ if ( mon_chosen == NUM_MONSTERS ||
+ mons_power(mon_chosen) < mons_power(cur_try) )
+ {
+ mon_chosen = cur_try;
+ chosen_x = you.x_pos;
+ chosen_y = you.y_pos;
+ }
+ }
+
+ if ( mon_chosen == NUM_MONSTERS ) // should never happen
+ return;
+
+ if ( power_level == 0 && one_chance_in(4) )
+ create_monster( mon_chosen, 3, BEH_HOSTILE,
+ chosen_x, chosen_y, MHITYOU, 250 );
+ else
+ create_monster( mon_chosen, 3, BEH_FRIENDLY,
+ chosen_x, chosen_y, you.pet_target, 250 );
+}
+
static int card_power(deck_rarity_type rarity)
{
int result = 0;
@@ -1031,9 +1076,13 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_WRAITH: drain_exp(); lose_level(); break;
case CARD_WRATH: godly_wrath(); break;
case CARD_SUMMON_DEMON: summon_demon_card(power, rarity); break;
+ case CARD_SUMMON_ANIMAL: summon_animals(random2(power/3)); break;
+ case CARD_SUMMON_ANY: summon_any_monster(power, rarity); break;
case CARD_XOM: xom_acts(5 + random2(power/10)); break;
case CARD_SPADE:
+ case CARD_SUMMON_WEAPON:
+ // XXX not yet implemented
mpr("Sorry, this card is not yet available.");
break;
@@ -1057,9 +1106,6 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
random2(power), 0 );
break;
- case CARD_SUMMON_ANIMAL: break; // not yet implemented
- case CARD_SUMMON_WEAPON: break; // not yet implemented
- case CARD_SUMMON_ANY: break; // not yet implemented
case CARD_FAMINE:
if (you.is_undead == US_UNDEAD)
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index cfd9b8921a..d000f65117 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1253,7 +1253,7 @@ int summon_elemental(int pow, int restricted_type,
//jmf: beefed up higher-level casting of this (formerly lame) spell
void summon_small_mammals(int pow)
{
- int thing_called = MONS_PROGRAM_BUG; // error trapping{dlb}
+ monster_type thing_called = MONS_PROGRAM_BUG; // error trapping{dlb}
int pow_spent = 0;
int pow_left = pow + 1;
@@ -1273,33 +1273,16 @@ void summon_small_mammals(int pow)
switch (pow_spent)
{
- case 75:
- case 74:
- case 38:
+ case 75: case 74: case 38:
thing_called = MONS_ORANGE_RAT;
break;
- case 65:
- case 64:
- case 63:
- case 27:
- case 26:
- case 25:
+ case 65: case 64: case 63: case 27: case 26: case 25:
thing_called = MONS_GREEN_RAT;
break;
- case 57:
- case 56:
- case 55:
- case 54:
- case 53:
- case 52:
- case 20:
- case 18:
- case 16:
- case 14:
- case 12:
- case 10:
+ case 57: case 56: case 55: case 54: case 53: case 52:
+ case 20: case 18: case 16: case 14: case 12: case 10:
thing_called = coinflip() ? MONS_QUOKKA : MONS_GREY_RAT;
break;
@@ -1313,6 +1296,44 @@ void summon_small_mammals(int pow)
}
} // end summon_small_mammals()
+void summon_animals(int pow)
+{
+ // maybe we should just generate a Lair monster instead? (and
+ // guarantee that it is mobile)
+ const monster_type animals[] = {
+ MONS_BUMBLEBEE, MONS_WAR_DOG, MONS_SHEEP, MONS_YAK,
+ MONS_HOG, MONS_SOLDIER_ANT, MONS_WOLF,
+ MONS_GRIZZLY_BEAR, MONS_POLAR_BEAR, MONS_BLACK_BEAR,
+ MONS_GIANT_SNAIL, MONS_BORING_BEETLE, MONS_GILA_MONSTER,
+ MONS_KOMODO_DRAGON, MONS_SPINY_FROG, MONS_HOUND
+ };
+
+ int num_so_far = 0;
+ int power_left = pow + 1;
+
+ while ( power_left >= 0 && num_so_far < 8 )
+ {
+ // pick a random monster and subtract its cost
+ monster_type mon_chosen = animals[random2(ARRAYSIZE(animals))];
+ const int power_cost = mons_power(mon_chosen) * 3;
+
+ // allow a certain degree of overuse, but not too much
+ if ( power_cost >= power_left * 2 &&
+ num_so_far > 0 ) // at least one monster, in any case
+ break;
+
+ power_left -= power_cost;
+ num_so_far++;
+
+ if ( random2(pow) < 5 ) // unfriendly
+ create_monster( mon_chosen, 4, BEH_HOSTILE,
+ you.x_pos, you.y_pos, MHITYOU, 250 );
+ else
+ create_monster( mon_chosen, 4, BEH_FRIENDLY,
+ you.x_pos, you.y_pos, you.pet_target, 250 );
+ }
+}
+
void summon_scorpions(int pow)
{
int numsc = 1 + random2(pow) / 10 + random2(pow) / 10;
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index 61bd654853..3a6c414625 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -144,6 +144,8 @@ void summon_ice_beast_etc(int pow, int ibc, bool divine_gift = false);
* *********************************************************************** */
void summon_scorpions(int pow);
+void summon_animals(int pow);
+
// last updated 24may2000 {dlb}
/* ***********************************************************************