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

29 lines
698 B
C
Raw Normal View History

#include <element.h>
2011-01-07 14:03:58 -06:00
int update_WARP(UPDATE_FUNC_ARGS) {
2011-01-09 13:23:05 -06:00
int trade, r, rx, ry;
2011-01-07 14:03:58 -06:00
for ( trade = 0; trade<5; trade ++)
{
2011-01-09 13:23:05 -06:00
rx = rand()%3-1;
ry = rand()%3-1;
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-09 13:23:05 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 14:03:58 -06:00
if ((r>>8)>=NPART || !r)
continue;
2011-01-09 13:23:05 -06:00
if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200))
2011-01-07 14:03:58 -06:00
{
parts[i].x = parts[r>>8].x;
parts[i].y = parts[r>>8].y;
parts[r>>8].x = x;
parts[r>>8].y = y;
parts[i].life += 4;
2011-01-09 13:23:05 -06:00
pmap[y][x] = r;
pmap[y+ry][x+rx] = (i<<8)|parts[i].type;
2011-01-07 14:03:58 -06:00
trade = 5;
}
}
}
return 0;
}