]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/effects/qc/casings.qc
Step 5: complete
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / effects / qc / casings.qc
index 3e0aa3592a6243fb034bf2e1afdbd853601a54b3..605d42e671a86dd7cf55b020d720fb1d83ac64ac 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef SVQC
+void SpawnCasing(vector vel, float randomvel, vector ang, vector avel, float randomavel, int casingtype, entity casingowner);
+#endif
+
 #ifdef IMPLEMENTATION
 
 #include <common/util.qh>
@@ -11,10 +15,10 @@ 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;
+    entity wep = casingowner.(weaponentity);
+    vector org = casingowner.origin + casingowner.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;
@@ -38,31 +42,31 @@ class(Casing) .bool silent;
 class(Casing) .int state;
 class(Casing) .float cnt;
 
-void Casing_Delete()
-{SELFPARAM();
-    remove(self);
+void Casing_Delete(entity this)
+{
+    remove(this);
 }
 
 void Casing_Draw(entity this)
 {
-    if (self.move_flags & FL_ONGROUND)
+    if (this.move_flags & FL_ONGROUND)
     {
-        self.move_angles_x = 0;
-        self.move_angles_z = 0;
-        UNSET_ONGROUND(self);
+        this.move_angles_x = 0;
+        this.move_angles_z = 0;
+        UNSET_ONGROUND(this);
     }
 
-    Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
-    if (wasfreed(self))
+    Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+    if (wasfreed(this))
         return; // deleted by touch function
 
-    self.renderflags = 0;
-    self.alpha = bound(0, self.cnt - time, 1);
+    this.renderflags = 0;
+    this.alpha = bound(0, this.cnt - time, 1);
 
-    if (self.alpha < ALPHA_MIN_VISIBLE)
+    if (this.alpha < ALPHA_MIN_VISIBLE)
     {
-        Casing_Delete();
-        self.drawmask = 0;
+        Casing_Delete(this);
+        this.drawmask = 0;
     }
 }
 
@@ -79,23 +83,23 @@ Sound SND_CASINGS_RANDOM() {
     return Sounds_from(SND_CASINGS1.m_id + floor(prandom() * 3));
 }
 
-void Casing_Touch()
-{SELFPARAM();
+void Casing_Touch(entity this)
+{
     if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
     {
-        Casing_Delete();
+        Casing_Delete(this);
         return;
     }
 
-    if (!self.silent)
+    if (!this.silent)
     if (!trace_ent || trace_ent.solid == SOLID_BSP)
     {
-        if(vdist(self.velocity, >, 50))
+        if(vdist(this.velocity, >, 50))
         {
-            if (time >= self.nextthink)
+            if (time >= this.nextthink)
             {
                 Sound s;
-                switch (self.state)
+                switch (this.state)
                 {
                     case 1:
                         s = SND_CASINGS_RANDOM();
@@ -105,12 +109,12 @@ void Casing_Touch()
                         break;
                 }
 
-                sound (self, CH_SHOTS, s, VOL_BASE, ATTEN_LARGE);
+                sound (this, CH_SHOTS, s, VOL_BASE, ATTEN_LARGE);
             }
         }
     }
 
-    self.nextthink = time + 0.2;
+    this.nextthink = time + 0.2;
 }
 
 void Casing_Damage(entity this, float thisdmg, int hittype, vector org, vector thisforce)
@@ -152,7 +156,7 @@ NET_HANDLE(casings, bool isNew)
     casing.move_angles = casing.angles;
     casing.move_avelocity = '0 250 0' + 100 * prandomvec();
     casing.move_movetype = MOVETYPE_BOUNCE;
-    casing.move_touch = Casing_Touch;
+    settouch(casing, Casing_Touch);
     casing.move_time = time;
     casing.event_damage = Casing_Damage;
     casing.solid = SOLID_TRIGGER;