]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Minor cleanup to func_vectormamamam, fix message2 not displaying properly if message...
authorMario <mario.mario@y7mail.com>
Fri, 31 Jul 2020 02:10:33 +0000 (12:10 +1000)
committerMario <mario.mario@y7mail.com>
Fri, 31 Jul 2020 02:10:45 +0000 (12:10 +1000)
qcsrc/common/mapobjects/func/vectormamamam.qc
qcsrc/common/mapobjects/func/vectormamamam.qh

index 4882fe37d83937798985bb545dd62c37783be626..bd1e14fb1671a3e307bd0e93ee0b3ae5d58d4c5b 100644 (file)
@@ -8,18 +8,16 @@
 
 vector func_vectormamamam_origin(entity o, float timestep)
 {
-       vector v, p;
-       float flags;
+       vector p;
        entity e;
-
-       flags = o.spawnflags;
-       v = '0 0 0';
+       int myflags = o.spawnflags;
+       vector v = '0 0 0';
 
        e = o.wp00;
        if(e)
        {
                p = e.origin + timestep * e.velocity;
-               if(flags & PROJECT_ON_TARGETNORMAL)
+               if(myflags & PROJECT_ON_TARGETNORMAL)
                        v = v + (p * o.targetnormal) * o.targetnormal * o.targetfactor;
                else
                        v = v + (p - (p * o.targetnormal) * o.targetnormal) * o.targetfactor;
@@ -29,7 +27,7 @@ vector func_vectormamamam_origin(entity o, float timestep)
        if(e)
        {
                p = e.origin + timestep * e.velocity;
-               if(flags & PROJECT_ON_TARGET2NORMAL)
+               if(myflags & PROJECT_ON_TARGET2NORMAL)
                        v = v + (p * o.target2normal) * o.target2normal * o.target2factor;
                else
                        v = v + (p - (p * o.target2normal) * o.target2normal) * o.target2factor;
@@ -39,7 +37,7 @@ vector func_vectormamamam_origin(entity o, float timestep)
        if(e)
        {
                p = e.origin + timestep * e.velocity;
-               if(flags & PROJECT_ON_TARGET3NORMAL)
+               if(myflags & PROJECT_ON_TARGET3NORMAL)
                        v = v + (p * o.target3normal) * o.target3normal * o.target3factor;
                else
                        v = v + (p - (p * o.target3normal) * o.target3normal) * o.target3factor;
@@ -49,7 +47,7 @@ vector func_vectormamamam_origin(entity o, float timestep)
        if(e)
        {
                p = e.origin + timestep * e.velocity;
-               if(flags & PROJECT_ON_TARGET4NORMAL)
+               if(myflags & 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 +58,7 @@ vector func_vectormamamam_origin(entity o, float timestep)
 
 void func_vectormamamam_controller_think(entity this)
 {
-       this.nextthink = time + vectormamamam_timestep;
+       this.nextthink = time + VECTORMAMAMAM_TIMESTEP;
 
        if(this.owner.active != ACTIVE_ACTIVE)
        {
@@ -69,21 +67,21 @@ 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, vectormamamam_timestep) - 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)
 {
-       if(this.target != "")
+       if(this.target && this.target != "")
                this.wp00 = find(NULL, targetname, this.target);
 
-       if(this.target2 != "")
+       if(this.target2 && this.target2 != "")
                this.wp01 = find(NULL, targetname, this.target2);
 
-       if(this.target3 != "")
+       if(this.target3 && this.target3 != "")
                this.wp02 = find(NULL, targetname, this.target3);
 
-       if(this.target4 != "")
+       if(this.target4 && this.target4 != "")
                this.wp03 = find(NULL, targetname, this.target4);
 
        if(!this.wp00 && !this.wp01 && !this.wp02 && !this.wp03)
@@ -91,8 +89,7 @@ void func_vectormamamam_findtarget(entity this)
 
        this.destvec = this.origin - func_vectormamamam_origin(this, 0);
 
-       entity controller;
-       controller = new(func_vectormamamam_controller);
+       entity controller = new(func_vectormamamam_controller);
        controller.owner = this;
        controller.nextthink = time + 1;
        setthink(controller, func_vectormamamam_controller_think);
@@ -164,9 +161,9 @@ spawnfunc(func_vectormamamam)
                this.target4normal = normalize(this.target4normal);
 
        setblocked(this, generic_plat_blocked);
-       if(this.dmg && (this.message == ""))
+       if(this.dmg && (!this.message || this.message == ""))
                this.message = " was squished";
-    if(this.dmg && (this.message == ""))
+    if(this.dmg && (!this.message2 || this.message2 == ""))
                this.message2 = "was squished by";
        if(this.dmg && (!this.dmgtime))
                this.dmgtime = 0.25;
index 7eb6b0a63b0f1be400212e81a94c1f41679cb2e5..c024160f78cc133f226ba46e68926af8ab1e4c71 100644 (file)
@@ -1,9 +1,8 @@
 #pragma once
 
-
 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);
 
-const float vectormamamam_timestep = 0.1;
+const float VECTORMAMAMAM_TIMESTEP = 0.1;