summaryrefslogtreecommitdiffstats
path: root/System.c4g/DTAutoTreeChop.c
diff options
context:
space:
mode:
Diffstat (limited to 'System.c4g/DTAutoTreeChop.c')
-rw-r--r--System.c4g/DTAutoTreeChop.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/System.c4g/DTAutoTreeChop.c b/System.c4g/DTAutoTreeChop.c
new file mode 100644
index 0000000..2e859af
--- /dev/null
+++ b/System.c4g/DTAutoTreeChop.c
@@ -0,0 +1,31 @@
+#strict 2
+#appendto TREE
+
+static TREE_AutoChop;
+
+global func NoAutoTreeChop() { return !TREE_AutoChop; }
+
+func Construction()
+{
+ if(!NoAutoTreeChop() && FindObject2(Find_AtPoint(), Find_OCF(OCF_Exclusive)))
+ {
+ return RemoveObject();
+ }
+ AddEffect("CheckStructure", this, 100, 10, this);
+ return _inherited(...);
+}
+
+func FxCheckStructureTimer()
+{
+ if(IsStanding())
+ {
+ if(!(GetOCF() & OCF_Chop) && !NoAutoTreeChop())
+ {
+ ChopDown();
+ }
+ }
+ else
+ {
+ return FX_Execute_Kill;
+ }
+}