]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
func_vectormamamam: remove magic numbers and better variable names
authorFreddy <schro.sb@gmail.com>
Fri, 9 Mar 2018 22:19:45 +0000 (23:19 +0100)
committerFreddy <schro.sb@gmail.com>
Fri, 9 Mar 2018 22:19:45 +0000 (23:19 +0100)
qcsrc/common/triggers/func/vectormamamam.qc
qcsrc/common/triggers/func/vectormamamam.qh
qcsrc/common/triggers/spawnflags.qh

index 951a740a2024675371cd2e35412f8887adfe188e..8812930b2ed2b2a45ca7987009451712ef27af8c 100644 (file)
@@ -6,20 +6,20 @@
 .float targetfactor, target2factor, target3factor, target4factor;
 .vector targetnormal, target2normal, target3normal, target4normal;
 
-vector func_vectormamamam_origin(entity o, float t)
+vector func_vectormamamam_origin(entity o, float timestep)
 {
        vector v, p;
-       float f;
+       float flags;
        entity e;
 
-       f = o.spawnflags;
+       flags = o.spawnflags;
        v = '0 0 0';
 
        e = o.wp00;
        if(e)
        {
-               p = e.origin + t * e.velocity;
-               if(f & 1)
+               p = e.origin + timestep * e.velocity;
+               if(flags & PROJECT_ON_TARGETNORMAL)
                        v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
                else
                        v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
@@ -28,8 +28,8 @@ vector func_vectormamamam_origin(entity o, float t)
        e = o.wp01;
        if(e)
        {
-               p = e.origin + t * e.velocity;
-               if(f & 2)
+               p = e.origin + timestep * e.velocity;
+               if(flags & PROJECT_ON_TARGET2NORMAL)
                        v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
                else
                        v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
@@ -38,8 +38,8 @@ vector func_vectormamamam_origin(entity o, float t)
        e = o.wp02;
        if(e)
        {
-               p = e.origin + t * e.velocity;
-               if(f & 4)
+               p = e.origin + timestep * e.velocity;
+               if(flags & PROJECT_ON_TARGET3NORMAL)
                        v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
                else
                        v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
@@ -48,8 +48,8 @@ vector func_vectormamamam_origin(entity o, float t)
        e = o.wp03;
        if(e)
        {
-               p = e.origin + t * e.velocity;
-               if(f & 8)
+               p = e.origin + timestep * e.velocity;
+               if(flags & PROJECT_ON_TARGET4NORMAL)
                        v = v + (p * o.target4normal) * o.target4normal * o.target4factor;
                else
                        v = v + (p - (p * o.target4normal) * o.target4normal) * o.target4factor;
@@ -60,7 +60,7 @@ vector func_vectormamamam_origin(entity o, float t)
 
 void func_vectormamamam_controller_think(entity this)
 {
-       this.nextthink = time + 0.1;
+       this.nextthink = time + vectormamamam_timestep;
 
        if(this.owner.active != ACTIVE_ACTIVE)
        {
@@ -69,7 +69,7 @@ void func_vectormamamam_controller_think(entity this)
        }
 
        if(this.owner.classname == "func_vectormamamam") // don't brake stuff if the func_vectormamamam was killtarget'ed
-               this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, 0.1) - this.owner.origin) * 10;
+               this.owner.velocity = (this.owner.destvec + func_vectormamamam_origin(this.owner, vectormamamam_timestep) - this.owner.origin) * 10;
 }
 
 void func_vectormamamam_findtarget(entity this)
@@ -139,9 +139,6 @@ spawnfunc(func_vectormamamam)
                this.dmgtime = 0.25;
        this.dmgtime2 = time;
 
-       if(this.netname == "")
-               this.netname = "1 0 0 0 1";
-
        if (!InitMovingBrushTrigger(this))
                return;
 
index 6f70f09beec2219624baeca92e2cd7deaa104fb4..4f40f629227631020280322a00cba7ea95a6f6a4 100644 (file)
@@ -1 +1,5 @@
 #pragma once
+#include "../spawnflags.qh"
+
+
+const float vectormamamam_timestep = 0.1;
index fb34b3f162f6c04e046b5e18295ffc0634adbb89..7eac4991756dffd47f21e385bdfedb4f4427428d 100644 (file)
@@ -61,6 +61,12 @@ const int VIEWLOC_NOSIDESCROLL = BIT(0); // NOTE: currently unimplemented
 const int VIEWLOC_FREEAIM = BIT(1);
 const int VIEWLOC_FREEMOVE = BIT(2);
 
+// vectormamamam
+const int PROJECT_ON_TARGETNORMAL = BIT(0);
+const int PROJECT_ON_TARGET2NORMAL = BIT(1);
+const int PROJECT_ON_TARGET3NORMAL = BIT(2);
+const int PROJECT_ON_TARGET4NORMAL = BIT(3);
+
 // platforms
 const int PLAT_LOW_TRIGGER = BIT(0);
 const int PLAT_CRUSH = BIT(2);