Added a number of functions that allow to differentiate between a net that currently traps a monster and one that doesn't, even if they are on the same square. This usually works but can fail if there's already a net lying on the target square.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2021 c06c8d41-db1a-0410-9941-cceddc491573
BRGAZR5AXWC2IALBVXO5SB354IRQEIRHSK55RZPGFI4AGIOD4LUQC
DMRXDEKHHBQNY37NPGZFAGUQPALWFANGGK4CUWIOQUPSLM2JBNFQC
4UXFU3FZOCBSLDQ4S7MJKAE2H7VUHCNRDQMIY6NJ3PHYXWNGISDQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
I2B33Z7NZGC33AMDSSK446AZZYWKPHWLAGULVHKKZU4MVB4BNJOAC
JR2RAQ523LOWNDYJNK6AZVKI6WVMI622PIV72XWOVZYPXPUKSQWAC
LIBWXPN6HLJAIGEFJYLOL4HLIUD236U3WM5QPHIZ3DSB4CCUJERAC
P2ZCF3BBG523ZEOD6XQA4X5YEHBTWH3IM33YVHXP2SQ5POXZIH4QC
X5WLJCJVW55SXZVP7IKP7ADCJIGNKN4PKAXFECVR6TNK7XSMZR7QC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
CPGSHENA5WYRZBW6NBZ2MQKNXE4RJS4SR3Q2H5NL5D3DDDRHHVVQC
TV3ZC6WOZKSQQJQN26JIVKCHK6UK7WMDBYZDUYRWEAZ4JB4YVNAAC
2VOD7XONHR3G2JGZGXOPHNR2AN7WUQZFR5KJH5ZY4P4G67H3RCSQC
77H4BWWPPGLM3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC
}
}
// returns the number of a net on a given square
// if trapped only stationary ones are counted
// otherwise the first net found is returned
int get_trapping_net(int x, int y, bool trapped)
{
int net, next;
for (net = igrd[x][y]; net != NON_ITEM; net = next)
{
next = mitm[net].link;
if (mitm[net].base_type == OBJ_MISSILES
&& mitm[net].sub_type == MI_THROWING_NET
&& (!trapped || item_is_stationary(mitm[net])))
{
return (net);
}
}
return (NON_ITEM);
}
// if there are more than one net on this square
// split off one of them for checking/setting values
static void maybe_split_nets(item_def &item, int x, int y)
{
if (item.quantity == 1)
{
set_item_stationary(item);
return;
}
item_def it;
it.base_type = item.base_type;
it.sub_type = item.sub_type;
it.plus = item.plus;
it.plus2 = item.plus2;
it.flags = item.flags;
it.special = item.special;
it.quantity = --item.quantity;
item_colour(it);
item.quantity = 1;
set_item_stationary(item);
copy_item_to_grid( it, x, y );
}
void mark_net_trapping(int x, int y)
{
int net = get_trapping_net(x,y);
if (net == NON_ITEM)
{
net = get_trapping_net(x,y, false);
if (net != NON_ITEM)
maybe_split_nets(mitm[net], x, y);
int net, next;
for (net = igrd[you.x_pos][you.y_pos]; net != NON_ITEM; net = next)
{
next = mitm[net].link;
if (mitm[net].base_type == OBJ_MISSILES
&& mitm[net].sub_type == MI_THROWING_NET)
{
break;
}
}
int net = get_trapping_net(you.x_pos, you.y_pos);