vector trigger_push_velocity_calculatevelocity(entity this, vector org, entity tgt, float speed, float count, entity pushed_entity, bool is_pushed)
{
+ bool is_playerdir_xy = boolean(this.spawnflags & PUSH_VELOCITY_PLAYERDIR_XY);
+ bool is_add_xy = boolean(this.spawnflags & PUSH_VELOCITY_ADD_XY);
+ bool is_playerdir_z = boolean(this.spawnflags & PUSH_VELOCITY_PLAYERDIR_Z);
+ bool is_add_z = boolean(this.spawnflags & PUSH_VELOCITY_ADD_Z);
+ bool is_bidirectional_xy = boolean(this.spawnflags & PUSH_VELOCITY_BIDIRECTIONAL_XY);
+ bool is_bidirectional_z = boolean(this.spawnflags & PUSH_VELOCITY_BIDIRECTIONAL_Z);
+ bool is_clamp_negative_adds = boolean(this.spawnflags & PUSH_VELOCITY_CLAMP_NEGATIVE_ADDS);
+
vector sdir = normalize(vec2(pushed_entity.velocity));
float zdir = pushed_entity.velocity.z;
- if(zdir != 0) zdir = copysign(1, pushed_entity.velocity.z);
+ if(zdir != 0) zdir = copysign(1, zdir);
vector vs_tgt = '0 0 0';
float vz_tgt = 0;
- if (!(this.spawnflags & PLAYERDIR_XY) || !(this.spawnflags & PLAYERDIR_Z))
+ if (!is_playerdir_xy || !is_playerdir_z)
{
vector vel_tgt = trigger_push_calculatevelocity(org, tgt, 0, pushed_entity);
vs_tgt = vec2(vel_tgt);
vz_tgt = vel_tgt.z;
// bidirectional jump pads do not play nicely with xonotic's jump pad targets
- if (this.spawnflags & BIDIRECTIONAL_XY)
+ if (is_bidirectional_xy)
{
if (normalize(vs_tgt) * sdir < 0)
{
}
}
- if (this.spawnflags & BIDIRECTIONAL_Z)
+ if (is_bidirectional_z)
{
if (signbit(vz_tgt) != signbit(zdir))
{
}
vector vs;
- if (this.spawnflags & PLAYERDIR_XY)
+ if (is_playerdir_xy)
{
vs = sdir * speed;
}
}
float vz;
- if (this.spawnflags & PLAYERDIR_Z)
+ if (is_playerdir_z)
{
vz = zdir * count;
}
vz = vz_tgt;
}
- if (this.spawnflags & ADD_XY)
+ if (is_add_xy)
{
vector vs_add = vec2(pushed_entity.velocity);
if (is_pushed)
{
vs += vs_add;
- if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
+ if (is_clamp_negative_adds)
{
if ((normalize(vs) * sdir) < 0)
{
}
}
- if (this.spawnflags & ADD_Z)
+ if (is_add_z)
{
float vz_add = pushed_entity.velocity.z;
if (is_pushed)
{
vz += vz_add;
- if (this.spawnflags & CLAMP_NEGATIVE_ADDS)
+ if (is_clamp_negative_adds)
{
if (signbit(vz) != signbit(zdir))
{
return vs + '0 0 1' * vz;
}
+// TODO: move this check to player/projectile physics?
void check_pushed(entity this) // first jump pad to think thinks for every jump pad
{
IL_EACH(are_pushed, true,
if(targ.has_pushed[i]) continue;
limit_reached = false;
targ.has_pushed[i] = this; // may be briefly out of sync between client and server if client prediction is toggled
+ break;
}
if(limit_reached)
{
}
}
- if(!is_pushed) UNSET_ONGROUND(targ);
+ if(!is_velocity_pad) UNSET_ONGROUND(targ);
#ifdef CSQC
if (targ.flags & FL_PROJECTILE)
const int PUSH_ONCE = BIT(0); // legacy, deactivate with relay instead
const int PUSH_SILENT = BIT(1); // not used?
-const int PLAYERDIR_XY = BIT(0); // if set, trigger will apply the horizontal speed in the player's horizontal direction of travel, otherwise it uses the target XY component.
-const int ADD_XY = BIT(1); // if set, trigger will add to the player's horizontal velocity, otherwise it sets the player's horizontal velocity.
-const int PLAYERDIR_Z = BIT(2); // if set, trigger will apply the vertical speed in the player's vertical direction of travel, otherwise it uses the target Z component.
-const int ADD_Z = BIT(3); // if set, trigger will add to the player's vertical velocity, otherwise it sets the player's vertical velocity.
-const int BIDIRECTIONAL_XY = BIT(4); // if set, non-playerdir velocity pads will function in 2 directions based on the target specified. The chosen direction is based on the current direction of travel. Applies to horizontal direction.
-const int BIDIRECTIONAL_Z = BIT(5); // if set, non-playerdir velocity pads will function in 2 directions based on the target specified. The chosen direction is based on the current direction of travel. Applies to vertical direction.
-const int CLAMP_NEGATIVE_ADDS = BIT(6); // if set, then a velocity pad that adds negative velocity will be clamped to 0, if the resultant velocity would bounce the player in the opposite direction.
+const int PUSH_VELOCITY_PLAYERDIR_XY = BIT(0);
+const int PUSH_VELOCITY_ADD_XY = BIT(1);
+const int PUSH_VELOCITY_PLAYERDIR_Z = BIT(2);
+const int PUSH_VELOCITY_ADD_Z = BIT(3);
+const int PUSH_VELOCITY_BIDIRECTIONAL_XY = BIT(4);
+const int PUSH_VELOCITY_BIDIRECTIONAL_Z = BIT(5);
+const int PUSH_VELOCITY_CLAMP_NEGATIVE_ADDS = BIT(6);
IntrusiveList g_jumppads;
STATIC_INIT(g_jumppads) { g_jumppads = IL_NEW(); }
void trigger_push_findtarget(entity this);
/*
- * ENTITY PARAMETERS:
+ * ENTITY PARAMETERS trigger_push:
*
* target: target of jump
* height: the absolute value is the height of the highest point of the jump
*/
/*
- * ENTITY PARAMETERS:
+ * ENTITY PARAMETERS trigger_push_velocity:
*
* target: this points to the target_position to which the player will jump.
* speed: XY speed for player-directional velocity pads - either sets or adds to the player's horizontal velocity.