]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve creation of destination waypoints for ladders with a lateral exit (e.g. under...
authorterencehill <piuntn@gmail.com>
Mon, 24 Jul 2017 18:36:30 +0000 (20:36 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 24 Jul 2017 18:38:40 +0000 (20:38 +0200)
qcsrc/common/triggers/func/ladder.qc

index 42fe0b9d302519a6a7da8d66ab0b7a3aeb3e00ce..9aec33b90702a2fa53306d972aba5351ecfce384 100644 (file)
@@ -60,7 +60,39 @@ void func_ladder_init(entity this)
                {
                        tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
                        if(trace_startsolid)
-                               return;
+                       {
+                               if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
+                                       && this.absmax.y - this.absmin.y < this.absmax.x - this.absmin.x)
+                               {
+                                       // move top on one side
+                                       top_max.y = top_min.y = this.absmin.y + (PL_MAX_CONST.y - PL_MIN_CONST.y) * 0.75;
+                               }
+                               else if(this.absmax.y - this.absmin.y > PL_MAX_CONST.y - PL_MIN_CONST.y
+                                       && this.absmax.x - this.absmin.x < this.absmax.y - this.absmin.y)
+                               {
+                                       // move top on one side
+                                       top_max.x = top_min.x = this.absmin.x + (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
+                               }
+                               tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+                               if(trace_startsolid)
+                               {
+                                       if(this.absmax.x - this.absmin.x > PL_MAX_CONST.x - PL_MIN_CONST.x
+                                               && this.absmax.y - this.absmin.y < this.absmax.x - this.absmin.x)
+                                       {
+                                               // alternatively on the other side
+                                               top_max.y = top_min.y = this.absmax.y - (PL_MAX_CONST.y - PL_MIN_CONST.y) * 0.75;
+                                       }
+                                       else if(this.absmax.y - this.absmin.y > PL_MAX_CONST.y - PL_MIN_CONST.y
+                                               && this.absmax.x - this.absmin.x < this.absmax.y - this.absmin.y)
+                                       {
+                                               // alternatively on the other side
+                                               top_max.x = top_min.x = this.absmax.x - (PL_MAX_CONST.x - PL_MIN_CONST.x) * 0.75;
+                                       }
+                                       tracebox(top_max, PL_MIN_CONST, PL_MAX_CONST, top_min, MOVE_NOMONSTERS, NULL);
+                                       if(trace_startsolid)
+                                               return;
+                               }
+                       }
                }
        }
        if(trace_endpos.z < this.absmax.z)