]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/triggers/trigger/jumppads.qc
Merge branch 'master' into terencehill/bot_waypoints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / jumppads.qc
index 5bb6d39877ac610803f0a9fb029db9d36420554b..a31f5a482f69bf12fff4b93bbe1c162dc9455640 100644 (file)
@@ -207,7 +207,10 @@ bool jumppad_push(entity this, entity targ)
                                        centerprint(targ, this.message);
                        }
                        else
+                       {
                                targ.lastteleporttime = time;
+                               targ.lastteleport_origin = targ.origin;
+                       }
 
                        if (!IS_DEAD(targ))
                                animdecide_setaction(targ, ANIMACTION_JUMP, true);
@@ -278,23 +281,27 @@ bool trigger_push_testorigin(entity tracetest_ent, entity targ, entity jp, vecto
        if(trace_startsolid)
                return false;
 
-       if(!jp.height)
+       if (!jp.height)
        {
                // since tracetoss starting from jumppad's origin often fails when target
                // is very close to real destination, start it directly from target's
                // origin instead
+               vector ofs = '0 0 0';
+               if (vdist(vec2(tracetest_ent.velocity), <, autocvar_sv_maxspeed))
+                       ofs = stepheightvec;
+
                tracetest_ent.velocity.z = 0;
-               setorigin(tracetest_ent, targ.origin + stepheightvec);
+               setorigin(tracetest_ent, targ.origin + ofs);
                tracetoss(tracetest_ent, tracetest_ent);
-               if(trace_startsolid)
+               if (trace_startsolid && ofs.z)
                {
-                       setorigin(tracetest_ent, targ.origin + stepheightvec / 2);
+                       setorigin(tracetest_ent, targ.origin + ofs / 2);
                        tracetoss(tracetest_ent, tracetest_ent);
-                       if(trace_startsolid)
+                       if (trace_startsolid && ofs.z)
                        {
                                setorigin(tracetest_ent, targ.origin);
                                tracetoss(tracetest_ent, tracetest_ent);
-                               if(trace_startsolid)
+                               if (trace_startsolid)
                                        return false;
                        }
                }
@@ -310,7 +317,7 @@ bool trigger_push_test(entity this, entity item)
 {
        // first calculate a typical start point for the jump
        vector org = (this.absmin + this.absmax) * 0.5;
-       org.z = this.absmax.z - PL_MIN_CONST.z;
+       org.z = this.absmax.z - PL_MIN_CONST.z - 7;
 
        if (this.target)
        {
@@ -465,9 +472,7 @@ float trigger_push_send(entity this, entity to, float sf)
        WriteByte(MSG_ENTITY, this.active);
        WriteCoord(MSG_ENTITY, this.height);
 
-       WriteCoord(MSG_ENTITY, this.movedir_x);
-       WriteCoord(MSG_ENTITY, this.movedir_y);
-       WriteCoord(MSG_ENTITY, this.movedir_z);
+       WriteVector(MSG_ENTITY, this.movedir);
 
        trigger_common_write(this, true);
 
@@ -530,9 +535,7 @@ bool target_push_send(entity this, entity to, float sf)
 
        WriteByte(MSG_ENTITY, this.cnt);
        WriteString(MSG_ENTITY, this.targetname);
-       WriteCoord(MSG_ENTITY, this.origin_x);
-       WriteCoord(MSG_ENTITY, this.origin_y);
-       WriteCoord(MSG_ENTITY, this.origin_z);
+       WriteVector(MSG_ENTITY, this.origin);
 
        WriteAngle(MSG_ENTITY, this.angles_x);
        WriteAngle(MSG_ENTITY, this.angles_y);
@@ -588,9 +591,7 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
        this.active = ReadByte();
        this.height = ReadCoord();
 
-       this.movedir_x = ReadCoord();
-       this.movedir_y = ReadCoord();
-       this.movedir_z = ReadCoord();
+       this.movedir = ReadVector();
 
        trigger_common_read(this, true);
 
@@ -605,13 +606,8 @@ NET_HANDLE(ENT_CLIENT_TRIGGER_PUSH, bool isnew)
 
 void target_push_remove(entity this)
 {
-       //if(this.classname)
-               //strunzone(this.classname);
-       //this.classname = string_null;
-
-       if(this.targetname)
-               strunzone(this.targetname);
-       this.targetname = string_null;
+       // strfree(this.classname);
+       strfree(this.targetname);
 }
 
 NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew)
@@ -619,9 +615,7 @@ NET_HANDLE(ENT_CLIENT_TARGET_PUSH, bool isnew)
        this.classname = "push_target";
        this.cnt = ReadByte();
        this.targetname = strzone(ReadString());
-       this.origin_x = ReadCoord();
-       this.origin_y = ReadCoord();
-       this.origin_z = ReadCoord();
+       this.origin = ReadVector();
 
        this.angles_x = ReadAngle();
        this.angles_y = ReadAngle();