git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1667 c06c8d41-db1a-0410-9941-cceddc491573
BTO5WE4OEK64DZQVNYLOESM74KKQNE7KSNMQVF5UDB26OBKP7ORQC
IIN7AVA6JYRBXH6ZYRR7BY7TV6PW7ANAQ2A3PD55FKBKKQFEEF2AC
NJ66DHOK2SWT6MWW5FIWHKZE3HHMFNCBBUYLDJGZGCH3B752OBYQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
H7BW6SEIQ57X6V4BM2RX54W42W6BH5XJBAS6FYCYKLQQG43ZMU4QC
LABXKXWWQY2V4FUDLGVTDYHXINAP6KRHZDHBQ2FE22FFOEIZPL6QC
TZ55IZNANEJO2WDTKYWVLY2W2VV6BR7WKIN7XLNISAMMFT6LG2WQC
KKROXTUPBNEXXEUUDJNADATK3BCQPSQWFZ6L4VTKBPTYXJLYUHDQC
/* AC mod - not for armours or rings of protection */
if (one_chance_in(4 + power_level)
&& aclass != OBJ_ARMOUR
&& (aclass != OBJ_JEWELLERY || atype != RING_PROTECTION))
if (!one_chance_in(5))
proprt[RAP_AC] = 1 + random2(3) + random2(3) + random2(3);
power_level++;
if (one_chance_in(4))
/* AC mod - not for armours or rings of protection */
if (one_chance_in(4 + power_level)
&& aclass != OBJ_ARMOUR
&& (aclass != OBJ_JEWELLERY || atype != RING_PROTECTION))
proprt[RAP_AC] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_AC] = 1 + random2(3) + random2(3) + random2(3);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_AC] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
}
/* ev mod - not for rings of evasion */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_EVASION))
{
proprt[RAP_EVASION] = 1 + random2(3) + random2(3) + random2(3);
power_level++;
if (one_chance_in(4))
/* ev mod - not for rings of evasion */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_EVASION))
proprt[RAP_EVASION] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_EVASION] = 1 + random2(3) + random2(3) + random2(3);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_EVASION] -= 1 + random2(3) + random2(3)
+ random2(3);
power_level--;
}
/* str mod - not for rings of strength */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_STRENGTH))
{
proprt[RAP_STRENGTH] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
/* str mod - not for rings of strength */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_STRENGTH))
proprt[RAP_STRENGTH] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_STRENGTH] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_STRENGTH] -= 1 + random2(3) + random2(3)
+ random2(3);
power_level--;
}
/* int mod - not for rings of intelligence */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_INTELLIGENCE))
{
proprt[RAP_INTELLIGENCE] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
/* int mod - not for rings of intelligence */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_INTELLIGENCE))
proprt[RAP_INTELLIGENCE] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_INTELLIGENCE] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_INTELLIGENCE] -= 1 + random2(3) + random2(3)
+ random2(3);
power_level--;
}
/* dex mod - not for rings of dexterity */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_DEXTERITY))
{
proprt[RAP_DEXTERITY] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
/* dex mod - not for rings of dexterity */
if (one_chance_in(4 + power_level)
&& (aclass != OBJ_JEWELLERY || atype != RING_DEXTERITY))
proprt[RAP_DEXTERITY] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_DEXTERITY] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_DEXTERITY] -= 1 + random2(3) + random2(3)
+ random2(3);
power_level--;
}
skip_mods:
if (random2(15) < power_level
|| aclass == OBJ_WEAPONS
|| (aclass == OBJ_JEWELLERY && atype == RING_SLAYING))
if (random2(15) >= power_level && aclass != OBJ_WEAPONS &&
(aclass != OBJ_JEWELLERY || atype != RING_SLAYING))
goto skip_combat;
}
/* Weapons and rings of slaying can't get these */
if (one_chance_in(4 + power_level)) /* to-hit */
{
proprt[RAP_ACCURACY] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
/* Weapons and rings of slaying can't get these */
if (one_chance_in(4 + power_level)) /* to-hit */
proprt[RAP_ACCURACY] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_ACCURACY] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_ACCURACY] -= 1 + random2(3) + random2(3) +
random2(3);
power_level--;
}
if (one_chance_in(4 + power_level)) /* to-dam */
{
proprt[RAP_DAMAGE] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
if (one_chance_in(4 + power_level)) /* to-dam */
proprt[RAP_DAMAGE] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
proprt[RAP_DAMAGE] = 1 + random2(3) + random2(2);
power_level++;
if (one_chance_in(4))
{
proprt[RAP_DAMAGE] -= 1 + random2(3) + random2(3) + random2(3);
power_level--;
}
case 0: /* makes noise */
if (aclass != OBJ_WEAPONS)
switch (random2(9))
{
case 0: /* makes noise */
if (aclass != OBJ_WEAPONS)
break;
proprt[RAP_NOISES] = 1 + random2(4);
break;
case 1: /* no magic */
proprt[RAP_PREVENT_SPELLCASTING] = 1;
break;
case 2: /* random teleport */
if (aclass != OBJ_WEAPONS)
break;
proprt[RAP_CAUSE_TELEPORTATION] = 5 + random2(15);
break;
case 3: /* no teleport - doesn't affect some instantaneous
* teleports */
if (aclass == OBJ_JEWELLERY && atype == RING_TELEPORTATION)
break; /* already is a ring of tport */
if (aclass == OBJ_JEWELLERY && atype == RING_TELEPORT_CONTROL)
break; /* already is a ring of tport ctrl */
proprt[RAP_BLINK] = 0;
proprt[RAP_CAN_TELEPORT] = 0;
proprt[RAP_PREVENT_TELEPORTATION] = 1;
proprt[RAP_NOISES] = 1 + random2(4);
break;
case 1: /* no magic */
proprt[RAP_PREVENT_SPELLCASTING] = 1;
break;
case 2: /* random teleport */
if (aclass != OBJ_WEAPONS)
case 4: /* berserk on attack */
if (aclass != OBJ_WEAPONS)
break;
proprt[RAP_ANGRY] = 1 + random2(8);
break;
case 5: /* susceptible to fire */
if (aclass == OBJ_JEWELLERY
&& (atype == RING_PROTECTION_FROM_FIRE || atype == RING_FIRE
|| atype == RING_ICE))
break; /* already does this or something */
if (aclass == OBJ_ARMOUR
&& (atype == ARM_DRAGON_ARMOUR || atype == ARM_ICE_DRAGON_ARMOUR
|| atype == ARM_GOLD_DRAGON_ARMOUR))
break;
proprt[RAP_FIRE] = -1;
proprt[RAP_CAUSE_TELEPORTATION] = 5 + random2(15);
break;
case 3: /* no teleport - doesn't affect some instantaneous teleports */
if (aclass == OBJ_JEWELLERY && atype == RING_TELEPORTATION)
break; /* already is a ring of tport */
if (aclass == OBJ_JEWELLERY && atype == RING_TELEPORT_CONTROL)
break; /* already is a ring of tport ctrl */
proprt[RAP_BLINK] = 0;
proprt[RAP_CAN_TELEPORT] = 0;
proprt[RAP_PREVENT_TELEPORTATION] = 1;
break;
case 4: /* berserk on attack */
if (aclass != OBJ_WEAPONS)
case 6: /* susceptible to cold */
if (aclass == OBJ_JEWELLERY
&& (atype == RING_PROTECTION_FROM_COLD || atype == RING_FIRE
|| atype == RING_ICE))
break; /* already does this or something */
if (aclass == OBJ_ARMOUR
&& (atype == ARM_DRAGON_ARMOUR || atype == ARM_ICE_DRAGON_ARMOUR
|| atype == ARM_GOLD_DRAGON_ARMOUR))
break;
proprt[RAP_COLD] = -1;
proprt[RAP_ANGRY] = 1 + random2(8);
break;
case 5: /* susceptible to fire */
if (aclass == OBJ_JEWELLERY
&& (atype == RING_PROTECTION_FROM_FIRE || atype == RING_FIRE
|| atype == RING_ICE))
break; /* already does this or something */
if (aclass == OBJ_ARMOUR
&& (atype == ARM_DRAGON_ARMOUR || atype == ARM_ICE_DRAGON_ARMOUR
|| atype == ARM_GOLD_DRAGON_ARMOUR))
case 7: /* speed metabolism */
if (aclass == OBJ_JEWELLERY && atype == RING_HUNGER)
break; /* already is a ring of hunger */
if (aclass == OBJ_JEWELLERY && atype == RING_SUSTENANCE)
break; /* already is a ring of sustenance */
proprt[RAP_METABOLISM] = 1 + random2(3);
proprt[RAP_FIRE] = -1;
break;
case 6: /* susceptible to cold */
if (aclass == OBJ_JEWELLERY
&& (atype == RING_PROTECTION_FROM_COLD || atype == RING_FIRE
|| atype == RING_ICE))
break; /* already does this or something */
if (aclass == OBJ_ARMOUR
&& (atype == ARM_DRAGON_ARMOUR || atype == ARM_ICE_DRAGON_ARMOUR
|| atype == ARM_GOLD_DRAGON_ARMOUR))
case 8:
/* emits mutagenic radiation - increases
magic_contamination. property is chance (1 in ...) of
increasing magic_contamination */
proprt[RAP_MUTAGENIC] = 2 + random2(4);
proprt[RAP_COLD] = -1;
break;
case 7: /* speed metabolism */
if (aclass == OBJ_JEWELLERY && atype == RING_HUNGER)
break; /* already is a ring of hunger */
if (aclass == OBJ_JEWELLERY && atype == RING_SUSTENANCE)
break; /* already is a ring of sustenance */
proprt[RAP_METABOLISM] = 1 + random2(3);
break;
case 8: /* emits mutagenic radiation - increases magic_contamination */
/* property is chance (1 in ...) of increasing magic_contamination */
proprt[RAP_MUTAGENIC] = 2 + random2(4);
break;
}
}
static int count_antifeature_in_box(int x0, int y0, int x1, int y1,
dungeon_feature_type feat)
{
return (x1-x0)*(y1-y0) - count_feature_in_box(x0,y0,x1,y1,feat);
}
// count how many neighbours of grd[x][y] are the feature feat.
static int count_neighbours(int x, int y, dungeon_feature_type feat)
{
return count_feature_in_box(x-1, y-1, x+2, y+2, feat);
if (timeout >= 30000)
break;
for ( int timeout = 0; pools < num_pools && timeout < 30000; ++timeout )
{
const int i = 6 + random2( GXM - 26 );
const int j = 6 + random2( GYM - 26 );
const int k = i + 2 + roll_dice( 2, 9 );
const int l = j + 2 + roll_dice( 2, 9 );
int px, py;
int i, j;
int k = 0, l = 0;
const dungeon_feature_type altar_type = pick_an_altar();
while(true)
for ( int numtry = 0; numtry < 5000; ++numtry )
px = 15 + random2(55);
py = 15 + random2(45);
k++;
const int numfloors = count_feature_in_box(px-2, py-2, px+3, py+3,
DNGN_FLOOR);
const int numgood =
count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_ROCK_WALL) +
count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_CLOSED_DOOR) +
count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_SECRET_DOOR) +
count_feature_in_box(px-2, py-2, px+3, py+3, DNGN_FLOOR);
for (cnx = romx1[which_room] - 1; cnx < romx2[which_room] + 1;
cnx++)
{
for (cny = romy1[which_room] - 1; cny < romy2[which_room] + 1;
cny++)
{
if (grd[cnx][cny] != DNGN_ROCK_WALL)
goto continuing;
}
}
int bx = romx1[which_room], by = romy1[which_room];
if (count_antifeature_in_box(bx-1,by-1,bx+2,by+2,DNGN_ROCK_WALL))
continue;
&& b1y <= forbid_y2 && b1y >= forbid_y1)
{
goto continuing;
}
else if (b2x <= forbid_x2 && b2x >= forbid_x1
&& b2y <= forbid_y2 && b2y >= forbid_y1)
{
goto continuing;
}
&& b1y <= forbid_y2 && b1y >= forbid_y1)
continue;
if (b2x <= forbid_x2 && b2x >= forbid_x1
&& b2y <= forbid_y2 && b2y >= forbid_y1)
continue;