Merge branch 'master' into terencehill/bot_waypoints
authorterencehill <piuntn@gmail.com>
Sat, 23 Dec 2017 17:51:09 +0000 (18:51 +0100)
committerterencehill <piuntn@gmail.com>
Sat, 23 Dec 2017 17:51:09 +0000 (18:51 +0100)
# Conflicts:
# qcsrc/common/triggers/trigger/jumppads.qc
# qcsrc/common/triggers/trigger/jumppads.qh

1  2 
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/jumppads.qh
qcsrc/server/bot/default/bot.qc

@@@ -25,10 -25,14 +25,11 @@@ REGISTER_NET_LINKED(ENT_CLIENT_TARGET_P
          tgt - target entity (can be either a point or a model entity; if it is
                the latter, its midpoint is used)
          ht  - jump height, measured from the higher one of org and tgt's midpoint
+         pushed_entity - object that is to be pushed
  
        Returns: velocity for the jump
 -      the global trigger_push_calculatevelocity_flighttime is set to the total
 -      jump time
   */
- vector trigger_push_calculatevelocity(vector org, entity tgt, float ht)
 -
+ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity pushed_entity)
  {
        float grav, sdist, zdist, vs, vz, jumpheight;
        vector sdir, torg;
@@@ -318,73 -287,13 +319,73 @@@ void trigger_push_findtarget(entity thi
                {
                        ++n;
  #ifdef SVQC
 +                      if(t.move_movetype != MOVETYPE_NONE)
 +                              continue;
 +
                        entity e = spawn();
 -                      setorigin(e, org);
                        setsize(e, PL_MIN_CONST, PL_MAX_CONST);
-                       e.velocity = trigger_push_calculatevelocity(org, t, this.height);
 +                      e.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
 -                      tracetoss(e, e);
 -                      if(e.move_movetype == MOVETYPE_NONE)
 -                              waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity));
+                       e.velocity = trigger_push_calculatevelocity(org, t, this.height, e);
-                               e.velocity = trigger_push_calculatevelocity(new_org, t, this.height);
 +                      vel = e.velocity;
 +                      vector best_target = '0 0 0';
 +                      vector best_org = '0 0 0';
 +                      vector best_vel = '0 0 0';
 +                      bool valid_best_target = false;
 +                      if (trigger_push_testorigin(e, t, this, org))
 +                      {
 +                              best_target = trace_endpos;
 +                              best_org = org;
 +                              best_vel = e.velocity;
 +                              valid_best_target = true;
 +                      }
 +
 +                      vector new_org;
 +                      vector dist = t.origin - org;
 +                      if (dist.x || dist.y) // if not perfectly vertical
 +                      {
 +                              // test trajectory with different starting points, sometimes the trajectory
 +                              // starting from the jumppad origin can't reach the real destination
 +                              // and destination waypoint ends up near the jumppad itself
 +                              vector flatdir = normalize(dist - eZ * dist.z);
 +                              vector ofs = flatdir * 0.5 * min(fabs(this.absmax.x - this.absmin.x), fabs(this.absmax.y - this.absmin.y));
 +                              new_org = org + ofs;
-                               e.velocity = trigger_push_calculatevelocity(new_org, t, this.height);
++                              e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e);
 +                              vel = e.velocity;
 +                              if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed))
 +                                      e.velocity = autocvar_sv_maxspeed * flatdir;
 +                              if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50))
 +                              {
 +                                      best_target = trace_endpos;
 +                                      best_org = new_org;
 +                                      best_vel = vel;
 +                                      valid_best_target = true;
 +                              }
 +                              new_org = org - ofs;
++                              e.velocity = trigger_push_calculatevelocity(new_org, t, this.height, e);
 +                              vel = e.velocity;
 +                              if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed))
 +                                      e.velocity = autocvar_sv_maxspeed * flatdir;
 +                              if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50))
 +                              {
 +                                      best_target = trace_endpos;
 +                                      best_org = new_org;
 +                                      best_vel = vel;
 +                                      valid_best_target = true;
 +                              }
 +                      }
 +
 +                      if (valid_best_target)
 +                      {
 +                              if (!(boxesoverlap(this.absmin, this.absmax + eZ * 50, best_target + PL_MIN_CONST, best_target + PL_MAX_CONST)))
 +                              {
 +                                      float velxy = vlen(vec2(best_vel));
 +                                      float cost = vlen(vec2(t.origin - best_org)) / velxy;
 +                                      if(velxy < autocvar_sv_maxspeed)
 +                                              velxy = autocvar_sv_maxspeed;
 +                                      cost += vlen(vec2(best_target - t.origin)) / velxy;
 +                                      waypoint_spawnforteleporter(this, best_target, cost, e);
 +                              }
 +                      }
                        delete(e);
  #endif
                }
@@@ -24,10 -26,14 +24,11 @@@ void trigger_push_use(entity this, enti
          tgt - target entity (can be either a point or a model entity; if it is
                the latter, its midpoint is used)
          ht  - jump height, measured from the higher one of org and tgt's midpoint
+         pushed_entity - object that is to be pushed
  
        Returns: velocity for the jump
 -      the global trigger_push_calculatevelocity_flighttime is set to the total
 -      jump time
   */
- vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
 -
+ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity pushed_entity);
  
  void trigger_push_touch(entity this, entity toucher);
  
Simple merge