summaryrefslogtreecommitdiff
path: root/src/elements/btry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/btry.cpp')
-rw-r--r--src/elements/btry.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/elements/btry.cpp b/src/elements/btry.cpp
new file mode 100644
index 0000000..3f11003
--- /dev/null
+++ b/src/elements/btry.cpp
@@ -0,0 +1,24 @@
+#include "element.h"
+
+int update_BTRY(UPDATE_FUNC_ARGS) {
+ int r, rx, ry, rt;
+ 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;
+ rt = parts[r>>8].type;
+ if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL)
+ {
+ if ((sim->ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4)
+ {
+ parts[r>>8].life = 4;
+ parts[r>>8].ctype = rt;
+ sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
+ }
+ }
+ }
+ return 0;
+}