From: terencehill Date: Sat, 23 Dec 2017 17:51:09 +0000 (+0100) Subject: Merge branch 'master' into terencehill/bot_waypoints X-Git-Tag: xonotic-v0.8.5~2378^2~7^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=99f5aae787d0e46852e2340594c5cb4805c0f3f3;p=xonotic%2Fxonotic-data.pk3dir.git Merge branch 'master' into terencehill/bot_waypoints # Conflicts: # qcsrc/common/triggers/trigger/jumppads.qc # qcsrc/common/triggers/trigger/jumppads.qh --- 99f5aae787d0e46852e2340594c5cb4805c0f3f3 diff --cc qcsrc/common/triggers/trigger/jumppads.qc index 999a615cb,4316a0edf..d10a1e330 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.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.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP; - e.velocity = trigger_push_calculatevelocity(org, t, this.height); + e.velocity = trigger_push_calculatevelocity(org, t, this.height, e); - tracetoss(e, e); - if(e.move_movetype == MOVETYPE_NONE) - waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity)); + 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.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 } diff --cc qcsrc/common/triggers/trigger/jumppads.qh index a1260c4e5,8615bc66d..c3b0b339d --- a/qcsrc/common/triggers/trigger/jumppads.qh +++ b/qcsrc/common/triggers/trigger/jumppads.qh @@@ -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);