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KJ7JK7VNKNQC
NPCTY7SLKPF6POZZDNAIJ4RZPWOH6R65APHPZ7IPRGCOR77CSVFAC
7YUGK5Q64KG5O7GJGTUBRRLHAHBCJ5YOE23YUPT6UBKUSB67CYAQC
C22455VGUQOSUX2OORA32LROFQ7NNYDMD2ZDTTUZSAQLXK4AD6QAC
TGJZXTUIAKCFZQJ54ZQEBGFBVZSJCAX6AWDRSH3TP7UJRLGUM5SAC
2FHNLTLN3DVVD67N4QMAQ2LO7YY4GVZWXJAOIWGCCYYGIX7UHSVQC
TZ2SH2SPO5TFSFL2OCV5A32P2X4CRHEKEK7ENUFCBVF3RKUWAD4AC
YX2LDGNQNB6AQRKAVXNYQ473X6EVPQEBT5AJKBIIWFIMS3U2BNQQC
5V47S4NNTHWTSAHV3YLO2VGH7JTUIYJ3GBPDN5ZM4UQALT2ZEXDQC
OE3TD4J5FSIFAM37J2UPEV7QQNXLSZM6GDUMPI66LC5LW2OM2J4AC
45CXZWWXI7SGKLHVSRP2U6KNXJBT2XADNLIIHQQJYL2E6QWNURKQC
}
// Returns a random location in (x_pos, y_pos)... the grid will be
// DNGN_FLOOR if clear, and NON_MONSTER if empty. Exclusive tells
// if we're using in_bounds() or map_bounds() restriction.
void random_in_bounds(int &x_pos, int &y_pos, int terr,
bool empty, bool excl)
{
bool done = false;
do
{
x_pos = X_BOUND_1 + random2(X_WIDTH - 2 * excl) + 1 * excl;
y_pos = Y_BOUND_1 + random2(Y_WIDTH - 2 * excl) + 1 * excl;
if (terr == DNGN_RANDOM)
done = true;
else if (terr == grd[x_pos][y_pos])
done = true;
else if (terr == DNGN_DEEP_WATER
&& grd[x_pos][y_pos] == DNGN_SHALLOW_WATER)
done = true;
else if (empty
&& mgrd[x_pos][y_pos] != NON_MONSTER
&& (coord_def(x_pos, y_pos) != you.pos()))
{
done = true;
}
}
while (!done);
// last updated 24may2000 {dlb}
/* ***********************************************************************
* called from: spell
* *********************************************************************** */
bool burn_freeze(int pow, beam_type flavour, int targetmon);
bool burn_freeze(int pow, beam_type flavour, monsters *monster);
monster_type mon = MONS_PROGRAM_BUG;
const int dur = !permanent ? std::min(2 + (random2(pow) / 4), 6) : 0;
const int dur = permanent ? 0 : std::min(2 + (random2(pow) / 4), 6);
switch (random2(14))
{
case 0:
case 1:
case 2: // prototypical swarming creature {dlb}
mon = MONS_KILLER_BEE;
break;
case 3:
mon = MONS_SCORPION; // think: "The Arrival" {dlb}
break;
case 4: //jmf: technically not insects but still cool
mon = MONS_WORM;
break; // but worms kinda "swarm" so s'ok {dlb}
case 5:
mon = MONS_GIANT_MOSQUITO;
break; // changed into giant mosquito 12jan2000 {dlb}
case 6:
mon = MONS_GIANT_BEETLE; // think: scarabs in "The Mummy" {dlb}
break;
case 7: //jmf: blowfly instead of queen bee
mon = MONS_GIANT_BLOWFLY;
break;
// Queen bee added if more than x bees in swarm? {dlb}
// The above would require code rewrite - worth it? {dlb}
case 8:
mon = MONS_WOLF_SPIDER; // think: "Kingdom of the Spiders" {dlb}
break;
case 9:
mon = MONS_BUTTERFLY; // comic relief? {dlb}
break;
case 10: // change into some kind of snake -- {dlb}
mon = MONS_YELLOW_WASP; // do wasps swarm? {dlb}
break; // think: "Indiana Jones" and snakepit? {dlb}
const monster_type swarmers[] = {
MONS_KILLER_BEE, MONS_KILLER_BEE, MONS_KILLER_BEE,
MONS_SCORPION, MONS_WORM, MONS_GIANT_MOSQUITO,
MONS_GIANT_BEETLE, MONS_GIANT_BLOWFLY, MONS_WOLF_SPIDER,
MONS_BUTTERFLY, MONS_YELLOW_WASP, MONS_GIANT_ANT,
MONS_GIANT_ANT, MONS_GIANT_ANT
};
const monster_type mon = RANDOM_ELEMENT(swarmers);
const bool friendly = force_hostile ? false : (random2(pow) > 7);
default: // 3 in 14 chance, 12jan2000 {dlb}
mon = MONS_GIANT_ANT;
break;
}
bool friendly = !force_hostile ? (random2(pow) > 7) : false;
int x_pos, y_pos;
int tries = 500;
do
coord_def itempos;
bool found = false;
for (int i = 0; i < 500 && !found; ++i)
{
itempos = random_in_bounds();
found = (grd(itempos) == DNGN_FLOOR
&& unforbidden(itempos, mapmask));
}
if (!found)
if (tries-- <= 0)
{
destroy_item(p);
return (NON_ITEM);
}
x_pos = random2(GXM);
y_pos = random2(GYM);
// Couldn't find a single good spot!
destroy_item(p);
return (NON_ITEM);
while (grd[x_pos][y_pos] != DNGN_FLOOR
|| !unforbidden(coord_def(x_pos, y_pos), mapmask));
move_item_to_grid( &p, coord_def(x_pos, y_pos) );
move_item_to_grid(&p, itempos);
if (mitm[thing_created].sub_type == WAND_FIRE)
mitm[thing_created].sub_type = WAND_FLAME;
if (mitm[thing_created].sub_type == WAND_COLD)
mitm[thing_created].sub_type = WAND_FROST;
if (mitm[thing_created].sub_type == WAND_LIGHTNING)
{
mitm[thing_created].sub_type = (coinflip() ? WAND_FLAME
: WAND_FROST);
}
if (wand.sub_type == WAND_FIRE)
wand.sub_type = WAND_FLAME;
if (wand.sub_type == WAND_COLD)
wand.sub_type = WAND_FROST;
if (wand.sub_type == WAND_LIGHTNING)
wand.sub_type = (coinflip() ? WAND_FLAME : WAND_FROST);
const int temp_rand = random2(5);
item.sub_type = ((temp_rand > 2) ? WPN_DAGGER : // 40%
(temp_rand > 0) ? WPN_SHORT_SWORD // 40%
: WPN_CLUB); // 20%
item.sub_type = random_choose(WPN_DAGGER, WPN_DAGGER,
WPN_SHORT_SWORD, WPN_SHORT_SWORD,
WPN_CLUB, -1);
const int temp_rand = random2(4);
item.sub_type = ((temp_rand == 0) ? WPN_SPIKED_FLAIL :
(temp_rand == 1) ? WPN_GREAT_MACE :
(temp_rand == 2) ? WPN_WAR_AXE
: WPN_TRIDENT);
item.sub_type = random_choose(WPN_SPIKED_FLAIL, WPN_GREAT_MACE,
WPN_WAR_AXE, WPN_TRIDENT, -1);
const int temp_rand = random2(12);
item.sub_type = ((temp_rand == 0) ? WPN_MACE :
(temp_rand == 1) ? WPN_FLAIL :
(temp_rand == 2) ? WPN_MORNINGSTAR :
(temp_rand == 3) ? WPN_DAGGER :
(temp_rand == 4) ? WPN_SHORT_SWORD :
(temp_rand == 5) ? WPN_LONG_SWORD :
(temp_rand == 6) ? WPN_SCIMITAR :
(temp_rand == 7) ? WPN_GREAT_SWORD :
(temp_rand == 8) ? WPN_HAND_AXE :
(temp_rand == 9) ? WPN_BATTLEAXE :
(temp_rand == 10) ? WPN_SPEAR
: WPN_HALBERD);
item.sub_type = random_choose(
WPN_MACE, WPN_FLAIL, WPN_MORNINGSTAR,
WPN_DAGGER, WPN_SHORT_SWORD, WPN_LONG_SWORD,
WPN_SCIMITAR, WPN_GREAT_SWORD, WPN_HAND_AXE,
WPN_BATTLEAXE, WPN_SPEAR, WPN_HALBERD,
-1);
const int temp_rand = random2(5);
item.sub_type = ((temp_rand > 2) ? WPN_SPEAR : // 40%
(temp_rand == 2) ? WPN_FLAIL : // 20%
(temp_rand == 1) ? WPN_HALBERD // 20%
: WPN_CLUB); // 20%
item.sub_type = random_choose(WPN_SPEAR, WPN_SPEAR, WPN_FLAIL,
WPN_HALBERD, WPN_CLUB, -1);
const int temp_rand = random2(240);
item.sub_type = ((temp_rand > 209) ? WPN_DAGGER : //12.50%
(temp_rand > 179) ? WPN_CLUB : //12.50%
(temp_rand > 152) ? WPN_FLAIL : //11.25%
(temp_rand > 128) ? WPN_HAND_AXE : //10.00%
(temp_rand > 108) ? WPN_HAMMER : // 8.33%
(temp_rand > 88) ? WPN_HALBERD : // 8.33%
(temp_rand > 68) ? WPN_SHORT_SWORD : // 8.33%
(temp_rand > 48) ? WPN_MACE : // 8.33%
(temp_rand > 38) ? WPN_WHIP : // 4.17%
(temp_rand > 28) ? WPN_TRIDENT : // 4.17%
(temp_rand > 18) ? WPN_FALCHION : // 4.17%
(temp_rand > 8) ? WPN_MORNINGSTAR : // 4.17%
(temp_rand > 2) ? WPN_WAR_AXE // 2.50%
: WPN_SPIKED_FLAIL);// 1.25%
item.sub_type = random_choose_weighted(
30, WPN_DAGGER, 30, WPN_CLUB,
27, WPN_FLAIL, 24, WPN_HAND_AXE,
20, WPN_HAMMER, 20, WPN_SHORT_SWORD,
20, WPN_MACE, 10, WPN_WHIP,
10, WPN_TRIDENT, 10, WPN_FALCHION,
10, WPN_MORNINGSTAR, 6, WPN_WAR_AXE,
3, WPN_SPIKED_FLAIL,
0);
const int temp_rand = random2(100);
item.sub_type = ((temp_rand > 79) ? WPN_LONG_SWORD : // 20%
(temp_rand > 59) ? WPN_SHORT_SWORD : // 20%
(temp_rand > 45) ? WPN_SCIMITAR : // 14%
(temp_rand > 31) ? WPN_MACE : // 14%
(temp_rand > 18) ? WPN_BOW : // 13%
(temp_rand > 5) ? WPN_HAND_CROSSBOW // 13%
: WPN_LONGBOW); // 6%
item.sub_type = random_choose_weighted(
20, WPN_LONG_SWORD, 20, WPN_SHORT_SWORD, 14, WPN_SCIMITAR,
14, WPN_MACE, 13, WPN_BOW, 13, WPN_HAND_CROSSBOW,
5, WPN_LONGBOW,
0);
const int temp_rand = random2(6);
item.sub_type = ((temp_rand > 3) ? WPN_LONG_SWORD : // 2 in 6
(temp_rand > 2) ? WPN_SHORT_SWORD :// 1 in 6
(temp_rand > 1) ? WPN_SABRE : // 1 in 6
(temp_rand > 0) ? WPN_DAGGER // 1 in 6
: WPN_WHIP); // 1 in 6
item.sub_type = random_choose(WPN_LONG_SWORD, WPN_LONG_SWORD,
WPN_SHORT_SWORD, WPN_SABRE,
WPN_DAGGER, WPN_WHIP,
-1);
const int temp_rand = random2(120);
item.sub_type = ((temp_rand > 109) ? WPN_LONG_SWORD : // 8.33%
(temp_rand > 99) ? WPN_SHORT_SWORD : // 8.33%
(temp_rand > 89) ? WPN_SCIMITAR : // 8.33%
(temp_rand > 79) ? WPN_BATTLEAXE : // 8.33%
(temp_rand > 69) ? WPN_HAND_AXE : // 8.33%
(temp_rand > 59) ? WPN_HALBERD : // 8.33%
(temp_rand > 49) ? WPN_GLAIVE : // 8.33%
(temp_rand > 39) ? WPN_MORNINGSTAR : // 8.33%
(temp_rand > 29) ? WPN_GREAT_MACE : // 8.33%
(temp_rand > 19) ? WPN_TRIDENT : // 8.33%
(temp_rand > 10) ? WPN_WAR_AXE : // 7.50%
(temp_rand > 1) ? WPN_FLAIL : // 7.50%
(temp_rand > 0) ? WPN_BROAD_AXE // 0.83%
: WPN_SPIKED_FLAIL); // 0.83%
item.sub_type = random_choose_weighted(
10, WPN_LONG_SWORD, 10, WPN_SHORT_SWORD,
10, WPN_SCIMITAR, 10, WPN_BATTLEAXE,
10, WPN_HAND_AXE, 10, WPN_HALBERD,
10, WPN_GLAIVE, 10, WPN_MORNINGSTAR,
10, WPN_GREAT_MACE, 10, WPN_TRIDENT,
9, WPN_WAR_AXE, 9, WPN_FLAIL,
1, WPN_BROAD_AXE, 1, WPN_SPIKED_FLAIL,
0);
const int temp_rand = random2(25);
item.sub_type = ((temp_rand > 20) ? WPN_GREAT_SWORD : // 16%
(temp_rand > 16) ? WPN_LONG_SWORD : // 16%
(temp_rand > 12) ? WPN_BATTLEAXE : // 16%
(temp_rand > 8) ? WPN_WAR_AXE : // 16%
(temp_rand > 5) ? WPN_GREAT_MACE : // 12%
(temp_rand > 3) ? WPN_DIRE_FLAIL : // 8%
(temp_rand > 2) ? WPN_BARDICHE : // 4%
(temp_rand > 1) ? WPN_GLAIVE : // 4%
(temp_rand > 0) ? WPN_BROAD_AXE // 4%
: WPN_HALBERD); // 4%
item.sub_type = random_choose_weighted(
4, WPN_GREAT_SWORD, 4, WPN_LONG_SWORD,
4, WPN_BATTLEAXE, 4, WPN_WAR_AXE,
3, WPN_GREAT_MACE, 2, WPN_DIRE_FLAIL,
1, WPN_BARDICHE, 1, WPN_GLAIVE,
1, WPN_BROAD_AXE, 1, WPN_HALBERD,
0);
const int temp_rand = random2(5);
set_item_ego_type( item, OBJ_WEAPONS,
((temp_rand == 0) ? SPWPN_DRAINING :
(temp_rand == 1) ? SPWPN_VORPAL :
(temp_rand == 2) ? SPWPN_PAIN :
(temp_rand == 3) ? SPWPN_DISTORTION
: SPWPN_SPEED) );
set_item_ego_type(item, OBJ_WEAPONS,
random_choose(SPWPN_DRAINING, SPWPN_VORPAL,
SPWPN_PAIN, SPWPN_DISTORTION,
SPWPN_SPEED, -1));
{
const int temp_rand = random2(5);
set_item_ego_type( item, OBJ_WEAPONS,
((temp_rand == 0) ? SPWPN_VENOM :
(temp_rand == 1) ? SPWPN_DRAINING :
(temp_rand == 2) ? SPWPN_VAMPIRICISM :
(temp_rand == 3) ? SPWPN_DISTORTION
: SPWPN_NORMAL) );
}
set_item_ego_type(item, OBJ_WEAPONS,
random_choose(SPWPN_VENOM, SPWPN_DRAINING,
SPWPN_VAMPIRICISM, SPWPN_DISTORTION,
SPWPN_NORMAL, -1));
const int temp_rand = random2(6);
item.sub_type = ((temp_rand == 5) ? WPN_GREAT_SWORD :
(temp_rand == 4) ? WPN_TRIDENT :
(temp_rand == 3) ? WPN_SPEAR :
(temp_rand == 2) ? WPN_GLAIVE :
(temp_rand == 1) ? WPN_BOW
: WPN_HALBERD);
item.sub_type = random_choose(WPN_GREAT_SWORD, WPN_TRIDENT,
WPN_SPEAR, WPN_GLAIVE,
WPN_BOW, WPN_HALBERD,
-1);
if (first == NUM_BOOKS || !you.had_book[first])
{
va_end(args);
return (first);
}
int nargs = 100;
while (nargs-- > 0)
{
const int another = va_arg(args, int);
if (another == NUM_BOOKS || !you.had_book[another])
{
va_end(args);
return (another);
}
}
ASSERT(nargs > 0);
va_end(args);
return (NUM_BOOKS);
}