From bf1d90d7c3283b9a145ea98d6b1802465ea259b4 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 11 Nov 2010 11:02:02 -0500 Subject: [PATCH] CRAC improvements. Resistant to fire when wet, steams when hot, fixed wall errors. --- includes/powder.h | 4 +- src/powder.c | 128 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 92 insertions(+), 40 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 255c5d7d1..28f05c6f3 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -310,7 +310,7 @@ static const part_type ptypes[PT_NUM] = {"34", PIXPACK(0x500050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "34! (34/34)", TYPE_SOLID}, {"LLIF", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Long Life! (5/345)", TYPE_SOLID}, {"STAN", PIXPACK(0x5000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Stains! (235678/3678)", TYPE_SOLID}, - {"CRAC", PIXPACK(0xF0F0BA), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP + 273.15f, 140, "A cracker acting like a sponge", TYPE_SOLID}, + {"CRAC", PIXPACK(0xFFBE30), 0.00f, 0.00f * CFDS, 0.00f, 1.00f, 0.00f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 1, 30, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "cracker64 - Spongey, Made by himself",TYPE_SOLID}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins(real world, by triclops200) Description }; @@ -407,7 +407,7 @@ static part_state pstates[PT_NUM] = /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* GOL */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, - /* CRAC */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* Crac */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 22730.0f}, }; static int grule[NGOL][9] = { diff --git a/src/powder.c b/src/powder.c index a371c635e..edc8f9e0f 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1904,45 +1904,97 @@ void update_particles_i(pixel *vid, int start, int inc) else if(t==PT_CRAC) { if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3) - { + { + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r || parts[i].temp>374.0f) + continue; + if(parts[r>>8].type==PT_WATR&&33>=rand()/(RAND_MAX/100)+1) + { + parts[i].life++; + parts[r>>8].type=PT_NONE; + } + } + } + else + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + if((bmap[(y+ny)/CELL][(x+nx)/CELL]==8||bmap[(y+ny)/CELL][(x+nx)/CELL]==7||bmap[(y+ny)/CELL][(x+nx)/CELL]==2||bmap[(y+ny)/CELL][(x+nx)/CELL]==1|| + bmap[(y+ny)/CELL][(x+nx)/CELL]==9||bmap[(y+ny)/CELL][(x+nx)/CELL]==10||bmap[(y+ny)/CELL][(x+nx)/CELL]==13)) + continue; + if((!r)&&parts[i].life>=1)//if nothing then create water + { + create_part(-1,x+nx,y+ny,PT_WATR); + parts[i].life--; + } + } + for(int trade = 0; trade<9;trade ++) + { + nx = rand()%5-2; + ny = rand()%5-2; + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0&&!((r>>8)>=NPART || !r))//diffusion + { + int temp = parts[i].life - parts[r>>8].life; + if(temp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + trade = 9; + } + else if(temp>0) + { + parts[r>>8].life += temp/2; + parts[i].life -= temp/2; + trade = 9; + } + } + } + } for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8].type==PT_WATR&&5>=rand()%100) - { - parts[i].life++; - parts[r>>8].type=PT_NONE; - } + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type==PT_FIRE&&parts[i].life>0) + { + if(parts[i].life<=2) + parts[i].life --; + parts[i].life -= parts[i].life/3; + } } - } - else - for(nx=-1; nx<2; nx++) - for(ny=-1; ny<2; ny++) - if(x+nx>=0 && y+ny>0 && - x+nx>8)>=NPART || !r )&&parts[i].life>=1)//if nothing then create water - { - create_part(-1,x+nx,y+ny,PT_WATR); - parts[i].life --; - } - } - nx = rand()%5-2; - ny = rand()%5-2; - if(x+nx>=0 && y+ny>0 && - x+nx>8].type==t&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0&&!((r>>8)>=NPART || !r))//diffusion - { - parts[r>>8].life ++; - parts[i].life --; - } - } + if(parts[i].temp>=374) + for(nx=-1; nx<2; nx++) + for(ny=-1; ny<2; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART) + continue; + if((bmap[(y+ny)/CELL][(x+nx)/CELL]==8||bmap[(y+ny)/CELL][(x+nx)/CELL]==3||bmap[(y+ny)/CELL][(x+nx)/CELL]==2||bmap[(y+ny)/CELL][(x+nx)/CELL]==1||bmap[(y+ny)/CELL][(x+nx)/CELL]==10)) + continue; + if((!r)&&parts[i].life>=1)//if nothing then create steam + { + create_part(-1,x+nx,y+ny,PT_WTRV); + parts[i].life--; + parts[r>>8].temp = parts[i].temp; + parts[i].temp -= 40.0f; + } + } } else if(t==PT_LCRY) { @@ -2208,7 +2260,7 @@ void update_particles_i(pixel *vid, int start, int inc) rt = parts[r>>8].type; if((a || ptypes[rt].explosive) && ((rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL && rt!=PT_SWCH) || t!=PT_SPRK) && !(t==PT_PHOT && rt==PT_INSL) && - (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && + (t!=PT_LAVA || parts[i].life>0 || (rt!=PT_STNE && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SWCH && rt!=PT_INWR)) && !(rt==PT_CRAC && parts[r>>8].life>0) && ptypes[rt].flammable && (ptypes[rt].flammable + (int)(pv[(y+ny)/CELL][(x+nx)/CELL]*10.0f))>(rand()%1000)) { parts[r>>8].type = PT_FIRE;