sanity checks to make sure we're not looking for monsters outside the monster grid, and reduce some code duplication.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3671 c06c8d41-db1a-0410-9941-cceddc491573
4OV4JZ6NWQ2ZK4LEWCUWALLB3BVANJJ2EMLHC5LJLA5WYSP25OIQC
S7ZADX2VFQCQELJFUQID45WSUAUGQ6S7XEN5WYMDIOMPVWVZALLAC
JDZCDMUCQ7VENYVLB62KQWUIRGABID37OKATOKCBUPCDL7W75NPAC
CGYTZT5QWIEGYKUOLOK7MFXSLJKLYRZONER5ZCDZO5XYWSLG475QC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
SS6MUIJYTGIVBYU356Z563QJWLJ47QNHSJWS7GJTS7EATZH2ESJQC
BWHU47MJ7KAVKMKMRBVYLOHUCASSNVCGPC3SPMNBAC7DLI6XX2YQC
TN2D3PHU7VSGUND2BDIC2F4U6O2HFSV3JXLF7HMYYMY7GZXM6IFAC
GUXTGUEMZYBRGV5QUAQSJHG3AOIQDWWCDIMOX4LASFJAZVGL2WQAC
B5YXP4UB4XK2I4W3WKCLF4GQVBXV3EV2MJWPY27RJUNVB5BDPZHAC
YMUDD3TCTXZ3U4W3AMKNCPO2K5VTOTSXSV34T36NIWMVDJXWA6TAC
XOQT7UV34HL6343R7VDXA6LAOTQDAKUAF3IWOROKHSMXRYGO5G6AC
for (int y=-radius; y<=radius; y++)
{
int posx = you.x_pos + x;
int posy = you.y_pos + y;
int dist = mons_inside_circle(posx, posy, radius);
{
for (int y=-radius; y<=radius; y++)
{
int posx = you.x_pos + x;
int posy = you.y_pos + y;
int dist = mons_inside_circle(posx, posy, radius);
// scare all hostile monsters inside sanctuary
if (dist != -1)
{
monster = mgrd[posx][posy];
monsters *mon = &menv[monster];
// scare all hostile monsters inside sanctuary
if (dist != -1)
{
monster = mgrd[posx][posy];
monsters *mon = &menv[monster];
if (!mons_friendly(mon)
&& mon->add_ench(mon_enchant(ENCH_FEAR, 0, KC_YOU)))
{
behaviour_event(mon, ME_SCARE, MHITYOU);
count++;
}
}
if (!mons_friendly(mon)
&& mon->add_ench(mon_enchant(ENCH_FEAR, 0, KC_YOU)))
{
behaviour_event(mon, ME_SCARE, MHITYOU);
count++;
}
}
// forming patterns
if (pattern == 0 // outward rays
&& (x == 0 || y == 0 || x == y || x == -y)
|| pattern == 1 // circles
&& (dist >= (radius-1)*(radius-1) && dist <= radius*radius
|| dist >= (radius/2-1)*(radius/2-1)
&& dist <= radius*radius/4)
|| pattern == 2 // latticed
&& (x%2 == 0 || y%2 == 0)
|| pattern == 3 // cross-like
&& (abs(x)+abs(y) < 5 && x != y && x != -y))
{
env.map[posx][posy].property = FPROP_SANCTUARY_1; // yellow
}
else
env.map[posx][posy].property = FPROP_SANCTUARY_2; // white
}
}
// forming patterns
if (pattern == 0 // outward rays
&& (x == 0 || y == 0 || x == y || x == -y)
|| pattern == 1 // circles
&& (dist >= (radius-1)*(radius-1) && dist <= radius*radius
|| dist >= (radius/2-1)*(radius/2-1)
&& dist <= radius*radius/4)
|| pattern == 2 // latticed
&& (x%2 == 0 || y%2 == 0)
|| pattern == 3 // cross-like
&& (abs(x)+abs(y) < 5 && x != y && x != -y))
{
env.map[posx][posy].property = FPROP_SANCTUARY_1; // yellow
}
else
env.map[posx][posy].property = FPROP_SANCTUARY_2; // white
}
if (count == 1)
simple_monster_message(&menv[monster], " turns to flee the light!");
else if (count > 0)
mpr("The monsters scatter in all directions!");
if (count == 1)
simple_monster_message(&menv[monster], " turns to flee the light!");
else if (count > 0)
mpr("The monsters scatter in all directions!");
// affect all monsters inside the halo
if (mons_inside_halo(posx, posy))
{
monster = mgrd[posx][posy];
monsters *mon = &menv[monster];
// affect all monsters inside the halo
if (mons_inside_halo(posx, posy))
{
monster = mgrd[posx][posy];
monsters *mon = &menv[monster];
int ystart = you.y_pos - 9, xstart = you.x_pos - 9;
int yend = you.y_pos + 9, xend = you.x_pos + 9;
if ( xstart < 0 ) xstart = 0;
if ( ystart < 0 ) ystart = 0;
if ( xend >= GXM ) xend = GXM;
if ( ystart >= GYM ) yend = GYM;
const int radius = 9;
int monster = -1;
monsters *monster = &menv[targ_monst];
if (mons_species(monster->type) == MONS_ORC
&& monster->attitude == ATT_FRIENDLY
&& (monster->flags & MF_ATT_CHANGE_ATTEMPT))
monster = mgrd[posx][posy];
monsters *mon = &menv[monster];
if (mons_species(mon->type) == MONS_ORC
&& mon->attitude == ATT_FRIENDLY
&& (mon->flags & MF_ATT_CHANGE_ATTEMPT))
if (mons_player_visible(monster)
&& !mons_is_sleeping(monster)
&& !mons_is_confused(monster)
&& !mons_is_paralysed(monster))
if (mons_player_visible(mon)
&& !mons_is_sleeping(mon)
&& !mons_is_confused(mon)
&& !mons_is_paralysed(mon))