From: Mario Date: Fri, 31 Jul 2020 02:10:33 +0000 (+1000) Subject: Minor cleanup to func_vectormamamam, fix message2 not displaying properly if message... X-Git-Tag: xonotic-v0.8.5~821 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=76c39b503985ddf85c6df4bc674eb25566316069;p=xonotic%2Fxonotic-data.pk3dir.git Minor cleanup to func_vectormamamam, fix message2 not displaying properly if message is null --- diff --git a/qcsrc/common/mapobjects/func/vectormamamam.qc b/qcsrc/common/mapobjects/func/vectormamamam.qc index 4882fe37d..bd1e14fb1 100644 --- a/qcsrc/common/mapobjects/func/vectormamamam.qc +++ b/qcsrc/common/mapobjects/func/vectormamamam.qc @@ -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; diff --git a/qcsrc/common/mapobjects/func/vectormamamam.qh b/qcsrc/common/mapobjects/func/vectormamamam.qh index 7eb6b0a63..c024160f7 100644 --- a/qcsrc/common/mapobjects/func/vectormamamam.qh +++ b/qcsrc/common/mapobjects/func/vectormamamam.qh @@ -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;