From 65a60b3812b708620b4ff4b13c3521fa5e4547ab Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Fri, 24 Dec 2010 15:00:59 -0500 Subject: [PATCH 1/4] updated with BOMB --- includes/powder.h | 9 ++++-- src/graphics.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ src/powder.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 3 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 150262beb..3b03aa3f4 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -176,7 +176,8 @@ #define PT_ARAY 126 #define PT_BRAY 127 #define PT_STKM2 128 -#define PT_NUM 129 +#define PT_BOMB 129 +#define PT_NUM 130 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -202,6 +203,7 @@ #define PROP_NEUTABSORB 0x0100 //256 Absorbs neutrons, reflect is default #define PROP_NEUTPASS 0x0200 //512 Neutrons pass through, such as with glass #define PROP_DEADLY 0x0400 //1024 Is deadly for stickman. +#define PROP_HOT_GLOW 0x0800 //2048 Hot Metal Glow #define FLAG_STAGNANT 1 struct particle @@ -397,8 +399,8 @@ static const part_type ptypes[PT_NUM] = {"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emmitter. Rays create points when they collide", TYPE_SOLID, NULL}, {"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL}, {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL}, - - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description + {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", TYPE_PART, NULL}, + //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; static part_state pstates[PT_NUM] = @@ -533,6 +535,7 @@ static part_state pstates[PT_NUM] = /* ARAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* BRAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* STKM2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f}, + /* BOMB */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, }; static int grule[NGOL][9] = diff --git a/src/graphics.c b/src/graphics.c index e719a0421..9beeeb07e 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2425,6 +2425,76 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); } } + else if(t==PT_BOMB){ + if(parts[i].tmp==0){ + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + if(cmode != CM_NOTHING && cmode != CM_CRACK){ + int newx = 0; + float gradv = 100; + blendpixel(vid, nx+1, ny, cr, cg, cb, 223); + blendpixel(vid, nx-1, ny, cr, cg, cb, 223); + blendpixel(vid, nx, ny+1, cr, cg, cb, 223); + blendpixel(vid, nx, ny-1, cr, cg, cb, 223); + + blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112); + blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112); + blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112); + for(newx = 0; gradv>0.5; newx++){ + addpixel(vid, nx+newx, ny, cr, cg, cb, gradv); + addpixel(vid, nx-newx, ny, cr, cg, cb, gradv); + + addpixel(vid, nx, ny+newx, cr, cg, cb, gradv); + addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); + gradv = gradv/1.1f; + } + } + } + else if(parts[i].tmp==1){ + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + if(cmode != CM_NOTHING && cmode != CM_CRACK){ + int newx = 0; + float gradv = 4*parts[i].life; + for(newx = 0; gradv>0.5; newx++){ + addpixel(vid, nx+newx, ny, cr, cg, cb, gradv); + addpixel(vid, nx-newx, ny, cr, cg, cb, gradv); + + addpixel(vid, nx, ny+newx, cr, cg, cb, gradv); + addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); + gradv = gradv/1.5f; + } + } + } + else { + blendpixel(vid, nx, ny, 255, 255, 255, 255); + } + + } + else if(ptypes[t].properties&PROP_HOT_GLOW && parts[i].temp>473.0f) + { + float frequency = 0.00146; + int q = (parts[i].temp>1370)?1370-473:parts[i].temp-473; + cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors); + cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors); + cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors); + if(cr>=255) + cr = 255; + if(cg>=255) + cg = 255; + if(cb>=255) + cb = 255; + if(cr<=0) + cr = 0; + if(cg<=0) + cg = 0; + if(cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } else if(t==PT_FIRE && parts[i].life) { float ttemp = (float)((int)(parts[i].life/2)); diff --git a/src/powder.c b/src/powder.c index 02a740fbf..ad3c9b688 100644 --- a/src/powder.c +++ b/src/powder.c @@ -133,6 +133,10 @@ int try_move(int i, int x, int y, int nx, int ny) return 1; e = eval_move(parts[i].type, nx, ny, &r); + + if((pmap[ny][nx]&0xFF)==PT_BOMB && parts[i].type==PT_BOMB && parts[i].tmp == 1) + e = 2; + if((pmap[ny][nx]&0xFF)==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f)) return 1; /* half-silvered mirror */ @@ -2788,6 +2792,66 @@ void update_particles_i(pixel *vid, int start, int inc) } } } + else if(t==PT_BOMB) + { + if(parts[i].tmp==1){ + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB){ + parts[i].type = PT_NONE; + goto killed; + } + } + } else if(parts[i].tmp==0){ + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB){ + int rad = 8; + int nxi; + int nxj; + pmap[y][x] = 0; + 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){ + int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + if(nb!=-1){ + parts[nb].tmp = 1; + parts[nb].life = 50; + parts[nb].temp = MAX_TEMP; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + } + } + 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){ + delete_part(x+nxi, y+nxj); + pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; + int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + if(nb!=-1){ + parts[nb].tmp = 2; + parts[nb].life = 2; + parts[nb].temp = MAX_TEMP; + } + } + //create_parts(x, y, 9, 9, PT_BOMB); + //create_parts(x, y, 8, 8, PT_NONE); + parts[i].type = PT_NONE; + goto killed; + } + } + } + } else if(t==PT_FWRK) { if((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) From 0dbb53606bca11d98cef874ff3c117c980e2b909 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Fri, 24 Dec 2010 15:59:27 -0500 Subject: [PATCH 2/4] forgot PROP thing in powder.h, adjustments to heat glow and BOMB --- includes/powder.h | 12 ++++---- src/graphics.c | 71 +++++++++++++++-------------------------------- src/powder.c | 21 +++++++------- 3 files changed, 40 insertions(+), 64 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 3b03aa3f4..71bfe01d7 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -284,7 +284,7 @@ static const part_type ptypes[PT_NUM] = {"C-4", PIXPACK(0xD080E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 1000, 2, 50, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Solid. Pressure sensitive explosive.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, {"GOO", PIXPACK(0x804000), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, {"ICE", PIXPACK(0xA0C0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP-50.0f+273.15f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air.", TYPE_SOLID, NULL}, - {"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", TYPE_SOLID|PROP_CONDUCTS, NULL}, + {"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, {"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", TYPE_SOLID, NULL}, {"SNOW", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_POWDERS, R_TEMP-30.0f+273.15f, 46, "Light particles.", TYPE_PART, NULL}, {"WOOD", PIXPACK(0xC0A040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Solid. Flammable.", TYPE_SOLID, NULL}, @@ -299,8 +299,8 @@ static const part_type ptypes[PT_NUM] = {"SALT", PIXPACK(0xFFFFFF), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 75, SC_POWDERS, R_TEMP+0.0f +273.15f, 110, "Salt, dissolves in water.", TYPE_PART, NULL}, {"SLTW", PIXPACK(0x4050F0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 35, SC_LIQUID, R_TEMP+0.0f +273.15f, 75, "Saltwater, conducts electricity, difficult to freeze.", TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTPENETRATE, NULL}, {"DMND", PIXPACK(0xCCFFFF), 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+0.0f +273.15f, 186, "Diamond. Indestructable.", TYPE_SOLID, NULL}, //ief015 - Added diamond. Because concrete blocks are kinda pointless. - {"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", TYPE_SOLID|PROP_CONDUCTS, NULL}, - {"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", TYPE_PART|PROP_CONDUCTS, NULL}, + {"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, + {"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", TYPE_PART|PROP_CONDUCTS|PROP_HOT_GLOW, NULL}, {"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", TYPE_ENERGY, NULL}, {"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", TYPE_PART, NULL}, {"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", TYPE_SOLID, NULL}, @@ -315,9 +315,9 @@ static const part_type ptypes[PT_NUM] = {"LRBD", PIXPACK(0xAAAAAA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 1000, 1, 0, 2, 1, 45, SC_EXPLOSIVE, R_TEMP+45.0f+273.15f, 170, "Liquid Rubidium.", TYPE_LIQUID|PROP_CONDUCTS, NULL}, {"NTCT", PIXPACK(0x505040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)", TYPE_SOLID, NULL}, {"SAND", PIXPACK(0xFFD090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Sand, Heavy particles. Meltable.", TYPE_PART, NULL}, - {"GLAS", PIXPACK(0x404040), 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_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", TYPE_SOLID | PROP_NEUTPASS, NULL}, + {"GLAS", PIXPACK(0x404040), 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_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW, NULL}, {"PTCT", PIXPACK(0x405050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 120C)", TYPE_SOLID, NULL}, - {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", TYPE_PART, NULL}, + {"BGLA", PIXPACK(0x606060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 5, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", TYPE_PART | PROP_HOT_GLOW, NULL}, {"THDR", PIXPACK(0xFFFFA0), 0.0f, 0.00f * CFDS, 1.0f, 0.30f, -0.99f, 0.6f, 0.62f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_ELEC, 9000.0f +273.15f, 251, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", TYPE_ENERGY, NULL}, {"PLSM", PIXPACK(0xBB99FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.30f, 0.001f * CFDS, 0, 0, 0, 0, 0, 1, 1, SC_GAS, 9000.0f +273.15f, 115, "Plasma, extremely hot.", TYPE_GAS, NULL}, {"ETRD", PIXPACK(0x404040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)", TYPE_SOLID, NULL}, @@ -337,7 +337,7 @@ static const part_type ptypes[PT_NUM] = {"DYST", PIXPACK(0xBBB0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 20, 0, 0, 30, 0, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Dead Yeast.", TYPE_PART, NULL}, {"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremly high temperature.", TYPE_PART, NULL}, {"GLOW", PIXPACK(0x445544), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", TYPE_LIQUID, NULL}, - {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", TYPE_SOLID, NULL}, + {"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", TYPE_SOLID|PROP_HOT_GLOW, NULL}, {"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", TYPE_GAS, NULL}, {"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", TYPE_PART, NULL}, {"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", TYPE_SOLID, NULL}, diff --git a/src/graphics.c b/src/graphics.c index 9beeeb07e..a2e73e61a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1459,49 +1459,24 @@ void draw_parts(pixel *vid) } else if(cmode==CM_GRAD) { - if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370) - { - float frequency = 0.00146; - int q = parts[i].temp-473; - cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors); - cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors); - cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors); - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - if(cr<=0) - cr = 0; - if(cg<=0) - cg = 0; - if(cb<=0) - cb = 0; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - else - { - float frequency = 0.05; - int q = parts[i].temp-40; - cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors); - cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors); - cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors); - if(cr>=255) - cr = 255; - if(cg>=255) - cg = 255; - if(cb>=255) - cb = 255; - if(cr<=0) - cr = 0; - if(cg<=0) - cg = 0; - if(cb<=0) - cb = 0; - blendpixel(vid, nx, ny, cr, cg, cb, 255); - } - + float frequency = 0.05; + int q = parts[i].temp-40; + cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors); + cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors); + cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors); + if(cr>=255) + cr = 255; + if(cg>=255) + cg = 255; + if(cb>=255) + cb = 255; + if(cr<=0) + cr = 0; + if(cg<=0) + cg = 0; + if(cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); } else if(t==PT_MWAX&&cmode == CM_FANCY) { @@ -2425,12 +2400,12 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); } } - else if(t==PT_BOMB){ + else if(t==PT_BOMB){ if(parts[i].tmp==0){ cr = PIXR(ptypes[t].pcolors); cg = PIXG(ptypes[t].pcolors); cb = PIXB(ptypes[t].pcolors); - if(cmode != CM_NOTHING && cmode != CM_CRACK){ + if(cmode != CM_CRACK){ int newx = 0; float gradv = 100; blendpixel(vid, nx+1, ny, cr, cg, cb, 223); @@ -2456,7 +2431,7 @@ void draw_parts(pixel *vid) cr = PIXR(ptypes[t].pcolors); cg = PIXG(ptypes[t].pcolors); cb = PIXB(ptypes[t].pcolors); - if(cmode != CM_NOTHING && cmode != CM_CRACK){ + if(cmode != CM_CRACK){ int newx = 0; float gradv = 4*parts[i].life; for(newx = 0; gradv>0.5; newx++){ @@ -2476,8 +2451,8 @@ void draw_parts(pixel *vid) } else if(ptypes[t].properties&PROP_HOT_GLOW && parts[i].temp>473.0f) { - float frequency = 0.00146; - int q = (parts[i].temp>1370)?1370-473:parts[i].temp-473; + float frequency = 3.1415/(2*pstates[t].ltemp-473.0); + int q = (parts[i].temp>pstates[t].ltemp)?pstates[t].ltemp-473:parts[i].temp-473; cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors); cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors); cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors); diff --git a/src/powder.c b/src/powder.c index ad3c9b688..aabe04fe0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2815,7 +2815,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB){ + if(parts[r>>8].type!=PT_NONE && parts[r>>8].type!=PT_BOMB && parts[r>>8].type!=PT_DMND && parts[r>>8].type!=PT_CLNE && parts[r>>8].type!=PT_PCLN && parts[r>>8].type!=PT_BCLN){ int rad = 8; int nxi; int nxj; @@ -2834,16 +2834,17 @@ void update_particles_i(pixel *vid, int start, int inc) } 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){ - delete_part(x+nxi, y+nxj); - pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; - int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); - if(nb!=-1){ - parts[nb].tmp = 2; - parts[nb].life = 2; - parts[nb].temp = MAX_TEMP; + 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); + pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; + int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + if(nb!=-1){ + parts[nb].tmp = 2; + parts[nb].life = 2; + parts[nb].temp = MAX_TEMP; + } } - } //create_parts(x, y, 9, 9, PT_BOMB); //create_parts(x, y, 8, 8, PT_NONE); parts[i].type = PT_NONE; From c5c88529c228987897b722cffafad4e888604132 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Sun, 26 Dec 2010 09:47:25 -0500 Subject: [PATCH 3/4] slight temp loading change so PUMP will load with 0C if saved at 0C. fix visual studio compiling --- src/main.c | 2 +- src/powder.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index 976bfe721..050469d2c 100644 --- a/src/main.c +++ b/src/main.c @@ -729,7 +729,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0) if(new_format) { ttv = (d[p++])<<8; ttv |= (d[p++]); - parts[i-1].temp = ttv; + parts[i-1].temp = ttv + 0.15; } else { parts[i-1].temp = (d[p++]*((MAX_TEMP+(-MIN_TEMP))/255))+MIN_TEMP; } diff --git a/src/powder.c b/src/powder.c index aabe04fe0..ce3c4fa03 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2794,6 +2794,7 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(t==PT_BOMB) { + int nb; if(parts[i].tmp==1){ for(nx=-2; nx<3; nx++) for(ny=-2; ny<3; ny++) @@ -2823,7 +2824,7 @@ void update_particles_i(pixel *vid, int start, int inc) 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){ - int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); if(nb!=-1){ parts[nb].tmp = 1; parts[nb].life = 50; @@ -2838,7 +2839,7 @@ void update_particles_i(pixel *vid, int start, int inc) 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); pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; - int nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); + nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); if(nb!=-1){ parts[nb].tmp = 2; parts[nb].life = 2; @@ -3119,10 +3120,10 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life%4==0&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) + else if(parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life==0&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { - flood_parts(x,y,PT_SPRK,PT_INST,-1);//add life - parts[r>>8].type==parts[r>>8].ctype; + flood_parts(x,y,PT_SPRK,PT_INST,-1);//spark the wire + //parts[r>>8].type=parts[r>>8].ctype; } } } From 761ea03882fd779cc77ac7cb49ff59bbfe94b51e Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Mon, 27 Dec 2010 17:29:05 -0500 Subject: [PATCH 4/4] added a basic coldflame explosive, ignites from CFLM or something cold. --- includes/powder.h | 7 +++++-- src/powder.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 71bfe01d7..45e818139 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -177,7 +177,8 @@ #define PT_BRAY 127 #define PT_STKM2 128 #define PT_BOMB 129 -#define PT_NUM 130 +#define PT_C5 130 +#define PT_NUM 131 #define R_TEMP 22 #define MAX_TEMP 9999 @@ -400,7 +401,8 @@ static const part_type ptypes[PT_NUM] = {"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", TYPE_SOLID, NULL}, {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, NULL}, {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", TYPE_PART, NULL}, - //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description + {"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", TYPE_SOLID | PROP_NEUTPENETRATE, NULL}, + //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description }; static part_state pstates[PT_NUM] = @@ -536,6 +538,7 @@ static part_state pstates[PT_NUM] = /* BRAY */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, /* STKM2*/ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_FIRE, 620.0f}, /* BOMB */ {ST_NONE, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, + /* C-5 */ {ST_SOLID, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f, PT_NONE, 0.0f}, }; static int grule[NGOL][9] = diff --git a/src/powder.c b/src/powder.c index ce3c4fa03..2c7944e5c 100644 --- a/src/powder.c +++ b/src/powder.c @@ -2792,7 +2792,28 @@ void update_particles_i(pixel *vid, int start, int inc) } } } - else if(t==PT_BOMB) + else if(t==PT_C5) + { + for(nx=-2; nx<3; nx++) + for(ny=-2; ny<3; ny++) + if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART || !r) + continue; + if((parts[r>>8].temp<100 && parts[r>>8].type!=PT_C5)||parts[r>>8].type==PT_HFLM) + { + if(1>rand()%6) + { + t = parts[i].type = PT_HFLM; + parts[r>>8].temp = parts[i].temp = 0; + parts[i].life = rand()%150+50; + pv[y/CELL][x/CELL] += 1.5; + } + } + } + } + else if(t==PT_BOMB) { int nb; if(parts[i].tmp==1){