The-Powder-Toy/src/elements/btry.c

25 lines
657 B
C
Raw Normal View History

#include <element.h>
2011-01-07 14:03:58 -06:00
int update_BTRY(UPDATE_FUNC_ARGS) {
2011-01-10 08:41:03 -06:00
int r, rx, ry, rt;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
2011-01-07 14:03:58 -06:00
{
2011-01-10 08:41:03 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 14:03:58 -06:00
if ((r>>8)>=NPART || !r)
continue;
rt = parts[r>>8].type;
if (parts_avg(i,r>>8,PT_INSL) != PT_INSL)
{
2011-01-10 08:41:03 -06:00
if ((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4)
2011-01-07 14:03:58 -06:00
{
parts[r>>8].life = 4;
parts[r>>8].ctype = rt;
2011-01-10 08:41:03 -06:00
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
2011-01-07 14:03:58 -06:00
}
}
}
return 0;
}