return sdir * vs + '0 0 1' * vz;
}
-vector trigger_push_velocity_calculatevelocity(entity this, vector org, entity tgt, float speed, float count, entity pushed_entity)
+vector trigger_push_velocity_calculatevelocity(entity this, vector org, entity tgt, float speed, float count, entity pushed_entity, bool is_pushed)
{
vector sdir = normalize(vec2(pushed_entity.velocity));
float zdir = copysign(1, pushed_entity.velocity.z);
- if(pushed_entity.velocity.z == 0) zdir = 1; // copysign is negative on zero, we don't want that
vector vs_tgt = '0 0 0';
float vz_tgt = 0;
if (this.spawnflags & ADD_XY)
{
- vs += vec2(pushed_entity.velocity);
- if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
+ vector vs_add = vec2(pushed_entity.velocity);
+ if (is_pushed)
{
- if ((normalize(vs) * sdir) < 0)
+ vs = vs_add;
+ }
+ else
+ {
+ vs += vs_add;
+
+ if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
{
- vs = '0 0 0';
+ if ((normalize(vs) * sdir) < 0)
+ {
+ vs = '0 0 0';
+ }
}
}
}
if (this.spawnflags & ADD_Z)
{
- vz += pushed_entity.velocity.z;
- if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
+ float vz_add = pushed_entity.velocity.z;
+ if (is_pushed)
{
- if (signbit(vz) != signbit(zdir))
+ vz = vz_add;
+ }
+ else
+ {
+ vz += vz_add;
+
+ if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
{
- vz = 0;
+ if (signbit(vz) != signbit(zdir))
+ {
+ vz = 0;
+ }
}
}
}
if (!isPushable(targ))
return false;
- if(is_velocity_pad && IL_CONTAINS(this.pushed, targ))
- return false;
-
- if(is_velocity_pad)
- {
- IL_PUSH(this.pushed, targ); // may be briefly out of sync between client and server if client prediction is toggled
- this.nextthink = time;
- }
-
vector org = targ.origin;
if(STAT(Q3COMPAT))
org.z += 1; // off by 1!
}
+ bool is_pushed = is_velocity_pad && IL_CONTAINS(this.pushed, targ);
+
if(this.enemy)
{
if(!is_velocity_pad)
}
else
{
- targ.velocity = trigger_push_velocity_calculatevelocity(this, org, this.enemy, this.speed, this.count, targ);
+ targ.velocity = trigger_push_velocity_calculatevelocity(this, org, this.enemy, this.speed, this.count, targ, is_pushed);
}
}
else if(this.target && this.target != "")
}
else
{
- targ.velocity = trigger_push_velocity_calculatevelocity(this, org, RandomSelection_chosen_ent, this.speed, this.count, targ);
+ targ.velocity = trigger_push_velocity_calculatevelocity(this, org, RandomSelection_chosen_ent, this.speed, this.count, targ, is_pushed);
}
}
else
}
}
- UNSET_ONGROUND(targ);
+ if(is_velocity_pad && !is_pushed)
+ {
+ IL_PUSH(this.pushed, targ); // may be briefly out of sync between client and server if client prediction is toggled
+ this.nextthink = time;
+ }
+
+ if(!is_pushed) UNSET_ONGROUND(targ);
#ifdef CSQC
if (targ.flags & FL_PROJECTILE)
// prevent sound spam when a player hits the jumppad more than once
// or when a dead player gets stuck in the jumppad for some reason
- if(this.pushltime < time && !(IS_DEAD(targ) && targ.velocity == '0 0 0'))
+ if(!is_pushed && this.pushltime < time && !(IS_DEAD(targ) && targ.velocity == '0 0 0'))
{
// flash when activated
Send_Effect(EFFECT_JUMPPAD, targ.origin, targ.velocity, 1);