summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-03-24 19:41:45 (GMT)
committer Simon <simon@hardwired.org.uk>2011-03-24 19:41:45 (GMT)
commit3ab47ae9d76e9e5e0416f81e43de15417354caf5 (patch)
treed80fbec366baa970cd565ca5a17decb444036fad /src/elements
parentfe90c86fa1f1365d07dc6eee83b074d08efec05a (diff)
downloadpowder-3ab47ae9d76e9e5e0416f81e43de15417354caf5.zip
powder-3ab47ae9d76e9e5e0416f81e43de15417354caf5.tar.gz
Effects for PRTO and PRTI
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/prti.c32
-rw-r--r--src/elements/prto.c29
2 files changed, 59 insertions, 2 deletions
diff --git a/src/elements/prti.c b/src/elements/prti.c
index 560ba8c..fa87562 100644
--- a/src/elements/prti.c
+++ b/src/elements/prti.c
@@ -1,7 +1,7 @@
#include <element.h>
int update_PRTI(UPDATE_FUNC_ARGS) {
- int r, nnx, rx, ry;
+ 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;
@@ -12,6 +12,8 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
{
r = pmap[y+ry][x+rx];
count ++;
+ if (!r)
+ fe = 1;
if ((r>>8)>=NPART || !r)
continue;
if ((r&0xFF)==PT_SPRK || ((r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (ptypes[r&0xFF].falldown!= 0 || ptypes[r&0xFF].state == ST_GAS)))
@@ -28,5 +30,33 @@ int update_PRTI(UPDATE_FUNC_ARGS) {
break;
}
}
+
+
+ if(fe){
+ if(!parts[i].life) parts[i].life = rand();
+ if(!parts[i].ctype) parts[i].life = rand();
+ int orbd[4] = {0, 0, 0, 0}; //Orbital distances
+ int orbl[4] = {0, 0, 0, 0}; //Orbital locations
+ 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
index fbbd5a1..9bec996 100644
--- a/src/elements/prto.c
+++ b/src/elements/prto.c
@@ -1,7 +1,7 @@
#include <element.h>
int update_PRTO(UPDATE_FUNC_ARGS) {
- int r, nnx, rx, ry, np;
+ 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;
@@ -12,6 +12,8 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
{
r = pmap[y+ry][x+rx];
count ++;
+ if (!r)
+ fe = 1;
if ((r>>8)>=NPART || r)
continue;
if (!r)
@@ -51,5 +53,30 @@ int update_PRTO(UPDATE_FUNC_ARGS) {
}
}
}
+ if(fe){
+ if(!parts[i].life) parts[i].life = rand();
+ if(!parts[i].ctype) parts[i].life = rand();
+ int orbd[4] = {0, 0, 0, 0}; //Orbital distances
+ int orbl[4] = {0, 0, 0, 0}; //Orbital locations
+ 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;
+ }
+ //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;
}