summaryrefslogtreecommitdiff
path: root/src/elements/sprk.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-10-10 22:41:19 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-10-10 22:41:19 (GMT)
commitbf8258ee306a9649e0cfbf5344f8a533907175d8 (patch)
treec6fc31a8f7719aa12176d8614fae8f93b93d032d /src/elements/sprk.c
parent9c9f6b2287b028f7d0367308c7669e0ba8960a36 (diff)
downloadpowder-bf8258ee306a9649e0cfbf5344f8a533907175d8.zip
powder-bf8258ee306a9649e0cfbf5344f8a533907175d8.tar.gz
Elements, LIGH, TESC, EMP and DEST thanks to MaksProg
Diffstat (limited to 'src/elements/sprk.c')
-rw-r--r--src/elements/sprk.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/elements/sprk.c b/src/elements/sprk.c
index bae66e8..45b9acb 100644
--- a/src/elements/sprk.c
+++ b/src/elements/sprk.c
@@ -32,7 +32,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
}
else if (ct==PT_ETRD&&parts[i].life==1)
{
- nearp = nearest_part(i, PT_ETRD);
+ nearp = nearest_part(i, PT_ETRD, -1);
if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
{
create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0);
@@ -52,6 +52,40 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
parts[i].temp = 3500;
pv[y/CELL][x/CELL] += 1;
}
+ else if (ct==PT_TESC) // tesla coil code
+ {
+ if (parts[i].tmp>300)
+ parts[i].tmp=300;
+ for (rx=-1; rx<2; rx++)
+ for (ry=-1; ry<2; ry++)
+ 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)
+ continue;
+ if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0)
+ {
+ int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH);
+ if (p!=-1)
+ {
+ parts[p].life=rand()%(2+parts[i].tmp/15)+4+parts[i].tmp/7;
+ if (parts[i].life>60)
+ parts[i].life=60;
+ parts[p].temp=parts[p].life*parts[i].tmp/2.5;
+ parts[p].tmp2=1;
+ parts[p].tmp=acos(1.0*rx/sqrt(rx*rx+ry*ry))/M_PI*360;
+ parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling
+ if (fabs(pv[y/CELL][x/CELL])!=0.0f)
+ {
+ if (fabs(pv[y/CELL][x/CELL])<=0.5f)
+ pv[y/CELL][x/CELL]=0;
+ else
+ pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5;
+ }
+ }
+ }
+ }
+ }
else if (ct==PT_IRON) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)