r5328 - in trunk/data: qcsrc/server scripts

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Dec 27 09:46:37 EST 2008


Author: div0
Date: 2008-12-27 09:46:37 -0500 (Sat, 27 Dec 2008)
New Revision: 5328

Modified:
   trunk/data/qcsrc/server/g_subs.qc
   trunk/data/qcsrc/server/t_plats.qc
   trunk/data/scripts/entities.def
Log:
func_door_rotating by RoKenn


Modified: trunk/data/qcsrc/server/g_subs.qc
===================================================================
--- trunk/data/qcsrc/server/g_subs.qc	2008-12-27 14:37:18 UTC (rev 5327)
+++ trunk/data/qcsrc/server/g_subs.qc	2008-12-27 14:46:37 UTC (rev 5328)
@@ -176,6 +176,7 @@
 		self.think1 ();
 }
 
+// FIXME: I fixed this function only for rotation around the main axes
 void SUB_CalcAngleMove (vector destangle, float tspeed, void() func)
 {
 	vector	delta;
@@ -183,16 +184,26 @@
 
 	if (!tspeed)
 		objerror ("No speed is defined!");
-
+	
+	// take the shortest distance for the angles
+	self.angles_x -= 360 * floor((self.angles_x - destangle_x) / 360 + 0.5);
+	self.angles_y -= 360 * floor((self.angles_y - destangle_y) / 360 + 0.5);
+	self.angles_z -= 360 * floor((self.angles_z - destangle_z) / 360 + 0.5);
 	delta = destangle - self.angles;
 	traveltime = vlen (delta) / tspeed;
-
-	self.avelocity = delta * (1 / traveltime);
-
+  
 	self.think1 = func;
 	self.finalangle = destangle;
+	self.think = SUB_CalcAngleMoveDone;
 
-	self.think = SUB_CalcAngleMoveDone;
+	if (traveltime < 0.1)
+	{
+		self.avelocity = '0 0 0';
+		self.nextthink = self.ltime + 0.1;
+		return;
+	}
+
+	self.avelocity = delta * (1 / traveltime);
 	self.nextthink = self.ltime + traveltime;
 }
 

Modified: trunk/data/qcsrc/server/t_plats.qc
===================================================================
--- trunk/data/qcsrc/server/t_plats.qc	2008-12-27 14:37:18 UTC (rev 5327)
+++ trunk/data/qcsrc/server/t_plats.qc	2008-12-27 14:46:37 UTC (rev 5328)
@@ -611,6 +611,8 @@
 
 void() door_go_down;
 void() door_go_up;
+void() door_rotating_go_down;
+void() door_rotating_go_up;
 
 void door_blocked()
 {
@@ -627,9 +629,21 @@
             if (self.wait >= 0)
             {
                 if (self.state == STATE_DOWN)
-                    door_go_up ();
+			if (self.classname == "door")
+			{
+				door_go_up ();
+			} else 
+			{
+				door_rotating_go_up ();
+			}
                 else
-                    door_go_down ();
+			if (self.classname == "door")
+			{
+				door_go_down ();
+			} else 
+			{
+				door_rotating_go_down ();
+			}
             }
         } else {
             //gib dying stuff just to make sure
@@ -659,7 +673,13 @@
 	self.state = STATE_TOP;
 	if (self.spawnflags & DOOR_TOGGLE)
 		return;		// don't come down automatically
-	self.think = door_go_down;
+	if (self.classname == "door")
+	{
+		self.think = door_go_down;
+	} else 
+	{
+		self.think = door_rotating_go_down;
+	}
 	self.nextthink = self.ltime + self.wait;
 };
 
@@ -733,7 +753,14 @@
 			starte = self;
 			do
 			{
-				door_go_down ();
+				if (self.classname == "door") 
+				{
+					door_go_down ();
+				}
+				else
+				{
+					door_rotating_go_down ();
+				}
 				self = self.enemy;
 			} while ( (self != starte) && (self != world) );
 			self = oself;
@@ -745,7 +772,13 @@
 	starte = self;
 	do
 	{
-		door_go_up ();
+		if (self.classname == "door")
+		{
+			door_go_up ();
+		} else 
+		{
+			door_rotating_go_up ();
+		}
 		self = self.enemy;
 	} while ( (self != starte) && (self != world) );
 	self = oself;
@@ -824,6 +857,104 @@
 	}
 };
 
