]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
target_push: implement Q3 wind tunnel and angles+speed modes
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 19 Mar 2024 03:42:31 +0000 (13:42 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 17 Apr 2024 14:49:37 +0000 (00:49 +1000)
qcsrc/common/mapobjects/trigger/jumppads.qc
qcsrc/common/mapobjects/trigger/jumppads.qh

index 94422b3bb397d58e42b079204bf17ef14429657b..5ded24a28c0b27559110e9164c308c845061270d 100644 (file)
@@ -365,11 +365,17 @@ bool jumppad_push(entity this, entity targ, bool is_velocity_pad)
                // or when a dead player gets stuck in the jumppad for some reason
                if(!already_pushed && this.pushltime < time && !(IS_DEAD(targ) && targ.velocity == '0 0 0'))
                {
-                       // flash when activated
-                       Send_Effect(EFFECT_JUMPPAD, targ.origin, targ.velocity, 1);
+                       if (Q3COMPAT_COMMON && this.classname == "target_push")
+                               this.pushltime = time + 1.5;
+                       else
+                       {
+                               // flash when activated
+                               Send_Effect(EFFECT_JUMPPAD, targ.origin, targ.velocity, 1);
+                               this.pushltime = time + 0.2;
+                       }
                        _sound (targ, CH_TRIGGER, this.noise, VOL_BASE, ATTEN_NORM);
-                       this.pushltime = time + 0.2;
                }
+
                if(IS_REAL_CLIENT(targ) || IS_BOT_CLIENT(targ))
                {
                        bool found = false;
@@ -803,7 +809,7 @@ void trigger_push_velocity_link(entity this)
  *            or OUTSIDE (negative) of the jump trajectory. General rule: use
  *            positive values for targets mounted on the floor, and use negative
  *            values to target a point on the ceiling.
- *   movedir: if target is not set, this * speed * 10 is the velocity to be reached.
+ *   movedir: if target is not set, movedir * speed * 10 is the velocity to be reached.
  */
 spawnfunc(trigger_push)
 {
@@ -891,20 +897,29 @@ void target_push_init(entity this)
        target_push_link(this);
 }
 
-void target_push_init2(entity this)
+spawnfunc(target_push)
 {
-       if(this.target && this.target != "") // we have an old style pusher!
-       {
+       target_push_init(this); // normal push target behaviour can be combined with a legacy pusher?
+       this.use = target_push_use;
+
+       if(this.target && this.target != "") // Q3 or old style Nexuiz pusher
                InitializeEntity(this, trigger_push_findtarget, INITPRIO_FINDTARGET);
-               this.use = target_push_use;
+       else // Q3 .angles and .speed pusher
+       {
+               if (!this.speed)
+                       this.speed = 1000;
+               SetMovedir(this); // this clears .angles so it must be after target_push_init()
+               this.movedir *= this.speed;
        }
 
-       target_push_init(this); // normal push target behaviour can be combined with a legacy pusher?
-}
-
-spawnfunc(target_push)
-{
-       target_push_init2(this);
+       if (!this.noise)
+       {
+               if (Q3COMPAT_COMMON && !(this.spawnflags & Q3_TARGET_PUSH_JUMPPAD))
+                       this.noise = "sound/misc/windfly.wav"; // Q3 mappers provide this, it's not in pak0
+               else
+                       this.noise = "misc/jumppad.wav";
+       }
+       precache_sound (this.noise);
 }
 
 spawnfunc(info_notnull)
index 7146cc52cb057a3d4d12f19c5664017d0aa71a8f..54366ddf4b290df1c97b99ddf607b474ad2c4a6e 100644 (file)
@@ -13,6 +13,8 @@ const int PUSH_STATIC = BIT(12); // xonotic-only, Q3 already behaves like this b
 #define PUSH_VELOCITY_BIDIRECTIONAL_Z     BIT(5)
 #define PUSH_VELOCITY_CLAMP_NEGATIVE_ADDS BIT(6)
 
+#define Q3_TARGET_PUSH_JUMPPAD            BIT(0) // target_push defaults to "wind tunnel" mode in Q3
+
 IntrusiveList g_jumppads;
 STATIC_INIT(g_jumppads) { g_jumppads = IL_NEW(); }