]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix wrong jumppad push when entity that is to be pushed has a gravity factor differen...
authorterencehill <piuntn@gmail.com>
Fri, 22 Dec 2017 23:16:47 +0000 (00:16 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 22 Dec 2017 23:16:47 +0000 (00:16 +0100)
qcsrc/common/gamemodes/gamemode/nexball/sv_weapon.qc
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/common/triggers/trigger/jumppads.qh
qcsrc/common/weapons/weapon/porto.qc

index 705ac6d541ac4d828e98adee8aa291f2fccb0515..3568f221b63fe53fbc440a282cf037bc14a59e6f 100644 (file)
@@ -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;
index 822411c6a23a93d2b58093f3e28c1616564be7b1..4316a0edf356124837c3586928de62e2b6dc4492 100644 (file)
@@ -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));
index 76d244da55b2d0b8e814b1d3574b53f293c01ff6..8615bc66d6a06e4137d102580d3bd5db0fc44f1d 100644 (file)
@@ -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);
 
index 9738914644ceb482b3936d07c734c4cef9eda899..a134c03ab5cce4368ca971fce13701a3ed1de8d8 100644 (file)
@@ -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))
                        {