+
+void door_rotating_blocked()
+{
+
+    if((self.spawnflags & 8) && (other.takedamage != DAMAGE_NO)) { // KIll Kill Kill!!
+        Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
+    } else {
+
+        if((self.dmg) && (other.takedamage == DAMAGE_YES))    // Shall we bite?
+            Damage (other, self, self, self.dmg, DEATH_HURTTRIGGER, other.origin, '0 0 0');
+
+         //Dont chamge direction for dead or dying stuff
+        if(other.deadflag != DEAD_NO && (other.takedamage == DAMAGE_NO)) {
+            if (self.wait >= 0)
+            {
+                if (self.state == STATE_DOWN)
+                    door_rotating_go_up ();
+                else
+                    door_rotating_go_down ();
+            }
+        } else {
+            //gib dying stuff just to make sure
+            if((self.dmg) && (other.takedamage != DAMAGE_NO))    // Shall we bite?
+                Damage (other, self, self, 10000, DEATH_HURTTRIGGER, other.origin, '0 0 0');
+        }
+    }
+
+	//T_Damage (other, self, self, self.dmg, self.dmg, self.deathtype, DT_IMPACT, (self.absmin + self.absmax) * 0.5, '0 0 0', Obituary_Generic);
+// if a door has a negative wait, it would never come back if blocked,
+// so let it just squash the object to death real fast
+/*	if (self.wait >= 0)
+	{
+		if (self.state == STATE_DOWN)
+			door_rotating_go_up ();
+		else
+			door_rotating_go_down ();
+	}
+*/
+};
+
+
+void door_rotating_hit_top()
+{
+	if (self.noise1 != "")
+		sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
+	self.state = STATE_TOP;
+	if (self.spawnflags & DOOR_TOGGLE)
+		return;		// don't come down automatically
+	self.think = door_rotating_go_down;
+	self.nextthink = self.ltime + self.wait;
+};
+
+void door_rotating_hit_bottom()
+{
+	if (self.noise1 != "")
+		sound (self, CHAN_TRIGGER, self.noise1, VOL_BASE, ATTN_NORM);
+	self.state = STATE_BOTTOM;
+};
+
+void door_rotating_go_down()
+{
+	if (self.noise2 != "")
+		sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
+	if (self.max_health)
+	{
+		self.takedamage = DAMAGE_YES;
+		self.health = self.max_health;
+	}
+
+	self.state = STATE_DOWN;
+	SUB_CalcAngleMove (self.pos1, self.speed, door_hit_bottom);
+};
+
+void door_rotating_go_up()
+{
+	if (self.state == STATE_UP)
+		return;		// already going up
+
+	if (self.state == STATE_TOP)
+	{	// reset top wait time
+		self.nextthink = self.ltime + self.wait;
+		return;
+	}
+	if (self.noise2 != "")
+		sound (self, CHAN_TRIGGER, self.noise2, VOL_BASE, ATTN_NORM);
+	self.state = STATE_UP;
+	SUB_CalcAngleMove (self.pos2, self.speed, door_rotating_hit_top);
+
+	string oldmessage;
+	oldmessage = self.message;
+	self.message = "";
+	SUB_UseTargets();
+	self.message = oldmessage;
+};
+
+
+
+
 /*
 =============================================================================
 
@@ -854,17 +985,17 @@
 
 float EntitiesTouching(entity e1, entity e2)
 {
-	if (e1.mins_x > e2.maxs_x)
+	if (e1.absmin_x > e2.absmax_x)
 		return FALSE;
-	if (e1.mins_y > e2.maxs_y)
+	if (e1.absmin_y > e2.absmax_y)
 		return FALSE;
-	if (e1.mins_z > e2.maxs_z)
+	if (e1.absmin_z > e2.absmax_z)
 		return FALSE;
-	if (e1.maxs_x < e2.mins_x)
+	if (e1.absmax_x < e2.absmin_x)
 		return FALSE;
-	if (e1.maxs_y < e2.mins_y)
+	if (e1.absmax_y < e2.absmin_y)
 		return FALSE;
-	if (e1.maxs_z < e2.mins_z)
+	if (e1.absmax_z < e2.absmin_z)
 		return FALSE;
 	return TRUE;
 };
@@ -894,13 +1025,12 @@
 			return;
 		if (self.items)
 			return;
-
 		self.trigger_field = spawn_field(self.absmin, self.absmax);
 
 		return;		// don't want to link this door
 	}
 
-	cmins = self.absmin;
+	cmins = self.absmin;			  
 	cmaxs = self.absmax;
 
 	starte = self;
@@ -970,7 +1100,7 @@
 
 TOGGLE causes the door to wait in both the start and end states for a trigger event.
 
-START_OPEN causes the door to move to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
+START_OPEN causes the door to move to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not useful for touch or takedamage doors).
 
 "message"	is printed when the door is touched if it is a trigger door and it hasn't been fired yet
 "angle"		determines the opening direction
@@ -1060,6 +1190,114 @@
 	InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
 };
 
+/*QUAKED spawnfunc_func_door_rotating (0 .5 .8) ? START_OPEN x DOOR_DONT_LINK x x TOGGLE X_AXIS Y_AXIS BIDIR
+if two doors touch, they are assumed to be connected and operate as a unit.
+
+TOGGLE causes the door to wait in both the start and end states for a trigger event.
+
+BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor. 
+This feature is NOT YET IMPLEMENTED!
+
+START_OPEN causes the door to move to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
+
+"message"	is printed when the door is touched if it is a trigger door and it hasn't been fired yet
+"angle"		determines the destination angle for opening. negative values reverse the direction.
+"targetname"    if set, no touch field will be spawned and a remote button or trigger field activates the door.
+"health"	if set, door must be shot open
+"speed"		movement speed (100 default)
+"wait"		wait before returning (3 default, -1 = never return)
+"dmg"		damage to inflict when blocked (2 default)
+"sounds"
+0)	no sound
+1)	stone
+2)	base
+3)	stone chain
+4)	screechy metal
+FIXME: only one sound set available at the time being
+*/
+
+void door_rotating_init_startopen()
+{
+	self.angles = self.movedir;
+	self.pos2 = '0 0 0';
+	self.pos1 = self.movedir;
+}
+
+
+void spawnfunc_func_door_rotating()
+{
+	
+	//if (!self.deathtype) // map makers can override this
+	//	self.deathtype = " got in the way";
+
+	// I abuse "movedir" for denoting the axis for now
+	if (self.spawnflags & 64) // X (untested)
+		self.movedir = '0 0 1';
+	else if (self.spawnflags & 128) // Y (untested)
+		self.movedir = '1 0 0';
+	else // Z
+		self.movedir = '0 1 0';
+
+	if (self.angles_y==0) self.angles_y = 90;
+
+	self.movedir = self.movedir * self.angles_y;
+	self.angles = '0 0 0';
+
+	self.max_health = self.health;
+	InitMovingBrushTrigger();
+	//self.effects |= EF_LOWPRECISION;
+	self.classname = "door_rotating";
+
+	self.blocked = door_blocked;
+	self.use = door_use;
+
+    if(self.spawnflags & 8)
+        self.dmg = 10000;
+
+    if(self.dmg && (!self.message))
+		self.message = "was squished";
+    if(self.dmg && (!self.message2))
+		self.message2 = "was squished by";
+
+    if (self.sounds > 0)
+	{
+		precache_sound ("plats/medplat1.wav");
+		precache_sound ("plats/medplat2.wav");
+		self.noise2 = "plats/medplat1.wav";
+		self.noise1 = "plats/medplat2.wav";
+	}
+
+	if (!self.speed)
+		self.speed = 50;
+	if (!self.wait)
+		self.wait = 1;
+
+	self.pos1 = '0 0 0';
+	self.pos2 = self.movedir;
+
+// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
+// but spawn in the open position
+	if (self.spawnflags & DOOR_START_OPEN)
+		InitializeEntity(self, door_rotating_init_startopen, INITPRIO_SETLOCATION);
+
+	self.state = STATE_BOTTOM;
+
+	if (self.health)
+	{
+		self.takedamage = DAMAGE_YES;
+		self.event_damage = door_damage;
+	}
+
+	if (self.items)
+		self.wait = -1;
+
+	self.touch = door_touch;
+
+// LinkDoors can't be done until all of the doors have been spawned, so
+// the sizes can be detected properly.
+	InitializeEntity(self, LinkDoors, INITPRIO_LINKDOORS);
+};
+
 /*
 =============================================================================
 

Modified: trunk/data/scripts/entities.def
===================================================================
--- trunk/data/scripts/entities.def	2008-12-27 14:37:18 UTC (rev 5327)
+++ trunk/data/scripts/entities.def	2008-12-27 14:46:37 UTC (rev 5328)
@@ -90,6 +90,29 @@
 TOGGLE: causes the door to wait in both the start and end states for a trigger event.
 */
 
