Not logged inOpenClonk Forum
Up Topic Development / Scenario & Object Development / StoneDoor: Added horizontal usage
- - By EroSennin Date 2011-02-12 23:01
I modified the StoneDoor, so that it now may be used horizontally too. Use StoneDoor#SetR(90) to use it horizontally.
There might be mistakes because this is my first adjustment. :-)

Thanks in advance for using it! :-)

Changeset:
# HG changeset patch
# User EroSennin <joswwa-clonk@yahoo.de>
# Date 1297544145 -3600
# Node ID 45b5bc70fc080e5cc7d9152cf3d333029015a96a
# Parent  c1d716188ea5f715a6cfc91cd39fc678a72d0dde
StoneDoor: Now may be used horizontally and vertically. Use StoneDoor#SetR(90) to use horizontally.

diff -r c1d716188ea5 -r 45b5bc70fc08 planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/DefCore.txt
--- a/planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/DefCore.txt  Sat Feb 12 17:37:42 2011 +0100
+++ b/planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/DefCore.txt  Sat Feb 12 21:55:45 2011 +0100
@@ -1,6 +1,6 @@
[DefCore]
id=StoneDoor
-Version=4,10,0,0
+Version=4,10,0,1
Category=C4D_Structure
Width=10
Height=40
@@ -9,3 +9,4 @@
Value=10
Mass=1000
Components=Rock=10;
+Rotate=1
diff -r c1d716188ea5 -r 45b5bc70fc08 planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/Script.c
--- a/planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/Script.c  Sat Feb 12 17:37:42 2011 +0100
+++ b/planet/Objects.c4d/Structures.c4d/StoneDoor.c4d/Script.c  Sat Feb 12 21:55:45 2011 +0100
@@ -22,27 +22,59 @@

protected func FxIntMoveGateUpTimer(object target)
{
-  if (GBackSolid(0, -20))
+  var backSolidX; // hitting coordinate x of the door
+  var backSolidY; // hitting coordinate y of the door
+  if (GetR() == 90 || GetR() == 270){
+    backSolidX = -20;
+    backSolidY = 0;
+  }
+  else{
+    backSolidX = 0;
+    backSolidY = -20;
+  }
+  if (GBackSolid(backSolidX, backSolidY)) // stop the door if it hits something
   {
     Sound("GateHit.ogg");
     SetYDir(0);
+    SetXDir(0);
     return -1;
   }
  
-  SetYDir(-5);
+  if(GetR() == 90 || GetR() == 270){
+    SetXDir(-5);
+  }
+  else{
+    SetYDir(-5);
+  }
   return 1;
}

protected func FxIntMoveGateDownTimer(object target)
{
-  if (GBackSolid(0, 19))
+  var backSolidX; // hitting coordinate x of the door
+  var backSolidY; // hitting coordinate y of the door
+  if (GetR() == 90){
+    backSolidX = 20;
+    backSolidY = 0;
+  }
+  else{
+    backSolidX = 0;
+    backSolidY = 19;
+  }

+  if (GBackSolid(backSolidX, backSolidY)) // stop the door if it hits something
   {
     Sound("GateHit.ogg");
     SetYDir(0);
+    SetXDir(0);
     return -1;
   }

-  SetYDir(5);
+  if(GetR() == 90){
+    SetXDir(5);
+  }
+  else{
+    SetYDir(5);
+  }
   return 1;
}

I hereby license the following file(s) under the CC-by license
Attachment: StoneDoor_AddedHorizontalUsage_EroSennin.txt - The Change in a text file. (2k)
Reply
Parent - - By Caesar [de] Date 2011-02-12 23:53
Are you sure that it works with 270°?

And, in danger of being over-critical, you could have used GBackSolid(-Sin(GetR(),20), -Cos(GetR(),20)) and SetX/YDir analogical to allow continuous rotation.
Parent - By EroSennin Date 2011-02-13 00:06
Thanks for the reply and the suggestions.
I am not sure if it's working with 270°. I am going to make a test scenario.
Reply
- By EroSennin Date 2011-02-21 17:15
Now the StoneDoor may be rotated freely and also its velocity can be adjusted (default is 5).
Also there is a test with many stone doors in Tests.c4f/StoneDoor.c4s.

hg clone https://bitbucket.org/EroSennin/openclonk/

Known Bugs:
- SetR(10) does not work
Reply
Up Topic Development / Scenario & Object Development / StoneDoor: Added horizontal usage

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill