The-Powder-Toy/src/elements/lcry.c
2011-05-14 13:38:52 +01:00

27 lines
570 B
C

#include <element.h>
int update_LCRY(UPDATE_FUNC_ARGS) {
if (parts[i].life>0 && parts[i].life!=10)
parts[i].life--;
if (parts[i].life==10)
{
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
if ((r&0xFF)==PT_LCRY)
{
if (parts[r>>8].life<10&&parts[r>>8].life>0)
parts[i].life = 9;
else if (parts[r>>8].life==0)
parts[r>>8].life = 10;
}
}
}
return 0;
}