+/*QUAKED func_door_rotating (0 .5 .8) ? START_OPEN - DOOR_DONT_LINK - - TOGGLE X_AXIS Y_AXIS BIDIR
+Normal rotating door entity. By default, the door will activate when player walks close to it or when damage is inflicted to it.
+If DOOR_DONT_LINK is not set, the door will be linked with all doors it touches.
+BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor.
+This feature is NOT YET IMPLEMENTED!
+-------- KEYS --------
+message: is printed when the door is touched if it is a trigger door and it hasn't been fired yet, or death message if dmg is set
+message2: death message when someone gets pushed into this (default: "was thrown into a world of hurt by"). The # character is replaced by the attacker name if present (and it instead does not get appended to the end)
+angle: determines the destination angle for opening. negative values reverse the direction (90 default)
+targetname: if set, no touch field will be spawned and a remote button or trigger field activates the door.
+health: if set, door must be shot open
+speed: speed to rotate (in degrees per second)
+wait: wait before returning (3 default, -1 = never return)
+dmg: damage to inflict when blocked (when triggered and someone is in the way)
+sounds: when 1, use default door sounds
+noise1: sound when the door opens
+noise2: sound when the door closes
+-------- SPAWNFLAGS --------
+START_OPEN: causes the door to move to its destination when spawned, and operate in reverse.  It is used to temporarily or permanently close off an area when triggered (not useful for touch or damage triggered doors).
+DOOR_DONT_LINK: the door won't link with another door it touches
+TOGGLE: causes the door to wait in both the start and end states for a trigger event.
+*/
+
 /*QUAKED func_door_secret (0 .5 .8) ? OPEN_ONCE 1ST_LEFT 1ST_DOWN NO_SHOOT ALWAYS_SHOOT
 Basic secret door. Slides back, then to the side. Angle determines direction. Opens when targeted or when shot; does not create its own trigger field like func_door does.
 -------- KEYS --------




More information about the nexuiz-commits mailing list