]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/ons_camera
authorterencehill <piuntn@gmail.com>
Tue, 18 Oct 2016 17:52:27 +0000 (19:52 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 18 Oct 2016 17:52:27 +0000 (19:52 +0200)
1  2 
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc

index 284b4fbb986341a8f89f6ae6fb53f41fc0eb882b,a18ce34c5d06e83ad98d95a2e606f0034b5bc333..f84a42eb6f567d5e760d89a738e6a4eac973ed2a
@@@ -28,27 -28,11 +28,27 @@@ float autocvar_g_onslaught_spawn_choose
  float autocvar_g_onslaught_click_radius;
  
  void FixSize(entity e);
 +entity cam;
  
  // =======================
  // CaptureShield Functions
  // =======================
  
 +bool clientcamera_send(entity this, entity to, int sf)
 +{
 +      WriteHeader(MSG_ENTITY, ENT_ONSCAMERA);
 +
 +      WriteCoord(MSG_ENTITY, this.origin_x);
 +      WriteCoord(MSG_ENTITY, this.origin_y);
 +      WriteCoord(MSG_ENTITY, this.origin_z);
 +
 +      WriteAngle(MSG_ENTITY, this.angles_x);
 +      WriteAngle(MSG_ENTITY, this.angles_y);
 +      WriteAngle(MSG_ENTITY, this.angles_z);
 +
 +      return true;
 +}
 +
  bool ons_CaptureShield_Customize(entity this, entity client)
  {
        entity e = WaypointSprite_getviewentity(client);
@@@ -833,45 -817,6 +833,45 @@@ void ons_Generator_UpdateSprite(entity 
        }
  }
  
 +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 = best_ang;
 +      Net_LinkEntity(cam, false, 0, clientcamera_send);
 +
 +      FOREACH_CLIENT(true, it.clientcamera = cam;);
 +
 +      WriteByte(MSG_ALL, SVC_SETVIEWANGLES);
 +      WriteAngle(MSG_ALL, cam.angles_x);
 +      WriteAngle(MSG_ALL, cam.angles_y);
 +      WriteAngle(MSG_ALL, cam.angles_z);
 +}
 +
  void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
  {
        if(damage <= 0) { return; }
                //WaypointSprite_Kill(this.sprite); // can't do this yet, code too poor
  
                onslaught_updatelinks();
 +
 +              ons_camSetup(this);
        }
  
        // Throw some flaming gibs on damage, more damage = more chance for gib
@@@ -1742,7 -1685,7 +1742,7 @@@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn
                {
                        if(SAME_TEAM(tmp_entity, player))
                        if(random_target)
-                               RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
+                               RandomSelection_AddEnt(tmp_entity, 1, 1);
                        else if(vlen2(tmp_entity.origin - spawn_loc) <= vlen2(closest_target.origin - spawn_loc) || closest_target == NULL)
                                closest_target = tmp_entity;
                }
                for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
                {
                        if(random_target)
-                               RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
+                               RandomSelection_AddEnt(tmp_entity, 1, 1);
                        else
                        {
                                if(SAME_TEAM(tmp_entity, player))