summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-30 12:44:18 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-30 12:44:18 (GMT)
commitd84abca852b9b693d40b253f674367789dda245c (patch)
tree4c99fdeba5c849c215459b3402efbe9ef6a3ed8d
parenta7ede2659ab354d36d9cf21bba040da884cc0357 (diff)
downloadpowder-d84abca852b9b693d40b253f674367789dda245c.zip
powder-d84abca852b9b693d40b253f674367789dda245c.tar.gz
Improvements to CBNW and BIZR act as a dye
-rw-r--r--includes/powder.h7
-rw-r--r--src/elements/bizr.c39
-rw-r--r--src/elements/cbnw.c23
3 files changed, 57 insertions, 12 deletions
diff --git a/includes/powder.h b/includes/powder.h
index c687b62..9e63d61 100644
--- a/includes/powder.h
+++ b/includes/powder.h
@@ -326,6 +326,7 @@ int update_GBMB(UPDATE_FUNC_ARGS);
int update_CO2(UPDATE_FUNC_ARGS);
int update_CBNW(UPDATE_FUNC_ARGS);
int update_STOR(UPDATE_FUNC_ARGS);
+int update_BIZR(UPDATE_FUNC_ARGS);
int update_MISC(UPDATE_FUNC_ARGS);
int update_legacy_PYRO(UPDATE_FUNC_ARGS);
@@ -508,9 +509,9 @@ static const part_type ptypes[PT_NUM] =
{"FRZZ", 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, 1, 50, SC_POWDERS, 90.0f, 46, "FREEZE", ST_SOLID, TYPE_PART, &update_FRZZ},
{"FRZW", PIXPACK(0x1020C0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_CRACKER2, 120.0f, 29, "FREEZE WATER", ST_LIQUID, TYPE_LIQUID||PROP_LIFE_DEC, &update_FRZW},
{"GRAV", PIXPACK(0xFFE0A0), 0.7f, 0.00f * CFDS, 1.00f, 1.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Changes colour based on velocity.", ST_SOLID, TYPE_PART, &update_MISC},
- {"BIZR", PIXPACK(0x00FF77), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP+0.0f +273.15f, 29, "Bizarre... contradicts the normal state changes.", ST_LIQUID, TYPE_LIQUID, NULL},
- {"BIZG", PIXPACK(0x00FFBB), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 2.75f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_CRACKER2, R_TEMP-200.0f+273.15f, 42, "Bizarre gas", ST_GAS, TYPE_GAS, NULL},
- {"BIZS", PIXPACK(0x00E455), 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_CRACKER2, R_TEMP+300.0f+273.15f, 251, "Bizarre solid", ST_SOLID, TYPE_SOLID, NULL},
+ {"BIZR", PIXPACK(0x00FF77), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP+0.0f +273.15f, 29, "Bizarre... contradicts the normal state changes.", ST_LIQUID, TYPE_LIQUID, &update_BIZR},
+ {"BIZG", PIXPACK(0x00FFBB), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 2.75f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_CRACKER2, R_TEMP-200.0f+273.15f, 42, "Bizarre gas", ST_GAS, TYPE_GAS, &update_BIZR},
+ {"BIZS", PIXPACK(0x00E455), 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_CRACKER2, R_TEMP+300.0f+273.15f, 251, "Bizarre solid", ST_SOLID, TYPE_SOLID, &update_BIZR},
{"INST", PIXPACK(0x404039), 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, "Instantly conducts, PSCN to charge, NSCN to take.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, NULL},
{"ISOZ", PIXPACK(0xAA30D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 0, 1, 1, 24, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 29, "Radioactive liquid", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE, &update_ISZ},
{"ISZS", PIXPACK(0x662089), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0007f* CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_NUCLEAR, 140.00f, 251, "Solid form of ISOZ, slowly decays.", ST_SOLID, TYPE_SOLID, &update_ISZ},
diff --git a/src/elements/bizr.c b/src/elements/bizr.c
new file mode 100644
index 0000000..d8a59cf
--- /dev/null
+++ b/src/elements/bizr.c
@@ -0,0 +1,39 @@
+#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;
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/cbnw.c b/src/elements/cbnw.c
index 701f9ae..1834879 100644
--- a/src/elements/cbnw.c
+++ b/src/elements/cbnw.c
@@ -14,7 +14,7 @@ int update_CBNW(UPDATE_FUNC_ARGS) {
if(oldt==1)
{
//Explode
- if(!(rand()%2))
+ if(rand()%4)
{
part_change_type(i,x,y,PT_WATR);
} else {
@@ -27,12 +27,22 @@ int update_CBNW(UPDATE_FUNC_ARGS) {
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)
+ if (!r)
continue;
- if ((r&0xFF)==PT_SALT && parts[i].tmp == 0 && 1>(rand()%250))
+ if (ptypes[r&0xFF].properties&TYPE_PART && parts[i].tmp == 0 && 1>(rand()%250))
{
//Start explode
- parts[i].tmp = rand()%50;//(rand()%100)+50;
+ 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_WATR);
+ } else {
+ pv[y/CELL][x/CELL] += 0.5f;
+ part_change_type(i,x,y,PT_CO2);
+ }
}
if ((r&0xFF)==PT_CBNW)
{
@@ -61,11 +71,6 @@ int update_CBNW(UPDATE_FUNC_ARGS) {
return 1;
}
}
- /*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;
}