From: terencehill Date: Mon, 19 Sep 2016 15:20:11 +0000 (+0200) Subject: Find best suitable angles for the generator's camera X-Git-Tag: xonotic-v0.8.2~487^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=64e4b229339877b89f155e2bfd4d1924903d9edc;p=xonotic%2Fxonotic-data.pk3dir.git Find best suitable angles for the generator's camera --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 8426b202d..284b4fbb9 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -837,10 +837,31 @@ void ons_camSetup(entity this) { if(cam) return; + vector dir; + vector ang = '0 0 0'; + vector best_ang = '0 0 0'; + float best_trace_fraction = 0; + while(ang.y < 360) + { + dir = eX * cos(ang.y * DEG2RAD) + eY * sin(ang.y * DEG2RAD); + dir *= 500; + traceline(this.origin, this.origin - dir, MOVE_WORLDONLY, this); + if(trace_fraction > best_trace_fraction) + { + best_trace_fraction = trace_fraction; + best_ang = ang; + if(trace_fraction == 1) + break; + } + ang.y += 90; + if(ang.y == 360) + ang.y = 45; + } + cam = new(objective_camera); cam.origin = this.origin; setorigin(cam, cam.origin); - cam.angles = this.angles; + cam.angles = best_ang; Net_LinkEntity(cam, false, 0, clientcamera_send); FOREACH_CLIENT(true, it.clientcamera = cam;);