From d6953be3a8271785b5912f3105f3ca92cc17aaae Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 19 Dec 2011 14:29:01 +0000 Subject: [PATCH] New element: Ignition cord --- includes/powder.h | 38 ++++++++++++++++++++------------------ src/elementdata.c | 8 ++++---- src/elements/bomb.c | 3 ++- src/elements/coal.c | 2 +- src/elements/elec.c | 4 ++-- src/elements/ignt.c | 43 +++++++++++++++++++++++++++++++++++++++++++ src/powder.c | 3 +++ 7 files changed, 75 insertions(+), 26 deletions(-) create mode 100644 src/elements/ignt.c diff --git a/includes/powder.h b/includes/powder.h index 0e834e671..cd1024472 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -193,13 +193,13 @@ #define PT_SING 131 #define PT_QRTZ 132 #define PT_PQRT 133 - #define PT_EMP 134 #define PT_BREC 135 #define PT_ELEC 136 #define PT_ACEL 137 #define PT_DCEL 138 - +#define PT_BANG 139 +#define PT_IGNT 140 #define PT_BOYL 141 #define OLD_PT_WIND 147 @@ -229,23 +229,24 @@ /* TODO: We should start to implement these. */ -#define TYPE_PART 0x0001 //1 Powders -#define TYPE_LIQUID 0x0002 //2 Liquids -#define TYPE_SOLID 0x0004 //4 Solids -#define TYPE_GAS 0x0008 //8 Gasses (Includes plasma) -#define TYPE_ENERGY 0x0010 //16 Energy (Thunder, Light, Neutrons etc.) -#define PROP_CONDUCTS 0x0020 //32 Conducts electricity -#define PROP_BLACK 0x0040 //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) -#define PROP_NEUTPENETRATE 0x0080 //128 Penetrated by neutrons -#define PROP_NEUTABSORB 0x0100 //256 Absorbs neutrons, reflect is default (not currently implemented or used) -#define PROP_NEUTPASS 0x0200 //512 Neutrons pass through, such as with glass -#define PROP_DEADLY 0x0400 //1024 Is deadly for stickman (not currently implemented or used) -#define PROP_HOT_GLOW 0x0800 //2048 Hot Metal Glow -#define PROP_LIFE 0x1000 //4096 Is a GoL type -#define PROP_RADIOACTIVE 0x2000 //8192 Radioactive -#define PROP_LIFE_DEC 0x4000 //2^14 Life decreases by one every frame if > zero -#define PROP_LIFE_KILL 0x8000 //2^15 Kill when life value is <= zero +#define TYPE_PART 0x00001 //1 Powders +#define TYPE_LIQUID 0x00002 //2 Liquids +#define TYPE_SOLID 0x00004 //4 Solids +#define TYPE_GAS 0x00008 //8 Gasses (Includes plasma) +#define TYPE_ENERGY 0x00010 //16 Energy (Thunder, Light, Neutrons etc.) +#define PROP_CONDUCTS 0x00020 //32 Conducts electricity +#define PROP_BLACK 0x00040 //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) +#define PROP_NEUTPENETRATE 0x00080 //128 Penetrated by neutrons +#define PROP_NEUTABSORB 0x00100 //256 Absorbs neutrons, reflect is default (not currently implemented or used) +#define PROP_NEUTPASS 0x00200 //512 Neutrons pass through, such as with glass +#define PROP_DEADLY 0x00400 //1024 Is deadly for stickman (not currently implemented or used) +#define PROP_HOT_GLOW 0x00800 //2048 Hot Metal Glow +#define PROP_LIFE 0x01000 //4096 Is a GoL type +#define PROP_RADIOACTIVE 0x02000 //8192 Radioactive +#define PROP_LIFE_DEC 0x04000 //2^14 Life decreases by one every frame if > zero +#define PROP_LIFE_KILL 0x08000 //2^15 Kill when life value is <= zero #define PROP_LIFE_KILL_DEC 0x10000 //2^16 Kill when life value is decremented to <= zero +#define PROP_SPARKSETTLE 0x20000 //2^17 Allow Sparks/Embers to settle #define FLAG_STAGNANT 1 @@ -428,6 +429,7 @@ int update_ELEC(UPDATE_FUNC_ARGS); int update_ACEL(UPDATE_FUNC_ARGS); int update_DCEL(UPDATE_FUNC_ARGS); int update_BANG(UPDATE_FUNC_ARGS); +int update_IGNT(UPDATE_FUNC_ARGS); int update_MISC(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); diff --git a/src/elementdata.c b/src/elementdata.c index 7c7c40a7c..7eeec0bc9 100644 --- a/src/elementdata.c +++ b/src/elementdata.c @@ -55,7 +55,7 @@ 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, 1, 45, SC_EXPLOSIVE, R_TEMP+45.0f+273.15f, 170, "Liquid Rubidium.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC, NULL, 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, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when hot (More than 100C)", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC, &update_NPTCT, 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, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Sand, Heavy particles. Meltable.", ST_SOLID, TYPE_PART, NULL, 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, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", ST_SOLID, TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW, &update_GLAS, 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, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 150, "Solid. Meltable. Shatters under pressure", ST_SOLID, TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW | PROP_SPARKSETTLE, &update_GLAS, 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, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Semi-conductor. Only conducts electricity when cold (Less than 100C)", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC, &update_NPTCT, 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, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 150, "Broken Glass, Heavy particles. Meltable. Bagels.", ST_SOLID, TYPE_PART | PROP_HOT_GLOW, NULL, 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, 1, SC_EXPLOSIVE, 9000.0f +273.15f, 1, "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals.", ST_NONE, TYPE_ENERGY, &update_THDR, &graphics_THDR}, @@ -139,7 +139,7 @@ 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, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 0, "Ray Emitter. Rays create points when they collide", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_ARAY, 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, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, NULL, &graphics_BRAY}, {"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, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM2, &graphics_STKM2}, - {"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, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_BOMB, &graphics_BOMB}, + {"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, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC|PROP_SPARKSETTLE, &update_BOMB, &graphics_BOMB}, {"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, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_C5, NULL}, {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART|PROP_LIFE_DEC, &update_SING, NULL}, {"QRTZ", PIXPACK(0xAADDDD), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 3, "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_QRTZ, &graphics_QRTZ}, @@ -150,7 +150,7 @@ part_type ptypes[PT_NUM] = {"ACEL", PIXPACK(0x0099CC), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Accelerator", ST_NONE, TYPE_SOLID, &update_ACEL, &graphics_ACEL}, {"DCEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Decelerator", ST_NONE, TYPE_SOLID, &update_DCEL, &graphics_DCEL}, {"TNT", PIXPACK(0xC05050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Explosive.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_BANG, NULL}, - /*FREE*/{"MYST", PIXPACK(0x0C3C00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "B3458/S05678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"IGNC", PIXPACK(0xC0B050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Ignition cord.", ST_SOLID, TYPE_PART | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL, &update_IGNT, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL}, /*FREE*/{"LOTE", PIXPACK(0xFF0000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"FRG2", PIXPACK(0x00FF00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, @@ -324,7 +324,7 @@ part_transition ptransitions[PT_NUM] = /* ACEL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* DCEL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* TNT */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, - /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* IGNP */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, /* BOYL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, diff --git a/src/elements/bomb.c b/src/elements/bomb.c index ee45624f2..ae5181074 100644 --- a/src/elements/bomb.c +++ b/src/elements/bomb.c @@ -2,6 +2,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { int r, rx, ry, nb; + //Spark is used so much now that it should be a seperate element. if (parts[i].tmp==1) { for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) @@ -10,7 +11,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID) && (r&0xFF)!=PT_BOMB) { + if (ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID) && !(ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) { kill_part(i); return 1; } diff --git a/src/elements/coal.c b/src/elements/coal.c index 14c3138c2..d17a547dd 100644 --- a/src/elements/coal.c +++ b/src/elements/coal.c @@ -35,7 +35,7 @@ int update_COAL(UPDATE_FUNC_ARGS) { if (parts[r>>8].ctype == PT_IRON) { parts[r>>8].ctype = PT_METL; kill_part(i); - return 1; + return 1; } } } diff --git a/src/elements/elec.c b/src/elements/elec.c index a05410275..6acbbab46 100644 --- a/src/elements/elec.c +++ b/src/elements/elec.c @@ -22,9 +22,9 @@ int update_ELEC(UPDATE_FUNC_ARGS) { 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; - for (rrx=-2; rrx<=2; rrx++) + for (rrx=-1; rrx<=1; rrx++) { - for (rry=-2; rry<=2; rry++) + for (rry=-1; rry<=1; rry++) { if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx + +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>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_BOMB); + if (nb!=-1) { + parts[nb].tmp = 1; + parts[nb].life = 30; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + } + } + else + { + create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + parts[i].life--; + } + return 0; +} diff --git a/src/powder.c b/src/powder.c index 853b216da..b0646b067 100644 --- a/src/powder.c +++ b/src/powder.c @@ -955,6 +955,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].life = 110; parts[i].tmp = 50; } + if (t==PT_IGNT) { + parts[i].life = 3; + } if (t==PT_FRZW) parts[i].life = 100; if (t==PT_PIPE)