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

27 lines
709 B
C
Raw Normal View History

#include <element.h>
2011-01-07 10:18:22 -06:00
int update_BMTL(UPDATE_FUNC_ARGS) {
2011-01-09 18:46:34 -06:00
int r, rx, ry, rt;
2011-01-07 10:18:22 -06:00
if (parts[i].tmp>1) {
parts[i].tmp--;
2011-01-09 18:46:34 -06:00
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))
2011-01-07 10:18:22 -06:00
{
2011-01-09 18:46:34 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 10:18:22 -06:00
if ((r>>8)>=NPART || !r)
continue;
2011-01-09 18:46:34 -06:00
rt = parts[r>>8].type;
2011-01-07 10:18:22 -06:00
if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100)))
{
2011-01-09 18:46:34 -06:00
part_change_type(r>>8,x+rx,y+ry,PT_BMTL);
2011-01-07 10:18:22 -06:00
parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;
}
}
} else if (parts[i].tmp==1 && 1>rand()%1000) {
parts[i].tmp = 0;
2011-01-09 18:46:34 -06:00
part_change_type(i,x,y,PT_BRMT);
2011-01-07 10:18:22 -06:00
}
return 0;
}