diff options
Diffstat (limited to 'src/elements')
109 files changed, 0 insertions, 9270 deletions
diff --git a/src/elements/O2.c b/src/elements/O2.c deleted file mode 100644 index a189e12..0000000 --- a/src/elements/O2.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_O2(UPDATE_FUNC_ARGS) -{ - int r,rx,ry; - if (parts[i].temp < 9273.15) - { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - - if ((r&0xFF)==PT_FIRE) - { - parts[r>>8].temp+=(rand()/(RAND_MAX/100)); - if(parts[r>>8].tmp&0x01) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 2; - } - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 2; - } - - } - } - else if (parts[i].temp > 9973.15 && pv[y/CELL][x/CELL] > 250.0f && fabsf(gravx[((y/CELL)*(XRES/CELL))+(x/CELL)]) + fabsf(gravy[((y/CELL)*(XRES/CELL))+(x/CELL)]) > 20) - { - if (rand()%5 < 1) - { - int j; - create_part(i,x,y,PT_BRMT); - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) parts[j].temp = 15000; - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM); if (j != -1) parts[j].temp = 15000; - - parts[i].temp = 15000; - pv[y/CELL][x/CELL] += 300; - } - } - return 0; -} diff --git a/src/elements/acel.c b/src/elements/acel.c deleted file mode 100644 index 17b89c5..0000000 --- a/src/elements/acel.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ACEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = 0; - 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) && !(rx && ry)) - { - r = pmap[y+ry][x+rx]; - if(!r) - r = photons[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if(ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) - { - parts[r>>8].vx *= 1.1f; - parts[r>>8].vy *= 1.1f; - parts[i].tmp = 1; - } - } - return 0; -} - -int graphics_ACEL(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp) - *pixel_mode |= PMODE_GLOW; - return 0; -} -int update_DCEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = 0; - 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) && !(rx && ry)) - { - r = pmap[y+ry][x+rx]; - if(!r) - r = photons[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if(ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) - { - parts[r>>8].vx *= 0.9f; - parts[r>>8].vy *= 0.9f; - parts[i].tmp = 1; - } - } - return 0; -} - -int graphics_DCEL(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp) - *pixel_mode |= PMODE_GLOW; - return 0; -} diff --git a/src/elements/acid.c b/src/elements/acid.c deleted file mode 100644 index 2e1f33e..0000000 --- a/src/elements/acid.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ACID(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_ACID && (r&0xFF)!=PT_CAUS) - { - if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD) - { - part_change_type(i,x,y,PT_FIRE); - part_change_type(r>>8,x+rx,y+ry,PT_FIRE); - parts[i].life = 4; - parts[r>>8].life = 4; - } - else if ((r&0xFF)==PT_WTRV) - { - if(!(rand()%250)) - { - part_change_type(i, x, y, PT_CAUS); - parts[i].life = (rand()%50)+25; - kill_part(r>>8); - } - } - else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) - { - if (parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid - { - float newtemp = ((60.0f-(float)ptypes[r&0xFF].hardness))*7.0f; - if(newtemp < 0){ - newtemp = 0; - } - parts[i].temp += newtemp; - parts[i].life--; - kill_part(r>>8); - } - } - else if (parts[i].life<=50) - { - kill_part(i); - return 1; - } - } - } - for ( trade = 0; trade<2; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - 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_ACID&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - int temp = parts[i].life - parts[r>>8].life; - if (temp ==1) - { - parts[r>>8].life ++; - parts[i].life --; - } - else if (temp>0) - { - parts[r>>8].life += temp/2; - parts[i].life -= temp/2; - } - } - } - } - return 0; -} diff --git a/src/elements/amtr.c b/src/elements/amtr.c deleted file mode 100644 index dcbad5f..0000000 --- a/src/elements/amtr.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_AMTR(UPDATE_FUNC_ARGS) { - 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) - continue; - if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO) - { - parts[i].life++; - if (parts[i].life==4) - { - kill_part(i); - return 1; - } - if (10>(rand()/(RAND_MAX/100))) - create_part(r>>8, x+rx, y+ry, PT_PHOT); - else - kill_part(r>>8); - pv[y/CELL][x/CELL] -= 2.0f; - } - } - return 0; -} diff --git a/src/elements/anar.c b/src/elements/anar.c deleted file mode 100644 index c6fb880..0000000 --- a/src/elements/anar.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ANAR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - - //if (parts[i].temp >= 0.23) - // parts[i].temp --; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_HFLM) - { - if (1>rand()%22) - { - part_change_type(i,x,y,PT_HFLM); - parts[i].life = rand()%150+50; - parts[r>>8].temp = parts[i].temp = 0; - pv[y/CELL][x/CELL] -= 0.5; - } - } - } - return 0; -} diff --git a/src/elements/aray.c b/src/elements/aray.c deleted file mode 100644 index e569d84..0000000 --- a/src/elements/aray.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ARAY(UPDATE_FUNC_ARGS) { - int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1; - if (parts[i].life==0) { - int colored =0; - 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) - continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life==3) { - int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; - int nostop = (parts[r>>8].ctype==PT_INST)?1:0; - for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1; docontinue; nyy+=nyi, nxx+=nxi) { - if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) { - break; - } - r = pmap[y+nyi+nyy][x+nxi+nxx]; - if (!r) { - int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); - if (nr!=-1) { - if (destroy) {//if it came from PSCN - parts[nr].tmp = 2; - parts[nr].life = 2; - } else - parts[nr].ctype = colored; - parts[nr].temp = parts[i].temp; - } - } else if (!destroy) { - if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==0) {//if it hits another BRAY that isn't red - if (nyy!=0 || nxx!=0) { - parts[r>>8].life = 1020;//makes it last a while - parts[r>>8].tmp = 1; - if (!parts[r>>8].ctype)//and colors it if it isn't already - parts[r>>8].ctype = colored; - } - docontinue = 0;//then stop it - } else if ((r&0xFF)==PT_BRAY&&parts[r>>8].tmp==1) {//if it hits one that already was a long life, reset it - parts[r>>8].life = 1020; - //docontinue = 1; - } else if ((r&0xFF)==PT_FILT) {//get color if passed through FILT - colored = parts[r>>8].ctype; - //this if prevents BRAY from stopping on certain materials - } else if ((r&0xFF)!=PT_STOR && (r&0xFF)!=PT_INWR && ((r&0xFF)!=PT_SPRK || parts[r>>8].ctype!=PT_INWR) && (r&0xFF)!=PT_ARAY && (r&0xFF)!=PT_WIFI && !((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { - if (nyy!=0 || nxx!=0) { - create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); - } - if (!(nostop && parts[r>>8].type==PT_SPRK && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { - docontinue = 0; - } else { - docontinue = 1; - } - } else if((r&0xFF)==PT_STOR) { - if(parts[r>>8].tmp) - { - //Cause STOR to release - for(ry1 = 1; ry1 >= -1; ry1--){ - for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ - int np = create_part(-1, x+nxi+nxx+rx1, y+nyi+nyy+ry1, parts[r>>8].tmp); - if (np!=-1) - { - parts[np].temp = parts[r>>8].temp; - parts[np].life = parts[r>>8].tmp2; - parts[np].tmp = parts[r>>8].pavg[0]; - parts[np].ctype = parts[r>>8].pavg[1]; - parts[r>>8].tmp = 0; - parts[r>>8].life = 10; - break; - } - } - } - } - else - { - parts[r>>8].life = 10; - } - } - } else if (destroy) { - if ((r&0xFF)==PT_BRAY) { - parts[r>>8].life = 1; - docontinue = 1; - //this if prevents red BRAY from stopping on certain materials - } else if ((r&0xFF)==PT_STOR || (r&0xFF)==PT_INWR || ((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_INWR) || (r&0xFF)==PT_ARAY || (r&0xFF)==PT_WIFI || (r&0xFF)==PT_FILT || ((r&0xFF)==PT_SWCH && parts[r>>8].life>=10)) { - if((r&0xFF)==PT_STOR) - { - parts[r>>8].tmp = 0; - parts[r>>8].life = 0; - } - docontinue = 1; - } else { - docontinue = 0; - } - } - } - } - //parts[i].life = 4; - } - } - return 0; -} diff --git a/src/elements/bang.c b/src/elements/bang.c deleted file mode 100644 index 1a2a1ec..0000000 --- a/src/elements/bang.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BANG(UPDATE_FUNC_ARGS) { - int r, rx, ry, nb; - if(parts[i].tmp==0) - { - if(parts[i].temp>=673.0f) - parts[i].tmp = 1; - else - 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) - continue; - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - parts[i].tmp = 1; - } - else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH) - { - parts[i].tmp = 1; - } - } - - } - else if(parts[i].tmp==1) - { - int tempvalue = 2; - flood_prop(x, y, offsetof(particle, tmp), &tempvalue, 0); - parts[i].tmp = 2; - } - else if(parts[i].tmp==2) - { - parts[i].tmp = 3; - } - else if(parts[i].tmp>=3) - { - float otemp = parts[i].temp-275.13f; - //Explode!! - pv[y/CELL][x/CELL] += 0.5f; - parts[i].tmp = 0; - if(!(rand()%3)) - { - if(!(rand()%2)) - { - create_part(i, x, y, PT_FIRE); - parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP); - } - else - { - create_part(i, x, y, PT_SMKE); - parts[i].temp = restrict_flt((MAX_TEMP/4)+otemp, MIN_TEMP, MAX_TEMP); - } - } - else - { - if(!(rand()%15)) - { - create_part(i, x, y, PT_EMBR); - parts[i].tmp = 0; - parts[i].life = 50; - parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP); - parts[i].vx = rand()%20-10; - parts[i].vy = rand()%20-10; - } - else - { - kill_part(i); - } - } - return 1; - } - return 0; -} diff --git a/src/elements/bcln.c b/src/elements/bcln.c deleted file mode 100644 index 63a2bbc..0000000 --- a/src/elements/bcln.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BCLN(UPDATE_FUNC_ARGS) { - if (!parts[i].life && pv[y/CELL][x/CELL]>4.0f) - parts[i].life = rand()%40+80; - if (parts[i].life) - { - float advection = 0.1f; - parts[i].vx += advection*vx[y/CELL][x/CELL]; - parts[i].vy += advection*vy[y/CELL][x/CELL]; - } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !ptypes[parts[i].ctype].enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - { - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && - (r&0xFF)<PT_NUM) - { - parts[i].ctype = r&0xFF; - if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; - } - } - } - else { - if (parts[i].ctype==PT_LIFE) create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0) - { - int np = create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - if (np>=0) - { - if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && ptransitions[parts[i].tmp].tht==PT_LAVA) - parts[np].ctype = parts[i].tmp; - } - } - } - return 0; -} diff --git a/src/elements/bcol.c b/src/elements/bcol.c deleted file mode 100644 index 1593470..0000000 --- a/src/elements/bcol.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BCOL(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, temp; - if (parts[i].life<=0) { - create_part(i, x, y, PT_FIRE); - return 1; - } else if (parts[i].life < 100) { - parts[i].life--; - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) - { - if (parts[i].life>100) { - parts[i].life = 99; - } - } - if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) - { - if (parts[r>>8].ctype == PT_IRON) { - parts[r>>8].ctype = PT_METL; - kill_part(i); - return 1; - } - } - } - /*if(100-parts[i].life > parts[i].tmp2) - parts[i].tmp2 = 100-parts[i].life; - if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion - { - int temp = parts[i].tmp2 - parts[r>>8].tmp2; - if(temp < 10) - continue; - if (temp ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - } - else if (temp>0) - { - parts[r>>8].tmp2 += temp/2; - parts[i].tmp2 -= temp/2; - } - } - } - }*/ - if(parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = parts[i].temp; - return 0; -} diff --git a/src/elements/bizr.c b/src/elements/bizr.c deleted file mode 100644 index e0fbd84..0000000 --- a/src/elements/bizr.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -//Used by ALL 3 BIZR states -int update_BIZR(UPDATE_FUNC_ARGS) { - int r, rx, ry, nr, ng, nb, na; - float tr, tg, tb, ta, mr, mg, mb, ma; - float blend; - if(parts[i].dcolour){ - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS) - { - blend = 0.95f; - tr = (parts[r>>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; - - mr = (parts[i].dcolour>>16)&0xFF; - mg = (parts[i].dcolour>>8)&0xFF; - mb = (parts[i].dcolour)&0xFF; - ma = (parts[i].dcolour>>24)&0xFF; - - nr = (tr*blend) + (mr*(1-blend)); - ng = (tg*blend) + (mg*(1-blend)); - nb = (tb*blend) + (mb*(1-blend)); - na = (ta*blend) + (ma*(1-blend)); - - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; - } - } - } - if(((r = photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) - { - part_change_type(r>>8, x, y, PT_ELEC); - parts[r>>8].ctype = 0; - } - return 0; -} diff --git a/src/elements/bmtl.c b/src/elements/bmtl.c deleted file mode 100644 index 06c2f47..0000000 --- a/src/elements/bmtl.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BMTL(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, tempFactor; - if (parts[i].tmp>1) - { - parts[i].tmp--; - 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) - continue; - rt = parts[r>>8].type; - if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) - { - part_change_type(r>>8,x+rx,y+ry,PT_BMTL); - 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; - part_change_type(i,x,y,PT_BRMT); - } - return 0; -} diff --git a/src/elements/bomb.c b/src/elements/bomb.c deleted file mode 100644 index f60c86b..0000000 --- a/src/elements/bomb.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BOMB(UPDATE_FUNC_ARGS) { - int r, rx, ry, nb; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) - { - int rad = 8; - int nxi; - int nxj; - pmap[y][x] = 0; - for (nxj=-rad; nxj<=rad; nxj++) - for (nxi=-rad; nxi<=rad; nxi++) - if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) - if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) { - delete_part(x+nxi, y+nxj, 0); - pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; - nb = create_part(-3, x+nxi, y+nxj, PT_EMBR); - if (nb!=-1) { - parts[nb].tmp = 2; - parts[nb].life = 2; - parts[nb].temp = MAX_TEMP; - } - } - for (nxj=-(rad+1); nxj<=(rad+1); nxj++) - for (nxi=-(rad+1); nxi<=(rad+1); nxi++) - if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1 && !(pmap[y+nxj][x+nxi]&0xFF)) { - nb = create_part(-3, x+nxi, y+nxj, PT_EMBR); - if (nb!=-1) { - parts[nb].tmp = 0; - parts[nb].life = 50; - parts[nb].temp = MAX_TEMP; - parts[nb].vx = rand()%40-20; - parts[nb].vy = rand()%40-20; - } - } - kill_part(i); - return 1; - } - } - return 0; -} -int graphics_BOMB(GRAPHICS_FUNC_ARGS) -{ - *pixel_mode |= PMODE_FLARE; - return 1; -} diff --git a/src/elements/boyl.c b/src/elements/boyl.c deleted file mode 100644 index 5121e9c..0000000 --- a/src/elements/boyl.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BOYL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (pv[y/CELL][x/CELL]<(parts[i].temp/100)) - pv[y/CELL][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL]); - if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<(parts[i].temp/100)) - pv[y/CELL+1][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL+1][x/CELL]); - if (x+CELL<XRES) - { - pv[y/CELL][x/CELL+1] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL+1]); - if (y+CELL<YRES) - pv[y/CELL+1][x/CELL+1] += 0.001f*((parts[i].temp/100)-pv[y/CELL+1][x/CELL+1]); - } - if (y-CELL>=0 && pv[y/CELL-1][x/CELL]<(parts[i].temp/100)) - pv[y/CELL-1][x/CELL] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL]); - if (x-CELL>=0) - { - pv[y/CELL][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL][x/CELL-1]); - if (y-CELL>=0) - pv[y/CELL-1][x/CELL-1] += 0.001f*((parts[i].temp/100)-pv[y/CELL-1][x/CELL-1]); - } - 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) - continue; - if ((r&0xFF)==PT_WATR && 1>rand()%30) - { - part_change_type(r>>8,x+rx,y+ry,PT_FOG); - } - else if ((r&0xFF)==PT_O2 && 1>rand()%9) - { - kill_part(r>>8); - part_change_type(i,x,y,PT_WATR); - pv[y/CELL][x/CELL] += 4.0; - } - } - return 0; -} diff --git a/src/elements/brel.c b/src/elements/brel.c deleted file mode 100644 index c97118b..0000000 --- a/src/elements/brel.c +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BREL(UPDATE_FUNC_ARGS) { - int np; - if (1>rand()%200 && (pv[y/CELL][x/CELL] > 30.0f) && parts[i].temp>9000 && parts[i].life>0) - { - part_change_type(i, x ,y ,PT_EXOT); - parts[i].life = 1000; - } - if ((pv[y/CELL][x/CELL] > 10.0f) && (parts[i].life>0)) { - parts[i].temp = parts[i].temp + (pv[y/CELL][x/CELL])/8; - } - return 0; -} - diff --git a/src/elements/brmt.c b/src/elements/brmt.c deleted file mode 100644 index 99702a2..0000000 --- a/src/elements/brmt.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BRMT(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, tempFactor; - if (parts[i].temp > (250.0f+273.15f)) - { - 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) - continue; - rt = parts[r>>8].type; - tempFactor = 1000 - (((250.0f+273.15f)-parts[i].temp)*2); - if(tempFactor < 2) - tempFactor = 2; - if ((rt==PT_BREL) && 1 > (rand()%tempFactor)) - { - if(rand()%2) - { - create_part(r>>8, x+rx, y+ry, PT_THRM); - } - else - { create_part(i, x, y, PT_THRM); - } - return 1; - //part_change_type(r>>8,x+rx,y+ry,PT_BMTL); - //parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; - } - } - } - return 0; -} diff --git a/src/elements/btry.c b/src/elements/btry.c deleted file mode 100644 index d220b83..0000000 --- a/src/elements/btry.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_BTRY(UPDATE_FUNC_ARGS) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - rt = parts[r>>8].type; - if (parts_avg(i,r>>8,PT_INSL) != PT_INSL) - { - 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) - { - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - } - } - } - return 0; -} diff --git a/src/elements/c5.c b/src/elements/c5.c deleted file mode 100644 index 827df6d..0000000 --- a/src/elements/c5.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_C5(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100 && ptypes[r&0xFF].hconduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10)) || (r&0xFF)==PT_HFLM) - { - if (1>rand()%6) - { - part_change_type(i,x,y,PT_HFLM); - parts[r>>8].temp = parts[i].temp = 0; - parts[i].life = rand()%150+50; - pv[y/CELL][x/CELL] += 1.5; - } - } - } - return 0; -} diff --git a/src/elements/caus.c b/src/elements/caus.c deleted file mode 100644 index 012b4c4..0000000 --- a/src/elements/caus.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CAUS(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_ACID && (r&0xFF)!=PT_CAUS) - { - if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) - { - if (parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid - { - float newtemp = ((60.0f-(float)ptypes[r&0xFF].hardness))*7.0f; - if(newtemp < 0){ - newtemp = 0; - } - parts[i].temp += newtemp; - parts[i].life--; - kill_part(r>>8); - } - } - else if (parts[i].life<=50) - { - kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/cbnw.c b/src/elements/cbnw.c deleted file mode 100644 index 8d68c84..0000000 --- a/src/elements/cbnw.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CBNW(UPDATE_FUNC_ARGS) { - int r, rx, ry, oldt; - oldt = parts[i].tmp; - if (pv[y/CELL][x/CELL]<=3) - { - if(20>(rand()%80000)) - { - part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - pv[y/CELL][x/CELL] += 0.5f; - } - else if(pv[y/CELL][x/CELL]<=-0.5) - { - part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - pv[y/CELL][x/CELL] += 0.5f; - } - } - if (parts[i].tmp>0) - parts[i].tmp--; - if(!(rand()%200)) - { - parts[i].tmp2 = rand()%40; - } else if(parts[i].tmp2!=20) { - parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1; - } - if(oldt==1) - { - //Explode - if(rand()%4) - { - part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - pv[y/CELL][x/CELL] += 0.2f; - } - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (ptypes[r&0xFF].properties&TYPE_PART && parts[i].tmp == 0 && 1>(rand()%250)) - { - //Start explode - parts[i].tmp = rand()%25;//(rand()%100)+50; - } - else if(ptypes[r&0xFF].properties&TYPE_SOLID && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-pv[y/CELL][x/CELL])>(rand()%20000)) - { - if(rand()%2) - { - part_change_type(i,x,y,PT_CO2); - parts[i].ctype = 5; - pv[y/CELL][x/CELL] += 0.2f; - } - } - if ((r&0xFF)==PT_CBNW) - { - if(!parts[i].tmp && parts[r>>8].tmp) - { - parts[i].tmp = parts[r>>8].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[i].tmp--; - } - else if(parts[i].tmp && !parts[r>>8].tmp) - { - parts[r>>8].tmp = parts[i].tmp; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].tmp++; - } - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - kill_part(r>>8); - if(1>(rand()%150)){ - kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/clne.c b/src/elements/clne.c deleted file mode 100644 index 05834b0..0000000 --- a/src/elements/clne.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CLNE(UPDATE_FUNC_ARGS) { - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !ptypes[parts[i].ctype].enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - { - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && - (r&0xFF)<PT_NUM) - { - parts[i].ctype = r&0xFF; - if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; - } - } - } - else { - if (parts[i].ctype==PT_LIFE) create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0) - { - int np = create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - if (np>=0) - { - if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && ptransitions[parts[i].tmp].tht==PT_LAVA) - parts[np].ctype = parts[i].tmp; - } - } - } - return 0; -} diff --git a/src/elements/clst.c b/src/elements/clst.c deleted file mode 100644 index 8fe1a6c..0000000 --- a/src/elements/clst.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CLST(UPDATE_FUNC_ARGS) { - int r, rx, ry; - float cxy; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_WATR && 1>(rand()%1500)) - { - part_change_type(i,x,y,PT_PSTS); - kill_part(r>>8); - } - if ((r&0xFF)==PT_NITR) - { - create_part(i, x, y, PT_BANG); - create_part(r>>8, x+rx, y+ry, PT_BANG); - } - if ((r&0xFF)==PT_CLST) - { - if(parts[i].temp <195) - cxy = 0.05; - if(parts[i].temp >= 195 && parts[i].temp <295) - cxy = 0.015; - if(parts[i].temp >= 295 && parts[i].temp <350) - cxy = 0.01; - if(parts[i].temp > 350) - cxy = 0.005; - parts[i].vx += cxy*rx; - parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005. - } - } - return 0; -} diff --git a/src/elements/co2.c b/src/elements/co2.c deleted file mode 100644 index d25b5f5..0000000 --- a/src/elements/co2.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CO2(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (parts[i].ctype==5 && 20>(rand()%40000)) - { - if (create_part(-1, x+rx, y+ry, PT_WATR)>=0) - parts[i].ctype = 0; - } - if ((r>>8)>=NPART || !r) - continue; - if ((r&0xFF)==PT_FIRE){ - kill_part(r>>8); - if(1>(rand()%150)){ - kill_part(i); - return 1; - } - } - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%250)) - { - part_change_type(r>>8, x+rx, y+ry, PT_CBNW); - if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet - create_part(i, x, y, PT_WATR); - else - kill_part(i); - } - } - if (parts[i].temp > 9773.15 && pv[y/CELL][x/CELL] > 200.0f) - { - if (rand()%5 < 1) - { - int j; - create_part(i,x,y,PT_O2); - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = 15000; - if (!(rand()%50)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = 15000; } - - parts[i].temp = 15000; - pv[y/CELL][x/CELL] += 100; - } - } - return 0; -} diff --git a/src/elements/coal.c b/src/elements/coal.c deleted file mode 100644 index 63eca57..0000000 --- a/src/elements/coal.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_COAL(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, temp; - if (parts[i].life<=0) { - create_part(i, x, y, PT_FIRE); - return 1; - } else if (parts[i].life < 100) { - parts[i].life--; - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - if ((pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if (parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if (parts[i].tmp<=0) { - create_part(i, x, y, PT_BCOL); - return 1; - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) - { - if (parts[i].life>100) { - parts[i].life = 99; - } - } - if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) - { - if (parts[r>>8].ctype == PT_IRON) { - parts[r>>8].ctype = PT_METL; - kill_part(i); - return 1; - } - } - } - /*if(100-parts[i].life > parts[i].tmp2) - parts[i].tmp2 = 100-parts[i].life; - if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion - { - int temp = parts[i].tmp2 - parts[r>>8].tmp2; - if(temp < 10) - continue; - if (temp ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - } - else if (temp>0) - { - parts[r>>8].tmp2 += temp/2; - parts[i].tmp2 -= temp/2; - } - } - } - }*/ - if(parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = parts[i].temp; - return 0; -} diff --git a/src/elements/conv.c b/src/elements/conv.c deleted file mode 100644 index 95edc0c..0000000 --- a/src/elements/conv.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_CONV(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !ptypes[parts[i].ctype].enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - { - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && - (r&0xFF)!=PT_CONV && (r&0xFF)<PT_NUM) - { - parts[i].ctype = r&0xFF; - if ((r&0xFF)==PT_LIFE) - parts[i].tmp = parts[r>>8].ctype; - } - } - } - else if(parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].enabled && parts[i].ctype!=PT_CONV) { - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=parts[i].ctype) - { - if (parts[i].ctype==PT_LIFE) create_part(r>>8, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); - else create_part(r>>8, x+rx, y+ry, parts[i].ctype); - } - } - } - return 0; -} diff --git a/src/elements/dest.c b/src/elements/dest.c deleted file mode 100644 index b6d5e71..0000000 --- a/src/elements/dest.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_DEST(UPDATE_FUNC_ARGS) { - int r,rx,ry,topv; - rx=rand()%5-2; - ry=rand()%5-2; - - r = pmap[y+ry][x+rx]; - if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN) - return 0; - - if (parts[i].life<=0 || parts[i].life>37) - { - parts[i].life=30+rand()%20; - parts[i].temp+=20000; - pv[y/CELL][x/CELL]+=60.0f; - } - parts[i].temp+=10000; - if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) - { - pv[y/CELL][x/CELL]+=20.0f; - parts[i].temp+=18000; - if (rand()%2==0) - { - float orig_temp = parts[r>>8].temp; - create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP); - pv[y/CELL][x/CELL] += 10.0f; - parts[i].life-=4; - } - } - else if ((r&0xFF)==PT_INSL) - { - create_part(r>>8, x+rx, y+ry, PT_PLSM); - } - else if (rand()%3==0) - { - kill_part(r>>8); - parts[i].life -= 4*((ptypes[r&0xFF].properties&TYPE_SOLID)?3:1); - if (parts[i].life<=0) - parts[i].life=1; - parts[i].temp+=10000; - } - else - { - if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); - } - topv=pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; - if (topv>40.0f) - topv=40.0f; - pv[y/CELL][x/CELL]+=40.0f+topv; - parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); - return 0; -} -int graphics_DEST(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life) - { - *pixel_mode |= PMODE_LFLARE; - } - else - { - *pixel_mode |= PMODE_SPARK; - } - return 0; -} diff --git a/src/elements/deut.c b/src/elements/deut.c deleted file mode 100644 index 73b95a9..0000000 --- a/src/elements/deut.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_DEUT(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - float gravtot = fabs(gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]); - int maxlife = ((10000/(parts[i].temp + 1))-1); - if ((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) - maxlife ++; - // Compress when Newtonian gravity is applied - // multiplier=1 when gravtot=0, multiplier -> 5 as gravtot -> inf - maxlife = maxlife*(5.0f - 8.0f/(gravtot+2.0f)); - if (parts[i].life < maxlife) - { - 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 || (parts[i].life >=maxlife)) - continue; - if ((r&0xFF)==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1) - { - if ((parts[i].life + parts[r>>8].life + 1) <= maxlife) - { - parts[i].life += parts[r>>8].life + 1; - kill_part(r>>8); - } - } - } - } - else - 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 (parts[i].life<=maxlife) - continue; - if ((!r)&&parts[i].life>=1)//if nothing then create deut - { - np = create_part(-1,x+rx,y+ry,PT_DEUT); - if (np<0) continue; - parts[i].life--; - parts[np].temp = parts[i].temp; - parts[np].life = 0; - } - } - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - int temp = parts[i].life - parts[r>>8].life; - if (temp ==1) - { - parts[r>>8].life ++; - parts[i].life --; - } - else if (temp>0) - { - parts[r>>8].life += temp/2; - parts[i].life -= temp/2; - } - } - } - } - return 0; -} - -int graphics_DEUT(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life>=240) - { - *firea = 60; - *firer = *colr += cpart->life*1; - *fireg = *colg += cpart->life*2; - *fireb = *colb += cpart->life*3; - *pixel_mode |= PMODE_GLOW | FIRE_ADD; - } - else - { - *colr += cpart->life*1; - *colg += cpart->life*2; - *colb += cpart->life*3; - *pixel_mode |= PMODE_BLUR; - } - return 0; -} diff --git a/src/elements/dlay.c b/src/elements/dlay.c deleted file mode 100644 index 961b115..0000000 --- a/src/elements/dlay.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_DLAY(UPDATE_FUNC_ARGS) { - int r, rx, ry, oldl; - oldl = parts[i].life; - if (parts[i].life>0) - parts[i].life--; - //if (parts[i].life==1) - //{ - if (parts[i].temp>=MAX_TEMP+273.15f) - parts[i].temp = MAX_TEMP+273.15f; - if (parts[i].temp<= 1.0f+273.15f) - parts[i].temp = 1.0f+273.15f; - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r || parts_avg(r>>8, i,PT_INSL)==PT_INSL) - continue; - if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = (int)(parts[i].temp-273.15); - } - else if ((r&0xFF)==PT_DLAY) - { - if(!parts[i].life && parts[r>>8].life) - { - parts[i].life = parts[r>>8].life; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[i].life--; - } - else if(parts[i].life && !parts[r>>8].life) - { - parts[r>>8].life = parts[i].life; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].life++; - } - } - else if((r&0xFF)==PT_NSCN && oldl==1) - { - create_part(-1, x+rx, y+ry, PT_SPRK); - } - } - //} - return 0; -} diff --git a/src/elements/dstw.c b/src/elements/dstw.c deleted file mode 100644 index a0aa23b..0000000 --- a/src/elements/dstw.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_DSTW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SALT && 1>(rand()%250)) - { - part_change_type(i,x,y,PT_SLTW); - // on average, convert 3 DSTW to SLTW before SALT turns into SLTW - if (rand()%3==0) - part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_WATR); - } - if ((r&0xFF)==PT_SLTW && 1>(rand()%10000)) - { - part_change_type(i,x,y,PT_SLTW); - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - } - if ((r&0xFF)==PT_FIRE){ - kill_part(r>>8); - if(1>(rand()%150)){ - kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/dtec.c b/src/elements/dtec.c deleted file mode 100644 index 28058e7..0000000 --- a/src/elements/dtec.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_DTEC(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, rd = parts[i].tmp2; - if (rd > 25) parts[i].tmp2 = rd = 25; - if (parts[i].life) - { - parts[i].life = 0; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - rt = parts[r>>8].type; - if (parts_avg(i,r>>8,PT_INSL) != PT_INSL) - { - 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 && in_radius(rd, rx, ry)) - { - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - } - } - } - } - for (rx=-rd; rx<rd+1; rx++) - for (ry=-rd; ry<rd+1; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (parts[r>>8].type == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].tmp)) - parts[i].life = 1; - } - return 0; -} - -int in_radius(int rd, int x, int y) -{ - return (pow((double)x,2)*pow((double)rd,2)+pow((double)y,2)*pow((double)rd,2)<=pow((double)rd,2)*pow((double)rd,2)); -}
\ No newline at end of file diff --git a/src/elements/elec.c b/src/elements/elec.c deleted file mode 100644 index bafe939..0000000 --- a/src/elements/elec.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ELEC(UPDATE_FUNC_ARGS) { - int r, rt, rx, ry, nb, rrx, rry; - float rr, rrr; - parts[i].pavg[0] = x; - parts[i].pavg[1] = y; - if(pmap[y][x]==PT_GLOW) - { - part_change_type(i, x, y, PT_PHOT); - } - for (rx=-2; rx<=2; rx++) - for (ry=-2; ry<=2; ry++) - if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) { - r = pmap[y+ry][x+rx]; - if (!r) - r = photons[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_GLAS) - { - for (rrx=-1; rrx<=1; rrx++) - { - for (rry=-1; rry<=1; rry++) - { - if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) { - nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_EMBR); - if (nb!=-1) { - parts[nb].tmp = 0; - parts[nb].life = 50; - parts[nb].temp = parts[i].temp*0.8f; - parts[nb].vx = rand()%20-10; - parts[nb].vy = rand()%20-10; - } - } - } - } - fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also shouldn't be here - fire_g[y/CELL][x/CELL] += rand()%200; - fire_b[y/CELL][x/CELL] += rand()%200; - /* possible alternative, but doesn't work well at the moment because FIRE_ADD divides firea by 8, so the glow isn't strong enough - create_part(i, x, y, PT_EMBR); - parts[i].tmp = 2; - parts[i].life = 2; - parts[i].ctype = ((rand()%200)<<16) | ((rand()%200)<<8) | (rand()%200); - */ - kill_part(i); - return 1; - } - if ((r&0xFF)==PT_LCRY) - { - parts[r>>8].tmp2 = 5+rand()%5; - } - if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW) - { - if(rand()<RAND_MAX/3) - { - create_part(r>>8, x+rx, y+ry, PT_O2); - } - else - { - create_part(r>>8, x+rx, y+ry, PT_H2); - } - kill_part(i); - return 1; - } - if ((r&0xFF)==PT_NEUT && !pmap[y+ry][x+rx]) - { - part_change_type(r>>8, x+rx, y+ry, PT_H2); - parts[r>>8].life = 0; - parts[r>>8].ctype = 0; - } - if ((r&0xFF)==PT_DEUT) - { - if(parts[r>>8].life < 6000) - parts[r>>8].life += 1; - parts[r>>8].temp = 0; - parts[i].temp = 0; - kill_part(i); - return 1; - } - if ((r&0xFF)==PT_EXOT) - { - parts[r>>8].tmp2 += 5; - parts[r>>8].life = 1000; - } - if (ptypes[r&0xFF].properties & PROP_CONDUCTS && ((r&0xFF)!=PT_NBLE||parts[i].temp<2273.15)) - { - create_part(-1, x+rx, y+ry, PT_SPRK); - kill_part(i); - return 1; - } - } - return 0; -} - -int graphics_ELEC(GRAPHICS_FUNC_ARGS) -{ - *firea = 70; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode |= FIRE_ADD; - return 0; -} diff --git a/src/elements/elementmisc.c b/src/elements/elementmisc.c deleted file mode 100644 index 71c3379..0000000 --- a/src/elements/elementmisc.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_MISC(UPDATE_FUNC_ARGS) { - int t = parts[i].type; - if (t==PT_LOVE) - ISLOVE=1; - else if (t==PT_LOLZ) - ISLOLZ=1; - else if (t==PT_GRAV) - ISGRAV=1; - return 0; -} diff --git a/src/elements/embr.c b/src/elements/embr.c deleted file mode 100644 index 16c4e70..0000000 --- a/src/elements/embr.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -/* ctype - colour RRGGBB (optional) - * life - decremented each frame, disappears when life reaches zero - * tmp - mode - * 0 - BOMB sparks - * 1 - firework sparks (colour defaults to white) - * 2 - flash (colour defaults to white) - */ -int update_EMBR(UPDATE_FUNC_ARGS) { - int r, rx, ry, nb; - 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) - continue; - if ((ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) - { - kill_part(i); - return 1; - } - } - return 0; -} -int graphics_EMBR(GRAPHICS_FUNC_ARGS) -{ - if (cpart->ctype&0xFFFFFF) - { - int maxComponent; - *colr = (cpart->ctype&0xFF0000)>>16; - *colg = (cpart->ctype&0x00FF00)>>8; - *colb = (cpart->ctype&0x0000FF); - maxComponent = *colr; - if (*colg>maxComponent) maxComponent = *colg; - if (*colb>maxComponent) maxComponent = *colb; - if (maxComponent<60)//make sure it isn't too dark to see - { - float multiplier = 60.0f/maxComponent; - *colr *= multiplier; - *colg *= multiplier; - *colb *= multiplier; - } - } - else if (cpart->tmp != 0) - { - *colr = *colg = *colb = 255; - } - - if (decorations_enable && cpart->dcolour) - { - int a = (cpart->dcolour>>24)&0xFF; - *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; - } - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - if (cpart->tmp==1) - { - *pixel_mode = FIRE_ADD | PMODE_BLEND | PMODE_GLOW; - *firea = (cpart->life-15)*4; - *cola = (cpart->life+15)*4; - } - else if (cpart->tmp==2) - { - *pixel_mode = PMODE_FLAT | FIRE_ADD; - *firea = 255; - } - else - { - *pixel_mode = PMODE_SPARK | PMODE_ADD; - if (cpart->life<64) *cola = 4*cpart->life; - } - return 0; -} diff --git a/src/elements/emp.c b/src/elements/emp.c deleted file mode 100644 index 7b3dbba..0000000 --- a/src/elements/emp.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_EMP(UPDATE_FUNC_ARGS) { - int r,rx,ry,ok=0,t,n,nx,ny; - if (parts[i].life) - return 0; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4) - { - ok=1; - break; - } - } - if (!ok) - return 0; - parts[i].life=220; - emp_decor+=3; - if (emp_decor>40) - emp_decor=40; - for (r=0; r<=parts_lastActiveIndex; r++) - { - t=parts[r].type; - rx=parts[r].x; - ry=parts[r].y; - if (t==PT_SPRK || (t==PT_SWCH && parts[r].life!=0 && parts[r].life!=10) || (t==PT_WIRE && parts[r].ctype>0)) - { - int is_elec=0; - if ((parts[r].ctype==PT_PSCN || parts[r].ctype==PT_NSCN || parts[r].ctype==PT_PTCT || - parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) - { - is_elec=1; - if (ptypes[parts[r].type].hconduct && rand()%100==0) - parts[r].temp = restrict_flt(parts[r].temp+3000.0f, MIN_TEMP, MAX_TEMP); - if (rand()%80==0) - part_change_type(r, rx, ry, PT_BREL); - else if (rand()%120==0) - part_change_type(r, rx, ry, PT_NTCT); - } - - for (nx=-2; nx<3; nx++) - for (ny=-2; ny<3; ny++) - if (rx+nx>=0 && ry+ny>=0 && rx+nx<XRES && ry+ny<YRES && (rx || ry)) - { - n = pmap[ry+ny][rx+nx]; - if (!n) - continue; - /*if ((n&0xFF)==PT_BTRY && rand()%60==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_PLSM); - parts[n>>8].life=rand()%100+70; - parts[n>>8].temp+=3000; - }*/ - - //Some elements should only be affected by wire/swch, or by a spark on inst/semiconductor - //So not affected by spark on metl, watr etc - if (is_elec) - { - if (((n&0xFF)==PT_METL || (n&0xFF)==PT_BMTL) && rand()%280==0) - { - parts[n>>8].temp = restrict_flt(parts[n>>8].temp+3000.0f, MIN_TEMP, MAX_TEMP); - } - if ((n&0xFF)==PT_BMTL && rand()%160==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL);//TODO: Redundant, was this meant to be BRMT or something? - parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); - } - if ((n&0xFF)==PT_METL && rand()%300==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BMTL); - } - if ((n&0xFF)==PT_WIFI && rand()%8==0) - { - //Randomise channel - parts[n>>8].temp = rand()%MAX_TEMP; - } - if ((n&0xFF)==PT_WIFI && rand()%16==0) - { - create_part(n>>8, rx+nx, ry+ny, PT_BREL); - parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); - } - } - if ((n&0xFF)==PT_SWCH && rand()%100==0) - { - part_change_type(n>>8, rx+nx, ry+ny, PT_BREL); - } - if ((n&0xFF)==PT_SWCH && rand()%100==0) - { - parts[n>>8].temp = restrict_flt(parts[n>>8].temp+2000.0f, MIN_TEMP, MAX_TEMP); - } - if ((n&0xFF)==PT_ARAY && rand()%60==0) - { - create_part(n>>8, rx+nx, ry+ny, PT_BREL); - parts[n>>8].temp = restrict_flt(parts[n>>8].temp+1000.0f, MIN_TEMP, MAX_TEMP); - } - if (t==PT_DLAY && rand()%70==0) - { - //Randomise delay - parts[n>>8].temp = (rand()%256) + 273.15f; - } - } - } - } - return 0; -} -int graphics_EMP(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life) - { - *colr = cpart->life*1.5; - *colg = cpart->life*1.5; - *colb = 200-(cpart->life); - if (*colr>255) - *colr = 255; - if (*colg>255) - *colg = 255; - if (*colb>255) - *colb = 255; - if (*colb<=0) - *colb = 0; - } - return 0; -} diff --git a/src/elements/exot.c b/src/elements/exot.c deleted file mode 100644 index 6be47cb..0000000 --- a/src/elements/exot.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_EXOT(UPDATE_FUNC_ARGS) { - int r, rt, rx, ry, nb, rrx, rry, trade, tym, t; - t = parts[i].type; - for (rx=-2; rx<=2; rx++) - for (ry=-2; ry<=2; ry++) - if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_WARP) - { - if (parts[r>>8].tmp2>2000) - if (1>rand()%100) - { - parts[i].tmp2 += 100; - } - } - if ((r&0xFF)==PT_EXOT && parts[r>>8].life==1500 && 1>rand()%1000) - parts[i].life = 1500; - if ((parts[i].tmp>245) && (parts[i].life>1000)) - if ((r&0xFF)!=PT_EXOT && (r&0xFF)!=PT_BREL && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_WARP && (r&0xFF)!=PT_NEUT) - { - create_part(i, x, y, parts[r>>8].type); - return 0; - } - } - parts[i].tmp--; - parts[i].tmp2--; - if (parts[i].tmp<1 || parts[i].tmp>250) - parts[i].tmp = 250; - if (parts[i].tmp2<1) - parts[i].tmp2 = 1; - else if (parts[i].tmp2>6000) - { - parts[i].tmp2 = 10000; - if (parts[i].life<1001) - { - part_change_type(i, x, y, PT_WARP); - return 0; - } - } - else if (parts[i].life<1001) - pv[y/CELL][x/CELL] += (parts[i].tmp2*CFDS)/160000; - if (pv[y/CELL][x/CELL]>200 && parts[i].temp>9000 && parts[i].tmp2>200) - { - parts[i].tmp2 = 6000; - part_change_type(i, x, y, PT_WARP); - return 0; - } - if (parts[i].tmp2>100) - { - for ( trade = 0; trade<9; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==t && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion - { - tym = parts[i].tmp2 - parts[r>>8].tmp2; - if (tym ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - break; - } - if (tym>0) - { - parts[r>>8].tmp2 += tym/2; - parts[i].tmp2 -= tym/2; - break; - } - } - } - } - } - if (parts[i].temp<273.15f) - { - parts[i].vx = 0; - parts[i].vy = 0; - pv[y/CELL][x/CELL] -= 0.01; - parts[i].tmp--; - } - return 0; - -} -int graphics_EXOT(GRAPHICS_FUNC_ARGS) -{ - int q = cpart->temp; - int b = cpart->tmp; - int c = cpart->tmp2; - if (cpart->life < 1001) - { - if ((cpart->tmp2 - 1)>rand()%1000) - { - float frequency = 0.04045; - *colr = (sin(frequency*c + 4) * 127 + 150); - *colg = (sin(frequency*c + 6) * 127 + 150); - *colb = (sin(frequency*c + 8) * 127 + 150); - *firea = 100; - *firer = 0; - *fireg = 0; - *fireb = 0; - *pixel_mode |= PMODE_FLAT; - *pixel_mode |= PMODE_FLARE; - } - else - { - float frequency = 0.00045; - *colr = (sin(frequency*q + 4) * 127 + (b/1.7)); - *colg = (sin(frequency*q + 6) * 127 + (b/1.7)); - *colb = (sin(frequency*q + 8) * 127 + (b/1.7)); - *cola = cpart->tmp / 6; - *firea = *cola; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *pixel_mode |= FIRE_ADD; - *pixel_mode |= PMODE_BLUR; - } - } - else - { - float frequency = 0.01300; - *colr = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80)); - *colg = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80)); - *colb = (sin(frequency*q + 6.00) * 127 + ((b/2.9) + 80)); - *cola = cpart->tmp / 6; - *firea = *cola; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *pixel_mode |= FIRE_ADD; - *pixel_mode |= PMODE_BLUR; - - - } - return 0; -} diff --git a/src/elements/figh.c b/src/elements/figh.c deleted file mode 100644 index 7c8c46c..0000000 --- a/src/elements/figh.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FIGH(UPDATE_FUNC_ARGS) -{ - playerst* figh = &fighters[(unsigned char)parts[i].tmp]; - - unsigned int tarx, tary; - - parts[i].tmp2 = 0; //0 - stay in place, 1 - seek a stick man - - //Set target coords - if (player.spwn && player2.spwn) - { - if ((pow(player.legs[2]-x, 2) + pow(player.legs[3]-y, 2))<= - (pow(player2.legs[2]-x, 2) + pow(player2.legs[3]-y, 2))) - { - tarx = (unsigned int)player.legs[2]; - tary = (unsigned int)player.legs[3]; - } - else - { - tarx = (unsigned int)player2.legs[2]; - tary = (unsigned int)player2.legs[3]; - } - parts[i].tmp2 = 1; - } - else - { - if (player.spwn) - { - tarx = (unsigned int)player.legs[2]; - tary = (unsigned int)player.legs[3]; - parts[i].tmp2 = 1; - } - if (player2.spwn) - { - tarx = (unsigned int)player2.legs[2]; - tary = (unsigned int)player2.legs[3]; - parts[i].tmp2 = 1; - } - } - - switch (parts[i].tmp2) - { - case 1: - if ((pow(tarx-x, 2) + pow(tary-y, 2))<600) - { - if (figh->elem == PT_LIGH || figh->elem == PT_NEUT - || ptypes[figh->elem].properties&(PROP_DEADLY|PROP_RADIOACTIVE) - || ptypes[figh->elem].heat>=323 || ptypes[figh->elem].heat<=243) - figh->comm = (int)figh->comm | 0x08; - } - else - if (tarx<x) - { - if(!(eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+6, NULL) - && eval_move(PT_FIGH, figh->legs[4]-10, figh->legs[5]+3, NULL))) - figh->comm = 0x01; - else - figh->comm = 0x02; - - if (!eval_move(PT_FIGH, figh->legs[4]-4, figh->legs[5]-1, NULL) - || !eval_move(PT_FIGH, figh->legs[12]-4, figh->legs[13]-1, NULL) - || eval_move(PT_FIGH, 2*figh->legs[4]-figh->legs[6], figh->legs[5]+5, NULL)) - figh->comm = (int)figh->comm | 0x04; - } - else - { - if (!(eval_move(PT_FIGH, figh->legs[12]+10, figh->legs[13]+6, NULL) - && eval_move(PT_FIGH, figh->legs[12]+10, figh->legs[13]+3, NULL))) - figh->comm = 0x02; - else - figh->comm = 0x01; - - if (!eval_move(PT_FIGH, figh->legs[4]+4, figh->legs[5]-1, NULL) - || !eval_move(PT_FIGH, figh->legs[4]+4, figh->legs[5]-1, NULL) - || eval_move(PT_FIGH, 2*figh->legs[12]-figh->legs[14], figh->legs[13]+5, NULL)) - figh->comm = (int)figh->comm | 0x04; - } - break; - default: - figh->comm = 0; - break; - } - - figh->pcomm = figh->comm; - - run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS); - return 0; -} diff --git a/src/elements/fire.c b/src/elements/fire.c deleted file mode 100644 index bc288bc..0000000 --- a/src/elements/fire.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int graphics_FIRE(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)flm_data[caddress]; - *colg = (unsigned char)flm_data[caddress+1]; - *colb = (unsigned char)flm_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/firw.c b/src/elements/firw.c deleted file mode 100644 index 8033d41..0000000 --- a/src/elements/firw.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -#include "hmap.h" - -int update_FIRW(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, np; - if (parts[i].tmp<=0) { - 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) - continue; - rt = parts[r>>8].type; - if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) - { - float gx, gy, multiplier; - get_gravity_field(x, y, ptypes[PT_FIRW].gravity, 1.0f, &gx, &gy); - if (gx*gx+gy*gy < 0.001f) - { - float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - gx += sinf(angle)*ptypes[PT_FIRW].gravity*0.5f; - gy += cosf(angle)*ptypes[PT_FIRW].gravity*0.5f; - } - parts[i].tmp = 1; - parts[i].life = rand()%10+20; - multiplier = (parts[i].life+20)*0.2f/sqrtf(gx*gx+gy*gy); - parts[i].vx -= gx*multiplier; - parts[i].vy -= gy*multiplier; - return 0; - } - } - } - else if (parts[i].tmp==1) { - if (parts[i].life<=0) { - parts[i].tmp=2; - } else { - parts[i].flags &= ~FLAG_STAGNANT; - } - } - else if (parts[i].tmp>=2) { - float angle, magnitude; - int caddress = (rand()%200)*3; - int n; - unsigned col = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2])); - for (n=0; n<40; n++) - { - np = create_part(-3, x, y, PT_EMBR); - if (np>-1) - { - magnitude = ((rand()%60)+40)*0.05f; - angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - parts[np].vx = parts[i].vx*0.5f + cosf(angle)*magnitude; - parts[np].vy = parts[i].vy*0.5f + sinf(angle)*magnitude; - parts[np].ctype = col; - parts[np].tmp = 1; - parts[np].life = rand()%40+70; - parts[np].temp = (rand()%500)+5750.0f; - parts[np].dcolour = parts[i].dcolour; - } - } - pv[y/CELL][x/CELL] += 8.0f; - kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/fog.c b/src/elements/fog.c deleted file mode 100644 index 8acb632..0000000 --- a/src/elements/fog.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FOG(UPDATE_FUNC_ARGS) { - 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) - continue; - if (ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? - { - part_change_type(i,x,y,PT_RIME); - } - if ((r&0xFF)==PT_SPRK) - { - parts[i].life += rand()%20; - } - } - return 0; -} diff --git a/src/elements/fray.c b/src/elements/fray.c deleted file mode 100644 index 6036d92..0000000 --- a/src/elements/fray.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FRAY(UPDATE_FUNC_ARGS) { - int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1; - 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) - continue; - if ((r&0xFF)==PT_SPRK) { - for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; docontinue; nyy+=nyi, nxx+=nxi, len++) { - if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>10) { - break; - } - r = pmap[y+nyi+nyy][x+nxi+nxx]; - if (!r) - r = photons[y+nyi+nyy][x+nxi+nxx]; - - if (r && !(ptypes[r&0xFF].properties & TYPE_SOLID)){ - parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); - } - } - } - } - return 0; -} diff --git a/src/elements/frzw.c b/src/elements/frzw.c deleted file mode 100644 index b2f55e8..0000000 --- a/src/elements/frzw.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FRZW(UPDATE_FUNC_ARGS) { - 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) - continue; - if ((r&0xFF)==PT_WATR&&5>rand()%70) - { - part_change_type(r>>8,x+rx,y+ry,PT_FRZW); - } - } - if (parts[i].life==0&&13>rand()%2500) - { - part_change_type(i,x,y,PT_ICEI); - parts[i].ctype=PT_FRZW; - parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); - } - else if ((100-(parts[i].life))>rand()%50000) - { - part_change_type(i,x,y,PT_ICEI); - parts[i].ctype=PT_FRZW; - parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); - } - return 0; -} diff --git a/src/elements/frzz.c b/src/elements/frzz.c deleted file mode 100644 index 37119ab..0000000 --- a/src/elements/frzz.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FRZZ(UPDATE_FUNC_ARGS) { - 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) - continue; - if ((r&0xFF)==PT_WATR&&5>rand()%100) - { - part_change_type(r>>8,x+rx,y+ry,PT_FRZW); - parts[r>>8].life = 100; - parts[i].type = PT_NONE; - } - - } - if (parts[i].type==PT_NONE) { - kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/fsep.c b/src/elements/fsep.c deleted file mode 100644 index f189ba7..0000000 --- a/src/elements/fsep.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FSEP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life<=0) { - r = create_part(i, x, y, PT_PLSM); - if (r!=-1) - parts[r].life = 50; - return 1; - } else if (parts[i].life < 40) { - parts[i].life--; - if ((rand()%10)==0) { - r = create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); - if (r!=-1) - parts[r].life = 50; - } - } - else { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15)) - { - if (parts[i].life>40) { - parts[i].life = 39; - } - } - } - } - return 0; -} diff --git a/src/elements/fuse.c b/src/elements/fuse.c deleted file mode 100644 index e917b9a..0000000 --- a/src/elements/fuse.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FUSE(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life<=0) { - r = create_part(i, x, y, PT_PLSM); - if (r!=-1) - parts[r].life = 50; - return 1; - } else if (parts[i].life < 40) { - parts[i].life--; - if ((rand()%100)==0) { - r = create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); - if (r!=-1) - parts[r].life = 50; - } - } - if ((pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if (parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if (parts[i].tmp<=0) { - create_part(i, x, y, PT_FSEP); - return 1; - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))) - { - if (parts[i].life>40) { - parts[i].life = 39; - } - } - } - return 0; -} diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c deleted file mode 100644 index d6dc59c..0000000 --- a/src/elements/fwrk.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_FWRK(UPDATE_FUNC_ARGS) { - int r, rx, ry, np; - if (parts[i].life==0 && ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&surround_space)||parts[i].ctype==PT_DUST)) - { - float gx, gy, multiplier, gmax; - int randTmp; - get_gravity_field(x, y, ptypes[PT_FWRK].gravity, 1.0f, &gx, &gy); - if (gx*gx+gy*gy < 0.001f) - { - float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - gx += sinf(angle)*ptypes[PT_FWRK].gravity*0.5f; - gy += cosf(angle)*ptypes[PT_FWRK].gravity*0.5f; - } - gmax = fmaxf(fabsf(gx), fabsf(gy)); - if (eval_move(PT_FWRK, (int)(x-(gx/gmax)+0.5f), (int)(y-(gy/gmax)+0.5f), NULL)) - { - multiplier = 15.0f/sqrtf(gx*gx+gy*gy); - - //Some variation in speed parallel to gravity direction - randTmp = (rand()%200)-100; - gx += gx*randTmp*0.002f; - gy += gy*randTmp*0.002f; - //and a bit more variation in speed perpendicular to gravity direction - randTmp = (rand()%200)-100; - gx += -gy*randTmp*0.005f; - gy += gx*randTmp*0.005f; - - parts[i].life=rand()%10+18; - parts[i].ctype=0; - parts[i].vx -= gx*multiplier; - parts[i].vy -= gy*multiplier; - parts[i].dcolour = parts[i].dcolour; - return 0; - } - } - if (parts[i].life>=45) - parts[i].life=0; - if (parts[i].life<3&&parts[i].life>0) - { - int r = (rand()%245+11); - int g = (rand()%245+11); - int b = (rand()%245+11); - int n; - float angle, magnitude; - unsigned col = (r<<16) | (g<<8) | b; - for (n=0; n<40; n++) - { - np = create_part(-3, x, y, PT_EMBR); - if (np>-1) - { - magnitude = ((rand()%60)+40)*0.05f; - angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi) - parts[np].vx = parts[i].vx*0.5f + cosf(angle)*magnitude; - parts[np].vy = parts[i].vy*0.5f + sinf(angle)*magnitude; - parts[np].ctype = col; - parts[np].tmp = 1; - parts[np].life = rand()%40+70; - parts[np].temp = (rand()%500)+5750.0f; - parts[np].dcolour = parts[i].dcolour; - } - } - pv[y/CELL][x/CELL] += 8.0f; - kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/gbmb.c b/src/elements/gbmb.c deleted file mode 100644 index a1da981..0000000 --- a/src/elements/gbmb.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -int update_GBMB(UPDATE_FUNC_ARGS) { - int rx,ry,r; - if (parts[i].life<=0) - { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - { - r = pmap[y+ry][x+rx]; - if(!r) - continue; - if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && - (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_DMND) - { - parts[i].life=60; - break; - } - } - } - if(parts[i].life>20) - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 20; - if(parts[i].life<20 && parts[i].life>=1) - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = -80; - return 0; -} diff --git a/src/elements/gel.c b/src/elements/gel.c deleted file mode 100644 index 86cb15a..0000000 --- a/src/elements/gel.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_GEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - float dx, dy; - char gel; - int absorbChanceDenom; - if (parts[i].tmp>100) parts[i].tmp = 100; - if (parts[i].tmp<0) parts[i].tmp = 0; - absorbChanceDenom = parts[i].tmp*10 + 500; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - - //Desaturation - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_FRZW) && parts[i].tmp<100 && 500>rand()%absorbChanceDenom) - { - parts[i].tmp++; - kill_part(r>>8); - } - if (((r&0xFF)==PT_PSTE) && parts[i].tmp<100 && 20>rand()%absorbChanceDenom) - { - parts[i].tmp++; - create_part(r>>8, x+rx, y+ry, PT_CLST); - } - if (((r&0xFF)==PT_SLTW) && parts[i].tmp<100 && 50>rand()%absorbChanceDenom) - { - parts[i].tmp++; - if (rand()%4) - kill_part(r>>8); - else - part_change_type(r>>8, x+rx, y+ry, PT_SALT); - } - if (((r&0xFF)==PT_CBNW) && parts[i].tmp<100 && 100>rand()%absorbChanceDenom) - { - parts[i].tmp++; - part_change_type(r>>8, x+rx, y+ry, PT_CO2); - } - - if ((r&0xFF)==PT_SPNG && parts[i].tmp<100 && ((parts[r>>8].life+1)>parts[i].tmp)) - { - parts[r>>8].life--; - parts[i].tmp++; - } - - gel = 0; - if ((r&0xFF)==PT_GEL) - gel = 1; - - //Concentration diffusion - if (gel && (parts[r>>8].tmp+1)<parts[i].tmp) - { - parts[r>>8].tmp++; - parts[i].tmp--; - } - - if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)<parts[i].tmp) - { - parts[r>>8].life++; - parts[i].tmp--; - } - - dx = parts[i].x - parts[r>>8].x; - dy = parts[i].y - parts[r>>8].y; - - //Stickness - if ((dx*dx + dy*dy)>1.5 && (gel || !ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2))) - { - float per, nd; - nd = dx*dx + dy*dy - 0.5; - - per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5); - if (ptypes[r&0xFF].state==ST_LIQUID) - per *= 0.1; - - dx *= per; dy *= per; - parts[i].vx += dx; - parts[i].vy += dy; - - if (ptypes[r&0xFF].properties&TYPE_PART || (r&0xFF)==PT_GOO) - { - parts[r>>8].vx -= dx; - parts[r>>8].vy -= dy; - } - } - } - return 0; -} diff --git a/src/elements/glas.c b/src/elements/glas.c deleted file mode 100644 index 23f4d1e..0000000 --- a/src/elements/glas.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_GLAS(UPDATE_FUNC_ARGS) { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) - { - part_change_type(i,x,y,PT_BGLA); - } - return 0; -} diff --git a/src/elements/glow.c b/src/elements/glow.c deleted file mode 100644 index de8cfea..0000000 --- a/src/elements/glow.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_GLOW(UPDATE_FUNC_ARGS) { - 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) - continue; - if ((r&0xFF)==PT_WATR&&5>(rand()%2000)) - { - parts[i].type = PT_NONE; - part_change_type(r>>8,x+rx,y+ry,PT_DEUT); - parts[r>>8].life = 10; - } - } - parts[i].ctype = pv[y/CELL][x/CELL]*16; - - parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); - //printf("%f %f\n", parts[i].vx, parts[i].vy); - if (parts[i].type==PT_NONE) { - kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/goo.c b/src/elements/goo.c deleted file mode 100644 index bf25799..0000000 --- a/src/elements/goo.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_GOO(UPDATE_FUNC_ARGS) { - if (!parts[i].life && pv[y/CELL][x/CELL]>1.0f) - parts[i].life = rand()%80+300; - if (parts[i].life) - { - float advection = 0.1f; - parts[i].vx += advection*vx[y/CELL][x/CELL]; - parts[i].vy += advection*vy[y/CELL][x/CELL]; - } - return 0; -} diff --git a/src/elements/gpmp.c b/src/elements/gpmp.c deleted file mode 100644 index 819a1e3..0000000 --- a/src/elements/gpmp.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_GPMP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - if (parts[i].temp>=256.0+273.15) - parts[i].temp=256.0+273.15; - if (parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 0.2f*(parts[i].temp-273.15); - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_GPMP) - { - 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; -} diff --git a/src/elements/graphics_default.c b/src/elements/graphics_default.c deleted file mode 100644 index eb5df95..0000000 --- a/src/elements/graphics_default.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int graphics_DEFAULT(GRAPHICS_FUNC_ARGS) -{ - int t = cpart->type; - //Property based defaults - if(ptypes[t].properties & PROP_RADIOACTIVE) *pixel_mode |= PMODE_GLOW; - if(ptypes[t].properties & TYPE_LIQUID) - { - *pixel_mode |= PMODE_BLUR; - } - if(ptypes[t].properties & TYPE_GAS) - { - *pixel_mode &= ~PMODE; - *pixel_mode |= FIRE_BLEND; - *firer = *colr/2; - *fireg = *colg/2; - *fireb = *colb/2; - *firea = 125; - *pixel_mode |= DECO_FIRE; - } - return 1; -} diff --git a/src/elements/h2.c b/src/elements/h2.c deleted file mode 100644 index 833ee7c..0000000 --- a/src/elements/h2.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_H2(UPDATE_FUNC_ARGS) -{ - int r,rx,ry,rt; - if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) - parts[i].tmp = 1; - 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)) - { - r = pmap[y+ry][x+rx]; - rt = (r&0xFF); - if (!r) - continue; - if (pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure - { - part_change_type(r>>8,x+rx,y+ry,PT_WATR); - part_change_type(i,x,y,PT_OIL); - } - if (parts[r>>8].temp > 2273.15)// && pv[y/CELL][x/CELL] > 50.0f) - continue; - if (parts[i].temp < 2273.15) - { - if (rt==PT_FIRE) - { - parts[r>>8].temp=2473.15; - if(parts[r>>8].tmp&0x02) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 1; - } - if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_LAVA) - { - create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 1; - } - } - } - if (parts[i].temp > 2273.15 && pv[y/CELL][x/CELL] > 50.0f) - { - if (rand()%5 < 1) - { - int j; - float temp = parts[i].temp; - create_part(i,x,y,PT_NBLE); - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; - if (!(rand()%10)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFFFF00; parts[j].temp = temp; } - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM); if (j != -1) parts[j].temp = temp; - - parts[i].temp = temp+750+rand()%500; - pv[y/CELL][x/CELL] += 30; - } - } - return 0; -} diff --git a/src/elements/hswc.c b/src/elements/hswc.c deleted file mode 100644 index 6287126..0000000 --- a/src/elements/hswc.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_HSWC(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_HSWC) - { - 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; -} diff --git a/src/elements/ice.c b/src/elements/ice.c deleted file mode 100644 index 009cc9c..0000000 --- a/src/elements/ice.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well - int r, rx, ry; - if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW - { - parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && parts[i].temp > ptransitions[PT_SLTW].tlv && 1>(rand()%1000)) - { - part_change_type(i,x,y,PT_SLTW); - part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && 1>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - } - return 0; -} diff --git a/src/elements/ignt.c b/src/elements/ignt.c deleted file mode 100644 index bf706bc..0000000 --- a/src/elements/ignt.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_IGNT(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if(parts[i].tmp==0) - { - 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) - continue; - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - parts[i].tmp = 1; - } - else if ((r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH || ((r&0xFF)==PT_IGNT && parts[r>>8].life==1)) - { - parts[i].tmp = 1; - } - } - } - else if(parts[i].life > 0) - { - if(rand()%3) - { - int nb = create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_EMBR); - if (nb!=-1) { - parts[nb].tmp = 0; - parts[nb].life = 30; - parts[nb].vx = rand()%20-10; - parts[nb].vy = rand()%20-10; - parts[nb].temp = restrict_flt(400.0f+parts[i].temp-273.15, MIN_TEMP, MAX_TEMP); - } - } - else - { - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - parts[i].life--; - } - return 0; -} diff --git a/src/elements/iron.c b/src/elements/iron.c deleted file mode 100644 index 55e8e75..0000000 --- a/src/elements/iron.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_IRON(UPDATE_FUNC_ARGS) { - 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) - continue; - if ((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || - ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || - ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || - ((r&0xFF) == PT_LO2))&& - (!(parts[i].life)) - ) - { - part_change_type(i,x,y,PT_BMTL); - parts[i].tmp=(rand()/(RAND_MAX/10))+20; - } - } - return 0; -} diff --git a/src/elements/isz.c b/src/elements/isz.c deleted file mode 100644 index aa081c0..0000000 --- a/src/elements/isz.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_ISZ(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ - float rr, rrr; - if (1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) - { - create_part(i, x, y, PT_PHOT); - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[i].vx = rr*cosf(rrr); - parts[i].vy = rr*sinf(rrr); - } - return 0; -} diff --git a/src/elements/lava.c b/src/elements/lava.c deleted file mode 100644 index 8847485..0000000 --- a/src/elements/lava.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int graphics_LAVA(GRAPHICS_FUNC_ARGS) -{ - *colr = cpart->life * 2 + 0xE0; - *colg = cpart->life * 1 + 0x50; - *colb = cpart->life / 2 + 0x10; - if (*colr>255) *colr = 255; - if (*colg>192) *colg = 192; - if (*colb>128) *colb = 128; - *firea = 40; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *pixel_mode |= FIRE_ADD; - *pixel_mode |= PMODE_BLUR; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/lcry.c b/src/elements/lcry.c deleted file mode 100644 index cc1e625..0000000 --- a/src/elements/lcry.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_LCRY(UPDATE_FUNC_ARGS) -{ - int r, rx, ry; - if(parts[i].tmp==1 || parts[i].tmp==0) - { - if(parts[i].tmp==1) - { - if(parts[i].life<=0) - parts[i].tmp = 0; - else - { - parts[i].life-=2; - if(parts[i].life < 0) - parts[i].life = 0; - parts[i].tmp2 = parts[i].life; - } - } - 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) - continue; - if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == 3) - { - parts[r>>8].tmp = 1; - } - } - } - else if(parts[i].tmp==2 || parts[i].tmp==3) - { - if(parts[i].tmp==2) - { - if(parts[i].life>=10) - parts[i].tmp = 3; - else - { - parts[i].life+=2; - if(parts[i].life > 10) - parts[i].life = 10; - parts[i].tmp2 = parts[i].life; - } - } - 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) - continue; - if ((r&0xFF)==PT_LCRY && parts[r>>8].tmp == 0) - { - parts[r>>8].tmp = 2; - } - } - } - return 0; -} diff --git a/src/elements/legacy.c b/src/elements/legacy.c deleted file mode 100644 index 1db6966..0000000 --- a/src/elements/legacy.c +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -// Interactions which only occur when legacy_enable is on -int update_legacy_all(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt; - int t = parts[i].type; - if (!legacy_enable) return 0; - if (t==PT_WTRV) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000)) - { - part_change_type(i,x,y,PT_WATR); - part_change_type(r>>8,x+rx,y+ry,PT_WATR); - } - if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) - { - part_change_type(i,x,y,PT_WATR); - if (1>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_WATR); - } - } - } - else if (t==PT_WATR) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) - { - part_change_type(i,x,y,PT_WTRV); - } - } - } - else if (t==PT_SLTW) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) - { - if (rand()%4==0) part_change_type(i,x,y,PT_SALT); - else part_change_type(i,x,y,PT_WTRV); - } - } - } - else if (t==PT_DSTW) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) - { - part_change_type(i,x,y,PT_WTRV); - } - } - } - else if (t==PT_ICEI) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) - { - part_change_type(i,x,y,PT_ICEI); - part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - } - } - } - else if (t==PT_SNOW) { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) - { - part_change_type(i,x,y,PT_ICEI); - part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - } - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) - part_change_type(i,x,y,PT_WATR); - } - } - if (t==PT_WTRV && pv[y/CELL][x/CELL]>4.0f) - part_change_type(i,x,y,PT_DSTW); - if (t==PT_OIL && pv[y/CELL][x/CELL]<-6.0f) - part_change_type(i,x,y,PT_GAS); - if (t==PT_GAS && pv[y/CELL][x/CELL]>6.0f) - part_change_type(i,x,y,PT_OIL); - if (t==PT_DESL && pv[y/CELL][x/CELL]>12.0f) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = rand()%50+120; - } - return 0; -} diff --git a/src/elements/ligh.c b/src/elements/ligh.c deleted file mode 100644 index 31f53b3..0000000 --- a/src/elements/ligh.c +++ /dev/null @@ -1,315 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -#define LIGHTING_POWER 0.65 - -int LIGH_nearest_part(int ci, int max_d) -{ - int distance = (max_d!=-1)?max_d:MAX_DISTANCE; - int ndistance = 0; - int id = -1; - int i = 0; - int cx = (int)parts[ci].x; - int cy = (int)parts[ci].y; - for (i=0; i<=parts_lastActiveIndex; i++) - { - if (parts[i].type && !parts[i].life && i!=ci && parts[i].type!=PT_LIGH && parts[i].type!=PT_THDR && parts[i].type!=PT_NEUT && parts[i].type!=PT_PHOT) - { - ndistance = abs(cx-parts[i].x)+abs(cy-parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); - if (ndistance<distance) - { - distance = ndistance; - id = i; - } - } - } - return id; -} - -int contact_part(int i, int tp) -{ - int x=parts[i].x, y=parts[i].y; - int r,rx,ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==tp) - return r>>8; - } - return -1; -} - -void create_line_par(int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) -{ - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; - float e, de; - if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) - return; // this function only for particles, no walls - if (cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if (x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if (dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1<y2) ? 1 : -1; - for (x=x1; x<=x2; x++) - { - int p; - if (cp) - p=create_part(-1, y, x, c); - else - p=create_part(-1, x, y,c); - if (p!=-1) - { - parts[p].life=life; - parts[p].temp=temp; - parts[p].tmp=tmp; - parts[p].tmp2=tmp2; - } - e += de; - if (e >= 0.5f) - { - y += sy; - e -= 1.0f; - } - } -} - -int update_LIGH(UPDATE_FUNC_ARGS) -{ - /* - * - * tmp2: - * -1 - part will be removed - * 0 - "branches" of the lightning - * 1 - bending - * 2 - branching - * 3 - transfer spark or make destruction - * 4 - first pixel - * - * life - "thickness" of lighting (but anyway one pixel) - * - * tmp - angle of lighting, measured in degrees anticlockwise from the positive x direction - * - */ - int r,rx,ry, multipler, powderful; - float angle, angle2=-1; - int near; - powderful = powderful=parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); - if (aheat_enable) - { - hv[y/CELL][x/CELL]+=powderful/50; - if (hv[y/CELL][x/CELL]>MAX_TEMP) - hv[y/CELL][x/CELL]=MAX_TEMP; - } - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_LIGH && (r&0xFF)!=PT_TESC) - { - if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT) - { - if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0) - { - create_part(r>>8,x+rx,y+ry,PT_SPRK); - } - pv[y/CELL][x/CELL] += powderful/400; - if (ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); - } - if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) // start nuclear reactions - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful, MIN_TEMP, MAX_TEMP); - pv[y/CELL][x/CELL] +=powderful/35; - if (rand()%3==0) - { - part_change_type(r>>8,x+rx,y+ry,PT_NEUT); - parts[r>>8].life = rand()%480+480; - parts[r>>8].vx=rand()%10-5; - parts[r>>8].vy=rand()%10-5; - } - } - if ((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL) // ignite coal - { - if (parts[r>>8].life>100) { - parts[r>>8].life = 99; - } - } - if (ptypes[r&0xFF].hconduct) - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); - if (((r&0xFF)==PT_STKM && player.elem!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && player2.elem!=PT_LIGH)) - { - parts[r>>8].life-=powderful/100; - } - } - } - if (parts[i].tmp2==3) - { - parts[i].tmp2=0; - return 1; - } - - if (parts[i].tmp2==-1) - { - kill_part(i); - return 1; - } - if (parts[i].tmp2<=0 || parts[i].life<=1) - { - if (parts[i].tmp2>0) - parts[i].tmp2=0; - parts[i].tmp2--; - return 1; - } - if (parts[i].tmp2<=-2) - { - kill_part(i); - return 1; - } - - angle2=-1; - - near = LIGH_nearest_part(i, parts[i].life*2.5); - if (near!=-1) - { - int t=parts[near].type; - float n_angle; // angle to nearest part - float angle_diff; - rx=parts[near].x-x; - ry=parts[near].y-y; - if (rx!=0 || ry!=0) - n_angle = atan2f(-ry, rx); - else - n_angle = 0; - if (n_angle<0) - n_angle+=M_PI*2; - angle_diff = fabsf(n_angle-parts[i].tmp*M_PI/180); - if (angle_diff>M_PI) - angle_diff = M_PI*2 - angle_diff; - if (parts[i].life<5 || angle_diff<M_PI*0.8) // lightning strike - { - create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, parts[i].tmp-90, 0); - - if (t!=PT_TESC) - { - near=contact_part(near, PT_LIGH); - if (near!=-1) - { - parts[near].tmp2=3; - parts[near].life=(int)(1.0*parts[i].life/2-1); - parts[near].tmp=parts[i].tmp-180; - parts[near].temp=parts[i].temp; - } - } - } - else near=-1; - } - - //if (parts[i].tmp2==1/* || near!=-1*/) - //angle=0;//parts[i].tmp-30+rand()%60; - angle = parts[i].tmp-30+rand()%60; - if (angle<0) - angle+=360; - if (angle>=360) - angle-=360; - if (parts[i].tmp2==2 && near==-1) - { - angle2=angle+100-rand()%200; - if (angle2<0) - angle2+=360; - if (angle2>=360) - angle-=360; - } - - multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); - rx=cos(angle*M_PI/180)*multipler; - ry=-sin(angle*M_PI/180)*multipler; - create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle, 0); - - if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if ((r&0xFF)==PT_LIGH) - { - parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+60); - parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); - parts[r>>8].tmp=angle; - parts[r>>8].temp=parts[i].temp; - } - } - - if (angle2!=-1) - { - multipler=parts[i].life*1.5+rand()%((int)(parts[i].life+1)); - rx=cos(angle2*M_PI/180)*multipler; - ry=-sin(angle2*M_PI/180)*multipler; - create_line_par(x, y, x+rx, y+ry, PT_LIGH, parts[i].temp, parts[i].life, angle2, 0); - - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if ((r&0xFF)==PT_LIGH) - { - parts[r>>8].tmp2=1+(rand()%200>parts[i].tmp2*parts[i].tmp2/10+40); - parts[r>>8].life=(int)(1.0*parts[i].life/1.5-rand()%2); - parts[r>>8].tmp=angle; - parts[r>>8].temp=parts[i].temp; - } - } - } - - parts[i].tmp2=-1; - return 1; -} -int graphics_LIGH(GRAPHICS_FUNC_ARGS) -{ - *firea = 120; - *firer = *colr = 235; - *fireg = *colg = 245; - *fireb = *colb = 255; - *pixel_mode |= PMODE_GLOW | FIRE_ADD; - return 1; -} diff --git a/src/elements/merc.c b/src/elements/merc.c deleted file mode 100644 index dcecdde..0000000 --- a/src/elements/merc.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_MERC(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - int maxtmp = ((10000/(parts[i].temp + 1))-1); - if ((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) - maxtmp ++; - if (parts[i].tmp < maxtmp) - { - 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 || (parts[i].tmp >=maxtmp)) - continue; - if ((r&0xFF)==PT_MERC&&33>=rand()/(RAND_MAX/100)+1) - { - if ((parts[i].tmp + parts[r>>8].tmp + 1) <= maxtmp) - { - parts[i].tmp += parts[r>>8].tmp + 1; - kill_part(r>>8); - } - } - } - } - else - 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 (parts[i].tmp<=maxtmp) - continue; - if ((!r)&&parts[i].tmp>=1)//if nothing then create deut - { - np = create_part(-1,x+rx,y+ry,PT_MERC); - if (np<0) continue; - parts[i].tmp--; - parts[np].temp = parts[i].temp; - parts[np].tmp = 0; - } - } - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[r>>8].tmp)&&parts[i].tmp>0)//diffusion - { - int temp = parts[i].tmp - parts[r>>8].tmp; - if (temp ==1) - { - parts[r>>8].tmp ++; - parts[i].tmp --; - } - else if (temp>0) - { - parts[r>>8].tmp += temp/2; - parts[i].tmp -= temp/2; - } - } - } - } - return 0; -} diff --git a/src/elements/mort.c b/src/elements/mort.c deleted file mode 100644 index 669fd0b..0000000 --- a/src/elements/mort.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_MORT(UPDATE_FUNC_ARGS) { - create_part(-1, x, y-1, PT_SMKE); - return 0; -} diff --git a/src/elements/nbhl.c b/src/elements/nbhl.c deleted file mode 100644 index 362c120..0000000 --- a/src/elements/nbhl.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_NBHL(UPDATE_FUNC_ARGS) { - if (parts[i].tmp) - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += restrict_flt(0.001f*parts[i].tmp, 0.1f, 51.2f); - else - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += 0.1f; - return 0; -} diff --git a/src/elements/nble.c b/src/elements/nble.c deleted file mode 100644 index 31f6fc8..0000000 --- a/src/elements/nble.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_NBLE(UPDATE_FUNC_ARGS) -{ - if (parts[i].temp > 5273.15 && pv[y/CELL][x/CELL] > 100.0f) - { - if (rand()%5 < 1) - { - int j; - float temp = parts[i].temp; - create_part(i,x,y,PT_CO2); - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) parts[j].temp = temp; - if (!(rand()%25)) { j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) parts[j].temp = temp; } - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } - - j = create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PLSM); if (j != -1) parts[j].temp = temp; - - parts[i].temp = temp+1750+rand()%500; - pv[y/CELL][x/CELL] += 50; - } - } - return 0; -} diff --git a/src/elements/neut.c b/src/elements/neut.c deleted file mode 100644 index 5b8a4ae..0000000 --- a/src/elements/neut.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - - -int create_n_parts(int n, int x, int y, float vx, float vy, float temp, int t)//testing a new deut create part -{ - int i, c; - n = (n/50); - if (n<1) { - n = 1; - } - if (n>340) { - n = 340; - } - if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM || !ptypes[t].enabled) - return -1; - - for (c=0; c<n; c++) { - float r = (rand()%128+128)/127.0f; - float a = (rand()%360)*M_PI/180.0f; - if (pfree == -1) - return -1; - i = pfree; - pfree = parts[i].life; - if (i>parts_lastActiveIndex) parts_lastActiveIndex = i; - - parts[i].x = (float)x; - parts[i].y = (float)y; -#ifdef OGLR - parts[i].lastX = (float)x; - parts[i].lastY = (float)y; -#endif - parts[i].type = t; - parts[i].life = rand()%480+480; - parts[i].vx = r*cosf(a); - parts[i].vy = r*sinf(a); - parts[i].ctype = 0; - parts[i].temp = temp; - parts[i].tmp = 0; - if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !pmap[y][x]) - pmap[y][x] = t|(i<<8); - else if ((t==PT_PHOT||t==PT_NEUT) && !photons[y][x]) - photons[y][x] = t|(i<<8); - - pv[y/CELL][x/CELL] += 6.0f * CFDS; - } - return 0; -} - -int update_NEUT(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt; - int pressureFactor = 3 + (int)pv[y/CELL][x/CELL]; - 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) - continue; - if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) - { - parts[i].vx *= 0.995; - parts[i].vy *= 0.995; - } - if ((r&0xFF)==PT_PLUT && pressureFactor>(rand()%1000)) - { - if (33>rand()%100) - { - create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN); - parts[r>>8].temp = MAX_TEMP; - if (parts[r>>8].type==PT_LAVA) { - parts[r>>8].tmp = 100; - parts[r>>8].ctype = PT_PLUT; - } - } - else - { - create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; - } - pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); - } -#ifdef SDEUT - else if ((r&0xFF)==PT_DEUT && (pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000)) - { - create_n_parts(parts[r>>8].life, x+rx, y+ry, parts[i].vx, parts[i].vy, restrict_flt(parts[r>>8].temp + parts[r>>8].life*500, MIN_TEMP, MAX_TEMP), PT_NEUT); - kill_part(r>>8); - } -#else - else if ((r&0xFF)==PT_DEUT && (pressureFactor+1)>(rand()%1000)) - { - create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; - if (parts[r>>8].life>0) - { - parts[r>>8].life --; - parts[r>>8].temp = restrict_flt(parts[r>>8].temp + parts[r>>8].life*17, MIN_TEMP, MAX_TEMP); - pv[y/CELL][x/CELL] += 6.0f * CFDS; - } - else - kill_part(r>>8); - } -#endif - else if ((r&0xFF)==PT_GUNP && 15>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_DUST); - else if ((r&0xFF)==PT_DYST && 15>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_YEST); - else if ((r&0xFF)==PT_YEST) - part_change_type(r>>8,x+rx,y+ry,PT_DYST); - else if ((r&0xFF)==PT_WATR && 15>(rand()%100)) - part_change_type(r>>8,x+rx,y+ry,PT_DSTW); - else if ((r&0xFF)==PT_PLEX && 15>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_GOO); - else if ((r&0xFF)==PT_NITR && 15>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_DESL); - else if ((r&0xFF)==PT_PLNT && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_WOOD); - else if ((r&0xFF)==PT_DESL && 15>(rand()%1000)) - part_change_type(r>>8,x+rx,y+ry,PT_GAS); - else if ((r&0xFF)==PT_COAL && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_WOOD); - else if ((r&0xFF)==PT_DUST && 5>(rand()%100)) - part_change_type(r>>8, x+rx, y+ry, PT_FWRK); - else if ((r&0xFF)==PT_FWRK && 5>(rand()%100)) - parts[r>>8].ctype = PT_DUST; - else if ((r&0xFF)==PT_ACID && 5>(rand()%100)) - create_part(r>>8, x+rx, y+ry, PT_ISOZ); - else if ((r&0xFF)==PT_TTAN && 5>(rand()%100)) - { - kill_part(i); - return 1; - } - else if ((r&0xFF)==PT_EXOT && 5>(rand()%100)) - parts[r>>8].life = 1500; - /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && - (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| - ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| - ptypes[parts[r>>8].type-1].menusection==SC_GAS|| - ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) - parts[r>>8].type--;*/ - } - return 0; -} - -int graphics_NEUT(GRAPHICS_FUNC_ARGS) -{ - *firea = 120; - *firer = 10; - *fireg = 80; - *fireb = 120; - - *pixel_mode &= ~PMODE_FLAT; - *pixel_mode |= FIRE_ADD | PMODE_ADD; - return 1; -} diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c deleted file mode 100644 index da3cb26..0000000 --- a/src/elements/newgraphics.c +++ /dev/null @@ -1,530 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -#include "hmap.h" - -int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT -{ - int t = cpart->type, z = cpart->tmp - 5;//speckles! - if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz - { - float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); - *colr += sin(frequency*q) * 226 + (z * 16); - *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); - *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); - } - else - { - *colr += z * 16; - *colg += z * 16; - *colb += z * 16; - } - return 0; -} -int graphics_CLST(GRAPHICS_FUNC_ARGS) -{ - int z = cpart->tmp - 5;//speckles! - *colr += z * 16; - *colg += z * 16; - *colb += z * 16; - return 0; -} -int graphics_CBNW(GRAPHICS_FUNC_ARGS) -{ - int z = cpart->tmp2 - 20;//speckles! - *colr += z * 1; - *colg += z * 2; - *colb += z * 8; - return 0; -} -int graphics_SPNG(GRAPHICS_FUNC_ARGS) -{ - *colr -= cpart->life*15; - *colg -= cpart->life*15; - *colb -= cpart->life*15; - if (*colr<=50) - *colr = 50; - if (*colg<=50) - *colg = 50; - if (*colb<=20) - *colb = 20; - return 0; -} -int graphics_LIFE(GRAPHICS_FUNC_ARGS) -{ - pixel pc; - if (cpart->ctype==NGT_LOTE)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(255, 128, 0); - else if (cpart->tmp==1) - pc = PIXRGB(255, 255, 0); - else - pc = PIXRGB(255, 0, 0); - } - else if (cpart->ctype==NGT_FRG2)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(0, 100, 50); - else - pc = PIXRGB(0, 255, 90); - } - else if (cpart->ctype==NGT_STAR)//colors for life states - { - if (cpart->tmp==4) - pc = PIXRGB(0, 0, 128); - else if (cpart->tmp==3) - pc = PIXRGB(0, 0, 150); - else if (cpart->tmp==2) - pc = PIXRGB(0, 0, 190); - else if (cpart->tmp==1) - pc = PIXRGB(0, 0, 230); - else - pc = PIXRGB(0, 0, 70); - } - else if (cpart->ctype==NGT_FROG)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(0, 100, 0); - else - pc = PIXRGB(0, 255, 0); - } - else if (cpart->ctype==NGT_BRAN)//colors for life states - { - if (cpart->tmp==1) - pc = PIXRGB(150, 150, 0); - else - pc = PIXRGB(255, 255, 0); - } else { - pc = gmenu[cpart->ctype].colour; - } - *colr = PIXR(pc); - *colg = PIXG(pc); - *colb = PIXB(pc); - return 0; -} -int graphics_GRAV(GRAPHICS_FUNC_ARGS) -{ - *colr = 20; - *colg = 20; - *colb = 20; - if (cpart->vx>0) - { - *colr += (cpart->vx)*GRAV_R; - *colg += (cpart->vx)*GRAV_G; - *colb += (cpart->vx)*GRAV_B; - } - if (cpart->vy>0) - { - *colr += (cpart->vy)*GRAV_G; - *colg += (cpart->vy)*GRAV_B; - *colb += (cpart->vy)*GRAV_R; - - } - if (cpart->vx<0) - { - *colr -= (cpart->vx)*GRAV_B; - *colg -= (cpart->vx)*GRAV_R; - *colb -= (cpart->vx)*GRAV_G; - - } - if (cpart->vy<0) - { - *colr -= (cpart->vy)*GRAV_R2; - *colg -= (cpart->vy)*GRAV_G2; - *colb -= (cpart->vy)*GRAV_B2; - } - return 0; -} -int graphics_WIFI(GRAPHICS_FUNC_ARGS) -{ - float frequency = 0.0628; - int q = cpart->tmp; - *colr = sin(frequency*q + 0) * 127 + 128; - *colg = sin(frequency*q + 2) * 127 + 128; - *colb = sin(frequency*q + 4) * 127 + 128; - *pixel_mode |= EFFECT_LINES; - return 0; -} -int graphics_GEL(GRAPHICS_FUNC_ARGS) -{ - int q = cpart->tmp; - *colr = q*(32-255)/120+255; - *colg = q*(48-186)/120+186; - *colb = q*208/120; - return 0; -} -int graphics_PRTI(GRAPHICS_FUNC_ARGS) -{ - *firea = 8; - *firer = 255; - *fireg = 0; - *fireb = 0; - *pixel_mode |= EFFECT_GRAVIN; - *pixel_mode |= EFFECT_LINES; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_ADD; - return 1; -} -int graphics_PRTO(GRAPHICS_FUNC_ARGS) -{ - *firea = 8; - *firer = 0; - *fireg = 0; - *fireb = 255; - *pixel_mode |= EFFECT_GRAVOUT; - *pixel_mode |= EFFECT_LINES; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_ADD; - return 1; -} -int graphics_BIZR(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS -{ - int x = 0; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - if(fabs(cpart->vx)+fabs(cpart->vy)>0) - { - *firea = 255; - *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); - *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); - *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); - *pixel_mode |= FIRE_ADD; - } - return 0; -} -int graphics_INVS(GRAPHICS_FUNC_ARGS) -{ - if(pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f) - { - *cola = 100; - *colr = 15; - *colg = 0; - *colb = 150; - *pixel_mode = PMODE_BLEND; - } - return 0; -} -int graphics_ACID(GRAPHICS_FUNC_ARGS) -{ - int s = cpart->life; - if (s>75) s = 75; //These two should not be here. - if (s<49) s = 49; - s = (s-49)*3; - if (s==0) s = 1; - *colr += s*4; - *colg += s*1; - *colb += s*2; - *pixel_mode |= PMODE_BLUR; - return 0; -} -int graphics_FILT(GRAPHICS_FUNC_ARGS) -{ - int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); - if (temp_bin < 0) temp_bin = 0; - if (temp_bin > 25) temp_bin = 25; - cpart->ctype = 0x1F << temp_bin; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *cola = 127; - *colr *= x; - *colg *= x; - *colb *= x; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_BLEND; - return 0; -} -int graphics_BRAY(GRAPHICS_FUNC_ARGS) -{ - int x, trans = 255; - if(cpart->tmp==0) - { - trans = cpart->life * 7; - if (trans>255) trans = 255; - if (cpart->ctype) { - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - } - } - else if(cpart->tmp==1) - { - trans = cpart->life/4; - if (trans>255) trans = 255; - if (cpart->ctype) { - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - } - } - else if(cpart->tmp==2) - { - trans = cpart->life*100; - if (trans>255) trans = 255; - *colr = 255; - *colg = 150; - *colb = 50; - } - *cola = trans; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_BLEND | PMODE_GLOW; - return 0; -} -int graphics_SWCH(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life >= 10) - { - *colr = 17; - *colg = 217; - *colb = 24; - *pixel_mode |= PMODE_GLOW; - } - return 0; -} -int graphics_THDR(GRAPHICS_FUNC_ARGS) -{ - *firea = 160; - *fireg = 192; - *fireb = 255; - *firer = 144; - *pixel_mode |= FIRE_ADD; - return 1; -} -int graphics_GLOW(GRAPHICS_FUNC_ARGS) -{ - *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; - *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; - *fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f; - - *colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255); - *colg = restrict_flt(64.0f+cpart->ctype, 0, 255); - *colb = restrict_flt(64.0f+cpart->tmp, 0, 255); - - *pixel_mode |= FIRE_ADD; - return 0; -} -int graphics_LCRY(GRAPHICS_FUNC_ARGS) -{ - if(decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) - { - *colr = (cpart->dcolour>>16)&0xFF; - *colg = (cpart->dcolour>>8)&0xFF; - *colb = (cpart->dcolour)&0xFF; - - if(cpart->tmp2<10){ - *colr /= 10-cpart->tmp2; - *colg /= 10-cpart->tmp2; - *colb /= 10-cpart->tmp2; - } - - } - else - { - *colr = *colg = *colb = 0x50+((cpart->tmp2>10?10:cpart->tmp2)*10); - } - *pixel_mode |= NO_DECO; - return 0; - - /*int lifemod = ((cpart->tmp2>10?10:cpart->tmp2)*10); - *colr += lifemod; - *colg += lifemod; - *colb += lifemod; - if(decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) - { - lifemod *= 2.5f; - if(lifemod < 40) - lifemod = 40; - *colr = (lifemod*((cpart->dcolour>>16)&0xFF) + (255-lifemod)**colr) >> 8; - *colg = (lifemod*((cpart->dcolour>>8)&0xFF) + (255-lifemod)**colg) >> 8; - *colb = (lifemod*((cpart->dcolour)&0xFF) + (255-lifemod)**colb) >> 8; - } - *pixel_mode |= NO_DECO; - return 0;*/ -} -int graphics_PCLN(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*10); - *colr += lifemod; - *colg += lifemod; - return 0; -} -int graphics_PBCN(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*10); - *colr += lifemod; - *colg += lifemod/2; - return 0; -} -int graphics_DLAY(GRAPHICS_FUNC_ARGS) -{ - int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); - *colr += stage; - *colg += stage; - *colb += stage; - return 0; -} -int graphics_HSWC(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colr += lifemod; - return 0; -} -int graphics_PVOD(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*16); - *colr += lifemod; - return 0; -} -int graphics_STOR(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp){ - *pixel_mode |= PMODE_GLOW; - *colr = 0x50; - *colg = 0xDF; - *colb = 0xDF; - } else { - *colr = 0x20; - *colg = 0xAF; - *colb = 0xAF; - } - return 0; -} -int graphics_PUMP(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colb += lifemod; - return 0; -} -int graphics_GPMP(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colg += lifemod; - *colb += lifemod; - return 0; -} -int graphics_HFLM(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)hflm_data[caddress]; - *colg = (unsigned char)hflm_data[caddress+1]; - *colb = (unsigned char)hflm_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} -int graphics_FIRW(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp > 0) - { - *pixel_mode |= PMODE_GLOW; - } - return 0; -} -int graphics_GBMB(GRAPHICS_FUNC_ARGS) -{ - if (cpart->life <= 0) { - *pixel_mode |= PMODE_FLARE; - } - else - { - *pixel_mode |= PMODE_SPARK; - } - return 0; -} -int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal -{ - *colr += (cpart->tmp2-295.15f)/3; - - if (*colr > 170) - *colr = 170; - if (*colr < *colg) - *colr = *colg; - - *colg = *colb = *colr; - - if((cpart->temp-295.15f) > 300.0f-200.0f) - { - float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); - int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); - - *colr += sin(frequency*q) * 226; - *colg += sin(frequency*q*4.55 +3.14) * 34; - *colb += sin(frequency*q*2.22 +3.14) * 64; - } - return 0; -} - -int graphics_BRCK(GRAPHICS_FUNC_ARGS) -{ - if (cpart->tmp == 1) - { - *pixel_mode |= FIRE_ADD; - *colb += 100; - - *firea = 40; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - } - return 0; -} diff --git a/src/elements/none.c b/src/elements/none.c deleted file mode 100644 index f2a7e2d..0000000 --- a/src/elements/none.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_(UPDATE_FUNC_ARGS) { - - return 0; -} diff --git a/src/elements/nptct.c b/src/elements/nptct.c deleted file mode 100644 index 4f32bd7..0000000 --- a/src/elements/nptct.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_NPTCT(UPDATE_FUNC_ARGS) { - if (parts[i].temp>295.0f) - parts[i].temp -= 2.5f; - return 0; -} diff --git a/src/elements/nwhl.c b/src/elements/nwhl.c deleted file mode 100644 index c1d75fa..0000000 --- a/src/elements/nwhl.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_NWHL(UPDATE_FUNC_ARGS) { - gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= 0.1f; - return 0; -} diff --git a/src/elements/pbcn.c b/src/elements/pbcn.c deleted file mode 100644 index 2754a1a..0000000 --- a/src/elements/pbcn.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PBCN(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (!parts[i].tmp2 && pv[y/CELL][x/CELL]>4.0f) - parts[i].tmp2 = rand()%40+80; - if (parts[i].tmp2) - { - float advection = 0.1f; - parts[i].vx += advection*vx[y/CELL][x/CELL]; - parts[i].vy += advection*vy[y/CELL][x/CELL]; - parts[i].tmp2--; - if(!parts[i].tmp2){ - kill_part(i); - return 1; - } - } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !ptypes[parts[i].ctype].enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK && - (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN && - (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && - (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM) - { - parts[i].ctype = r&0xFF; - if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; - } - } - if (parts[i].life==10) - { - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_PBCN) - { - 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; - } - } - } - if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].enabled && parts[i].life==10) { - if (parts[i].ctype==PT_PHOT) {//create photons a different way - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) - { - if (rx || ry) - { - int r = create_part(-1, x+rx, y+ry, parts[i].ctype); - if (r!=-1) - { - parts[r].vx = rx*3; - parts[r].vy = ry*3; - if (r>i) - { - // Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced - parts[r].flags |= FLAG_SKIPMOVE; - } - } - } - } - } - } - else if (parts[i].ctype==PT_LIFE) {//create life a different way - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) { - create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); - } - } - } - else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0) - { - int np = create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - if (np>=0) - { - if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && ptransitions[parts[i].tmp].tht==PT_LAVA) - parts[np].ctype = parts[i].tmp; - } - } - } - return 0; -} diff --git a/src/elements/pcln.c b/src/elements/pcln.c deleted file mode 100644 index 30055e8..0000000 --- a/src/elements/pcln.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PCLN(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4) - { - if (parts[r>>8].ctype==PT_PSCN) - parts[i].life = 10; - else if (parts[r>>8].ctype==PT_NSCN) - parts[i].life = 9; - } - if ((r&0xFF)==PT_PCLN) - { - if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[i].life==0&&parts[r>>8].life==10) - parts[i].life = 10; - } - } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || !ptypes[parts[i].ctype].enabled || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - 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) - { - r = photons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK && - (r&0xFF)!=PT_NSCN && (r&0xFF)!=PT_PSCN && - (r&0xFF)!=PT_STKM && (r&0xFF)!=PT_STKM2 && - (r&0xFF)!=PT_PBCN && (r&0xFF)<PT_NUM) - { - parts[i].ctype = r&0xFF; - if ((r&0xFF)==PT_LIFE || (r&0xFF)==PT_LAVA) - parts[i].tmp = parts[r>>8].ctype; - } - } - if (parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].enabled && parts[i].life==10) { - if (parts[i].ctype==PT_PHOT) {//create photons a different way - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) - { - if (rx || ry) - { - int r = create_part(-1, x+rx, y+ry, parts[i].ctype); - if (r!=-1) - { - parts[r].vx = rx*3; - parts[r].vy = ry*3; - if (r>i) - { - // Make sure movement doesn't happen until next frame, to avoid gaps in the beams of photons produced - parts[r].flags |= FLAG_SKIPMOVE; - } - } - } - } - } - } - else if (parts[i].ctype==PT_LIFE) {//create life a different way - for (rx=-1; rx<2; rx++) { - for (ry=-1; ry<2; ry++) { - create_part(-1, x+rx, y+ry, parts[i].ctype|(parts[i].tmp<<8)); - } - } - } - else if (parts[i].ctype!=PT_LIGH || (rand()%30)==0) - { - int np = create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - if (np>=0) - { - if (parts[i].ctype==PT_LAVA && parts[i].tmp>0 && parts[i].tmp<PT_NUM && ptransitions[parts[i].tmp].tht==PT_LAVA) - parts[np].ctype = parts[i].tmp; - } - } - } - return 0; -} diff --git a/src/elements/phot.c b/src/elements/phot.c deleted file mode 100644 index d014ba5..0000000 --- a/src/elements/phot.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PHOT(UPDATE_FUNC_ARGS) { - int r, rt, rx, ry; - float rr, rrr; - parts[i].pavg[0] = x; - parts[i].pavg[1] = y; - if (!(parts[i].ctype&0x3FFFFFFF)) { - kill_part(i); - return 1; - } - if (parts[i].temp > 506) - if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); - 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) - continue; - if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) - { - parts[i].vx *= 0.90; - parts[i].vy *= 0.90; - create_part(r>>8, x+rx, y+ry, PT_PHOT); - rrr = (rand()%360)*3.14159f/180.0f; - rr = (rand()%128+128)/127.0f; - parts[r>>8].vx = rr*cosf(rrr); - parts[r>>8].vy = rr*sinf(rrr); - pv[y/CELL][x/CELL] -= 15.0f * CFDS; - } - if ((r&0xFF)==PT_ISZS && 5>(rand()%2000)) - { - parts[i].vx *= 0.90; - parts[i].vy *= 0.90; - create_part(r>>8, x+rx, y+ry, PT_PHOT); - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[r>>8].vx = rr*cosf(rrr); - parts[r>>8].vy = rr*sinf(rrr); - pv[y/CELL][x/CELL] -= 15.0f * CFDS; - } - } - r = pmap[y][x]; - if((r&0xFF) == PT_QRTZ && r)// && parts[i].ctype==0x3FFFFFFF) - { - float a = (rand()%360)*3.14159f/180.0f; - parts[i].vx = 3.0f*cosf(a); - parts[i].vy = 3.0f*sinf(a); - if(parts[i].ctype == 0x3FFFFFFF) - parts[i].ctype = 0x1F<<(rand()%26); - parts[i].life++; //Delay death - } - //r = pmap[y][x]; - //rt = r&0xFF; - /*if (rt==PT_CLNE || rt==PT_PCLN || rt==PT_BCLN || rt==PT_PBCN) { - if (!parts[r>>8].ctype) - parts[r>>8].ctype = PT_PHOT; - }*/ - - return 0; -} - -int graphics_PHOT(GRAPHICS_FUNC_ARGS) -{ - int x = 0; - *colr = *colg = *colb = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - - *firea = 100; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode &= ~PMODE_FLAT; - *pixel_mode |= FIRE_ADD | PMODE_ADD; - return 0; -} diff --git a/src/elements/pipe.c b/src/elements/pipe.c deleted file mode 100644 index 9502d38..0000000 --- a/src/elements/pipe.c +++ /dev/null @@ -1,563 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -#define PFLAG_NORMALSPEED 0x00010000 - -// parts[].tmp flags -// trigger flags to be processed this frame (trigger flags for next frame are shifted 3 bits to the left): -#define PPIP_TMPFLAG_TRIGGER_ON 0x10000000 -#define PPIP_TMPFLAG_TRIGGER_OFF 0x08000000 -#define PPIP_TMPFLAG_TRIGGER_REVERSE 0x04000000 -#define PPIP_TMPFLAG_TRIGGERS 0x1C000000 -// current status of the pipe -#define PPIP_TMPFLAG_PAUSED 0x02000000 -#define PPIP_TMPFLAG_REVERSED 0x01000000 -// 0x000000FF element -// 0x00000100 is single pixel pipe -// 0x00000200 will transfer like a single pixel pipe when in forward mode -// 0x00001C00 forward single pixel pipe direction -// 0x00002000 will transfer like a single pixel pipe when in reverse mode -// 0x0001C000 reverse single pixel pipe direction - -signed char pos_1_rx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; -signed char pos_1_ry[] = {-1, 0, 1,-1, 1,-1, 0, 1}; - -int ppip_changed = 0; - -void PPIP_flood_trigger(int x, int y, int sparkedBy) -{ - int coord_stack_limit = XRES*YRES; - unsigned short (*coord_stack)[2]; - int coord_stack_size = 0; - int x1, x2; - - // Separate flags for on and off in case PPIP is sparked by PSCN and NSCN on the same frame - // - then PSCN can override NSCN and behaviour is not dependent on particle order - int prop = 0; - if (sparkedBy==PT_PSCN) prop = PPIP_TMPFLAG_TRIGGER_ON << 3; - else if (sparkedBy==PT_NSCN) prop = PPIP_TMPFLAG_TRIGGER_OFF << 3; - else if (sparkedBy==PT_INST) prop = PPIP_TMPFLAG_TRIGGER_REVERSE << 3; - - if (prop==0 || (pmap[y][x]&0xFF)!=PT_PPIP || (parts[pmap[y][x]>>8].tmp & prop)) - return; - - coord_stack = malloc(sizeof(unsigned short)*2*coord_stack_limit); - coord_stack[coord_stack_size][0] = x; - coord_stack[coord_stack_size][1] = y; - coord_stack_size++; - - do - { - coord_stack_size--; - x = coord_stack[coord_stack_size][0]; - y = coord_stack[coord_stack_size][1]; - x1 = x2 = x; - // go left as far as possible - while (x1>=CELL) - { - if ((pmap[y][x1-1]&0xFF)!=PT_PPIP) - { - break; - } - x1--; - } - // go right as far as possible - while (x2<XRES-CELL) - { - if ((pmap[y][x2+1]&0xFF)!=PT_PPIP) - { - break; - } - x2++; - } - // fill span - for (x=x1; x<=x2; x++) - { - if (!(parts[pmap[y][x]>>8].tmp & prop)) - ppip_changed = 1; - parts[pmap[y][x]>>8].tmp |= prop; - } - - // add adjacent pixels to stack - // +-1 to x limits to include diagonally adjacent pixels - // Don't need to check x bounds here, because already limited to [CELL, XRES-CELL] - if (y>=CELL+1) - for (x=x1-1; x<=x2+1; x++) - if ((pmap[y-1][x]&0xFF)==PT_PPIP && !(parts[pmap[y-1][x]>>8].tmp & prop)) - { - coord_stack[coord_stack_size][0] = x; - coord_stack[coord_stack_size][1] = y-1; - coord_stack_size++; - if (coord_stack_size>=coord_stack_limit) - { - free(coord_stack); - return; - } - } - if (y<YRES-CELL-1) - for (x=x1-1; x<=x2+1; x++) - if ((pmap[y+1][x]&0xFF)==PT_PPIP && !(parts[pmap[y+1][x]>>8].tmp & prop)) - { - coord_stack[coord_stack_size][0] = x; - coord_stack[coord_stack_size][1] = y+1; - coord_stack_size++; - if (coord_stack_size>=coord_stack_limit) - { - free(coord_stack); - return; - } - } - } while (coord_stack_size>0); - free(coord_stack); -} - -void PIPE_transfer_pipe_to_part(particle *pipe, particle *part) -{ - part->type = (pipe->tmp & 0xFF); - part->temp = pipe->temp; - part->life = pipe->tmp2; - part->tmp = pipe->pavg[0]; - part->ctype = pipe->pavg[1]; - pipe->tmp &= ~0xFF; - - if (!ptypes[part->type].properties & TYPE_ENERGY) - { - part->vx = 0.0f; - part->vy = 0.0f; - } - else if (part->type == PT_PHOT && part->ctype == 0x40000000) - part->ctype = 0x3FFFFFFF; - part->tmp2 = 0; - part->flags = 0; - part->dcolour = 0; -} - -void PIPE_transfer_part_to_pipe(particle *part, particle *pipe) -{ - pipe->tmp = (pipe->tmp&~0xFF) | part->type; - pipe->temp = part->temp; - pipe->tmp2 = part->life; - pipe->pavg[0] = part->tmp; - pipe->pavg[1] = part->ctype; -} - -void PIPE_transfer_pipe_to_pipe(particle *src, particle *dest) -{ - dest->tmp = (dest->tmp&~0xFF) | (src->tmp&0xFF); - dest->temp = src->temp; - dest->tmp2 = src->tmp2; - dest->pavg[0] = src->pavg[0]; - dest->pavg[1] = src->pavg[1]; - src->tmp &= ~0xFF; -} - - -void pushParticle(int i, int count, int original) -{ - int rndstore, rnd, rx, ry, r, x, y, np, q, notctype=(((parts[i].ctype)%3)+2); - if ((parts[i].tmp&0xFF) == 0 || count >= 2)//don't push if there is nothing there, max speed of 2 per frame - return; - x = (int)(parts[i].x+0.5f); - y = (int)(parts[i].y+0.5f); - if( !(parts[i].tmp&0x200) ) - { - //normal random push - rndstore = rand(); - // RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1 - // so can go 5 cycles without regenerating rndstore - for (q=0; q<3; q++)//try to push 3 times - { - rnd = rndstore&7; - rndstore = rndstore>>3; - rx = pos_1_rx[rnd]; - ry = pos_1_ry[rnd]; - if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0) - { - PIPE_transfer_pipe_to_pipe(parts+i, parts+(r>>8)); - if (r>>8 > original) - parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed - count++; - pushParticle(r>>8,count,original); - } - else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase - { - int nnx; - for (nnx=0; nnx<80; nnx++) - if (!portalp[parts[r>>8].tmp][count][nnx].type) - { - PIPE_transfer_pipe_to_part(parts+i, &(portalp[parts[r>>8].tmp][count][nnx])); - count++; - break; - } - } - } - } - } - else //predefined 1 pixel thick pipe movement - { - int coords = 7 - ((parts[i].tmp>>10)&7); - r = pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; - if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0) - { - PIPE_transfer_pipe_to_pipe(parts+i, parts+(r>>8)); - if (r>>8 > original) - parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed - count++; - pushParticle(r>>8,count,original); - } - else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase - { - int nnx; - for (nnx=0; nnx<80; nnx++) - if (!portalp[parts[r>>8].tmp][count][nnx].type) - { - PIPE_transfer_pipe_to_part(parts+i, &(portalp[parts[r>>8].tmp][count][nnx])); - count++; - break; - } - } - else if ((r&0xFF) == PT_NONE) //Move particles out of pipe automatically, much faster at ends - { - rx = pos_1_rx[coords]; - ry = pos_1_ry[coords]; - np = create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF); - if (np!=-1) - { - PIPE_transfer_pipe_to_part(parts+i, parts+np); - } - } - } - return; -} - -int update_PIPE(UPDATE_FUNC_ARGS) { - int r, rx, ry, np; - int rnd, rndstore; - if (parts[i].tmp & PPIP_TMPFLAG_TRIGGERS) - { - int pause_changed = 0; - if (parts[i].tmp & PPIP_TMPFLAG_TRIGGER_ON) // TRIGGER_ON overrides TRIGGER_OFF - { - if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) - pause_changed = 1; - parts[i].tmp &= ~PPIP_TMPFLAG_PAUSED; - } - else if (parts[i].tmp & PPIP_TMPFLAG_TRIGGER_OFF) - { - if (!(parts[i].tmp & PPIP_TMPFLAG_PAUSED)) - pause_changed = 1; - parts[i].tmp |= PPIP_TMPFLAG_PAUSED; - } - if (pause_changed) - { - int rx, ry, r; - 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)) - { - r = pmap[y+ry][x+rx]; - if ((r&0xFF) == PT_BRCK) - { - if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) - parts[r>>8].tmp = 0; - else - parts[r>>8].tmp = 1; //make surrounding BRCK glow - } - } - } - } - - if (parts[i].tmp & PPIP_TMPFLAG_TRIGGER_REVERSE) - { - parts[i].tmp ^= PPIP_TMPFLAG_REVERSED; - if (parts[i].ctype == 2) //Switch colors so it goes in reverse - parts[i].ctype = 4; - else if (parts[i].ctype == 4) - parts[i].ctype = 2; - if (parts[i].tmp & 0x100) //Switch one pixel pipe direction - { - int coords = (parts[i].tmp>>13)&0xF; - int coords2 = (parts[i].tmp>>9)&0xF; - parts[i].tmp &= ~0x1FE00; - parts[i].tmp |= coords<<9; - parts[i].tmp |= coords2<<13; - } - } - - parts[i].tmp &= ~PPIP_TMPFLAG_TRIGGERS; - } - - if (parts[i].ctype>=2 && parts[i].ctype<=4 && !(parts[i].tmp & PPIP_TMPFLAG_PAUSED)) - { - if (parts[i].life==3) - { - int lastneighbor = -1; - int neighborcount = 0; - int count = 0; - // make automatic pipe pattern - 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) - continue; - if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[r>>8].ctype==1) - { - parts[r>>8].ctype = (((parts[i].ctype)%3)+2);//reverse - parts[r>>8].life = 6; - if ( parts[i].tmp&0x100)//is a single pixel pipe - { - parts[r>>8].tmp |= 0x200;//will transfer to a single pixel pipe - parts[r>>8].tmp |= count<<10;//coords of where it came from - parts[i].tmp |= ((7-count)<<14); - parts[i].tmp |= 0x2000; - } - neighborcount ++; - lastneighbor = r>>8; - } - else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[r>>8].ctype!=(((parts[i].ctype-1)%3)+2)) - { - neighborcount ++; - lastneighbor = r>>8; - } - count++; - } - if(neighborcount == 1) - parts[lastneighbor].tmp |= 0x100; - } - else - { - if (parts[i].flags&PFLAG_NORMALSPEED)//skip particle push to prevent particle number being higher causing speed up - { - parts[i].flags &= ~PFLAG_NORMALSPEED; - } - else - { - pushParticle(i,0,i); - } - - if (nt)//there is something besides PIPE around current particle - { - rndstore = rand(); - rnd = rndstore&7; - rndstore = rndstore>>3; - rx = pos_1_rx[rnd]; - ry = pos_1_ry[rnd]; - if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) - { - r = pmap[y+ry][x+rx]; - if(!r) - r = photons[y+ry][x+rx]; - if (surround_space && !r && (parts[i].tmp&0xFF)!=0) //creating at end - { - np = create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF); - if (np!=-1) - { - PIPE_transfer_pipe_to_part(parts+i, parts+np); - } - } - //try eating particle at entrance - else if ((parts[i].tmp&0xFF) == 0 && (ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) - { - if ((r&0xFF)==PT_SOAP) - detach(r>>8); - PIPE_transfer_part_to_pipe(parts+(r>>8), parts+i); - kill_part(r>>8); - } - else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp && (ptypes[parts[r>>8].tmp].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) - { - // STOR stores properties in the same places as PIPE does - PIPE_transfer_pipe_to_pipe(parts+(r>>8), parts+i); - } - } - } - } - } - else if (!parts[i].ctype && parts[i].life<=10) - { - if (parts[i].temp<272.15)//manual pipe colors - { - if (parts[i].temp>173.25&&parts[i].temp<273.15) - { - parts[i].ctype = 2; - parts[i].life = 0; - } - if (parts[i].temp>73.25&&parts[i].temp<=173.15) - { - parts[i].ctype = 3; - parts[i].life = 0; - } - if (parts[i].temp>=0&&parts[i].temp<=73.15) - { - parts[i].ctype = 4; - parts[i].life = 0; - } - } - else - { - // make a border - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - { - int index = create_part(-1,x+rx,y+ry,PT_BRCK);//BRCK border, people didn't like DMND - if (parts[i].type == PT_PPIP && index != -1) - parts[index].tmp = 1; - } - } - } - if (parts[i].life<=1) - parts[i].ctype = 1; - } - } - else if (parts[i].ctype==1)//wait for empty space before starting to generate automatic pipe pattern - { - if (!parts[i].life) - { - 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)) - { - if (!pmap[y+ry][x+rx] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_ALLOWAIR && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_WALL && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_WALLELEC && (bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_EWALL || emap[(y+ry)/CELL][(x+rx)/CELL])) - parts[i].life=50; - } - } - else if (parts[i].life==5)//check for beginning of pipe single pixel - { - int issingle = 1; - 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&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && parts[i].ctype==1 && parts[i].life ) - issingle = 0; - } - if (issingle) - parts[i].tmp |= 0x100; - } - else if (parts[i].life==2) - { - parts[i].ctype = 2; - parts[i].life = 6; - } - } - return 0; -} - -int graphics_PIPE(GRAPHICS_FUNC_ARGS) -{ - - if ((cpart->tmp&0xFF)>0 && (cpart->tmp&0xFF)<PT_NUM) - { - //Create a temp. particle and do a subcall. - particle tpart; - int t; - memset(&tpart, 0, sizeof(particle)); - tpart.type = cpart->tmp&0xFF; - tpart.temp = cpart->temp; - tpart.life = cpart->tmp2; - tpart.tmp = cpart->pavg[0]; - tpart.ctype = cpart->pavg[1]; - if (tpart.type == PT_PHOT && tpart.ctype == 0x40000000) - tpart.ctype = 0x3FFFFFFF; - t = tpart.type; - if (graphicscache[t].isready) - { - *pixel_mode = graphicscache[t].pixel_mode; - *cola = graphicscache[t].cola; - *colr = graphicscache[t].colr; - *colg = graphicscache[t].colg; - *colb = graphicscache[t].colb; - *firea = graphicscache[t].firea; - *firer = graphicscache[t].firer; - *fireg = graphicscache[t].fireg; - *fireb = graphicscache[t].fireb; - } - else - { - *colr = PIXR(ptypes[t].pcolors); - *colg = PIXG(ptypes[t].pcolors); - *colb = PIXB(ptypes[t].pcolors); - if (ptypes[t].graphics_func) - { - (*(ptypes[t].graphics_func))(&tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); - } - else - { - graphics_DEFAULT(&tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); - } - } - //*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors); - //*colg = PIXG(ptypes[cpart->tmp&0xFF].pcolors); - //*colb = PIXB(ptypes[cpart->tmp&0xFF].pcolors); - } - else - { - if (cpart->ctype==2) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - else if (cpart->ctype==3) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - else if (cpart->ctype==4) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - else if (cpart->temp<272.15&&cpart->ctype!=1) - { - if (cpart->temp>173.25&&cpart->temp<273.15) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - if (cpart->temp>73.25&&cpart->temp<=173.15) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - if (cpart->temp>=0&&cpart->temp<=73.15) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - } - } - return 0; -} diff --git a/src/elements/plnt.c b/src/elements/plnt.c deleted file mode 100644 index 3bdfeac..0000000 --- a/src/elements/plnt.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PLNT(UPDATE_FUNC_ARGS) { - int r, rx, ry, np; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_WATR && 1>(rand()%250)) - { - np = create_part(r>>8,x+rx,y+ry,PT_PLNT); - if (np<0) continue; - parts[np].life = 0; - } - else if ((r&0xFF)==PT_LAVA && 1>(rand()%250)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - } - else if (((r&0xFF)==PT_SMKE || (r&0xFF)==PT_CO2) && (1>rand()%250)) - { - kill_part(r>>8); - parts[i].life = rand()%60 + 60; - } - else if (surround_space && ((r&0xFF)==PT_WOOD) && (1>rand()%20) && (abs(rx+ry)<=2) && (VINE_MODE || parts[i].tmp==1) ) - { - int nnx = rand()%3 -1; - int nny = rand()%3 -1; - if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny)) - { - if (pmap[y+ry+nny][x+rx+nnx]) - continue; - np = create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE); - if (np<0) continue; - parts[np].temp = parts[i].temp; - } - } - } - if (parts[i].life==2) - { - 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) - create_part(-1,x+rx,y+ry,PT_O2); - } - parts[i].life = 0; - } - if (parts[i].temp > 400 && parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = (int)parts[i].temp; - return 0; -} - -int graphics_PLNT(GRAPHICS_FUNC_ARGS) -{ - float maxtemp = fmax(cpart->tmp2,cpart->temp); - if (maxtemp > 300) - { - *colr += (int)restrict_flt((maxtemp-300)/5,0,58); - *colg -= (int)restrict_flt((maxtemp-300)/2,0,102); - *colb += (int)restrict_flt((maxtemp-300)/5,0,70); - } - if (maxtemp < 273) - { - *colg += (int)restrict_flt((273-maxtemp)/4,0,255); - *colb += (int)restrict_flt((273-maxtemp)/1.5,0,255); - } - return 0; -} diff --git a/src/elements/plsm.c b/src/elements/plsm.c deleted file mode 100644 index 2861c25..0000000 --- a/src/elements/plsm.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -#include "hmap.h" - -int graphics_PLSM(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)plasma_data[caddress]; - *colg = (unsigned char)plasma_data[caddress+1]; - *colb = (unsigned char)plasma_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_GLOW | PMODE_ADD; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/plut.c b/src/elements/plut.c deleted file mode 100644 index e453b56..0000000 --- a/src/elements/plut.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PLUT(UPDATE_FUNC_ARGS) { - if (1>rand()%100 && ((int)(5.0f*pv[y/CELL][x/CELL]))>(rand()%1000)) - { - create_part(i, x, y, PT_NEUT); - } - return 0; -} diff --git a/src/elements/prti.c b/src/elements/prti.c deleted file mode 100644 index fc6f37b..0000000 --- a/src/elements/prti.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -/*these are the count values of where the particle gets stored, depending on where it came from - 0 1 2 - 7 . 3 - 6 5 4 - PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in - PRTO does +/-1 to the count, so it doesn't jam as easily -*/ -int portal_rx[8] = {-1, 0, 1, 1, 1, 0,-1,-1}; -int portal_ry[8] = {-1,-1,-1, 0, 1, 1, 1, 0}; - -int update_PRTI(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, fe = 0; - int count =0; - parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; - else if (parts[i].tmp<0) parts[i].tmp = 0; - for (count=0; count<8; count++) - { - rx = portal_rx[count]; - ry = portal_ry[count]; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - fe = 1; - if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (!(ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK)) - { - r = photons[y+ry][x+rx]; - if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (!(ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK)) - continue; - } - - if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH) - continue;// Handling these is a bit more complicated, and is done in STKM_interact() - - if ((r&0xFF) == PT_SOAP) - detach(r>>8); - - for ( nnx=0; nnx<80; nnx++) - if (!portalp[parts[i].tmp][count][nnx].type) - { - portalp[parts[i].tmp][count][nnx] = parts[r>>8]; - if ((r&0xFF)==PT_SPRK) - part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype); - else - kill_part(r>>8); - fe = 1; - break; - } - } - } - - - if (fe) { - int orbd[4] = {0, 0, 0, 0}; //Orbital distances - int orbl[4] = {0, 0, 0, 0}; //Orbital locations - if (!parts[i].life) parts[i].life = rand()*rand()*rand(); - if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); - orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); - for (r = 0; r < 4; r++) { - if (orbd[r]>1) { - orbd[r] -= 12; - if (orbd[r]<1) { - orbd[r] = (rand()%128)+128; - orbl[r] = rand()%255; - } else { - orbl[r] += 2; - orbl[r] = orbl[r]%255; - } - } else { - orbd[r] = (rand()%128)+128; - orbl[r] = rand()%255; - } - } - orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); - } else { - parts[i].life = 0; - parts[i].ctype = 0; - } - return 0; -} diff --git a/src/elements/prto.c b/src/elements/prto.c deleted file mode 100644 index d7eb642..0000000 --- a/src/elements/prto.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> -/*these are the count values of where the particle gets stored, depending on where it came from - 0 1 2 - 7 . 3 - 6 5 4 - PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in - PRTO does +/-1 to the count, so it doesn't jam as easily -*/ -int update_PRTO(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, np, fe = 0; - int count = 0; - parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; - else if (parts[i].tmp<0) parts[i].tmp = 0; - for (count=0; count<8; count++) - { - rx = portal_rx[count]; - ry = portal_ry[count]; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - fe = 1; - if (r) - continue; - if (!r) - { - for ( nnx =0 ; nnx<80; nnx++) - { - int randomness = (count + rand()%3-1 + 4)%8;//add -1,0,or 1 to count - if (portalp[parts[i].tmp][randomness][nnx].type==PT_SPRK)// TODO: make it look better, spark creation - { - create_part(-1,x+1,y,PT_SPRK); - create_part(-1,x+1,y+1,PT_SPRK); - create_part(-1,x+1,y-1,PT_SPRK); - create_part(-1,x,y-1,PT_SPRK); - create_part(-1,x,y+1,PT_SPRK); - create_part(-1,x-1,y+1,PT_SPRK); - create_part(-1,x-1,y,PT_SPRK); - create_part(-1,x-1,y-1,PT_SPRK); - portalp[parts[i].tmp][randomness][nnx] = emptyparticle; - break; - } - else if (portalp[parts[i].tmp][randomness][nnx].type) - { - if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM) - player.spwn = 0; - if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) - player2.spwn = 0; - if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) - { - fighcount--; - fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 0; - } - np = create_part(-1,x+rx,y+ry,portalp[parts[i].tmp][randomness][nnx].type); - if (np<0) - { - if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM) - player.spwn = 1; - if (portalp[parts[i].tmp][randomness][nnx].type==PT_STKM2) - player2.spwn = 1; - if (portalp[parts[i].tmp][randomness][nnx].type==PT_FIGH) - { - fighcount++; - fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; - } - continue; - } - if (parts[np].type==PT_FIGH) - { - // Release the fighters[] element allocated by create_part, the one reserved when the fighter went into the portal will be used - fighters[(unsigned char)parts[np].tmp].spwn = 0; - fighters[(unsigned char)portalp[parts[i].tmp][randomness][nnx].tmp].spwn = 1; - } - if (portalp[parts[i].tmp][randomness][nnx].vx == 0.0f && portalp[parts[i].tmp][randomness][nnx].vy == 0.0f) - { - // particles that have passed from PIPE into PRTI have lost their velocity, so use the velocity of the newly created particle if the particle in the portal has no velocity - float tmp_vx = parts[np].vx; - float tmp_vy = parts[np].vy; - parts[np] = portalp[parts[i].tmp][randomness][nnx]; - parts[np].vx = tmp_vx; - parts[np].vy = tmp_vy; - } - else - { - parts[np] = portalp[parts[i].tmp][randomness][nnx]; - } - parts[np].x = x+rx; - parts[np].y = y+ry; - portalp[parts[i].tmp][randomness][nnx] = emptyparticle; - break; - } - } - } - } - } - if (fe) { - int orbd[4] = {0, 0, 0, 0}; //Orbital distances - int orbl[4] = {0, 0, 0, 0}; //Orbital locations - if (!parts[i].life) parts[i].life = rand()*rand()*rand(); - if (!parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); - orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); - for (r = 0; r < 4; r++) { - if (orbd[r]<254) { - orbd[r] += 16; - if (orbd[r]>254) { - orbd[r] = 0; - orbl[r] = rand()%255; - } else { - orbl[r] += 1; - orbl[r] = orbl[r]%255; - } - } else { - orbd[r] = 0; - orbl[r] = rand()%255; - } - } - orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); - } else { - parts[i].life = 0; - parts[i].ctype = 0; - } - return 0; -} diff --git a/src/elements/pump.c b/src/elements/pump.c deleted file mode 100644 index 77369c2..0000000 --- a/src/elements/pump.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PUMP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - if (parts[i].temp>=256.0+273.15) - parts[i].temp=256.0+273.15; - if (parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if ((x+rx)-CELL>=0 && (y+ry)-CELL>0 && (x+rx)+CELL<XRES && (y+ry)+CELL<YRES && !(rx && ry)) - { - pv[(y/CELL)+ry][(x/CELL)+rx] += 0.1f*((parts[i].temp-273.15)-pv[(y/CELL)+ry][(x/CELL)+rx]); - } - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_PUMP) - { - 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; -} diff --git a/src/elements/pvod.c b/src/elements/pvod.c deleted file mode 100644 index 5078745..0000000 --- a/src/elements/pvod.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PVOD(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SPRK && parts[r>>8].life>0 && parts[r>>8].life<4) - { - if (parts[r>>8].ctype==PT_PSCN) - parts[i].life = 10; - else if (parts[r>>8].ctype==PT_NSCN) - parts[i].life = 9; - } - if ((r&0xFF)==PT_PVOD) - { - if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[i].life==0&&parts[r>>8].life==10) - parts[i].life = 10; - } - } - return 0; -} diff --git a/src/elements/pyro.c b/src/elements/pyro.c deleted file mode 100644 index c09dd63..0000000 --- a/src/elements/pyro.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_PYRO(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, t = parts[i].type; - if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1) - { - t = PT_NBLE; - part_change_type(i,x,y,t); - parts[i].life = 0; - } - if(t==PT_FIRE && parts[i].life <=1) - { - if (parts[i].tmp==3){ - t = PT_DSTW; - part_change_type(i,x,y,t); - parts[i].life = 0; - parts[i].ctype = PT_FIRE; - } - else if (parts[i].temp<625) - { - t = PT_SMKE; - part_change_type(i,x,y,t); - parts[i].life = rand()%20+250; - } - } - if(t==PT_PLSM && parts[i].life <=1) - { - if (parts[i].tmp==3){ - t = PT_DSTW; - part_change_type(i,x,y,t); - parts[i].life = 0; - parts[i].ctype = PT_FIRE; - } - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) - continue; - rt = parts[r>>8].type; - if ((surround_space || ptypes[rt].explosive) && - (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && - (t!=PT_PHOT || rt!=PT_INSL) && - (rt!=PT_SPNG || parts[r>>8].life==0) && - (rt!=PT_H2 || parts[r>>8].temp < 2273.15) && - ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) - { - part_change_type(r>>8,x+rx,y+ry,PT_FIRE); - parts[r>>8].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[rt].flammable/2), MIN_TEMP, MAX_TEMP); - parts[r>>8].life = rand()%80+180; - parts[r>>8].tmp = parts[r>>8].ctype = 0; - if (ptypes[rt].explosive) - pv[y/CELL][x/CELL] += 0.25f * CFDS; - } - } - if (legacy_enable) update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS); - return 0; -} - -int update_legacy_PYRO(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, lpv, t = parts[i].type; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) - continue; - rt = r&0xFF; - lpv = (int)pv[(y+ry)/CELL][(x+rx)/CELL]; - if (lpv < 1) lpv = 1; - if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && - ptypes[rt].meltable*lpv>(rand()%1000)) - { - if (t!=PT_LAVA || parts[i].life>0) - { - parts[r>>8].ctype = (rt==PT_BRMT)?PT_BMTL:parts[r>>8].type; - parts[r>>8].ctype = (parts[r>>8].ctype==PT_SAND)?PT_GLAS:parts[r>>8].ctype; - part_change_type(r>>8,x+rx,y+ry,PT_LAVA); - parts[r>>8].life = rand()%120+240; - } - else - { - parts[i].life = 0; - t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; - parts[i].ctype = PT_NONE;//rt; - part_change_type(i,x,y,t); - return 1; - } - } - if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW)) - { - parts[r>>8].type = PT_WATR; - if (t==PT_FIRE) - { - kill_part(i); - return 1; - } - if (t==PT_LAVA) - { - parts[i].life = 0; - t = parts[i].type = PT_STNE; - part_change_type(i,x,y,t); - } - } - if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)) - { - kill_part(r>>8); - if (t==PT_FIRE) - { - kill_part(i); - return 1; - } - if (t==PT_LAVA) - { - parts[i].life = 0; - t = parts[i].type = (parts[i].ctype)?parts[i].ctype:PT_STNE; - parts[i].ctype = PT_NONE; - part_change_type(i,x,y,t); - } - } - } - return 0; -} diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c deleted file mode 100644 index 26c9f45..0000000 --- a/src/elements/qrtz.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_QRTZ(UPDATE_FUNC_ARGS) { - int r, tmp, trade, rx, ry, np, t; - t = parts[i].type; - if (t == PT_QRTZ) - { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = pv[y/CELL][x/CELL]; - if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) - { - part_change_type(i,x,y,PT_PQRT); - } - } - // absorb SLTW - if (parts[i].ctype!=-1) - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - else if ((r&0xFF)==PT_SLTW && (1>rand()%2500)) - { - kill_part(r>>8); - parts[i].ctype ++; - } - } - // grow if absorbed SLTW - if (parts[i].ctype>0) - { - for ( trade = 0; trade<5; trade ++) - { - rx = rand()%3-1; - ry = rand()%3-1; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r && parts[i].ctype!=0) - { - np = create_part(-1,x+rx,y+ry,PT_QRTZ); - if (np>-1) - { - parts[np].tmp = parts[i].tmp; - parts[i].ctype--; - if (5>rand()%10) - { - parts[np].ctype=-1;//dead qrtz - } - else if (!parts[i].ctype && 1>rand()%15) - { - parts[i].ctype=-1; - } - - break; - } - } - } - } - } - // diffuse absorbed SLTW - if (parts[i].ctype>0) - { - for ( trade = 0; trade<9; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion - { - tmp = parts[i].ctype - parts[r>>8].ctype; - if (tmp ==1) - { - parts[r>>8].ctype ++; - parts[i].ctype --; - break; - } - if (tmp>0) - { - parts[r>>8].ctype += tmp/2; - parts[i].ctype -= tmp/2; - break; - } - } - } - } - } - return 0; -} diff --git a/src/elements/repl.c b/src/elements/repl.c deleted file mode 100644 index 7b7605d..0000000 --- a/src/elements/repl.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_REPL(UPDATE_FUNC_ARGS) { - int r, rx, ry, ri; - for(ri = 0; ri <= 10; ri++) - { - rx = (rand()%20)-10; - ry = (rand()%20)-10; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - r = photons[y+ry][x+rx]; - - if (r && !(ptypes[r&0xFF].properties & TYPE_SOLID)){ - parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); - } - } - } - return 0; -} diff --git a/src/elements/rime.c b/src/elements/rime.c deleted file mode 100644 index 4ac6c29..0000000 --- a/src/elements/rime.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_RIME(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].vx = 0; - parts[i].vy = 0; - 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) - continue; - if ((r&0xFF)==PT_SPRK) - { - part_change_type(i,x,y,PT_FOG); - parts[i].life = rand()%50 + 60; - } - else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0) - { - part_change_type(i,x,y,PT_FOG); - parts[i].life = parts[r>>8].life; - } - } - return 0; -} diff --git a/src/elements/shld.c b/src/elements/shld.c deleted file mode 100644 index b1661c9..0000000 --- a/src/elements/shld.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SHLD1(UPDATE_FUNC_ARGS) { - int r, nnx, nny, 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) - continue; - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - { - if (55>rand()%200&&parts[i].life==0) - { - part_change_type(i,x,y,PT_SHLD2); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - } - else if ((r&0xFF)==PT_SHLD3&&4>rand()%10) - { - part_change_type(i,x,y,PT_SHLD2); - parts[i].life = 7; - } - } - return 0; -} - -int update_SHLD2(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - 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 && parts[i].life>0) - create_part(-1,x+rx,y+ry,PT_SHLD1); - if (!r) - continue; - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - { - if (25>rand()%200&&parts[i].life==0) - { - part_change_type(i,x,y,PT_SHLD3); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - else if ((r&0xFF)==PT_SHLD4&&4>rand()%10) - { - part_change_type(i,x,y,PT_SHLD3); - parts[i].life = 7; - } - } - return 0; -} - -int update_SHLD3(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - 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) - { - if (1>rand()%2500) - { - np = create_part(-1,x+rx,y+ry,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - part_change_type(i,x,y,PT_SHLD2); - } - else - continue; - - } - if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) - { - part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); - parts[r>>8].life=7; - } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - { - if (18>rand()%3000&&parts[i].life==0) - { - part_change_type(i,x,y,PT_SHLD4); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - } - return 0; -} - -int update_SHLD4(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - 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) - { - if (1>rand()%5500) - { - np = create_part(-1,x+rx,y+ry,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - part_change_type(i,x,y,PT_SHLD2); - } - else - continue; - - } - if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) - { - part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); - parts[r>>8].life = 7; - } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - return 0; -} diff --git a/src/elements/sing.c b/src/elements/sing.c deleted file mode 100644 index e8b4a07..0000000 --- a/src/elements/sing.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SING(UPDATE_FUNC_ARGS) { - int r, rx, ry, cry, crx, rad, nxi, nxj, nb, j, spawncount; - int singularity = -parts[i].life; - float angle, v; - - if (pv[y/CELL][x/CELL]<singularity) - pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]); - if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<singularity) - pv[y/CELL+1][x/CELL] += 0.1f*(singularity-pv[y/CELL+1][x/CELL]); - if (x+CELL<XRES) - { - pv[y/CELL][x/CELL+1] += 0.1f*(singularity-pv[y/CELL][x/CELL+1]); - if (y+CELL<YRES) - pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]); - } - if (y-CELL>=0 && pv[y/CELL-1][x/CELL]<singularity) - pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]); - if (x-CELL>=0) - { - pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]); - if (y-CELL>=0) - pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]); - } - if (parts[i].life<1) { - //Pop! - for (rx=-1; rx<2; rx++) { - crx = (x/CELL)+rx; - for (ry=-1; ry<2; ry++) { - cry = (y/CELL)+ry; - if (cry >= 0 && crx >= 0 && crx < (XRES/CELL) && cry < (YRES/CELL)) { - pv[cry][crx] += (float)parts[i].tmp; - } - } - } - spawncount = (parts[i].tmp>255)?255:parts[i].tmp; - if (spawncount>=1) - spawncount = spawncount/8; - spawncount = spawncount*spawncount*M_PI; - for (j=0;j<spawncount;j++) - { - switch(rand()%3) - { - case 0: - nb = create_part(-3, x, y, PT_PHOT); - break; - case 1: - nb = create_part(-3, x, y, PT_NEUT); - break; - case 2: - nb = create_part(-3, x, y, PT_ELEC); - break; - } - if (nb!=-1) { - parts[nb].life = (rand()%300); - parts[nb].temp = MAX_TEMP/2; - angle = rand()*2.0f*M_PI/RAND_MAX; - v = (float)(rand())*5.0f/RAND_MAX; - parts[nb].vx = v*cosf(angle); - parts[nb].vy = v*sinf(angle); - } - else if (pfree==-1) - break;//if we've run out of particles, stop trying to create them - saves a lot of lag on "sing bomb" saves - } - kill_part(i); - return 1; - } - 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) - continue; - if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1) - { - if ((r&0xFF)==PT_SING && parts[r>>8].life >10) - { - if (parts[i].life+parts[r>>8].life > 255) - continue; - parts[i].life += parts[r>>8].life; - } - else - { - if (parts[i].life+3 > 255) - { - if (parts[r>>8].type!=PT_SING && 1>rand()%100) - { - int np; - np = create_part(r>>8,x+rx,y+ry,PT_SING); - parts[np].life = rand()%50+60; - } - continue; - } - parts[i].life += 3; - parts[i].tmp++; - } - parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP); - kill_part(r>>8); - } - } - return 0; -} diff --git a/src/elements/sltw.c b/src/elements/sltw.c deleted file mode 100644 index 4e562f7..0000000 --- a/src/elements/sltw.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SLTW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SALT && 1>(rand()%10000)) - part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - if ((r&0xFF)==PT_PLNT&&5>(rand()%1000)) - kill_part(r>>8); - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - } - if ((r&0xFF)==PT_FIRE){ - kill_part(r>>8); - if(1>(rand()%150)){ - kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/smke.c b/src/elements/smke.c deleted file mode 100644 index 5949034..0000000 --- a/src/elements/smke.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int graphics_SMKE(GRAPHICS_FUNC_ARGS) -{ - *colr = 55; - *colg = 55; - *colb = 55; - - *firea = 75; - *firer = 55; - *fireg = 55; - *fireb = 55; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_BLEND; - //Returning 1 means static, cache as we please - return 1; -} diff --git a/src/elements/soap.c b/src/elements/soap.c deleted file mode 100644 index 6b69778..0000000 --- a/src/elements/soap.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -void attach(int i1, int i2) -{ - if (!(parts[i2].ctype&4)) - { - parts[i1].ctype |= 2; - parts[i1].tmp = i2; - - parts[i2].ctype |= 4; - parts[i2].tmp2 = i1; - } - else - if (!(parts[i2].ctype&2)) - { - parts[i1].ctype |= 4; - parts[i1].tmp2= i2; - - parts[i2].ctype |= 2; - parts[i2].tmp = i1; - } -} - -int update_SOAP(UPDATE_FUNC_ARGS) -{ - int r, rx, ry, nr, ng, nb, na; - float tr, tg, tb, ta; - float blend; - - //0x01 - bubble on/off - //0x02 - first mate yes/no - //0x04 - "back" mate yes/no - - if (parts[i].ctype&1) - { - if (parts[i].temp>0) - { - if (parts[i].life<=0) - { - if ((parts[i].ctype&6) != 6 && (parts[i].ctype&6)) - { - int target; - - target = i; - - while((parts[target].ctype&6) != 6 && (parts[target].ctype&6)) - { - if (parts[target].ctype&2) - { - target = parts[target].tmp; - detach(target); - } - - if (parts[target].ctype&4) - { - target = parts[target].tmp2; - detach(target); - } - } - } - - if ((parts[i].ctype&6) != 6) - parts[i].ctype = 0; - - if ((parts[i].ctype&6) == 6 && (parts[parts[i].tmp].ctype&6) == 6 && parts[parts[i].tmp].tmp == i) - detach(i); - } - - parts[i].vy -= 0.1f; - - parts[i].vy *= 0.5f; - parts[i].vx *= 0.5f; - } - - if (!(parts[i].ctype&2)) - { - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - - if ((parts[r>>8].type == PT_SOAP) && (parts[r>>8].ctype&1) && !(parts[r>>8].ctype&4)) - attach(i, r>>8); - } - } - else - { - if (parts[i].life<=0) - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL]) - continue; - - if (parts[i].temp>0) - { - if (bmap[(y+ry)/CELL][(x+rx)/CELL] - || (r && ptypes[r&0xFF].state != ST_GAS - && (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS)) - { - detach(i); - continue; - } - } - - if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 1) - { - int buf; - - buf = parts[i].tmp; - - parts[i].tmp = r>>8; - parts[buf].tmp2 = r>>8; - parts[r>>8].tmp2 = i; - parts[r>>8].tmp = buf; - parts[r>>8].ctype = 7; - } - - if ((r&0xFF) == PT_SOAP && parts[r>>8].ctype == 7 && parts[i].tmp != r>>8 && parts[i].tmp2 != r>>8) - { - int buf; - - parts[parts[i].tmp].tmp2 = parts[r>>8].tmp2; - parts[parts[r>>8].tmp2].tmp = parts[i].tmp; - parts[r>>8].tmp2 = i; - parts[i].tmp = r>>8; - } - } - } - - if(parts[i].ctype&2) - { - float d, dx, dy; - - dx = parts[i].x - parts[parts[i].tmp].x; - dy = parts[i].y - parts[parts[i].tmp].y; - - d = 9/(pow(dx, 2)+pow(dy, 2)+9)-0.5; - - parts[parts[i].tmp].vx -= dx*d; - parts[parts[i].tmp].vy -= dy*d; - - parts[i].vx += dx*d; - parts[i].vy += dy*d; - - if ((parts[parts[i].tmp].ctype&2) && (parts[parts[i].tmp].ctype&1) - && (parts[parts[parts[i].tmp].tmp].ctype&2) && (parts[parts[parts[i].tmp].tmp].ctype&1)) - { - int ii; - - ii = parts[parts[parts[i].tmp].tmp].tmp; - - dx = parts[ii].x - parts[parts[i].tmp].x; - dy = parts[ii].y - parts[parts[i].tmp].y; - - d = 81/(pow(dx, 2)+pow(dy, 2)+81)-0.5; - - parts[parts[i].tmp].vx -= dx*d*0.5f; - parts[parts[i].tmp].vy -= dy*d*0.5f; - - parts[ii].vx += dx*d*0.5f; - parts[ii].vy += dy*d*0.5f; - } - } - } - else - { - if (pv[y/CELL][x/CELL]>0.5f || pv[y/CELL][x/CELL]<(-0.5f)) - { - parts[i].ctype = 1; - parts[i].life = 10; - } - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - - if ((r&0xFF) == PT_OIL) - { - float ax, ay; - - parts[i].vy -= 0.1f; - - parts[i].vy *= 0.5f; - parts[i].vx *= 0.5f; - - ax = (parts[i].vx + parts[r>>8].vx)/2; - ay = (parts[i].vy + parts[r>>8].vy)/2; - - parts[i].vx = ax; - parts[i].vy = ay; - parts[r>>8].vx = ax; - parts[r>>8].vy = ay; - } - } - } - - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_SOAP) - { - blend = 0.85f; - tr = (parts[r>>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; - - nr = (tr*blend); - ng = (tg*blend); - nb = (tb*blend); - na = (ta*blend); - - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; - } - } - - return 0; -} diff --git a/src/elements/spng.c b/src/elements/spng.c deleted file mode 100644 index 9776c79..0000000 --- a/src/elements/spng.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SPNG(UPDATE_FUNC_ARGS) { - int r, trade, rx, ry, tmp, np; - int limit = 50; - if (parts[i].life<limit && pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3&&parts[i].temp<=374.0f) - { - int absorbChanceDenom = parts[i].life*1000/limit + 500; - 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) - continue; - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_FRZW) && parts[i].life<limit && 500>rand()%absorbChanceDenom) - { - parts[i].life++; - kill_part(r>>8); - } - if ((r&0xFF)==PT_SLTW && parts[i].life<limit && 50>rand()%absorbChanceDenom) - { - parts[i].life++; - if (rand()%4) - kill_part(r>>8); - else - part_change_type(r>>8, x+rx, y+ry, PT_SALT); - } - if ((r&0xFF)==PT_CBNW && parts[i].life<limit && 100>rand()%absorbChanceDenom) - { - parts[i].life++; - part_change_type(r>>8, x+rx, y+ry, PT_CO2); - } - if ((r&0xFF)==PT_PSTE && parts[i].life<limit && 20>rand()%absorbChanceDenom) - { - parts[i].life++; - create_part(r>>8, x+rx, y+ry, PT_CLST); - } - } - } - else - 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)&&parts[i].life>=1)//if nothing then create water - { - np = create_part(-1,x+rx,y+ry,PT_WATR); - if (np>-1) parts[i].life--; - } - } - for ( trade = 0; trade<9; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - tmp = parts[i].life - parts[r>>8].life; - if (tmp ==1) - { - parts[r>>8].life ++; - parts[i].life --; - trade = 9; - } - else if (tmp>0) - { - parts[r>>8].life += tmp/2; - parts[i].life -= tmp/2; - trade = 9; - } - } - } - } - tmp = 0; - if (parts[i].life>0) - { - 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) - continue; - if ((r&0xFF)==PT_FIRE) - { - tmp++; - if (parts[r>>8].life>60) - parts[r>>8].life -= parts[r>>8].life/60; - else if (parts[r>>8].life>2) - parts[r>>8].life--; - } - } - } - if (tmp && parts[i].life>3) - parts[i].life -= parts[i].life/3; - if (tmp>1) - tmp = tmp/2; - if (tmp || parts[i].temp>=374) - 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)&&parts[i].life>=1)//if nothing then create steam - { - np = create_part(-1,x+rx,y+ry,PT_WTRV); - if (np>-1) - { - parts[np].temp = parts[i].temp; - tmp--; - parts[i].life--; - parts[i].temp -= 20.0f; - } - } - } - if (tmp>0) - { - if (parts[i].life>tmp) - parts[i].life -= tmp; - else - parts[i].life = 0; - } - return 0; -} diff --git a/src/elements/sprk.c b/src/elements/sprk.c deleted file mode 100644 index 1c4c5bc..0000000 --- a/src/elements/sprk.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SPRK(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype; - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); - - if (parts[i].life<=0) - { - if (ct==PT_WATR||ct==PT_SLTW||ct==PT_PSCN||ct==PT_NSCN||ct==PT_ETRD||ct==PT_INWR) - parts[i].temp = R_TEMP + 273.15f; - if (ct<=0 || ct>=PT_NUM || !ptypes[ct].enabled) - ct = PT_METL; - part_change_type(i,x,y,ct); - parts[i].ctype = PT_NONE; - parts[i].life = 4; - if (ct == PT_WATR) - parts[i].life = 64; - if (ct == PT_SLTW) - parts[i].life = 54; - if (ct == PT_SWCH) - parts[i].life = 14; - return 0; - } - if (ct==PT_SPRK) - { - kill_part(i); - return 1; - } - else if (ct==PT_NTCT || ct==PT_PTCT) - { - update_NPTCT(UPDATE_FUNC_SUBCALL_ARGS); - } - else if (ct==PT_ETRD&&parts[i].life==1) - { - nearp = nearest_part(i, PT_ETRD, -1); - if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) - { - create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); - part_change_type(i,x,y,ct); - ct = parts[i].ctype = PT_NONE; - parts[i].life = 20; - part_change_type(nearp,(int)(parts[nearp].x+0.5f),(int)(parts[nearp].y+0.5f),PT_SPRK); - parts[nearp].life = 9; - parts[nearp].ctype = PT_ETRD; - } - } - else if (ct==PT_NBLE&&parts[i].life<=1&&parts[i].temp<5273.15) - { - parts[i].life = rand()%150+50; - part_change_type(i,x,y,PT_PLSM); - parts[i].ctype = PT_NBLE; - parts[i].temp = 3500; - pv[y/CELL][x/CELL] += 1; - } - else if (ct==PT_TESC) // tesla coil code - { - if (parts[i].tmp>300) - parts[i].tmp=300; - 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) - continue; - if (parts[i].tmp>4 && rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) - { - int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); - if (p!=-1) - { - parts[p].life=rand()%(2+parts[i].tmp/15)+parts[i].tmp/7; - if (parts[i].life>60) - parts[i].life=60; - parts[p].temp=parts[p].life*parts[i].tmp/2.5; - parts[p].tmp2=1; - parts[p].tmp=atan2(-ry, rx)/M_PI*360; - parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling - if (fabs(pv[y/CELL][x/CELL])!=0.0f) - { - if (fabs(pv[y/CELL][x/CELL])<=0.5f) - pv[y/CELL][x/CELL]=0; - else - pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5; - } - } - } - } - } - else if (ct==PT_IRON) { - 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) - continue; - if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) || - ((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000)))) - { - if (rand()<RAND_MAX/3) - part_change_type(r>>8,x+rx,y+ry,PT_O2); - else - part_change_type(r>>8,x+rx,y+ry,PT_H2); - } - } - } - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - rt = parts[r>>8].type; - conduct_sprk = 1; - - - pavg = parts_avg(r>>8, i,PT_INSL); - if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL && parts[i].life<4) // make sparked SWCH turn off correctly - { - if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) { - parts[r>>8].life = 10; - } - if (ct==PT_NSCN) { - part_change_type(r>>8,x+rx,y+ry,PT_SWCH); - parts[r>>8].ctype = PT_NONE; - parts[r>>8].life = 9; - } - } - else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN) && parts[i].life<4) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves - { - if (ct==PT_PSCN) parts[r>>8].life = 10; - else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; - } - else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2) && parts[i].life<4) - { - if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2; - else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1; - } - - if (rt == PT_PPIP && parts[i].life == 3 && pavg!=PT_INSL) - { - if (ct == PT_NSCN || ct == PT_PSCN || ct == PT_INST) - PPIP_flood_trigger(x+rx, y+ry, ct); - } - - // ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed - - if (pavg == PT_INSL) conduct_sprk = 0; - if (!(ptypes[rt].properties&PROP_CONDUCTS||rt==PT_INST||rt==PT_QRTZ)) conduct_sprk = 0; - if (abs(rx)+abs(ry)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH) - conduct_sprk = 0; - - - if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))) && pavg!=PT_INSL && parts[i].life<4) - { - parts[r>>8].temp = 473.0f; - if (rt==PT_NTCT||rt==PT_PTCT) - conduct_sprk = 0; - } - if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f))) - conduct_sprk = 0; - if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f))) - conduct_sprk = 0; - if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN)) - conduct_sprk = 0; - if (ct==PT_NSCN && rt==PT_PSCN) - conduct_sprk = 0; - if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)) - conduct_sprk = 0; - if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0; - if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) - conduct_sprk = 0; - if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||pv[(y+ry)/CELL][(x+rx)/CELL]>8))) - conduct_sprk = 0; - if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f))) - conduct_sprk = 0; - if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f))) - conduct_sprk = 0; - if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN)) - conduct_sprk = 0; - if (rt==PT_INST&&ct!=PT_PSCN) - conduct_sprk = 0; - if (rt == PT_NBLE && parts[r>>8].temp > 5273.15) - conduct_sprk = 0; - - if (conduct_sprk) { - if (rt==PT_WATR||rt==PT_SLTW) { - if (parts[r>>8].life==0 && parts[i].life<3) - { - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - if (rt==PT_WATR) parts[r>>8].life = 6; - else parts[r>>8].life = 5; - parts[r>>8].ctype = rt; - } - } - else if (rt==PT_INST) { - if (parts[r>>8].life==0 && parts[i].life<4) - { - flood_INST(x+rx,y+ry,PT_SPRK,PT_INST);//spark the wire - } - } - else if (parts[r>>8].life==0 && parts[i].life<4) { - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON)) - parts[r>>8].temp = parts[r>>8].temp+10.0f; - } - else if (ct==PT_ETRD && parts[i].life==5) - { - part_change_type(i,x,y,ct); - parts[i].ctype = PT_NONE; - parts[i].life = 20; - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - } - } - } - return 0; -} - -int graphics_SPRK(GRAPHICS_FUNC_ARGS) -{ - *firea = 80; - - *firer = 170; - *fireg = 200; - *fireb = 220; - //*pixel_mode |= FIRE_ADD; - *pixel_mode |= FIRE_ADD; - return 1; -} diff --git a/src/elements/stkm.c b/src/elements/stkm.c deleted file mode 100644 index d517844..0000000 --- a/src/elements/stkm.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#define INBOND(x, y) ((x)>=0 && (y)>=0 && (x)<XRES && (y)<YRES) - -#include <element.h> - -int update_SPAWN(UPDATE_FUNC_ARGS) { - if (!player.spwn) - create_part(-1, x, y, PT_STKM); - - return 0; -} - -int update_STKM(UPDATE_FUNC_ARGS) -{ - run_stickman(&player, UPDATE_FUNC_SUBCALL_ARGS); - return 0; -} - -int graphics_STKM(GRAPHICS_FUNC_ARGS) -{ - *colr = *colg = *colb = *cola = 0; - *pixel_mode = PSPEC_STICKMAN; - return 0; -} - -int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { - int r, rx, ry; - int t = parts[i].type; - float pp, d; - float dt = 0.9;///(FPSB*FPSB); //Delta time in square - float gvx, gvy; - float gx, gy, dl, dr; - - if ((parts[i].ctype>0 && parts[i].ctype<PT_NUM && ptypes[parts[i].ctype].enabled && ptypes[parts[i].ctype].falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH) - playerp->elem = parts[i].ctype; - playerp->frames++; - - //Temperature handling - if (parts[i].temp<243) - parts[i].life -= 1; - if ((parts[i].temp<309.6f) && (parts[i].temp>=243)) - parts[i].temp += 1; - - //Death - if (parts[i].life<1 || (pv[y/CELL][x/CELL]>=4.5f && playerp->elem != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... - { - for (r=-2; r<=1; r++) - { - create_part(-1, x+r, y-2, playerp->elem); - create_part(-1, x+r+1, y+2, playerp->elem); - create_part(-1, x-2, y+r+1, playerp->elem); - create_part(-1, x+2, y+r, playerp->elem); - } - kill_part(i); //Kill him - return 1; - } - - //Follow gravity - gvx = gvy = 0.0f; - switch (gravityMode) - { - default: - case 0: - gvy = 1; - break; - case 1: - gvy = gvx = 0.0f; - break; - case 2: - { - float gravd; - gravd = 0.01f - hypotf((parts[i].x - XCNTR), (parts[i].y - YCNTR)); - gvx = ((float)(parts[i].x - XCNTR) / gravd); - gvy = ((float)(parts[i].y - YCNTR) / gravd); - } - } - - gvx += gravx[((int)parts[i].y/CELL)*(XRES/CELL)+((int)parts[i].x/CELL)]; - gvy += gravy[((int)parts[i].y/CELL)*(XRES/CELL)+((int)parts[i].x/CELL)]; - - parts[i].vx -= gvx*dt; //Head up! - parts[i].vy -= gvy*dt; - - //Verlet integration - pp = 2*playerp->legs[0]-playerp->legs[2]+playerp->accs[0]*dt*dt; - playerp->legs[2] = playerp->legs[0]; - playerp->legs[0] = pp; - pp = 2*playerp->legs[1]-playerp->legs[3]+playerp->accs[1]*dt*dt; - playerp->legs[3] = playerp->legs[1]; - playerp->legs[1] = pp; - - pp = 2*playerp->legs[4]-playerp->legs[6]+(playerp->accs[2]+gvx)*dt*dt; - playerp->legs[6] = playerp->legs[4]; - playerp->legs[4] = pp; - pp = 2*playerp->legs[5]-playerp->legs[7]+(playerp->accs[3]+gvy)*dt*dt; - playerp->legs[7] = playerp->legs[5]; - playerp->legs[5] = pp; - - pp = 2*playerp->legs[8]-playerp->legs[10]+playerp->accs[4]*dt*dt; - playerp->legs[10] = playerp->legs[8]; - playerp->legs[8] = pp; - pp = 2*playerp->legs[9]-playerp->legs[11]+playerp->accs[5]*dt*dt; - playerp->legs[11] = playerp->legs[9]; - playerp->legs[9] = pp; - - pp = 2*playerp->legs[12]-playerp->legs[14]+(playerp->accs[6]+gvx)*dt*dt; - playerp->legs[14] = playerp->legs[12]; - playerp->legs[12] = pp; - pp = 2*playerp->legs[13]-playerp->legs[15]+(playerp->accs[7]+gvy)*dt*dt; - playerp->legs[15] = playerp->legs[13]; - playerp->legs[13] = pp; - - //Setting acceleration to 0 - playerp->accs[0] = 0; - playerp->accs[1] = 0; - - playerp->accs[2] = 0; - playerp->accs[3] = 0; - - playerp->accs[4] = 0; - playerp->accs[5] = 0; - - playerp->accs[6] = 0; - playerp->accs[7] = 0; - - gx = (playerp->legs[4] + playerp->legs[12])/2 - gvy; - gy = (playerp->legs[5] + playerp->legs[13])/2 + gvx; - dl = pow(gx - playerp->legs[4], 2) + pow(gy - playerp->legs[5], 2); - dr = pow(gx - playerp->legs[12], 2) + pow(gy - playerp->legs[13], 2); - - //Go left - if (((int)(playerp->comm)&0x01) == 0x01) - { - if (dl>dr) - { - if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) - { - playerp->accs[2] = -3*gvy-3*gvx; - playerp->accs[3] = 3*gvx-3*gvy; - playerp->accs[0] = -gvy; - playerp->accs[1] = gvx; - } - } - else - { - if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) - { - playerp->accs[6] = -3*gvy-3*gvx; - playerp->accs[7] = 3*gvx-3*gvy; - playerp->accs[0] = -gvy; - playerp->accs[1] = gvx; - } - } - } - - //Go right - if (((int)(playerp->comm)&0x02) == 0x02) - { - if (dl<dr) - { - if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) - { - playerp->accs[2] = 3*gvy-3*gvx; - playerp->accs[3] = -3*gvx-3*gvy; - playerp->accs[0] = gvy; - playerp->accs[1] = -gvx; - } - } - else - { - if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) - { - playerp->accs[6] = 3*gvy-3*gvx; - playerp->accs[7] = -3*gvx-3*gvy; - playerp->accs[0] = gvy; - playerp->accs[1] = -gvx; - } - } - } - - //Jump - if (((int)(playerp->comm)&0x04) == 0x04 && - ((INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) - || (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL)))) - { - parts[i].vy -= 4*gvy; - playerp->accs[3] -= gvy; - playerp->accs[7] -= gvy; - } - - //Charge detector wall if foot inside - if (bmap[(int)(playerp->legs[5]+0.5)/CELL][(int)(playerp->legs[4]+0.5)/CELL]==WL_DETECT) - set_emap((int)playerp->legs[4]/CELL, (int)playerp->legs[5]/CELL); - if (bmap[(int)(playerp->legs[13]+0.5)/CELL][(int)(playerp->legs[12]+0.5)/CELL]==WL_DETECT) - set_emap((int)(playerp->legs[12]+0.5)/CELL, (int)(playerp->legs[13]+0.5)/CELL); - - //Searching for particles near head - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - r = photons[y+ry][x+rx]; - - if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL]) - continue; - - if (ptypes[r&0xFF].falldown!=0 || ptypes[r&0xFF].state == ST_GAS - || ptypes[r&0xFF].properties&TYPE_GAS - || ptypes[r&0xFF].properties&TYPE_LIQUID - || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) - { - playerp->elem = r&0xFF; //Current element - } - if ((r&0xFF)==PT_TESC || (r&0xFF)==PT_LIGH) - playerp->elem = PT_LIGH; - if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP - { - if (parts[i].life<=95) - parts[i].life += 5; - else - parts[i].life = 100; - kill_part(r>>8); - } - - if ((r&0xFF) == PT_NEUT) - { - if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2; - else parts[i].life *= 0.9f; - kill_part(r>>8); - } - if (bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN) - playerp->elem = SPC_AIR; - if ((r&0xFF)==PT_PRTI) - STKM_interact(playerp, i, rx, ry); - if (!parts[i].type)//STKM_interact may kill STKM - return 1; - } - - //Head position - rx = x + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01); - ry = y - 3*(playerp->pcomm == 0); - - //Spawn - if (((int)(playerp->comm)&0x08) == 0x08) - { - ry -= 2*(rand()%2)+1; - r = pmap[ry][rx]; - if (ptypes[r&0xFF].state == ST_SOLID) - { - create_part(-1, rx, ry, PT_SPRK); - playerp->frames = 0; - } - else - { - int np = -1; - if (playerp->elem == SPC_AIR) - create_parts(rx + 3*((((int)playerp->pcomm)&0x02) == 0x02) - 3*((((int)playerp->pcomm)&0x01) == 0x01), ry, 4, 4, SPC_AIR, 0, 1); - else if (playerp->elem==PT_LIGH && playerp->frames<30)//limit lightning creation rate - np = -1; - else - np = create_part(-1, rx, ry, playerp->elem); - if ( (np < NPART) && np>=0) - { - if (playerp->elem == PT_PHOT) - { - int random = abs(rand()%3-1)*3; - if (random==0) - { - kill_part(np); - } - else - { - parts[np].vy = 0; - if (((int)playerp->pcomm)&(0x01|0x02)) - parts[np].vx = (((((int)playerp->pcomm)&0x02) == 0x02) - (((int)(playerp->pcomm)&0x01) == 0x01))*random; - else - parts[np].vx = random; - } - } - else if (playerp->elem == PT_LIGH) - { - float angle; - int power = 100; - if (gvx!=0 || gvy!=0) - angle = atan2(gvx, gvy)*180.0f/M_PI; - else - angle = rand()%360; - if (((int)playerp->comm)&0x01) - angle += 180; - if (angle>360) - angle-=360; - if (angle<0) - angle+=360; - parts[np].tmp = angle; - parts[np].life=rand()%(2+power/15)+power/7; - parts[np].temp=parts[np].life*power/2.5; - parts[np].tmp2=1; - } - else if (playerp->elem != SPC_AIR) - { - parts[np].vx -= -gvy*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01)); - parts[np].vy -= gvx*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01)); - parts[i].vx -= (ptypes[(int)playerp->elem].weight*parts[np].vx)/1000; - } - playerp->frames = 0; - } - - } - } - - //Simulation of joints - d = 25/(pow((playerp->legs[0]-playerp->legs[4]), 2) + pow((playerp->legs[1]-playerp->legs[5]), 2)+25) - 0.5; //Fast distance - playerp->legs[4] -= (playerp->legs[0]-playerp->legs[4])*d; - playerp->legs[5] -= (playerp->legs[1]-playerp->legs[5])*d; - playerp->legs[0] += (playerp->legs[0]-playerp->legs[4])*d; - playerp->legs[1] += (playerp->legs[1]-playerp->legs[5])*d; - - d = 25/(pow((playerp->legs[8]-playerp->legs[12]), 2) + pow((playerp->legs[9]-playerp->legs[13]), 2)+25) - 0.5; - playerp->legs[12] -= (playerp->legs[8]-playerp->legs[12])*d; - playerp->legs[13] -= (playerp->legs[9]-playerp->legs[13])*d; - playerp->legs[8] += (playerp->legs[8]-playerp->legs[12])*d; - playerp->legs[9] += (playerp->legs[9]-playerp->legs[13])*d; - - d = 36/(pow((playerp->legs[0]-parts[i].x), 2) + pow((playerp->legs[1]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (playerp->legs[0]-parts[i].x)*d; - parts[i].vy -= (playerp->legs[1]-parts[i].y)*d; - playerp->legs[0] += (playerp->legs[0]-parts[i].x)*d; - playerp->legs[1] += (playerp->legs[1]-parts[i].y)*d; - - d = 36/(pow((playerp->legs[8]-parts[i].x), 2) + pow((playerp->legs[9]-parts[i].y), 2)+36) - 0.5; - parts[i].vx -= (playerp->legs[8]-parts[i].x)*d; - parts[i].vy -= (playerp->legs[9]-parts[i].y)*d; - playerp->legs[8] += (playerp->legs[8]-parts[i].x)*d; - playerp->legs[9] += (playerp->legs[9]-parts[i].y)*d; - - if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) - { - playerp->legs[4] = playerp->legs[6]; - playerp->legs[5] = playerp->legs[7]; - } - - if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) - { - playerp->legs[12] = playerp->legs[14]; - playerp->legs[13] = playerp->legs[15]; - } - - //This makes stick man "pop" from obstacles - if (INBOND(playerp->legs[4], playerp->legs[5]) && !eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) - { - float t; - t = playerp->legs[4]; playerp->legs[4] = playerp->legs[6]; playerp->legs[6] = t; - t = playerp->legs[5]; playerp->legs[5] = playerp->legs[7]; playerp->legs[7] = t; - } - - if (INBOND(playerp->legs[12], playerp->legs[13]) && !eval_move(t, playerp->legs[12], playerp->legs[13], NULL)) - { - float t; - t = playerp->legs[12]; playerp->legs[12] = playerp->legs[14]; playerp->legs[14] = t; - t = playerp->legs[13]; playerp->legs[13] = playerp->legs[15]; playerp->legs[15] = t; - } - - //Keeping legs distance - if ((pow((playerp->legs[4] - playerp->legs[12]), 2) + pow((playerp->legs[5]-playerp->legs[13]), 2))<16) - { - float tvx, tvy; - tvx = -gvy; - tvy = gvx; - - if (tvx || tvy) - { - playerp->accs[2] -= 0.2*tvx/hypot(tvx, tvy); - playerp->accs[3] -= 0.2*tvy/hypot(tvx, tvy); - - playerp->accs[6] += 0.2*tvx/hypot(tvx, tvy); - playerp->accs[7] += 0.2*tvy/hypot(tvx, tvy); - } - } - - if ((pow((playerp->legs[0] - playerp->legs[8]), 2) + pow((playerp->legs[1]-playerp->legs[9]), 2))<16) - { - float tvx, tvy; - tvx = -gvy; - tvy = gvx; - - if (tvx || tvy) - { - playerp->accs[0] -= 0.2*tvx/hypot(tvx, tvy); - playerp->accs[1] -= 0.2*tvy/hypot(tvx, tvy); - - playerp->accs[4] += 0.2*tvx/hypot(tvx, tvy); - playerp->accs[5] += 0.2*tvy/hypot(tvx, tvy); - } - } - - //If legs touch something - STKM_interact(playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5)); - STKM_interact(playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5)); - STKM_interact(playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]); - STKM_interact(playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]); - if (!parts[i].type) - return 1; - - parts[i].ctype = playerp->elem; - return 0; -} - -void STKM_interact(playerst* playerp, int i, int x, int y) -{ - int r; - if (x<0 || y<0 || x>=XRES || y>=YRES || !parts[i].type) - return; - r = pmap[y][x]; - if (r) - { - if ((r&0xFF)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge - { - parts[i].life -= (int)(rand()*20/RAND_MAX)+32; - } - - if (ptypes[r&0xFF].hconduct && ((playerp->elem!=PT_LIGH && parts[r>>8].temp>=323) || parts[r>>8].temp<=243)) - { - parts[i].life -= 2; - playerp->accs[3] -= 1; - } - - if (ptypes[r&0xFF].properties&PROP_DEADLY) - switch (r&0xFF) - { - case PT_ACID: - parts[i].life -= 5; - break; - default: - parts[i].life -= 1; - } - - if (ptypes[r&0xFF].properties&PROP_RADIOACTIVE) - parts[i].life -= 1; - - if ((r&0xFF)==PT_PRTI && parts[i].type) - { - int nnx, count=1;//gives rx=0, ry=1 in update_PRTO - parts[r>>8].tmp = (int)((parts[r>>8].temp-73.15f)/100+1); - if (parts[r>>8].tmp>=CHANNELS) parts[r>>8].tmp = CHANNELS-1; - else if (parts[r>>8].tmp<0) parts[r>>8].tmp = 0; - for (nnx=0; nnx<80; nnx++) - if (!portalp[parts[r>>8].tmp][count][nnx].type) - { - portalp[parts[r>>8].tmp][count][nnx] = parts[i]; - kill_part(i); - //stop new STKM/fighters being created to replace the ones in the portal: - playerp->spwn = 1; - if (portalp[parts[r>>8].tmp][count][nnx].type==PT_FIGH) - fighcount++; - break; - } - } - - if (((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) && parts[i].type) - { - if (!legacy_enable) - { - parts[r>>8].temp = restrict_flt(parts[r>>8].temp+parts[i].temp/2, MIN_TEMP, MAX_TEMP); - } - kill_part(i); - } - if (((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && parts[r>>8].life==10)) && (!parts[r>>8].ctype || (parts[r>>8].ctype==parts[i].type)!=(parts[r>>8].tmp&1)) && parts[i].type) - { - kill_part(i); - } - } -} - -void STKM_init_legs(playerst* playerp, int i) -{ - int x, y; - - x = (int)(parts[i].x+0.5f); - y = (int)(parts[i].y+0.5f); - - playerp->legs[0] = x-1; - playerp->legs[1] = y+6; - playerp->legs[2] = x-1; - playerp->legs[3] = y+6; - - playerp->legs[4] = x-3; - playerp->legs[5] = y+12; - playerp->legs[6] = x-3; - playerp->legs[7] = y+12; - - playerp->legs[8] = x+1; - playerp->legs[9] = y+6; - playerp->legs[10] = x+1; - playerp->legs[11] = y+6; - - playerp->legs[12] = x+3; - playerp->legs[13] = y+12; - playerp->legs[14] = x+3; - playerp->legs[15] = y+12; -} diff --git a/src/elements/stkm2.c b/src/elements/stkm2.c deleted file mode 100644 index a83f0d0..0000000 --- a/src/elements/stkm2.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SPAWN2(UPDATE_FUNC_ARGS) { - if (!player2.spwn) - create_part(-1, x, y, PT_STKM2); - - return 0; -} - -int update_STKM2(UPDATE_FUNC_ARGS) { - run_stickman(&player2, UPDATE_FUNC_SUBCALL_ARGS); - return 0; -}
\ No newline at end of file diff --git a/src/elements/stor.c b/src/elements/stor.c deleted file mode 100644 index 72cfef6..0000000 --- a/src/elements/stor.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_STOR(UPDATE_FUNC_ARGS) { - int r, rx, ry, np, rx1, ry1; - if(parts[i].life && !parts[i].tmp) - parts[i].life--; - 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)) - { - r = pmap[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(ptypes[(r&0xFF)].properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype)) - { - parts[i].tmp = parts[r>>8].type; - parts[i].temp = parts[r>>8].temp; - parts[i].tmp2 = parts[r>>8].life; - parts[i].pavg[0] = parts[r>>8].tmp; - parts[i].pavg[1] = parts[r>>8].ctype; - kill_part(r>>8); - } - if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life>0 && parts[r>>8].life<4) - { - for(ry1 = 1; ry1 >= -1; ry1--){ - for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1) - np = create_part(-1,x+rx1,y+ry1,parts[i].tmp); - if (np!=-1) - { - parts[np].temp = parts[i].temp; - parts[np].life = parts[i].tmp2; - parts[np].tmp = parts[i].pavg[0]; - parts[np].ctype = parts[i].pavg[1]; - parts[i].tmp = 0; - parts[i].life = 10; - break; - } - } - } - } - } - return 0; -} diff --git a/src/elements/swch.c b/src/elements/swch.c deleted file mode 100644 index d0acf45..0000000 --- a/src/elements/swch.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_SWCH(UPDATE_FUNC_ARGS) { - int r, rt, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { - rt = r&0xFF; - if (rt==PT_SWCH) - { - if (parts[i].life>=10&&parts[r>>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[i].life==0&&parts[r>>8].life>=10) - { - //Set to other particle's life instead of 10, otherwise spark loops form when SWCH is sparked while turning on - parts[i].life = parts[r>>8].life; - } - } - else if (rt==PT_SPRK&&parts[i].life==10&&parts[r>>8].ctype!=PT_PSCN&&parts[r>>8].ctype!=PT_NSCN) { - part_change_type(i,x,y,PT_SPRK); - parts[i].ctype = PT_SWCH; - parts[i].life = 4; - } - } - } - //turn off SWCH from two red BRAYS - if (parts[i].life==10 && (!(pmap[y-1][x-1]&0xFF) && ((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) && !(pmap[y-1][x+1]&0xFF) && ((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2))) - { - parts[i].life = 9; - } - //turn on SWCH from two red BRAYS - else if (parts[i].life<=5 && (!(pmap[y-1][x-1]&0xFF) && (((pmap[y-1][x]&0xFF)==PT_BRAY&&parts[pmap[y-1][x]>>8].tmp==2) || ((pmap[y+1][x]&0xFF)==PT_BRAY&&parts[pmap[y+1][x]>>8].tmp==2)) && !(pmap[y-1][x+1]&0xFF) && (((pmap[y][x+1]&0xFF)==PT_BRAY&&parts[pmap[y][x+1]>>8].tmp==2) || ((pmap[y][x-1]&0xFF)==PT_BRAY&&parts[pmap[y][x-1]>>8].tmp==2)))) - { - parts[i].life = 14; - } - return 0; -} diff --git a/src/elements/thdr.c b/src/elements/thdr.c deleted file mode 100644 index f1aafa3..0000000 --- a/src/elements/thdr.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_THDR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) - { - parts[i].type = PT_NONE; - parts[r>>8].ctype = parts[r>>8].type; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; - } - else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF)) - { - pv[y/CELL][x/CELL] += 100.0f; - if (legacy_enable&&1>(rand()%200)) - { - parts[i].life = rand()%50+120; - part_change_type(i,x,y,PT_FIRE); - } - else - { - parts[i].type = PT_NONE; - } - } - } - if (parts[i].type==PT_NONE) { - kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/thrm.c b/src/elements/thrm.c deleted file mode 100644 index b953d72..0000000 --- a/src/elements/thrm.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_THRM(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO? - { - if (1>(rand()%500)) { - part_change_type(i,x,y,PT_LAVA); - parts[i].ctype = PT_BMTL; - parts[i].temp = 3500.0f; - pv[y/CELL][x/CELL] += 50.0f; - } else { - part_change_type(i,x,y,PT_LAVA); - parts[i].life = 400; - parts[i].ctype = PT_THRM; - parts[i].temp = 3500.0f; - parts[i].tmp = 20; - } - } - } - return 0; -} diff --git a/src/elements/tron.c b/src/elements/tron.c deleted file mode 100644 index 4c50321..0000000 --- a/src/elements/tron.c +++ /dev/null @@ -1,206 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -/* TRON element is meant to resemble a tron bike (or worm) moving around and trying to avoid obstacles itself. - * It has four direction each turn to choose from, 0 (left) 1 (up) 2 (right) 3 (down). - * Each turn has a small random chance to randomly turn one way (so it doesn't do the exact same thing in a large room) - * If the place it wants to move isn't a barrier, it will try and 'see' infront of itself to determine its safety. - * For now the tron can only see its own body length in pixels ahead of itself (and around corners) - * - - - - - - - - - - - * - - - - + - - - - - - * - - - + + + - - - - - * - - +<--+-->+ - - - - * - +<----+---->+ - - - * - - - - H - - - - - - * Where H is the head with tail length 4, it checks the + area to see if it can hit any of the edges, then it is called safe, or picks the biggest area if none safe. - * .tmp bit values: 1st head, 2nd no tail growth, 3rd wait flag, 4th Nodie, 5th Dying, 6th & 7th is direction, 8th - 16th hue - * .tmp2 is tail length (gets longer every few hundred frames) - * .life is the timer that kills the end of the tail (the head uses life for how often it grows longer) - * .ctype Contains the colour, lost on save, regenerated using hue tmp (bits 7 - 16) - */ -#define TRON_HEAD 1 -#define TRON_NOGROW 2 -#define TRON_WAIT 4 //it was just created, so WAIT a frame -#define TRON_NODIE 8 -#define TRON_DEATH 16 //Crashed, now dying -int tron_rx[4] = {-1, 0, 1, 0}; -int tron_ry[4] = { 0,-1, 0, 1}; -unsigned int tron_colours[32]; -int new_tronhead(int x, int y, int i, int direction) -{ - int np = create_part(-1, x , y ,PT_TRON); - if (np==-1) - return -1; - if (parts[i].life >= 100) // increase tail length - { - if (!(parts[i].tmp&TRON_NOGROW)) - parts[i].tmp2++; - parts[i].life = 5; - } - //give new head our properties - parts[np].tmp = 1 | direction<<5 | parts[i].tmp&(TRON_NOGROW|TRON_NODIE) | (parts[i].tmp&0xF800); - if (np > i) - parts[np].tmp |= TRON_WAIT; - - parts[np].ctype = parts[i].ctype; - parts[np].tmp2 = parts[i].tmp2; - parts[np].life = parts[i].life + 2; - return 1; -} -int trymovetron(int x, int y, int dir, int i, int len) -{ - int k,j,r,rx,ry,tx,ty,count; - count = 0; - rx = x; - ry = y; - for (k = 1; k <= len; k ++) - { - rx += tron_rx[dir]; - ry += tron_ry[dir]; - r = pmap[ry][rx]; - if (!r && !bmap[(ry)/CELL][(rx)/CELL] && ry > CELL && rx > CELL && ry < YRES-CELL && rx < XRES-CELL) - { - count++; - for (tx = rx - tron_ry[dir] , ty = ry - tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx-=tron_ry[dir],ty-=tron_rx[dir],j++) - { - r = pmap[ty][tx]; - if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL) - { - if (j == (len-k))//there is a safe path, so we can break out - return len+1; - count++; - } - else //we hit a block so no need to check farther here - break; - } - for (tx = rx + tron_ry[dir] , ty = ry + tron_rx[dir], j=1; abs(tx-rx) < (len-k) && abs(ty-ry) < (len-k); tx+=tron_ry[dir],ty+=tron_rx[dir],j++) - { - r = pmap[ty][tx]; - if (!r && !bmap[(ty)/CELL][(tx)/CELL] && ty > CELL && tx > CELL && ty < YRES-CELL && tx < XRES-CELL) - { - if (j == (len-k)) - return len+1; - count++; - } - else - break; - } - } - else //a block infront, no need to continue - break; - } - return count; -} -int update_TRON(UPDATE_FUNC_ARGS) { - int r, rx, ry, np; - if (parts[i].tmp&TRON_WAIT) - { - parts[i].tmp &= ~TRON_WAIT; - return 0; - } - if (parts[i].tmp&TRON_HEAD) - { - int firstdircheck = 0,seconddir,seconddircheck = 0,lastdir,lastdircheck = 0; - int direction = (parts[i].tmp>>5 & 0x3); - int originaldir = direction; - - //random turn - int random = rand()%340; - if (random==1 || random==3) - { - //randomly turn left(3) or right(1) - direction = (direction + random)%4; - } - - //check infront - //do sight check - firstdircheck = trymovetron(x,y,direction,i,parts[i].tmp2); - if (firstdircheck < parts[i].tmp2) - { - if (originaldir != direction) //if we just tried a random turn, don't pick random again - { - seconddir = originaldir; - lastdir = (direction + 2)%4; - } - else - { - seconddir = (direction + ((rand()%2)*2)+1)% 4; - lastdir = (seconddir + 2)%4; - } - seconddircheck = trymovetron(x,y,seconddir,i,parts[i].tmp2); - lastdircheck = trymovetron(x,y,lastdir,i,parts[i].tmp2); - } - //find the best move - if (seconddircheck > firstdircheck) - direction = seconddir; - if (lastdircheck > seconddircheck && lastdircheck > firstdircheck) - direction = lastdir; - //now try making new head, even if it fails - if (new_tronhead(x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1) - { - //ohgod crash - parts[i].tmp |= TRON_DEATH; - //trigger tail death for TRON_NODIE, or is that mode even needed? just set a high tail length(but it still won't start dying when it crashes) - } - - //set own life and clear .tmp (it dies if it can't move anyway) - parts[i].life = parts[i].tmp2; - parts[i].tmp &= parts[i].tmp&0xF818; - } - else // fade tail deco, or prevent tail from dieing - { - if (parts[i].tmp&TRON_NODIE) - parts[i].life++; - //parts[i].dcolour = clamp_flt((float)parts[i].life/(float)parts[i].tmp2,0,1.0f) << 24 | parts[i].dcolour&0x00FFFFFF; - } - return 0; -} - -int graphics_TRON(GRAPHICS_FUNC_ARGS) { - unsigned int col = tron_colours[(cpart->tmp&0xF800)>>11]; - if(cpart->tmp & TRON_HEAD) - *pixel_mode |= PMODE_GLOW; - *colr = (col & 0xFF0000)>>16; - *colg = (col & 0x00FF00)>>8; - *colb = (col & 0x0000FF); - if(cpart->tmp & TRON_DEATH) - { - *pixel_mode |= FIRE_ADD | PMODE_FLARE; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *firea = 255; - } - if(cpart->life < cpart->tmp2 && !(cpart->tmp & TRON_HEAD)) - { - *pixel_mode |= PMODE_BLEND; - *pixel_mode &= ~PMODE_FLAT; - *cola = (int)((((float)cpart->life)/((float)cpart->tmp2))*255.0f); - } - return 0; -} - -void TRON_init_graphics() -{ - int i; - int r, g, b; - for (i=0; i<32; i++) - { - HSV_to_RGB(i<<4,255,255,&r,&g,&b); - tron_colours[i] = r<<16 | g<<8 | b; - } -} diff --git a/src/elements/ttan.c b/src/elements/ttan.c deleted file mode 100644 index 9023939..0000000 --- a/src/elements/ttan.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_TTAN(UPDATE_FUNC_ARGS) { - int nx, ny, ttan = 0; - if(nt<=2) - ttan = 2; - else if(parts[i].tmp) - ttan = 2; - else if(nt<=6) - for (nx=-1; nx<2; nx++) { - for (ny=-1; ny<2; ny++) { - if ((!nx != !ny) && x+nx>=0 && y+ny>=0 && x+nx<XRES && y+ny<YRES) { - if((pmap[y+ny][x+nx]&0xFF)==PT_TTAN) - ttan++; - } - } - } - - if(ttan>=2) { - bmap_blockair[y/CELL][x/CELL] = 1; - bmap_blockairh[y/CELL][x/CELL] = 1; - } - return 0; -} diff --git a/src/elements/uran.c b/src/elements/uran.c deleted file mode 100644 index e5b971b..0000000 --- a/src/elements/uran.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_URAN(UPDATE_FUNC_ARGS) { - if (!legacy_enable && pv[y/CELL][x/CELL]>0.0f) - { - float atemp = parts[i].temp + (-MIN_TEMP); - parts[i].temp = restrict_flt((atemp*(1+(pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP); - } - return 0; -} diff --git a/src/elements/vine.c b/src/elements/vine.c deleted file mode 100644 index 5af5d48..0000000 --- a/src/elements/vine.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_VINE(UPDATE_FUNC_ARGS) { - int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (1>rand()%15) - part_change_type(i,x,y,PT_PLNT); - else if (!r) - { - np = create_part(-1,x+rx,y+ry,PT_VINE); - if (np<0) return 0; - parts[np].temp = parts[i].temp; - parts[i].tmp = 1; - part_change_type(i,x,y,PT_PLNT); - } - } - return 0; -} diff --git a/src/elements/warp.c b/src/elements/warp.c deleted file mode 100644 index 42f2d3a..0000000 --- a/src/elements/warp.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WARP(UPDATE_FUNC_ARGS) { - int trade, r, rx, ry; - - if (parts[i].tmp2>2000) - { - parts[i].temp = 10000; - pv[y/CELL][x/CELL] += (parts[i].tmp2/5000) * CFDS; - if (2>rand()%100) - create_part(-3, x, y, PT_ELEC); - } - for ( trade = 0; trade<5; trade ++) - { - rx = rand()%3-1; - ry = rand()%3-1; - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - 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) - { - 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[r>>8].vx = (rand()%4)-1.5; - parts[r>>8].vy = (rand()%4)-2; - parts[i].life += 4; - pmap[y][x] = r; - pmap[y+ry][x+rx] = (i<<8)|parts[i].type; - trade = 5; - } - } - } - return 0; -} -int graphics_WARP(GRAPHICS_FUNC_ARGS) -{ - *colr = *colg = *colb = *cola = 0; - *pixel_mode &= ~PMODE; - return 0; -} diff --git a/src/elements/watr.c b/src/elements/watr.c deleted file mode 100644 index ecf96aa..0000000 --- a/src/elements/watr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WATR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_SALT && 1>(rand()%250)) - { - part_change_type(i,x,y,PT_SLTW); - // on average, convert 3 WATR to SLTW before SALT turns into SLTW - if (rand()%3==0) - part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - kill_part(r>>8); - if(1>(rand()%150)){ - kill_part(i); - return 1; - } - } - if ((r&0xFF)==PT_SLTW && 1>(rand()%10000)) - { - part_change_type(i,x,y,PT_SLTW); - } - /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular - { - part_change_type(i,x,y,PT_PSTE); - kill_part(r>>8); - }*/ - } - return 0; -} diff --git a/src/elements/wifi.c b/src/elements/wifi.c deleted file mode 100644 index 40e1f96..0000000 --- a/src/elements/wifi.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WIFI(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; - else if (parts[i].tmp<0) parts[i].tmp = 0; - 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) - continue; - // wireless[][0] - whether channel is active on this frame - // wireless[][1] - whether channel should be active on next frame - if (wireless[parts[i].tmp][0]) - { - if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && wireless[parts[i].tmp][0]) - { - parts[r>>8].ctype = r&0xFF; - part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; - } - } - else - { - if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) - { - wireless[parts[i].tmp][1] = 1; - ISWIRE = 2; - } - } - } - return 0; -} diff --git a/src/elements/wire.c b/src/elements/wire.c deleted file mode 100644 index 81b1d5f..0000000 --- a/src/elements/wire.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WIRE(UPDATE_FUNC_ARGS) { - int s,r,rx,ry,count; - /* - 0: wire - 1: spark head - 2: spark tail - - tmp is previous state, ctype is current state - */ - //parts[i].tmp=parts[i].ctype; - parts[i].ctype=0; - if(parts[i].tmp==1) - { - parts[i].ctype=2; - } - if(parts[i].tmp==2) - { - parts[i].ctype=0; - } - - count=0; - 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) - continue; - if((r&0xFF)==PT_SPRK && parts[r>>8].life==3 && parts[r>>8].ctype==PT_PSCN) - { - parts[i].ctype=1; - return 0; - } - else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);} - else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;} - } - } - if(count==1 || count==2) - parts[i].ctype=1; - return 0; -} - -int graphics_WIRE(GRAPHICS_FUNC_ARGS) -{ - if (cpart->ctype==0) - { - *colr = 255; - *colg = 204; - *colb = 0; - return 0; - } - if (cpart->ctype==1) - { - *colr = 50; - *colg = 100; - *colb = 255; - //*pixel_mode |= PMODE_GLOW; - return 0; - } - if (cpart->ctype==2) - { - *colr = 255; - *colg = 100; - *colb = 50; - //*pixel_mode |= PMODE_GLOW; - return 0; - } -} diff --git a/src/elements/wood.c b/src/elements/wood.c deleted file mode 100644 index e5fec9a..0000000 --- a/src/elements/wood.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WOOD(UPDATE_FUNC_ARGS) { - if (parts[i].temp > 550 && parts[i].temp > parts[i].tmp) - parts[i].tmp = (int)parts[i].temp; - return 0; -} - -int graphics_WOOD(GRAPHICS_FUNC_ARGS) -{ - float maxtemp = fmax(cpart->tmp,cpart->temp); - if (maxtemp > 400) - { - *colr -= (int)restrict_flt((maxtemp-400)/3,0,172); - *colg -= (int)restrict_flt((maxtemp-400)/4,0,140); - *colb -= (int)restrict_flt((maxtemp-400)/20,0,44); - } - if (maxtemp < 273) - { - *colr -= (int)restrict_flt((273-maxtemp)/5,0,40); - *colg += (int)restrict_flt((273-maxtemp)/4,0,40); - *colb += (int)restrict_flt((273-maxtemp)/1.5,0,150); - } - return 0; -} diff --git a/src/elements/wtrv.c b/src/elements/wtrv.c deleted file mode 100644 index b7f94cf..0000000 --- a/src/elements/wtrv.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_WTRV(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) - { - part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - } - if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE) - parts[i].temp-=parts[i].temp/1000; - return 0; -} diff --git a/src/elements/yest.c b/src/elements/yest.c deleted file mode 100644 index afd6243..0000000 --- a/src/elements/yest.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include <element.h> - -int update_YEST(UPDATE_FUNC_ARGS) { - int r, rx, ry; - 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)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable) - { - part_change_type(i,x,y,PT_DYST); - } - } - if (parts[i].temp>303&&parts[i].temp<317) { - create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST); - } - return 0; -} |
