]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Decouple doublejump
authorMario <mario@smbclan.net>
Mon, 23 Nov 2015 14:54:45 +0000 (00:54 +1000)
committerMario <mario@smbclan.net>
Mon, 23 Nov 2015 14:54:45 +0000 (00:54 +1000)
qcsrc/common/mutators/all.inc
qcsrc/common/mutators/mutator/dodging/dodging.qc
qcsrc/common/mutators/mutator/doublejump/doublejump.qc [new file with mode: 0644]
qcsrc/common/mutators/mutator/doublejump/module.inc [new file with mode: 0644]
qcsrc/common/physics.qc
qcsrc/common/physics.qh
qcsrc/server/autocvars.qh

index b7d5b4495c679cff03e9dd3a56babd38dee3ce89..e99092c660896d524f4c97e268dd8be7bead69b1 100644 (file)
@@ -15,6 +15,7 @@
 #include "mutator/cloaked/module.inc"
 #include "mutator/damagetext/module.inc"
 #include "mutator/dodging/module.inc"
+#include "mutator/doublejump/module.inc"
 #include "mutator/hook/module.inc"
 #include "mutator/instagib/module.inc"
 #include "mutator/invincibleproj/module.inc"
index b2140bbfcd36f1f7c0c518dc7bc353ba3ecad4d6..327f78b1d53c98b5c4eebeadb6098809eaab6238 100644 (file)
@@ -285,10 +285,6 @@ void PM_dodging(entity this)
 
                this.velocity += PHYS_DODGING_UP_SPEED * v_up;
 
-       #ifdef CSQC
-               LOG_INFO("YES?!\n");
-       #endif
-
 #ifdef SVQC
                if (autocvar_sv_dodging_sound)
                        PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
diff --git a/qcsrc/common/mutators/mutator/doublejump/doublejump.qc b/qcsrc/common/mutators/mutator/doublejump/doublejump.qc
new file mode 100644 (file)
index 0000000..a2bd9ca
--- /dev/null
@@ -0,0 +1,90 @@
+#ifdef IMPLEMENTATION
+#ifdef SVQC
+       #include "../../../../server/antilag.qh"
+#endif
+#include "../../../physics.qh"
+
+
+#if defined(SVQC)
+void doublejump_AddStats();
+
+REGISTER_MUTATOR(doublejump, true)
+{
+       MUTATOR_ONADD
+       {
+               doublejump_AddStats();
+       }
+       return false;
+}
+#elif defined(CSQC)
+REGISTER_MUTATOR(doublejump, true);
+#endif
+
+
+#ifdef CSQC
+
+#define PHYS_DOUBLEJUMP                                                getstati(STAT_DOUBLEJUMP)
+
+#elif defined(SVQC)
+
+bool autocvar_sv_doublejump;
+
+#define PHYS_DOUBLEJUMP                                                autocvar_sv_doublejump
+
+.int stat_doublejump;
+
+void doublejump_UpdateStats(entity this)
+{
+       this.stat_doublejump = PHYS_DOUBLEJUMP;
+}
+
+void doublejump_AddStats()
+{
+       addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
+}
+
+#endif
+
+
+MUTATOR_HOOKFUNCTION(doublejump, PlayerJump)
+{
+       if (PHYS_DOUBLEJUMP)
+       {
+               tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
+               if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
+               {
+                       player_multijump = true;
+
+                       // we MUST clip velocity here!
+                       float f = self.velocity * trace_plane_normal;
+                       if (f < 0)
+                               self.velocity -= f * trace_plane_normal;
+               }
+       }
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(doublejump, PlayerPhysics)
+{
+#ifdef SVQC
+       doublejump_UpdateStats(self);
+#endif
+       return false;
+}
+
+#ifdef SVQC
+
+MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsString)
+{
+       ret_string = strcat(ret_string, ":doublejump");
+       return false;
+}
+
+MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsPrettyString)
+{
+       ret_string = strcat(ret_string, ", Double jump");
+       return false;
+}
+
+#endif
+#endif
diff --git a/qcsrc/common/mutators/mutator/doublejump/module.inc b/qcsrc/common/mutators/mutator/doublejump/module.inc
new file mode 100644 (file)
index 0000000..f4c695b
--- /dev/null
@@ -0,0 +1,3 @@
+#ifndef MENUQC
+#include "doublejump.qc"
+#endif
index 6c81fe2733476b0b9d4c861ce802c3a8b0cc374c..928440d9c9128ee47678d5af56ba62e33320f339 100644 (file)
@@ -73,9 +73,6 @@ void Physics_AddStats()
        addstat(STAT_MOVEVARS_CL_TRACK_CANJUMP, AS_INT, cvar_cl_movement_track_canjump);
        addstat(STAT_MOVEVARS_TRACK_CANJUMP, AS_INT, stat_sv_track_canjump);
 
