]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make multijump smoother
authorMario <mario@smbclan.net>
Mon, 23 Nov 2015 15:07:59 +0000 (01:07 +1000)
committerMario <mario@smbclan.net>
Mon, 23 Nov 2015 15:07:59 +0000 (01:07 +1000)
qcsrc/common/csqcmodel_settings.qh
qcsrc/common/mutators/mutator/multijump/multijump.qc
qcsrc/common/stats.qh

index 066f48517eff63b64d31b4c4fda8aa7e2e64403e..d86efb5e979f7bf81ba8b44c2a049a6a8c609d38 100644 (file)
@@ -62,7 +62,8 @@
        CSQCMODEL_PROPERTY(BIT(11), int, ReadByte, WriteByte, traileffect) \
        CSQCMODEL_PROPERTY_SCALED(BIT(12), float, ReadByte, WriteByte, scale, 16, 0, 255) \
        CSQCMODEL_PROPERTY(BIT(13), int, ReadInt24_t, WriteInt24_t, dphitcontentsmask) \
-       CSQCMODEL_PROPERTY(BIT(14), TAG_VIEWLOC_TYPE, ReadShort, WriteEntity, TAG_VIEWLOC_NAME)
+       CSQCMODEL_PROPERTY(BIT(14), TAG_VIEWLOC_TYPE, ReadShort, WriteEntity, TAG_VIEWLOC_NAME) \
+       CSQCMODEL_PROPERTY(BIT(15), int, ReadByte, WriteByte, multijump_count)
 // TODO get rid of colormod/glowmod here, find good solution for vortex charge glowmod hack; also get rid of some useless properties on non-players that only exist for CopyBody
 
 // add hook function calls here
index 10214591e5e62d8a796d25309b3f245df3a99616..2ed1acfda9f9caab6b91048de82729c8562fa1f0 100644 (file)
@@ -22,18 +22,23 @@ REGISTER_MUTATOR(multijump, true);
 
 .int multijump_count;
 .bool multijump_ready;
-.bool cvar_cl_multijump;
 
 #ifdef CSQC
 
+bool autocvar_cl_multijump = true;
+
 #define PHYS_MULTIJUMP                                 getstati(STAT_MULTIJUMP)
 #define PHYS_MULTIJUMP_SPEED           getstatf(STAT_MULTIJUMP_SPEED)
 #define PHYS_MULTIJUMP_ADD                     getstati(STAT_MULTIJUMP_ADD)
 #define PHYS_MULTIJUMP_MAXSPEED        getstatf(STAT_MULTIJUMP_MAXSPEED)
 #define PHYS_MULTIJUMP_DODGING                 getstati(STAT_MULTIJUMP_DODGING)
+#define PHYS_MULTIJUMP_COUNT(s)        getstati(STAT_MULTIJUMP_COUNT)
+#define PHYS_MULTIJUMP_CLIENT(s)       autocvar_cl_multijump
 
 #elif defined(SVQC)
 
+.bool cvar_cl_multijump;
+
 int autocvar_g_multijump;
 float autocvar_g_multijump_add;
 float autocvar_g_multijump_speed;
@@ -45,6 +50,8 @@ float autocvar_g_multijump_dodging = 1;
 #define PHYS_MULTIJUMP_ADD                     autocvar_g_multijump_add
 #define PHYS_MULTIJUMP_MAXSPEED        autocvar_g_multijump_maxspeed
 #define PHYS_MULTIJUMP_DODGING                 autocvar_g_multijump_dodging
+#define PHYS_MULTIJUMP_COUNT(s)        (s).multijump_count
+#define PHYS_MULTIJUMP_CLIENT(s)       (s).cvar_cl_multijump
 
 .float stat_multijump;
 .float stat_multijump_speed;
@@ -68,6 +75,7 @@ void multijump_AddStats()
        addstat(STAT_MULTIJUMP_ADD, AS_INT, stat_multijump_add);
        addstat(STAT_MULTIJUMP_MAXSPEED, AS_FLOAT, stat_multijump_maxspeed);
        addstat(STAT_MULTIJUMP_DODGING, AS_INT, stat_multijump_dodging);
+       addstat(STAT_MULTIJUMP_COUNT, AS_INT, multijump_count);
 }
 
 #endif
@@ -84,14 +92,9 @@ bool PM_multijump_checkjump(entity this)
 {
        if(!PHYS_MULTIJUMP) { return false; }
 
-#ifdef SVQC
-       bool client_multijump = this.cvar_cl_multijump;
-#elif defined(CSQC)
-       bool client_multijump = cvar("cl_multijump");
-
-       if(cvar("cl_multijump") > 1)
+       int client_multijump = PHYS_MULTIJUMP_CLIENT(this);
+       if(client_multijump > 1)
                return false; // nope
-#endif
 
        if (!IS_JUMP_HELD(this) && !IS_ONGROUND(this) && client_multijump) // jump button pressed this frame and we are in midair
                this.multijump_ready = true;  // this is necessary to check that we released the jump button and pressed it again
@@ -100,11 +103,7 @@ bool PM_multijump_checkjump(entity this)
 
        int phys_multijump = PHYS_MULTIJUMP;
 
-#ifdef CSQC
-       phys_multijump = (PHYS_MULTIJUMP) ? -1 : 0;
-#endif
-
-       if(!player_multijump && this.multijump_ready && (this.multijump_count < phys_multijump || phys_multijump == -1) && this.velocity_z > PHYS_MULTIJUMP_SPEED && (!PHYS_MULTIJUMP_MAXSPEED || vlen(this.velocity) <= PHYS_MULTIJUMP_MAXSPEED))
+       if(!player_multijump && this.multijump_ready && (PHYS_MULTIJUMP_COUNT(this) < phys_multijump || phys_multijump == -1) && this.velocity_z > PHYS_MULTIJUMP_SPEED && (!PHYS_MULTIJUMP_MAXSPEED || vlen(this.velocity) <= PHYS_MULTIJUMP_MAXSPEED))
        {
                if (PHYS_MULTIJUMP)
                {
@@ -160,6 +159,8 @@ MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics)
 {
 #ifdef SVQC
        multijump_UpdateStats(self);
+#elif defined(CSQC)
+       self.multijump_count = PHYS_MULTIJUMP_COUNT(self);
 #endif
        PM_multijump(self);
        return false;
index cbf54fef2918cc9f694c08913afe1c7251303926..ed3d077f9c3cc8e62e515ffb59f0f409a5bf2168 100644 (file)
@@ -204,6 +204,7 @@ enum {
     STAT_JETPACK_ACCEL_SIDE,
     STAT_JETPACK_ACCEL_UP,
     STAT_MOVEVARS_HIGHSPEED,
+    STAT_MULTIJUMP_COUNT,
 
     STAT_LAST_MAIN
 };