From: Mario Date: Mon, 23 Nov 2015 15:07:59 +0000 (+1000) Subject: Make multijump smoother X-Git-Tag: xonotic-v0.8.2~1626 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5e7ba70ff17f88b449dd2a30813ec1e90cf8fd4f;p=xonotic%2Fxonotic-data.pk3dir.git Make multijump smoother --- diff --git a/qcsrc/common/csqcmodel_settings.qh b/qcsrc/common/csqcmodel_settings.qh index 066f48517..d86efb5e9 100644 --- a/qcsrc/common/csqcmodel_settings.qh +++ b/qcsrc/common/csqcmodel_settings.qh @@ -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 diff --git a/qcsrc/common/mutators/mutator/multijump/multijump.qc b/qcsrc/common/mutators/mutator/multijump/multijump.qc index 10214591e..2ed1acfda 100644 --- a/qcsrc/common/mutators/mutator/multijump/multijump.qc +++ b/qcsrc/common/mutators/mutator/multijump/multijump.qc @@ -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; diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index cbf54fef2..ed3d077f9 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -204,6 +204,7 @@ enum { STAT_JETPACK_ACCEL_SIDE, STAT_JETPACK_ACCEL_UP, STAT_MOVEVARS_HIGHSPEED, + STAT_MULTIJUMP_COUNT, STAT_LAST_MAIN };