]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapobjects/trigger/jumppads.qc
Rename sv_vq3compat to sv_q3defragcompat to clarify its purpose
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / trigger / jumppads.qc
index a61935eb8c5633515f95924872fb9daa25a49ccf..2c160eae95e8a05e75f1ead2512b81c257716242 100644 (file)
@@ -36,8 +36,8 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity p
        torg = tgt.origin + (tgt.mins + tgt.maxs) * 0.5;
 
        grav = PHYS_GRAVITY(NULL);
-       if(pushed_entity && PHYS_ENTGRAVITY(pushed_entity))
-               grav *= PHYS_ENTGRAVITY(pushed_entity);
+       if(pushed_entity && pushed_entity.gravity)
+               grav *= pushed_entity.gravity;
 
        zdist = torg.z - org.z;
        sdist = vlen(torg - org - zdist * '0 0 1');
@@ -135,9 +135,9 @@ bool jumppad_push(entity this, entity targ)
 
        vector org = targ.origin;
 #ifdef SVQC
-       if(autocvar_sv_vq3compat)
+       if(autocvar_sv_q3defragcompat)
 #elif defined(CSQC)
-       if(STAT(VQ3COMPAT))
+       if(STAT(Q3DEFRAGCOMPAT))
 #endif
        {
                org.z += targ.mins_z;
@@ -339,13 +339,57 @@ bool trigger_push_testorigin_for_item(entity tracetest_ent, entity item, vector
 }
 #endif
 
+#ifdef SVQC
+vector trigger_push_get_start_point(entity this)
+{
+       // 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 - 7;
+       return org;
+}
+
+float trigger_push_get_push_time(entity this, vector endpos)
+{
+       vector org = trigger_push_get_start_point(this);
+
+       float grav = PHYS_GRAVITY(NULL);
+
+       entity t = this.enemy;
+       if (t)
+       {
+               entity e = spawn();
+               setsize(e, PL_MIN_CONST, PL_MAX_CONST);
+               e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+               vector v = trigger_push_calculatevelocity(org, t, this.height, e);
+               vector v2 = trigger_push_calculatevelocity(endpos, t, this.height, e);
+               delete(e);
+               return (v.z + v2.z) / grav;
+       }
+       else if (!(this.target && this.target != ""))
+       {
+               if (!this.team)
+               {
+                       vector v = this.movedir;
+
+                       float t = v.z / grav;
+                       float jump_height = 1/2 * grav * (t ** 2);
+                       float remaining_height = org.z + jump_height - endpos.z;
+                       float v2_z = sqrt(2 * grav * remaining_height);
+
+                       return (v.z + v2_z) / grav;
+               }
+       }
+       return 0;
+}
+#endif
+
 /// if (item != NULL) returns true if the item can be reached by using this jumppad, false otherwise
 /// if (item == NULL) tests jumppad's trajectory and eventually spawns waypoints for it (return value doesn't matter)
 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 - 7;
+#ifdef SVQC
+       vector org = trigger_push_get_start_point(this);
+#endif
 
        if (this.target)
        {