]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Casings: move to qc effects
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 11:19:41 +0000 (22:19 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 5 Nov 2015 11:19:41 +0000 (22:19 +1100)
qcsrc/client/progs.inc
qcsrc/common/casings.qc [deleted file]
qcsrc/common/effects/qc/all.inc
qcsrc/common/effects/qc/casings.qc [new file with mode: 0644]
qcsrc/server/progs.inc

index 476bbf5d75b317d40dae803c50ef814861aa1681..a4eee1c73d21011292f04978a2ee17ded3461a70 100644 (file)
@@ -29,7 +29,6 @@
 #include "weapons/projectile.qc" // TODO
 
 #include "../common/animdecide.qc"
-#include "../common/casings.qc"
 #include "../common/effects/effectinfo.qc"
 #include "../common/mapinfo.qc"
 #include "../common/movetypes/include.qc"
diff --git a/qcsrc/common/casings.qc b/qcsrc/common/casings.qc
deleted file mode 100644 (file)
index 22046dd..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#include "util.qh"
-
-#ifdef CSQC
-#include "movetypes/movetypes.qh"
-#include "../client/rubble.qh"
-#endif
-
-REGISTER_NET_TEMP(casings)
-
-#ifdef SVQC
-void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
-{SELFPARAM();
-    .entity weaponentity = weaponentities[0]; // TODO: parameter
-    entity wep = self.(weaponentity);
-    vector org = self.origin + self.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
-
-    if (!sound_allowed(MSG_BROADCAST, casingowner))
-        casingtype |= 0x80;
-
-    WriteHeader(MSG_ALL, casings);
-    WriteByte(MSG_ALL, casingtype);
-    WriteCoord(MSG_ALL, org.x);
-    WriteCoord(MSG_ALL, org.y);
-    WriteCoord(MSG_ALL, org.z);
-    WriteShort(MSG_ALL, compressShortVector(vel)); // actually compressed velocity
-    WriteByte(MSG_ALL, ang.x * 256 / 360);
-    WriteByte(MSG_ALL, ang.y * 256 / 360);
-    WriteByte(MSG_ALL, ang.z * 256 / 360);
-}
-#endif
-
-#ifdef CSQC
-entityclass(Casing);
-class(Casing) .float alpha;
-class(Casing) .bool silent;
-class(Casing) .int state;
-class(Casing) .float cnt;
-
-void Casing_Delete()
-{SELFPARAM();
-    remove(self);
-}
-
-void Casing_Draw(entity this)
-{
-    if (self.move_flags & FL_ONGROUND)
-    {
-        self.move_angles_x = 0;
-        self.move_angles_z = 0;
-        self.flags &= ~FL_ONGROUND;
-    }
-
-    Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
-    if (wasfreed(self))
-        return; // deleted by touch function
-
-    self.renderflags = 0;
-    self.alpha = bound(0, self.cnt - time, 1);
-
-    if (self.alpha < ALPHA_MIN_VISIBLE)
-    {
-        Casing_Delete();
-        self.drawmask = 0;
-    }
-}
-
-SOUND(BRASS1, W_Sound("brass1"));
-SOUND(BRASS2, W_Sound("brass2"));
-SOUND(BRASS3, W_Sound("brass3"));
-Sound SND_BRASS_RANDOM() {
-    return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
-}
-SOUND(CASINGS1, W_Sound("casings1"));
-SOUND(CASINGS2, W_Sound("casings2"));
-SOUND(CASINGS3, W_Sound("casings3"));
-Sound SND_CASINGS_RANDOM() {
-    return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
-}
-
-void Casing_Touch()
-{SELFPARAM();
-    if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
-    {
-        Casing_Delete();
-        return;
-    }
-
-    if (!self.silent)
-    if (!trace_ent || trace_ent.solid == SOLID_BSP)
-    {
-        if (vlen(self.velocity) > 50)
-        {
-            if (time >= self.nextthink)
-            {
-                Sound s;
-                switch (self.state)
-                {
-                    case 1:
-                        s = SND_CASINGS_RANDOM();
-                        break;
-                    default:
-                        s = SND_BRASS_RANDOM();
-                        break;
-                }
-
-                sound (self, CH_SHOTS, s, VOL_BASE, ATTEN_LARGE);
-            }
-        }
-    }
-
-    self.nextthink = time + 0.2;
-}
-
-void Casing_Damage(float thisdmg, int hittype, vector org, vector thisforce)
-{SELFPARAM();
-    if (thisforce.z < 0)
-        thisforce.z = 0;
-    self.move_velocity = self.move_velocity + thisforce + '0 0 100';
-    self.move_flags &= ~FL_ONGROUND;
-}
-
-NET_HANDLE(casings, bool isNew)
-{
-    int _state = ReadByte();
-    vector org;
-    org_x = ReadCoord();
-    org_y = ReadCoord();
-    org_z = ReadCoord();
-    vector vel = decompressShortVector(ReadShort());
-    vector ang;
-    ang_x = ReadByte() * 360 / 256;
-    ang_y = ReadByte() * 360 / 256;
-    ang_z = ReadByte() * 360 / 256;
-    return = true;
-
-    if (!autocvar_cl_casings) return;
-
-    Casing casing = RubbleNew("casing");
-    casing.silent = (_state & 0x80);
-    casing.state = (_state & 0x7F);
-    casing.origin = org;
-    setorigin(casing, casing.origin);
-    casing.velocity = vel;
-    casing.angles = ang;
-    casing.drawmask = MASK_NORMAL;
-
-    casing.draw = Casing_Draw;
-    casing.move_origin = casing.origin;
-    casing.move_velocity = casing.velocity + 2 * prandomvec();
-    casing.move_angles = casing.angles;
-    casing.move_avelocity = '0 250 0' + 100 * prandomvec();
-    casing.move_movetype = MOVETYPE_BOUNCE;
-    casing.move_touch = Casing_Touch;
-    casing.move_time = time;
-    casing.event_damage = Casing_Damage;
-    casing.solid = SOLID_TRIGGER;
-
-    switch (casing.state)
-    {
-        case 1:
-            setmodel(casing, MDL_CASING_SHELL);
-            casing.cnt = time + autocvar_cl_casings_shell_time;
-            break;
-        default:
-            setmodel(casing, MDL_CASING_BULLET);
-            casing.cnt = time + autocvar_cl_casings_bronze_time;
-            break;
-    }
-
-    setsize(casing, '0 0 -1', '0 0 -1');
-
-    RubbleLimit("casing", autocvar_cl_casings_maxcount, Casing_Delete);
-}
-
-#endif
index 2e5bfef250d53c85ac60b312d26b34c115ebfe39..7b0639610b9fef2dffcc731d8d8d3251f1bb4023 100644 (file)
@@ -1 +1,2 @@
+#include "casings.qc"
 #include "lightningarc.qc"
diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc
new file mode 100644 (file)
index 0000000..e79300c
--- /dev/null
@@ -0,0 +1,178 @@
+#ifdef IMPLEMENTATION
+
+#include "../../util.qh"
+
+#ifdef CSQC
+#include "../../movetypes/movetypes.qh"
+#include "../../../client/rubble.qh"
+#endif
+
+REGISTER_NET_TEMP(casings)
+
+#ifdef SVQC
+void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner)
+{SELFPARAM();
+    .entity weaponentity = weaponentities[0]; // TODO: parameter
+    entity wep = self.(weaponentity);
+    vector org = self.origin + self.view_ofs + wep.spawnorigin.x * v_forward - wep.spawnorigin.y * v_right + wep.spawnorigin.z * v_up;
+
+    if (!sound_allowed(MSG_BROADCAST, casingowner))
+        casingtype |= 0x80;
+
+    WriteHeader(MSG_ALL, casings);
+    WriteByte(MSG_ALL, casingtype);
+    WriteCoord(MSG_ALL, org.x);
+    WriteCoord(MSG_ALL, org.y);
+    WriteCoord(MSG_ALL, org.z);
+    WriteShort(MSG_ALL, compressShortVector(vel)); // actually compressed velocity
+    WriteByte(MSG_ALL, ang.x * 256 / 360);
+    WriteByte(MSG_ALL, ang.y * 256 / 360);
+    WriteByte(MSG_ALL, ang.z * 256 / 360);
+}
+#endif
+
+#ifdef CSQC
+entityclass(Casing);
+class(Casing) .float alpha;
+class(Casing) .bool silent;
+class(Casing) .int state;
+class(Casing) .float cnt;
+
+void Casing_Delete()
+{SELFPARAM();
+    remove(self);
+}
+
+void Casing_Draw(entity this)
+{
+    if (self.move_flags & FL_ONGROUND)
+    {
+        self.move_angles_x = 0;
+        self.move_angles_z = 0;
+        self.flags &= ~FL_ONGROUND;
+    }
+
+    Movetype_Physics_MatchTicrate(autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+    if (wasfreed(self))
+        return; // deleted by touch function
+
+    self.renderflags = 0;
+    self.alpha = bound(0, self.cnt - time, 1);
+
+    if (self.alpha < ALPHA_MIN_VISIBLE)
+    {
+        Casing_Delete();
+        self.drawmask = 0;
+    }
+}
+
+SOUND(BRASS1, W_Sound("brass1"));
+SOUND(BRASS2, W_Sound("brass2"));
+SOUND(BRASS3, W_Sound("brass3"));
+Sound SND_BRASS_RANDOM() {
+    return Sounds_from(SND_BRASS1.m_id + floor(prandom() * 3));
+}
+SOUND(CASINGS1, W_Sound("casings1"));
+SOUND(CASINGS2, W_Sound("casings2"));
+SOUND(CASINGS3, W_Sound("casings3"));
+Sound SND_CASINGS_RANDOM() {
+    return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
+}
+
+void Casing_Touch()
+{SELFPARAM();
+    if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
+    {
+        Casing_Delete();
+        return;
+    }
+
+    if (!self.silent)
+    if (!trace_ent || trace_ent.solid == SOLID_BSP)
+    {
+        if (vlen(self.velocity) > 50)
+        {
+            if (time >= self.nextthink)
+            {
+                Sound s;
+                switch (self.state)
+                {
+                    case 1:
+                        s = SND_CASINGS_RANDOM();
+                        break;
+                    default:
+                        s = SND_BRASS_RANDOM();
+                        break;
+                }
+
+                sound (self, CH_SHOTS, s, VOL_BASE, ATTEN_LARGE);
+            }
+        }
+    }
+
+    self.nextthink = time + 0.2;
+}
+
+void Casing_Damage(float thisdmg, int hittype, vector org, vector thisforce)
+{SELFPARAM();
+    if (thisforce.z < 0)
+        thisforce.z = 0;
+    self.move_velocity = self.move_velocity + thisforce + '0 0 100';
+    self.move_flags &= ~FL_ONGROUND;
+}
+
+NET_HANDLE(casings, bool isNew)
+{
+    int _state = ReadByte();
+    vector org;
+    org_x = ReadCoord();
+    org_y = ReadCoord();
+    org_z = ReadCoord();
+    vector vel = decompressShortVector(ReadShort());
+    vector ang;
+    ang_x = ReadByte() * 360 / 256;
+    ang_y = ReadByte() * 360 / 256;
+    ang_z = ReadByte() * 360 / 256;
+    return = true;
+
+    if (!autocvar_cl_casings) return;
+
+    Casing casing = RubbleNew("casing");
+    casing.silent = (_state & 0x80);
+    casing.state = (_state & 0x7F);
+    casing.origin = org;
+    setorigin(casing, casing.origin);
+    casing.velocity = vel;
+    casing.angles = ang;
+    casing.drawmask = MASK_NORMAL;
+
+    casing.draw = Casing_Draw;
+    casing.move_origin = casing.origin;
+    casing.move_velocity = casing.velocity + 2 * prandomvec();
+    casing.move_angles = casing.angles;
+    casing.move_avelocity = '0 250 0' + 100 * prandomvec();
+    casing.move_movetype = MOVETYPE_BOUNCE;
+    casing.move_touch = Casing_Touch;
+    casing.move_time = time;
+    casing.event_damage = Casing_Damage;
+    casing.solid = SOLID_TRIGGER;
+
+    switch (casing.state)
+    {
+        case 1:
+            setmodel(casing, MDL_CASING_SHELL);
+            casing.cnt = time + autocvar_cl_casings_shell_time;
+            break;
+        default:
+            setmodel(casing, MDL_CASING_BULLET);
+            casing.cnt = time + autocvar_cl_casings_bronze_time;
+            break;
+    }
+
+    setsize(casing, '0 0 -1', '0 0 -1');
+
+    RubbleLimit("casing", autocvar_cl_casings_maxcount, Casing_Delete);
+}
+
+#endif
+#endif
index 561a1d17b17eab868a172e3d89377e8b9d922d5f..6fd58e707626ca94baef223eea21d6efe2a54ac6 100644 (file)
@@ -57,7 +57,6 @@
 #include "../common/animdecide.qc"
 #include "../common/campaign_file.qc"
 #include "../common/campaign_setup.qc"
-#include "../common/casings.qc"
 #include "../common/effects/effectinfo.qc"
 #include "../common/mapinfo.qc"
 #include "../common/minigames/minigames.qc"