From: terencehill Date: Fri, 22 Dec 2017 23:16:47 +0000 (+0100) Subject: Fix wrong jumppad push when entity that is to be pushed has a gravity factor differen... X-Git-Tag: xonotic-v0.8.5~2412 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d43ce9b61ff0ac46e59bac1a011603fa75071cc;p=xonotic%2Fxonotic-data.pk3dir.git Fix wrong jumppad push when entity that is to be pushed has a gravity factor different from 1 --- diff --git a/qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc b/qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc index 705ac6d54..3568f221b 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc @@ -2,7 +2,7 @@ void W_Nexball_Attack(entity actor, .entity weaponentity, float t); void W_Nexball_Attack2(entity actor, .entity weaponentity); -vector trigger_push_calculatevelocity(vector org, entity tgt, float ht); +vector trigger_push_calculatevelocity(vector org, entity tgt, float ht, entity pushed_entity); METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire)) { @@ -147,7 +147,7 @@ void W_Nexball_Attack2(entity actor, .entity weaponentity) { entity _ball = actor.ballcarried; W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); - DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32)); + DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32, _ball)); setthink(_ball, W_Nexball_Think); _ball.nextthink = time; return; diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index 822411c6a..4316a0edf 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -25,22 +25,23 @@ REGISTER_NET_LINKED(ENT_CLIENT_TARGET_PUSH) 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; torg = tgt.origin + (tgt.mins + tgt.maxs) * 0.5; - grav = PHYS_GRAVITY(tgt); - if(PHYS_ENTGRAVITY(tgt)) - grav *= PHYS_ENTGRAVITY(tgt); + grav = PHYS_GRAVITY(NULL); + if(pushed_entity && PHYS_ENTGRAVITY(pushed_entity)) + grav *= PHYS_ENTGRAVITY(pushed_entity); zdist = torg.z - org.z; sdist = vlen(torg - org - zdist * '0 0 1'); @@ -137,7 +138,7 @@ bool jumppad_push(entity this, entity targ) if(this.enemy) { - targ.velocity = trigger_push_calculatevelocity(targ.origin, this.enemy, this.height); + targ.velocity = trigger_push_calculatevelocity(targ.origin, this.enemy, this.height, targ); } else if(this.target && this.target != "") { @@ -150,7 +151,7 @@ bool jumppad_push(entity this, entity targ) else RandomSelection_AddEnt(e, 1, 1); } - targ.velocity = trigger_push_calculatevelocity(targ.origin, RandomSelection_chosen_ent, this.height); + targ.velocity = trigger_push_calculatevelocity(targ.origin, RandomSelection_chosen_ent, this.height, targ); } else { @@ -289,7 +290,7 @@ void trigger_push_findtarget(entity this) entity e = spawn(); setorigin(e, org); setsize(e, PL_MIN_CONST, PL_MAX_CONST); - 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)); diff --git a/qcsrc/common/triggers/trigger/jumppads.qh b/qcsrc/common/triggers/trigger/jumppads.qh index 76d244da5..8615bc66d 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qh +++ b/qcsrc/common/triggers/trigger/jumppads.qh @@ -26,13 +26,14 @@ void trigger_push_use(entity this, entity actor, entity trigger); 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); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 973891464..a134c03ab 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -45,7 +45,7 @@ void W_Porto_Fail(entity this, float failhard) { this.flags = FL_ITEM; IL_PUSH(g_items, this); - this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128); + this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128, this); tracetoss(this, this); if(vdist(trace_endpos - this.realowner.origin, <, 128)) {