#endif
#include "../../../physics.qh"
+
+#if defined(SVQC)
+void multijump_AddStats();
+
+REGISTER_MUTATOR(multijump, cvar("g_multijump"))
+{
+ MUTATOR_ONADD
+ {
+ multijump_AddStats();
+ }
+ return false;
+}
+#elif defined(CSQC)
+REGISTER_MUTATOR(multijump, true);
+#endif
+
.int multijump_count;
.bool multijump_ready;
.bool cvar_cl_multijump;
.float stat_multijump_maxspeed;
.float stat_multijump_dodging;
-void multijump_UpdateStats()
-{SELFPARAM();
- self.stat_multijump = PHYS_MULTIJUMP;
- self.stat_multijump_speed = PHYS_MULTIJUMP_SPEED;
- self.stat_multijump_add = PHYS_MULTIJUMP_ADD;
- self.stat_multijump_maxspeed = PHYS_MULTIJUMP_MAXSPEED;
- self.stat_multijump_dodging = PHYS_MULTIJUMP_DODGING;
+void multijump_UpdateStats(entity this)
+{
+ this.stat_multijump = PHYS_MULTIJUMP;
+ this.stat_multijump_speed = PHYS_MULTIJUMP_SPEED;
+ this.stat_multijump_add = PHYS_MULTIJUMP_ADD;
+ this.stat_multijump_maxspeed = PHYS_MULTIJUMP_MAXSPEED;
+ this.stat_multijump_dodging = PHYS_MULTIJUMP_DODGING;
}
void multijump_AddStats()
#endif
-void PM_multijump()
-{SELFPARAM();
+void PM_multijump(entity this)
+{
if(!PHYS_MULTIJUMP) { return; }
- if(IS_ONGROUND(self))
- {
- self.multijump_count = 0;
- }
+ if(IS_ONGROUND(this))
+ this.multijump_count = 0;
}
-bool PM_multijump_checkjump()
-{SELFPARAM();
+bool PM_multijump_checkjump(entity this)
+{
if(!PHYS_MULTIJUMP) { return false; }
#ifdef SVQC
- bool client_multijump = self.cvar_cl_multijump;
+ bool client_multijump = this.cvar_cl_multijump;
#elif defined(CSQC)
bool client_multijump = cvar("cl_multijump");
return false; // nope
#endif
- if (!IS_JUMP_HELD(self) && !IS_ONGROUND(self) && client_multijump) // jump button pressed this frame and we are in midair
- self.multijump_ready = true; // this is necessary to check that we released the jump button and pressed it again
+ 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
else
- self.multijump_ready = false;
+ this.multijump_ready = false;
int phys_multijump = PHYS_MULTIJUMP;
phys_multijump = (PHYS_MULTIJUMP) ? -1 : 0;
#endif
- if(!player_multijump && self.multijump_ready && (self.multijump_count < phys_multijump || phys_multijump == -1) && self.velocity_z > PHYS_MULTIJUMP_SPEED && (!PHYS_MULTIJUMP_MAXSPEED || vlen(self.velocity) <= PHYS_MULTIJUMP_MAXSPEED))
+ 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 (PHYS_MULTIJUMP)
{
if (!PHYS_MULTIJUMP_ADD) // in this case we make the z velocity == jumpvelocity
{
- if (self.velocity_z < PHYS_JUMPVELOCITY)
+ if (this.velocity_z < PHYS_JUMPVELOCITY)
{
player_multijump = true;
- self.velocity_z = 0;
+ this.velocity_z = 0;
}
}
else
if(player_multijump)
{
if(PHYS_MULTIJUMP_DODGING)
- if(self.movement_x != 0 || self.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
+ if(this.movement_x != 0 || this.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys
{
float curspeed;
vector wishvel, wishdir;
/*#ifdef SVQC
curspeed = max(
- vlen(vec2(self.velocity)), // current xy speed
- vlen(vec2(antilag_takebackavgvelocity(self, max(self.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
+ vlen(vec2(this.velocity)), // current xy speed
+ vlen(vec2(antilag_takebackavgvelocity(this, max(this.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs
);
#elif defined(CSQC)*/
- curspeed = vlen(vec2(self.velocity));
+ curspeed = vlen(vec2(this.velocity));
//#endif
- makevectors(self.v_angle_y * '0 1 0');
- wishvel = v_forward * self.movement_x + v_right * self.movement_y;
+ makevectors(this.v_angle_y * '0 1 0');
+ wishvel = v_forward * this.movement_x + v_right * this.movement_y;
wishdir = normalize(wishvel);
- self.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
- self.velocity_y = wishdir_y * curspeed;
+ this.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump
+ this.velocity_y = wishdir_y * curspeed;
// keep velocity_z unchanged!
}
if (PHYS_MULTIJUMP > 0)
{
- self.multijump_count += 1;
+ this.multijump_count += 1;
}
}
}
- self.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
+ this.multijump_ready = false; // require releasing and pressing the jump button again for the next jump
}
return false;
}
-#ifdef SVQC
-REGISTER_MUTATOR(multijump, cvar("g_multijump"))
-{
- MUTATOR_ONADD
- {
- multijump_AddStats();
- }
- return false;
-}
-
MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics)
{
- multijump_UpdateStats();
- PM_multijump();
-
+#ifdef SVQC
+ multijump_UpdateStats(self);
+#endif
+ PM_multijump(self);
return false;
}
MUTATOR_HOOKFUNCTION(multijump, PlayerJump)
{
- return PM_multijump_checkjump();
+ return PM_multijump_checkjump(self);
}
+#ifdef SVQC
+
MUTATOR_HOOKFUNCTION(multijump, GetCvars)
{
GetCvars_handleFloat(get_cvars_s, get_cvars_f, cvar_cl_multijump, "cl_multijump");
string item_model_output;
MUTATOR_HOOKABLE(ItemModel, EV_ItemModel);
-/** called when a player presses the jump key */
-#define EV_PlayerJump(i, o) \
- /**/ i(float, player_multijump) \
- /**/ i(float, player_jumpheight) \
- /**/ o(float, player_multijump) \
- /**/ o(float, player_jumpheight) \
- /**/
-float player_multijump;
-float player_jumpheight;
-MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump);
-
/** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */
#define EV_GiveFragsForKill(i, o) \
/**/ i(entity, __self) \
/** TODO change this into a general PlayerPostThink hook? */
MUTATOR_HOOKABLE(GetPressedKeys, EV_NO_ARGS);
-/**
- * called before any player physics, may adjust variables for movement,
- * is run AFTER bot code and idle checking
- */
-MUTATOR_HOOKABLE(PlayerPhysics, EV_NO_ARGS);
-
/** is meant to call GetCvars_handle*(get_cvars_s, get_cvars_f, cvarfield, "cvarname") for cvars this mutator needs from the client */
#define EV_GetCvars(i, o) \
/**/ i(float, get_cvars_f) \