-       // double jump
-       addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump);
-
        // jump speed caps
        addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps);
 
@@ -129,8 +126,6 @@ void Physics_UpdateStats(float maxspd_mod)
        self.stat_sv_maxspeed = Physics_ClientOption(self, "maxspeed") * maxspd_mod; // also slow walking
        self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this!
 
-       self.stat_doublejump = PHYS_DOUBLEJUMP;
-
        self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY;
        self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP;
        self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE;
@@ -542,10 +537,6 @@ bool PlayerJump ()
 
        bool doublejump = false;
        float mjumpheight = PHYS_JUMPVELOCITY;
-#ifdef CSQC
-       player_multijump = doublejump;
-       player_jumpheight = mjumpheight;
-#endif
 
        if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight))
                return true;
@@ -553,21 +544,6 @@ bool PlayerJump ()
        doublejump = player_multijump;
        mjumpheight = player_jumpheight;
 
-       if (PHYS_DOUBLEJUMP)
-       {
-               tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self);
-               if (trace_fraction < 1 && trace_plane_normal_z > 0.7)
-               {
-                       doublejump = true;
-
-                       // we MUST clip velocity here!
-                       float f;
-                       f = self.velocity * trace_plane_normal;
-                       if (f < 0)
-                               self.velocity -= f * trace_plane_normal;
-               }
-       }
-
        if (self.waterlevel >= WATERLEVEL_SWIMMING)
        {
                self.velocity_z = PHYS_MAXSPEED(self) * 0.7;
index 7b46b0379384fde56bbcc357f1d29c3d49381a7b..9d5d4f76c10e87cd547db6fd928bb7f0ed6e5eb7 100644 (file)
@@ -99,8 +99,6 @@ bool IsFlying(entity a);
 
        #define PHYS_FROZEN(s)                                          getstati(STAT_FROZEN)
 
-       #define PHYS_DOUBLEJUMP                                         getstati(STAT_DOUBLEJUMP)
-
        #define PHYS_JUMPSPEEDCAP_MIN                           cvar_string("cl_jumpspeedcap_min")
        #define PHYS_JUMPSPEEDCAP_MAX                           cvar_string("cl_jumpspeedcap_max")
        #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS       getstati(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS)
@@ -172,8 +170,6 @@ bool IsFlying(entity a);
        .float stat_sv_friction_on_land;
        .float stat_sv_friction_slick;
 
-       .float stat_doublejump;
-
        .string stat_jumpspeedcap_min;
        .string stat_jumpspeedcap_max;
        .float stat_jumpspeedcap_disable_onramps;
@@ -270,8 +266,6 @@ bool IsFlying(entity a);
 
        #define PHYS_FROZEN(s)                                          s.frozen
 
-       #define PHYS_DOUBLEJUMP                                         autocvar_sv_doublejump
-
        #define PHYS_JUMPSPEEDCAP_MIN                           autocvar_sv_jumpspeedcap_min
        #define PHYS_JUMPSPEEDCAP_MAX                           autocvar_sv_jumpspeedcap_max
        #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS       autocvar_sv_jumpspeedcap_max_disable_on_ramps
index fff61774b1eb4236f84e019ff3a7a2f452971371..ae36e0cb86bfb885913db3eeccf9615bf7608212 100644 (file)
@@ -346,7 +346,6 @@ string autocvar_sv_defaultplayermodel_red;
 string autocvar_sv_defaultplayermodel_yellow;
 int autocvar_sv_defaultplayerskin;
 bool autocvar_sv_dodging_frozen;
-bool autocvar_sv_doublejump;
 bool autocvar_sv_eventlog;
 bool autocvar_sv_eventlog_console;
 bool autocvar_sv_eventlog_files;